If nothing else, persistent.
Another shader.
One thing you can say about shaders is they are counter-intuitive.
Have to reverse your logic.
Think this shader is for a glass ball but (as dumb as it might seem) not sure what a glass ball should look like.
Appreciate feedback.
Best,
Share a Shader!
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Share a Shader!
- Attachments
-
- Glass Ball.love
- Glass shader
- (206.13 KiB) Downloaded 636 times
Re: Share a Shader!
What do you mean by that?Ref wrote:Would like a transparent ball shader.
Yeah, you basically have to think in terms of what should be done to the pixel that you are processing right now instead of what are the pixels that you need to process given the thing that you have at the moment. Or in other words: You have to think in implicit rather than explicit terms.Ref wrote:One thing you can say about shaders is they are counter-intuitive.
Have to reverse your logic.
I really like the pixel effect way, because it forces you approach you problem from a new direction, which in turn leads to a better understanding of what you are doing.
Cool effect by the way
Re: Share a Shader!
Guess I didn't really appreciate how setPixelEffect works.
Ran into another gotchU.
Coordinate system (y axis) appears to be inverted when effect is applied to an 'image' rather than to a 'canvas'.
Such is life.
Have to do some more reading.
Ran into another gotchU.
Coordinate system (y axis) appears to be inverted when effect is applied to an 'image' rather than to a 'canvas'.
Such is life.
Have to do some more reading.
Re: Share a Shader!
Still trying to figure out PixelEffect.
Got a morphing effect to almost work.
and in love.draw()
Works as expected but ran into a dumb situation when I tried to create a Love file.
The image files hve to have an alpha channel - so I used png files.
Zip doesn't seem to like to include png files.
What am I doing wrong?
Help appreciated.
Got a morphing effect to almost work.
Code: Select all
morph = gr.newPixelEffect [[
extern float tran;
vec4 effect(vec4 color, Image texture, vec2 tc, vec2 pc )
{
vec4 pixel = Texel( texture, tc );
{pixel.r = tran*pixel.r;}
{pixel.g = tran*pixel.g;}
{pixel.b = tran*pixel.b;}
{pixel.a = tran*pixel.a;}
return pixel;
}
]]
Code: Select all
morph:send( 'tran', tran )
gr.setPixelEffect( morph )
gr.draw( image1,0,0,0,1,1 )
morph:send( 'tran', 1-tran )
gr.setPixelEffect( morph )
gr.draw( image2,0,0,0,1,1 )
gr.setPixelEffect()
The image files hve to have an alpha channel - so I used png files.
Zip doesn't seem to like to include png files.
What am I doing wrong?
Help appreciated.
Re: Share a Shader!
What program do you use to create .zips?
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Re: Share a Shader!
You can shorten the code by sending the target image to the effect.
Effect code:
Lua side code:
Effect code:
Code: Select all
extern Image target_image;
extern number s; // from 0 to 1
vec4 effect(vec4 color, Image texture, vec2 tc, vec2 pc )
{
vec4 pixel_from = Texel(texture, tc);
vec4 pixel_to = Texel(target_image, tc);
// you don't have to add the individual channels here
return (1.0 - s) * pixel_from + s * pixel_to;
// you could also write:
// return (1.0 - s) * Texel(texture,tx) + s * Texel(target_image, tc);
}
Code: Select all
fade:send('target_image', image2) -- somewhere in love.load
-- ...
fade:send('s', s)
love.graphics.setPixelEffect(fade)
love.graphics.draw(image1, 0, 0)
love.graphics.setPixelEffect()
Re: Share a Shader!
Thanks for the responses!
Nixola - using Windows SENG TO which works fine for jpg - so was surprised when it didn't do png.
Vrid - exactly what I wanted to know! will try your code.
Thanks all1
Nixola - using Windows SENG TO which works fine for jpg - so was surprised when it didn't do png.
Vrid - exactly what I wanted to know! will try your code.
Thanks all1
Re: Share a Shader!
I don't trust Windows anymore, I'd suggest trying 7zip
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Re: Share a Shader!
Sorry! Problem with zip was a typo.
Vrid's PixelEffect works fine (once tx is shanged to tc).
Would still like to be ale to change only a portion of the image so need to know how to index image2 data.
Vrid's PixelEffect works fine (once tx is shanged to tc).
Would still like to be ale to change only a portion of the image so need to know how to index image2 data.
- Attachments
-
- morph.love
- Simple image morphing
- (1.03 MiB) Downloaded 545 times
Re: Share a Shader!
Ok!
Just another (not too bright) example of PixelEffect.
Falls into the pigless 8 second category.
If you get tired of seeing random spots before your eyes, just hit 'r' and arrow keys & 'a'/'s' keys are available.
Still struggling with syntax for GLSL effects but coming slowly.
Best
Just another (not too bright) example of PixelEffect.
Falls into the pigless 8 second category.
If you get tired of seeing random spots before your eyes, just hit 'r' and arrow keys & 'a'/'s' keys are available.
Still struggling with syntax for GLSL effects but coming slowly.
Best
- Attachments
-
- spot.love
- (1.04 MiB) Downloaded 548 times
Who is online
Users browsing this forum: Ahrefs [Bot] and 5 guests