Vignette Effect


(Posted 1 year ago) RonTek

straight-up no frills vignette effect for OpenB3D, great with survival and post-apoc games!

OpenB3D - Vignette Effect GLSL

Usage

Local shader:TShader=LoadShader("","../glsl/default.vert.glsl", "../glsl/vignette.frag.glsl")
ShaderTexture(shader,colortex,"texture0",0) ' Our render texture
SetFloat(shader,"Radius",0.75)
SetFloat(shader,"Softness",0.45)
ShadeEntity(screensprite, shader)

vignette.frag.glsl

uniform sampler2D texture0;

uniform float Radius;
uniform float Softness;

void main() {   

    vec4 Color = texture2D(texture0, gl_TexCoord[0].xy);        
    vec2 screenpos = gl_TexCoord[0].xy * vec2(1.0, -1.0);
    float dist = length(screenpos - 0.5);    
    float vignette = smoothstep(Radius, Radius - Softness, dist);    
    Color.rgb = mix(Color.rgb, Color.rgb * vignette, 1.0);    
    gl_FragColor = Color;   

}
(Posted 1 year ago) markcwm commented:

Hi Ron,

it's a nice and simple effect, it does add a bit of nostalgia to the scene. I'm thinking it would also suit an RPG.

Thanks!

(Posted 1 year ago) RonTek commented:

Ah yes of course, RPG games would be nice as well! :D

Reply To Topic

Please log in to reply