Pete´s Messageboard... No ISO/BIOS requests!

Homepage Members Register Login Search Old board


Neuer Thread ...


AuthorTopics » Book an abo for this threadClose Thread Move Thread Fix the thread Print view Delete this thread

MegaManJuno 
Strong supporter
......

...

Status:Offline
Date registered: 28.02.2006
Post:34
Send Message
...   Created on 04.09.2006 - 10:50Jump to top Quote this post Report this post Edit Delete


It seems guest beat me to the punch with his AA bloom shader... Anyway, here's a "fake" HDR-ish shader I started working on before guest posted his shader.

SLF

Code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
 

// MMJ's Simulated HDR Shader - v1.0
//
// Here's one to simulate (to some extent) the HDR effect used in some modern games.
// The Shader Level setting will increase the strength of the effect in increments of 25%.
//
// Try adjusting the m, cutoffL, and cutoffH values in the colorAdjust function to alter the effect.
//
// ------------------------
// MegaManJuno

uniform sampler2D OGL2Texture;
uniform vec4 OGL2Param;

vec3 RGB2HSL(in vec3 cRGB) {
    float vH, vS, vL, cR, cG, cB, vMin, vMax, dMax, dR, dG, dB;

    cR = cRGB[0]; cG = cRGB[1]; cB = cRGB[2];

    vMin = min(min(cR, cG), cB); vMax = max(max(cR, cG), cB);
    dMax = vMax - vMin;

    vL = (vMax + vMin) / 2.0;

    if(dMax == 0.0) { // gray, no chromatic data present
        vH = 0.0; vS = 0.0;

    } else { // chromatic data present
        if(vL < 0.5) { vS = dMax / (vMax + vMin); }
        else         { vS = dMax / (2.0 - vMax - vMin); }

        dR = (((vMax - cR) / 6.0) + (dMax / 2.0)) / dMax;
        dG = (((vMax - cG) / 6.0) + (dMax / 2.0)) / dMax;
        dB = (((vMax - cB) / 6.0) + (dMax / 2.0)) / dMax;

        if     (cR >= vMax) { vH = dB - dG; }
        else if(cG >= vMax) { vH = (1.0 / 3.0) + dR - dB; }
        else if(cB >= vMax) { vH = (2.0 / 3.0) + dG - dR; }

        if     (vH < 0.0) { vH += 1.0; }
        else if(vH > 1.0) { vH -= 1.0; }
    }
    return vec3(vH, vS, vL);
}

vec3 colorAdjust(in vec3 co0, in vec3 co1, in vec3 co2, in vec3 co3, in vec3 co4, in vec3 co5, in vec3 co6, in vec3 co7, in vec3 co8) {
    float m, m0, m1, m2, m3, m4, m5, m6, m7, m8, cutoffH, cutoffL;

    // value to determine where we switch from brightening (overexposure) to darkening (underexposure) of the output color
    m = 1.6; // default: 1.6

    // cutoff value for increasing the "overexposure" brightness (don't multiply the brightness more than ~this~)
    cutoffH = 1.125; // default: 1.125

    // cutoff value for decreasing the "underexposure" brightness (don't multiply the brightness less than ~this~)
    cutoffL = 0.875; // default: 0.875

    // brightness adjustment calculations
    m0 = 0.5 * clamp(m - (1.0 - RGB2HSL(co0)[2] ), cutoffL, cutoffH);
    m1 = 1.0 * clamp(m - (1.0 - RGB2HSL(co1)[2] ), cutoffL, cutoffH);
    m2 = 0.5 * clamp(m - (1.0 - RGB2HSL(co2)[2] ), cutoffL, cutoffH);
    m3 = 1.0 * clamp(m - (1.0 - RGB2HSL(co3)[2] ), cutoffL, cutoffH);
    m4 = 0.4 * clamp(m - (1.0 - RGB2HSL(co4)[2] ), cutoffL, cutoffH);
    m5 = 1.0 * clamp(m - (1.0 - RGB2HSL(co5)[2] ), cutoffL, cutoffH);
    m6 = 0.5 * clamp(m - (1.0 - RGB2HSL(co6)[2] ), cutoffL, cutoffH);
    m7 = 1.0 * clamp(m - (1.0 - RGB2HSL(co7)[2] ), cutoffL, cutoffH);
    m8 = 0.5 * clamp(m - (1.0 - RGB2HSL(co8)[2] ), cutoffL, cutoffH);

    // return blended color with brightness adjustments applied
    return (co0 * m0 + co1 * m1 + co2 * m2 + co3 * m3 + co4 * m4 + co5 * m5 + co6 * m6 + co7 * m7 + co8 * m8) / 6.4;
}

void main(void) {
    vec3  c0, c1, c2, c3, c4, c5, c6, c7, c8, b;

    b = (OGL2Param.z + 1.0) * 0.25;

    c0 = texture2D(OGL2Texture, gl_TexCoord[3].xy).rgb;
    c1 = texture2D(OGL2Texture, gl_TexCoord[2].xy).rgb;
    c2 = texture2D(OGL2Texture, gl_TexCoord[3].zy).rgb;
    c3 = texture2D(OGL2Texture, gl_TexCoord[1].xy).rgb;
    c4 = texture2D(OGL2Texture, gl_TexCoord[0].xy).rgb;
    c5 = texture2D(OGL2Texture, gl_TexCoord[1].zw).rgb;
    c6 = texture2D(OGL2Texture, gl_TexCoord[3].xw).rgb;
    c7 = texture2D(OGL2Texture, gl_TexCoord[2].zw).rgb;
    c8 = texture2D(OGL2Texture, gl_TexCoord[3].zw).rgb;

    gl_FragColor.rgb = mix(c4, colorAdjust(c0, c1, c2, c3, c4, c5, c6, c7, c8), b);
}


SLV
Code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
 

// MMJ's Simulated HDR Shader - v1.0
//
// Here's one to simulate (to some extent) the HDR effect used in some modern games.
// The Shader Level setting will increase the strength of the effect in increments of 25%.
//
// ------------------------
// MegaManJuno

uniform vec4 OGL2InvSize;

void main() {
    vec4 offset;

    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;

    gl_TexCoord[0] = gl_MultiTexCoord0.xyxy;

    offset.xy = -(offset.zw = vec2(OGL2InvSize.x, 0.0));
    gl_TexCoord[1] = gl_TexCoord[0] + offset;

    offset.xy = -(offset.zw = vec2(0.0, OGL2InvSize.y));
    gl_TexCoord[2] = gl_TexCoord[0] + offset;
    gl_TexCoord[3] = gl_TexCoord[1] + offset;
}


[Dieser Beitrag wurde am 04.09.2006 - 18:15 von MegaManJuno aktualisiert]





Signature


Similarly threads:
Topics Created by Replies Boardname
Natural Vision Shader + AA Shader v2.o = Best Shader for 2d !! zaykho 10 pete_bernert
MMJ's 4-in-1 Shader MegaManJuno 10 pete_bernert
What's a Shader Near 1 pete_bernert
Shader Aquamarin 0 schaddi
4-in-1 Shader v1.10 MegaManJuno 3 pete_bernert
Neuer Thread ...





Masthead

This forum is a free service of razyboard.com powered by:
Geizkragen Price Comparison. Top product in the price comparison: Krups Nespresso Essenza (XN2001)
Do you want a free forum in less than two minutes? Then click here!



Verwandte Suchbegriffe:
hdr shader | simulated hdr | hdr shader slf | hdr arb shader | rgb2hsl shader | rgb2hsl | bloom hdr shaders | hdr shader void main
blank