Search the Community
Showing results for tags 'Fog Of War'.
Found 1 result
Hello ! I'm working on a project in which a moving light revolves closely around an arbitrary model, revealing the surface it has lit, in a "fog of war" style (but with precise lighting): (this model is "Ice Asteroid" by jesterelly and is under CC-By license) (the *point* light is just an example, may as well be directional light with a shadowgenerator). To do this, I must keep track of once-lit areas to display them even if they are not illuminated atm. As this information can only be assigned to the whole surface (the camera is mobile, and all surface is concerned), I thought of using a texture to store it, "inside" the model material. I was kindly pointed toward RenderTargetTextures, which seem the way to go , but I struggle with implementing my plan (and I don't know if it is correct anymore) : 1) using a new material = standard material + a light map texture, which stores all pixels of the diffuse texture ever lit ( 0/1 states), and display (or not) a fragment accordingly. Seems OK. 2) the "light map" is a RTT which onBeforeRender replaces the model material with a "detect light" custom material : its fragment shader output only convoys light/shadow information, and it is displayed on a plane, to form the model UV map (but only with lit/unlit zones).the rendering takes place, creating the "instant" light maponAfterRender puts back the almost-standard model material, and makes an "addition" of the newly created light map and the previous one (final_uvpixel_value = uvpixel_value_1 + uvpixel_value_2), passing it as a texture to the model material. I scratch my head on these 2 points : in particular, I have no idea how to access to the "light state" of the model surface, presented as a flat texture. I tried to "unwrap" my model by replacing gl_Position = viewProjection * finalWorld * vec4(position, 1.0);by gl_Position = vec4(vDiffuseUV,0., 1.0);in the standard material vertex, but so far I only got beautiful glitches (always on UV-mapped models). I can't think of another way to go for the moment. Any idea about this "real-time surface illumination texture" is welcome (thank you very much for reading this)