- Edited
I'm trying to make a light shader that instead of adding light to a spot instead makes the screen black and leaves the spot around the player normal, I'm new to shader work :).
I'm trying to make a light shader that instead of adding light to a spot instead makes the screen black and leaves the spot around the player normal, I'm new to shader work :).
I'm not entirely sure I understand what you mean by "adding light to a spot instead makes the screen black and leaves the spot around the player normal" however if I do understand it right then you might not even need a light shader for it but instead just need a screenspace shader applying a mask of the player, maybe blurred, to a black screen buffer so the character and some range of surrounding pixels get masked out of it leaving those pixels transparent.
This tutorial I wrote on color masking shaders may be helpful for the shader part: Godot Color Mask Tutorial
As Megalomaniak said, you probably want a screen shader that covers the entire screen, and then have some method to remove parts (via a shader) to reveal the player and any other objects you want to show. I’m not sure if the tutorial shows that effect directly, but the gist is hopefully there!
OK, sleeping on it I think I now get what you really mean. You want a world-space projection to be centered on player characters location along Y axis at all times so that only n-units around the character are visible. But then why not just use a spotlight and parent it to the player?
@Megalomaniak @TwistedTwigleg
I don't know if you can do a comment reply on here but I was able to make a representation of what I mean using the Light2D node (but with some limitations).
this is what I'm looking to make with a shader:
but my biggest problems are the way light sources react with each other as they overlap making the spot even brighter but with a shader, I was hoping to make the overlapping spot stay the same brightness:
and also the fact that doing the way I did the shadows don't work as the spot is a mask out:
Ah, I see, I assumed basically this, but in 3D.
Since you don't want it to act as a light(light is additive so 2 sources would naturally add up to a greater value) I recommend avoiding lights altogether and following the tutorial linked by @TwistedTwigleg you could create your own blend map that multiplies over the display buffer.
Basically you would create your own shadow pass in a sense, rather than lightening parts it would be black and white clamped to the 0-1 range and multiplying over the below buffer it would only darken the relevant parts.
Hey @theformerglitch, I actually have the same question you posted and have been looking for answers myself. I am unable to test the tutorial above. I was wondering if it has helped you get the answer. I'm new to shaders as well, so I'd appreciate guidance if you did get the effect working.
@Nano-95 yes I did in fact find a way to get what I was looking for, if you put a canvasmodulate node over your world scene and then on the player set a normal light2d node with a texture (for me a 64x64 pixel white circle) and put the mode to mix everything does not add when two light sources collide and instead stay the same clarity and shadow occlusion work fine