Page 1 of 1

To canvas then to screen, why change?. See #5.

Posted: Mon Oct 12, 2015 4:21 pm
by padicao2010
I use shader to implement an animation, by changing shader parameters.
When the animation ends, the shader is set to

Code: Select all

vec4 effect(vec4 color, Image texture, vec2 tc, vec2 _)
{
	return Texel(texture, tc) * color;
}
And then I remove the shader, it change a lot.

I'm so new at shader.

My question is how can i keep the screen the same when i remove a shader.

What the shader should be like?

Re: What the shader is like when it does nothing?

Posted: Tue Oct 13, 2015 1:07 am
by arampl
You can bake any effects to canvas, then draw this canvas like simple image.

Re: What the shader is like when it does nothing?

Posted: Tue Oct 13, 2015 1:08 am
by Alexar
i am not quite follow you, but draw things to a canvas with shader, you can deal with canvas more easily.
oh, your code

Code: Select all

vec4 effect(vec4 color, Image texture, vec2 tc, vec2 _)  
{
   return Texel(texture, tc) * color;
//just return the "color" is what you want...
//  Texel(texture, tc)==color if you draw a texture
}

Re: What the shader is like when it does nothing?

Posted: Tue Oct 13, 2015 2:32 am
by padicao2010
Alexar wrote:i am not quite follow you, but draw things to a canvas with shader, you can deal with canvas more easily.
oh, your code

Code: Select all

vec4 effect(vec4 color, Image texture, vec2 tc, vec2 _)  
{
   return Texel(texture, tc) * color;
//just return the "color" is what you want...
//  Texel(texture, tc)==color if you draw a texture
}
Sorry, following the detail.

I use https://github.com/vrld/shine, and add a new shader, imitating colorgradesimple, as follow

Code: Select all

		extern number grade;
		vec4 effect(vec4 color, Image texture, vec2 tc, vec2 _)
		{
			return vec4(grade, grade, grade, grade) * Texel(texture, tc) * color;
		}

Code: Select all

if shader then
    shader:draw(function()
        DRAW SOMETHING
    end)
else
    DRAW SOMETHING
end
Grade is change from 0.0 to 1.0 smoothly.
When Grade is equal to or larger than 1.0f, the shader is removed.
I want to keep 'DRAW SOMTHING' looks almost the same after the shader is removed.
However, it changes a lot.

Also i change BlendMode from 'premultiplied' (colorgradesimple, vrld/shine) to 'alpha'.
Does it matter?

Re: What the shader is like when it does nothing?

Posted: Wed Oct 14, 2015 3:21 pm
by padicao2010
I do a test, remove the shader.

It seems that CASE 1:

Code: Select all

local raw = love.graphics.newCanvas()
local r, g, b, a = love.graphics.getColor()
love.graphics.setCanvas(raw)

DRAW SOMETHING

love.graphics.setColor(r, g, b, a)
love.graphics.setCanvas(nil)
love.graphics.draw(raw, 0, 0)
is not the the same with CASE 2

Code: Select all

DRAW SOMETHING
The color in CASE 2 is a little more bright then in CASE 1.

Is that right? But why?
And how to make them the same?