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.
User avatar
farzher
Prole
Posts: 41
Joined: Fri Jul 31, 2015 5:38 pm

Re: Share a Shader!

Post by farzher » Sun Feb 28, 2016 1:52 am

binaryeye wrote:This may be the wrong thread because I don't know if this shader actually works.

I'm trying to convert a CRT shader found on Shadertoy to LÖVE. It runs without errors, but I get a black screen. I don't know if this is because the shader isn't working or because my system doesn't support it. I'm not exactly sure what I should be passing to the iChannel variable (it seems to want an image, so I'm drawing to a buffer and passing that), nor what the first variable should be in iResolution, so those could also be problems.

I've attached a .love. If anyone could run it and let me know what happens, I'd appreciate it. There should be a white circle in the center of the screen. Thanks!

Funny, I spent a few hours getting that exact shader working the other day. We ended up not using it though because it makes things look too blurry and dark. If anyone finds a nice CRT shader PLEASE LET ME KNOW! <3
The shaders on retroarch look awesome, but I don't know how to convert them.

I attached a working version of the shader, (although it still splits the image in 3 sections)
Attachments
shadertoy-crt-shader.love
(2.18 KiB) Downloaded 545 times
butts

bobbyjones
Party member
Posts: 720
Joined: Sat Apr 26, 2014 7:46 pm

Re: Share a Shader!

Post by bobbyjones » Sun Feb 28, 2016 8:17 am

I think shine has a CRT shader.
Do you frequently have great ideas but immediately lose them? Check out the MVP for my website called IdeaVault. It is designed to solve that problem. Desktop browsers only currently.

User avatar
Jack5500
Party member
Posts: 149
Joined: Wed Dec 07, 2011 8:38 pm
Location: Hamburg, Germany

Re: Share a Shader!

Post by Jack5500 » Sun Feb 28, 2016 10:44 am

bobbyjones wrote:I think shine has a CRT shader.
yes, shine has a CRT shader:

https://github.com/vrld/shine/blob/master/crt.lua

binaryeye
Prole
Posts: 8
Joined: Wed Feb 03, 2016 2:58 pm

Re: Share a Shader!

Post by binaryeye » Sun Feb 28, 2016 1:07 pm

farzher wrote:I attached a working version of the shader, (although it still splits the image in 3 sections)
Thanks for that. I would have never tried defining iResolution as a vec2.

I modified it to work full screen and you're right; it's generally too blurry and dark. It can be sharpened up but at the cost of losing the shadow mask effect, which is mainly what I'm after in a CRT shader.

User avatar
ingsoc451
Citizen
Posts: 86
Joined: Sat Feb 06, 2016 9:42 pm
Location: Oceania

Re: Share a Shader!

Post by ingsoc451 » Sun Feb 28, 2016 8:15 pm

I wish this was sticky
eom

User avatar
kbmonkey
Party member
Posts: 127
Joined: Tue Sep 01, 2015 12:19 pm

Re: Share a Shader!

Post by kbmonkey » Sun Apr 10, 2016 9:28 am

I got curious about adding reflective water in my games (specifically for 2D platform or point-and-click adventure perspectives). I implemented such a mirror via ImageData manipulation and was aghast yet unsurprised at the performance hit. So I had my hand at writing my first shader.

Very simple and likely an eyesore to those of you with more experience creating shaders :ehem:

Code: Select all

vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords )
        {
        
            // n represents where the source of the mirror pixels start.
            // 1.0 mirrors from the very top of the screen.
            // 0.5 mirrors from half-way up the screen.
            number n = 0.5;
            
            // Alter reflection with a slight blue tint
            vec4 overlayColor = vec4(0.1, 0.3, 0.6, 1.0);
        
            // Its a kind fo magic pink
            vec4 texcolor = Texel(texture, texture_coords);
            if (texcolor.r == 1.0 && texcolor.g == 0.0 && texcolor.b == 1.0)
            {
                // Mirror mirror on the wall
                vec2 mirrorpoint = vec2(
                    texture_coords.x,
                    1.0 - (texture_coords.y * n)
                    );
                
                return Texel(texture, mirrorpoint) * overlayColor;
                
            }
            else 
            {
                return texcolor * color;
            }
        }
    ]]
Attachments
simple-reflection-tech-demo.love
(22.84 KiB) Downloaded 435 times

User avatar
GhostAction
Prole
Posts: 34
Joined: Wed Apr 22, 2015 11:10 pm
Contact:

Re: Share a Shader!

Post by GhostAction » Mon Jun 06, 2016 9:51 pm

I am using the Mari0 CRT.frag shader for my project and for some reason I'm getting this result where the player is basically duplicated I guess: https://gyazo.com/ef7d97e62c1a6da9a5cd49e36fce8b0a

Anybody know whats going on?
Attachments
game.love
(5.88 KiB) Downloaded 288 times
Owner of Isocubic. (Developer of void²)

User avatar
rmcode
Party member
Posts: 454
Joined: Tue Jul 15, 2014 12:04 pm
Location: Germany
Contact:

Re: Share a Shader!

Post by rmcode » Mon Jun 06, 2016 10:03 pm

GhostAction wrote:I am using the Mari0 CRT.frag shader for my project and for some reason I'm getting this result where the player is basically duplicated I guess: https://gyazo.com/ef7d97e62c1a6da9a5cd49e36fce8b0a

Anybody know whats going on?
All you need to do is clearing the canvas before drawing to it again:

Code: Select all

function love.draw()
	love.graphics.setCanvas(canvas)
	love.graphics.clear()
	love.graphics.setColor(155, 155, 155)
	love.graphics.rectangle("fill", 0, 400, 800, 200)
	...

User avatar
GhostAction
Prole
Posts: 34
Joined: Wed Apr 22, 2015 11:10 pm
Contact:

Re: Share a Shader!

Post by GhostAction » Mon Jun 06, 2016 10:15 pm

@rmcode Thanks a lot!

Does anyone know how I could make the colors like stay the same as the game without shaders (ex. https://gyazo.com/3ab99d33a99f4d19bf2753f36d0dddb9)?
Owner of Isocubic. (Developer of void²)

User avatar
4aiman
Party member
Posts: 248
Joined: Sat Jan 16, 2016 10:30 am

Re: Share a Shader!

Post by 4aiman » Thu Jun 09, 2016 9:43 pm

It may be a little off-topic, but this thread has so many people sharing their shaders...

So, the question is: is there a way to somehow grab what was drawn so far and apply a shader to that?
I've tried using shine (and it worked ok) but failed to understand how to make it respect all my scale() and transform().

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 10 guests