Share a Shader!

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Dynodzzo
Prole
Posts: 1
Joined: Thu Aug 02, 2012 11:16 pm

Re: Share a Shader!

Post 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 ^^
User avatar
Petunien
Party member
Posts: 191
Joined: Fri Feb 03, 2012 8:02 pm
Location: South Tyrol (Italy)

Re: Share a Shader!

Post 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).
"Docendo discimus" - Lucius Annaeus Seneca
randrews
Prole
Posts: 1
Joined: Fri Aug 03, 2012 9:53 pm

Re: Share a Shader!

Post by randrews »

My first shader! It pixelates an image.
Attachments
pixelize.love
(61.19 KiB) Downloaded 685 times
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Share a Shader!

Post 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.
Attachments
headlights.love
simple shader for simulated head lights
(149.06 KiB) Downloaded 521 times
User avatar
Petunien
Party member
Posts: 191
Joined: Fri Feb 03, 2012 8:02 pm
Location: South Tyrol (Italy)

Re: Share a Shader!

Post by Petunien »

Thank you! It's very nice! :)

I think I've got to learn this anyway.
"Docendo discimus" - Lucius Annaeus Seneca
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Share a Shader!

Post 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!
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Share a Shader!

Post 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.
Attachments
mask.love
Just a test of masking using characters
(58.15 KiB) Downloaded 397 times
User avatar
Petunien
Party member
Posts: 191
Joined: Fri Feb 03, 2012 8:02 pm
Location: South Tyrol (Italy)

Re: Share a Shader!

Post by Petunien »

Sorry for the late answer. Thank you for the explanation. :)

I'll try it if I get spare time. Thank you again.
"Docendo discimus" - Lucius Annaeus Seneca
User avatar
Mandarancio
Prole
Posts: 11
Joined: Mon Nov 03, 2008 5:08 pm
Location: Parma - Italy
Contact:

Re: Share a Shader!

Post 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!
Arch Linux user..
..No Freedom without Sharing..
http://mandarancio.deviantart.com/
http://manda.netsons.org/
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Share a Shader!

Post by Jasoco »

Those are really nice. I like the second one.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], Semrush [Bot] and 3 guests