Creating a shadow with a Sprite and change its tint or use shader?

Hi all,

these days I was reading about shader, fragments and materials, I wanted to create a shader that changes the screen darker making it so it feels darker.

Now I did not really know how to do it with a shader, I could practice a bit with the examples I found here, which yeah made me realise I will have to read more into OpenGL to really create a Shader. I was reading into it but I did not found away to make a vect4 transparent.

So i decided to create a GO with a sprite and add a black rectangle as sprite and changed its color with like this:

sprite.set_constant("shadow#sprite", "tint", vmath.vector4(1, 1, 1, 0.2))

Is this a viable way for this effect?
How would you do a shader on a quad thats screen size to make it have that effect?

I’m not sure if I fully understand what you’re trying to do, but there might be several ways to approach it. There’s a good (though possibly a bit old) tutorial on color grading:

Or if you want something like this:

More complex with shadows:

This would describe it the best:

I would like to have a full screen shader like these which makes everything darker. Like if i would put a black sprite over everything and change its ā€œtintā€ to an alpha value of 0.4. This gives me the same effect basicly.

This is exactly what color grading does. You can combine it with the first shadow tutorial

2 Likes

Ok thank you. i will have a look into it!

I think for this simple effect don’t need to borher with shaders… For full screen effect you can use a GUI node and play with its color property - it’s a vector4 with ā€˜w’ component as alpha (opacity).

Maybe you have solved it already but it can help someone else.

1 Like

Thanks yeah the GUI approach seems good for that. I did make a Gameobject instead of a GUI object with the same result. But yeah GUI makes more sense since it always will cover all. the Gameobject i had to add to the player.

Thanks.

1 Like