markcwm / openb3d.docs

OpenB3D source code examples with media included
3 stars 2 forks source link

Sepia Shader #4

Open blitzcoder opened 1 year ago

blitzcoder commented 1 year ago

Hey Mark, recently found this sepia shader to add more effects.. just the frag, use default.vert.glsl same as greyscale..

// https://www.shadertoy.com/view/3slfDl

varying vec4 vertColor;
uniform sampler2D texture0;

void main() {
    vec4 col = texture2D(texture0, gl_TexCoord[0].st)*vertColor;

    float rr = .393;
    float rg = .769;
    float rb = .189;
    float ra = 0.0;

    float gr = .349;
    float gg = .686;
    float gb = .168;
    float ga = 0.0;

    float br = .272;
    float bg = .534;
    float bb = .131;
    float ba = 0.0;

    float red = (rr * col.r) + (rb * col.b) + (rg * col.g) + (ra * col.a);
    float green = (gr * col.r) + (gb * col.b) + (gg * col.g) + (ga * col.a);
    float blue = (br * col.r) + (bb * col.b) + (bg * col.g) + (ba * col.a);

    gl_FragColor = vec4(red,green,blue,col.a);  
}
Kippykip commented 1 year ago

Oh cool! I was using the greyscale and putting a yellowish tint on with max2d all this time.

blitzcoder commented 1 year ago

cheers @Kippykip