Page 1 of 1

Shaders and setColor

Posted: Fri May 19, 2023 10:59 pm
by seiya
I am learning shaders right now and I have a shader doing what I want for the most part (just diffusing a color). I had a single pixel have its color reset to full red with:

Code: Select all

love.graphics.setColor(1,0,0,1)
love.graphics.circle("fill",rx,ry,1)
Nothing special there, or so I thought. I wanted to see how it interacted with a line of color, so I did this when first making the canvas:

Code: Select all

love.graphics.setColor(0,0,1,1)
love.graphics.rectangle("fill",4,0,1,64)
The blue line was always disappearing though. I did a lot of experimenting to find why it was disappearing and what I found is that setColor was acting to multiply the colors the shader returned by what setColor was set to. Or to be more clear, if the shader returned red at 0.5 and I had used setColor to setColor(0.5,0.5,0.5,1), the red would be 0.25.

Is this interaction intended?

Re: Shaders and setColor

Posted: Sat May 20, 2023 6:46 am
by UnixRoot
Yes, setColor sets a global color value that's used for every drawing operation afterwards. Everything you draw after setColor is affected. With setColor( 0.5, 0.5, 0.5, 1.0 ) you get halfed color values.

Re: Shaders and setColor

Posted: Sat May 20, 2023 6:58 am
by seiya
Thank you.

I thought that was the case, but it is better to better to get confirmation than set myself up for problems later.