Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Fog of war using Directional Light and it's Cookie property.

Discussion in 'General Graphics' started by komandos332, Jan 28, 2019.

  1. komandos332

    komandos332

    Joined:
    Dec 11, 2016
    Posts:
    3
    Hello there! At the begining - sorry for my english ^^
    I'm very new using Unity and other graphics engines. I know C# very well but not the Unity API at all.
    I have to create a Fog of war feature in the game. After days of research i found out the easiest way to handle that using as i wrote in the title - Cookie propety of Light source. I'v created a texture in the script and it works very well when i put it in the Cookie property, using Texture2D.SetPixel method. Now i want to make it better and i need to draw a Circle on that texture. It's very slow using SetPixel method, faster using SetPixels but it is drawing rectangle only. I found a solution and i know i have to use Graphics.DrawTexute, RenderTexture.ReadPixels and other base stuff from unity engine. I have the data to use like player position on the terrain from 0 to 1 in x and 0 to 1 in z axis. Can you guys help me with that? The goal is to apply a LightShape texture on a LightMap texture in a specified point which is player position, and then put this LightMap texture to the Cookie property of DirectionalLight component.
    Thanks you very much and greetings from Poland! ;)