Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / converting scanline shader to sprite shader and playing with it

Author
Message
tmu
7
Years of Service
User Offline
Joined: 2nd Feb 2017
Location:
Posted: 17th Aug 2017 13:42
While trying to get the shockwave shader to go fullscreen, I used the scanline shader (community shader thread page 2) as an example. Then I figured it could be useful for me as a sprite shader so I tried to port the other way too from fullscreen->sprite shader.

This is what I got:

main.agc:



scanline.ps:




So it seems to work fine as a sprite shader. But a few questions.

Notice how I tried to change the scanline to move across the image in the y-direction. This is the "offset" variable I added into the scanline pixel shader. I am shader n00b forever, so probably all wrong. Anyway, I feel like I got a bit of an odd result.
If you use the "noscanline.png" image (just download it from baxslash's shader post), it seems to "flicker". That is, the size or lines seem to go up and down. Different flicker than what I got with multiple ripples in shockwave. This flicker here is actually quite nice, and I would like to have a version that does this reliably as another version.

But if I use the "spr_shield_preview.png" image from https://opengameart.org/content/shield-effect, the scanlines seem to be moving up as I was trying to do. Is it just some property of the images or what is the cause?

Also, I am not entirely clear as to what the last line of the scanline shader does:

gl_FragColor = texture2D(texture0, uvVarying.xy) * (delta + ran);

When a line is changed to "black" (creates the scanline) is it also changing the alpha to 0 so that it is actually transparent? I tried to put the shield with the shader applied on it on top of something else and it seems to be transparent, but it would not be the first time for me to try it wrong



tmu
7
Years of Service
User Offline
Joined: 2nd Feb 2017
Location:
Posted: 17th Aug 2017 21:43
Well I managed to get this kind of working more as I expected.

main.agc:






and scanline.ps:



This causes the images to have dynamic noise on it. That is, the noise changes over time. Because the previous version had "static" noise in the sense it stays the same.
This also has a black line moving up every 200 pixels. The scanline.
I read somewhere on the internet that branching is bad performance in shaders so I made tricks to avoid. Because everything on the internet must be true.

Something I haven't quite managed to figure out is how to make the black line not black but transparent? If I put something behind the sprite, it does not show up through the black scanline.

Was thinking of using this on an energy shield image to give it some life. Not sure if that makes sense given how it looks. If anyone has a link to a more suitable shader hidden in these forums or something..


Login to post a reply

Server time is: 2024-04-19 16:32:37
Your offset time is: 2024-04-19 16:32:37