I have 1 background mesh, which is pretty much just a plane (for now), and one generated mesh (not generated in Update())
I made 2 types of mesh generation, first one:
http://gfycat.com/CriminalGreenCollie
Second one (instead of a circle mesh, its just the outline with a Z scale)
http://gfycat.com/NervousSecondAurochs
Now, I need to just hide parts of the background mesh which are intersecting with one of these 2 meshes (i made the second one for a boolean intersection approach, which proved way too slow for real-time, maybe a shader would help here? I have zero experience in making shaders)
What would be the best approach for this?
Solution:
As the firsts reply by Gambit suggest, the solution was a stencil shader.
Background shader:
Shader "Custom/FogBackground" {
Properties{
_Color("Main Color", Color) = (1,1,1,1)
_MainTex("Base (RGB)", 2D) = "white" {}
}
Category{
Lighting Off
ZWrite on
Cull Back
SubShader{
Stencil{
Ref 1
Comp notequal
Pass Zero
}
Tags{
"Queue" = "Geometry"
"LightMode" = "Always"
"RenderType" = "Opaque"
"IgnoreProjector" = "True"
}
Pass{
SetTexture[_MainTex]{
constantColor[_Color]
Combine texture * constant, texture * constant
}
}
}
}
}
Custom mesh shader:
Shader "Custom/Vision" {
Category{
Lighting Off
Cull Back
zwrite off
SubShader{
Colormask 0
Stencil{
Ref 1
Comp always
Pass replace
}
Tags{
"Queue" = "Geometry-1"
"LightMode" = "Always"
"RenderType" = "Opaque"
"IgnoreProjector" = "True"
}
Pass{
}
}
}
}