Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question ShaderGraph Artificial Point Light

Discussion in 'Shaders' started by unity_cQCNRvcMW6X8ig, Mar 25, 2023.

  1. unity_cQCNRvcMW6X8ig


    Jul 3, 2022
    The title pretty much sums it up, I am trying to make a "Point light" inside of a shader graph. I am currently using some custom "Toon" shaders that I have made, and I know it's possible to make a toon shader work with multiple lights, but those solutions don't really work for what I need. I am looking for something more like this: Dynamic 3D Pixel Art Particle Lighting - YouTube
    I barely know anything about shaders and don't understand a word coming out of his mouth, but it seems like the lights are just spheres with shaders over them that give a "point light" type of effect to the surroundings. What I need is pretty much just that. So far what I've been trying to do to make this "point light" is use a depth texture (Using a second camera as the scene depth node does not work for me for some reason and I have tried everything to get it to work properly but it only ever works in scene view and I don't feel like messing with it anymore) but I've been taking that depth texture and putting it into a remap node with the near and far clip plane so I get the depth in meters, then I planned to make a vector by taking the angle of the camera and the depth, then once I had that vector I would add the camera position to it to get the world position of each pixel in the image, then use a distance function to get the distance from that pixel to the object and color/modify that pixel accordingly. However, I am not able to get this to work and it seems like the fault is where I try to rotate the depth texture and get the world position of each pixel. Is there an easier way to make a "point light" in a shader? If not, then how can I go about getting the world position of each pixel in the depth texture?
    Sorry for no images, I am unable to get them at the time. If needed I can post some in the comments later.
    I am using the Shader graph in URP in unity 2022.1.7f1.