Hello, I am beginner at shader writing and I want to achieve a specific result, but I do not have enough knowledge to complete my progress. Can someone please help me?
Secondly, the results achieved
Preview: Screenshot by Lightshot
Also please find a Unity 5.3 project attached. The achieved results produce the single circle of lights, but upon overlapping lights do not merge.
Finally, I will really appreciate it if someone could guide me through this and help to achieve the desired result.
I don’t think you can simply modify Unitys internal deferred lighting shader, because each light is applied separately to the background.
I think what you want is to render all your lighting of this type into a separate buffer, and then apply it to the background at once in one pass.
When rendering into your separate lighting buffer, you should probably change the blend mode from normal additive to
BlendMode Max
this will store the brightest value from any light at a pixel, instead of a sum of all the lights hitting that pixel.
Try doing some experiments with shaders with that blendmode. Just drawing shapes with custom shaders into a rendertexture.
Once you understand how that works, you need to render shapes actually corresponding to the lights that you want and with the correct intensity that you want, and this has to be rendered against the depth buffer, just like the code in UnityDeferredLibrary does. In fact you might be able to use that library in your shader, but instead of waiting for Unity to call it as part of the pipeline, you will be calling your own shader to render the point lights into your temporary lighting rendertexture.
Once that is done (and you can admire the lighting in your rendertexture), it is time to make a full screen pass where you multiply the lighting in your buffer with the colours/textures of the scene stored in the G-buffer.
This stuff doesn’t deal with reflection. You are on your own there.
Thank you for the reply, but I have no idea how to do all of those things, I tried researching as to how to create a separate buffer or what it is but with no results. I also do not understand what type of shader should I be modifying or creating.
Such a buffer would be a RenderTexture. To learn a bit about how rendertextures work, try creating a rendertexture, create an extra camera, and try setting the “targetTexture” of the camera to the rendertexture.
However, I think what you are trying to do is a bit above your current skill level.
Modifying the internal workings of the lighting is quite a tricky and advanced thing to do.
Maybe experiment with some simpler stuff first and see if you can find a similar looking cool effect?
Also I need specifically this effect, maybe there is an easier way of achieving it than modifying the internal workings of the lighting, but so far that is the only method I was able to find.
The code in the example from the other thread should be put inside a Start() function (not OnStart, he made a mistake)
And that code should be put on some object in your scene. That is what you do with MonoBehaviour scripts.
A RenderTexture can be used to hold intermediate graphics calculations, such as a picture of all the the lighting before the lighting is combined with the background. That would be its role in my original explanation.
Sorry, but it would take me longer to explain to you step by step how to do this, than to code the whole thing myself.
And coding it myself would probably take between half a day and a whole day.
I understand. Thank you very much for helping, I played around with the code a bit and managed to get this which is close to the desired result. Screenshot by Lightshot
I will keep trying to figure it out and maybe if i poke it enough I will get what i want : )