GLSL equivalents of cartoon, glow shaders?

The cartoon-shader and glow-shader examples have some nice shaders I’d like to use for my game. But they’re in Cg, which is deprecated and missing support on some devices (Arm linux). I don’t suppose anyone’s converted these to modern GLSL implementations?

Please note that glow-shader is not implemented correctly and you will not be able to use it without problems. I think the problem is that this example was written a long time ago and at that time the Panda was less developed.

I’m actually using a custom glowShader.sha that tells objects to glow or not based on a shader input I give them. I’ve managed to convert that to GLSL, but any attempts to convert the x/y blur shaders that come with it fail, as do any attempts to convert the cartoon shaders.

I’m talking about implementing the example, if I’m not very wrong there, the buffer output is not correct.
Try adding an object and you will see that what I am talking about will become visible duplicated diffuse color. I used to fix this with a stencil buffer. However, it got straight edges of the glow.

self.box = loader.loadModel("box")
self.box.reparentTo(render)
self.box.setPos(0, -25, 0)

In fact, you can find any Gaussian blur code on the web and just redo it.

#version 330 core
out vec4 FragColor;
  
in vec2 TexCoords;

uniform sampler2D image;
  
uniform bool horizontal;
uniform float weight[5] = float[] (0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);

void main()
{             
    vec2 tex_offset = 1.0 / textureSize(image, 0); 
    vec3 result = texture(image, TexCoords).rgb * weight[0]; 
    if(horizontal)
    {
        for(int i = 1; i < 5; ++i)
        {
            result += texture(image, TexCoords + vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
            result += texture(image, TexCoords - vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
        }
    }
    else
    {
        for(int i = 1; i < 5; ++i)
        {
            result += texture(image, TexCoords + vec2(0.0, tex_offset.y * i)).rgb * weight[i];
            result += texture(image, TexCoords - vec2(0.0, tex_offset.y * i)).rgb * weight[i];
        }
    }
    FragColor = vec4(result, 1.0);
}

What should i set as the shader image ‘input’ in the context of Panda3d here?

It is obvious that texture: uniform sampler2D
You must pass the result of your first Shader as a texture to this one.

That’s not a very efficient shader, try this one instead:

The code to hook it up in Panda with FilterManager is here:

1 Like

This is because the glow filter is intended to be used together with the shader generator, which has a mode to write a glow mask to the alpha channel of the framebuffer (or to a separate bitplane). Without that, it acts more like a bloom filter instead.

Thank you both. This has gotten my code on the right path and the glow/blur shaders are working for a bloom effect. Any though on converting inkgen.sha to GLSL or finding a good equivalent?

ship engines