Page 12 of 33

Re: Share a Shader!

Posted: Thu Aug 02, 2012 11:39 pm
by Dynodzzo
Hi,

recently, i started thinking about the lights in a project. So i first look for some topics talking about that, i saw the "This is not a game" way to do that, but i didn't found this method apropriate. Then I found PixelEffects. I learned GLSL language and tried to make my own light effect, and I did it :ultrahappy:
But in my game, i want more than one light source, so i started to modify the shader in a way that it can handle 32 light sources, multidirectional or unidirectional. The problems comes here, despite my best efforts, only one source is displayed at a time...

I hope someone could read my work and, maybe, found the problem, it would help me a lot !
Here's the shader.

Thank you beforehand, and sorry for the english, not my first language ^^

Re: Share a Shader!

Posted: Fri Aug 03, 2012 10:46 am
by Petunien
Hi,

I'm new to shaders and I'm sure I wouldn't learn it that fast.

Therefore my question.

Is it difficult to make two lights for a little spaceships? All areas that are not affected by the lights should be obscured/nebulized.

Basically like in Ref's "tile_page" (viewtopic.php?f=4&t=3733&start=100#p61880).

Re: Share a Shader!

Posted: Fri Aug 03, 2012 9:55 pm
by randrews
My first shader! It pixelates an image.

Re: Share a Shader!

Posted: Sat Aug 04, 2012 2:45 am
by Ref
Petunien wrote: Hi,
I'm new to shaders and I'm sure I wouldn't learn it that fast.
Therefore my question.
Is it difficult to make two lights for a little spaceships? All areas that are not affected by the lights should be obscured/nebulized.
Basically like in Ref's "tile_page" (viewtopic.php?f=4&t=3733&start=100#p61880).
Not sure that this is exactly what's wanted but hope it helps.
CAUTION: Contains 'CANVASES' and can cause heavy breathing and red eyes in some people!
Haven't figure out exactly what Xgolf is doing with fakecanvases yet.
Sure is a lot of code to get around. Like the greater than 200 fps with canvases even with a hand cranked dual core.

Re: Share a Shader!

Posted: Sat Aug 04, 2012 9:30 am
by Petunien
Thank you! It's very nice! :)

I think I've got to learn this anyway.

Re: Share a Shader!

Posted: Sat Aug 04, 2012 2:09 pm
by Ref
Petunien wrote:Thank you! It's very nice! :)
I think I've got to learn this anyway.
I don't know if this is any clearer but you can simplify the shader:

Code: Select all

effect = gr.newPixelEffect [[
    extern Image  mask;
    vec4 effect(vec4 color,Image tex,vec2 tc,vec2 pc)
    {	
        vec4 img_color   = Texel( tex, tc );
        vec4 mask_color = Texel( mask, tc );
        img_color.a        = mask_color.a;    // just transfer the mask's alpha to image
        return img_color;
    }
    ]]
and determine what gets shown by:

Code: Select all

mask_canvas:clear(0,0,0,backgnd_intensity)    -- for areas to be suppressed
gr.setColor( 255, 255, 255, beam.intensity )     -- for areas to be transferred as a  beam
You could have a gradient light beam by how you set the coloralpha when drawing the mask.
With a few extra lines in the shader, you could also add some color to the beam (yellow?).
Good luck being creative!

Re: Share a Shader!

Posted: Mon Aug 13, 2012 12:34 am
by Ref
Tried to comparing masking using pixelEffect and Stencil + mapPixel.
Result: pixelEffect >200 fps while Stencil + mapPixel 1 fps
Didn't full appreciate the speed penality with mapPixel plus I was unsuccesful at using characters as a mask - just got white rectangles.
The mask via pixelEffect is really simple to impliment:
1. create a canvas with the desired background alpha
2. draw on canvas using the desired foreground alpha
3. apply the effect
4. everywhere you drew will now appear with the foreground alpha
Attached file is a simple test.

Re: Share a Shader!

Posted: Mon Aug 20, 2012 5:41 pm
by Petunien
Sorry for the late answer. Thank you for the explanation. :)

I'll try it if I get spare time. Thank you again.

Re: Share a Shader!

Posted: Sat Sep 08, 2012 12:49 pm
by Mandarancio
Some one can help me to understand how make shaders like this two (of course I think is more than a single shader), both made using Love!

https://vimeo.com/45259228
https://vimeo.com/43841761

Final effect is really cool!

Re: Share a Shader!

Posted: Wed Sep 19, 2012 3:36 am
by Jasoco
Those are really nice. I like the second one.