Hi,
After hours of googling, trawling forums and reading, I admit I need some community help. I’m trying to implement a Fog Of War using the alpha channel of a Texture2D.
Let’s say for ease of discussion my terrain/map is square, with world coordinates (0,0,0) to (1024, 0, 1024) with grid size of 1 - not really important. I’m able to create a Texture2D RGBA image of 1024x1024 pixels, with each pixel representing a point on the terrain grid. In the alpha channel used for FoW, I have black as invisible (fogged), white as visible, and grays inbetween as fade levels. Each character in the game will project an area of influence with decay etc. Generating this “FogTexture2D” map is not what I require help with.
I’d planned for an ImageEffect script similar to SepiaTone to take each rendered frame, and for each pixel:
1 - Get the world (x, z) coordinates of the screen pixel, and convert this to a pixel lookup in FogTexture2D.
2 - Take the alpha channel value for FoW, and set the alpha value of the screen pixel
All this needs to happen before any UI is drawn on top, and it needs to be fast.
Any Shader experts out there who can nudge me in the right direction please?
Many thanks in advance.