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

Homepage Members Register Login Search Old board


Neuer Thread ...
More : [1] [2]


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 27.06.2006 - 08:30Jump to top Quote this post Report this post Edit Delete


Updated release: v1.02.

The shader level settings in the video plugin will change the "mode" used with the shader as such:

1 - Pencil Sketch Mode
2 - 1/3 Strength Normal Mode
3 - 2/3 Strength Normal Mode
4 - Full Strength Normal Mode

I've included functions to handle RGB HSL conversion, and am using the L value of the HSL color to manipulate the color Luminance instead of the old method. I've noticed a couple of places so far where it seems to offer some better results with the resulting colors vs. my old calculations.

Also, I've added a saturation modifier that will increase the saturation, to (hopefully) give it more of a brightly-colored cartoon look.

There's some additional comments scattered throughout, which lists what some of the values are for, along with their defaults. If you want to play around with the settings, this might make things easier for you.

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:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
 

// MMJ's Cel Shader - v1.02
//
// ----------------------------------------------------------------
// Special thanks go out to Maruke for his CComic shader,
// and for allowing me to release this shader based upon his work.
// ----------------------------------------------------------------
//
// Shader Level settings will change the "mode" used
//
// 1 - Pencil Mode
// 2 - 1/3 Strength
// 3 - 2/3 Strength
// 4 - Full Strength
//
// -----------
// 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;

    // gray, no chroma
    if(dMax == 0.0) {
        vH = 0.0; vS = 0.0;

    // chromatic data
    } else {
        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);
}

float Hue2RGB(in float v1, in float v2, in float vH) {
    float v3;

    if     (vH < 0.0) { vH += 1.0; }
    else if(vH > 1.0) { vH -= 1.0; }

    if     ((6.0 * vH) < 1.0) { v3 = v1 + (v2 - v1) * 6.0 * vH; }
    else if((2.0 * vH) < 1.0) { v3 = v2; }
    else if((3.0 * vH) < 2.0) { v3 = v1 + (v2 - v1) * ((2.0 / 3.0) - vH) * 6.0; }
    else                      { v3 = v1; }

    return v3;
}

vec3 HSL2RGB(in vec3 vHSL) {
    float cR, cG, cB, v1, v2;

    if(vHSL[1] == 0.0) {
        cR = vHSL[2]; cG = vHSL[2]; cB = vHSL[2];

    } else {
        if(vHSL[2] < 0.5) { v2 = vHSL[2] * (1.0 + vHSL[1] ); }
        else              { v2 = (vHSL[2] + vHSL[1] ) - (vHSL[1] * vHSL[2] ); }

        v1 = 2.0 * vHSL[2] - v2;

        cR = Hue2RGB(v1, v2, vHSL[0] + (1.0 / 3.0));
        cG = Hue2RGB(v1, v2, vHSL[0] );
        cB = Hue2RGB(v1, v2, vHSL[0] - (1.0 / 3.0));
    }
    return vec3(cR, cG, cB);
}

vec3 colorAdjust(in vec3 cRGB) {
    vec3 cHSL;
    float cr, sl, ml, ms, aw, ab;

    cHSL = RGB2HSL(cRGB);

    // absolute white level cutoff
    aw = 0.9675; // default: 0.9675

    // absolute black level cutoff
    ab = 0.0325; // default: 0.0325

    // number of shading levels (not counting absolute white and black levels)
    sl = 7.0; // default: 7.0

    // color range per shading level
    cr = 1.0 / sl; // default: 1.0 / sl

    // modification value for color adjustment
    ml = mod(cHSL[2], cr); // default: mod(cHSL[2], cr)

    // saturation modifier
    ms = 1.2; // default: 1.2

    // normal modes
    if(OGL2Param.z > 0.0) {
        if     (cHSL[2] > aw) { cHSL[1]  = 1.0; cHSL[2]  = 1.0; }
        else if(cHSL[2] > ab) { cHSL[1] *= ms;  cHSL[2] += ((cr * (cHSL[2] + 0.6)) - ml); }
        else                  { cHSL[1]  = 0.0; cHSL[2]  = 0.0; }
        cHSL[2] = clamp(cHSL[2], float(int(cHSL[2] / cr) - 1) * cr, float(int(cHSL[2] / cr) + 1) * cr);
        cRGB = HSL2RGB(cHSL);

    // pencil mode
    } else {
        if     (cHSL[2] + 0.2 > aw) { cRGB = vec3(1.0); }
        else if(cHSL[2] > ab)       { cRGB = vec3(cHSL[2] + ((cr * (cHSL[2] + 0.65)) - ml + 0.2)); }
        else                        { cRGB = vec3(0.2); }
    }
    return cRGB;
}

void main(void) {
    vec3  h, hz, o, c0, c2, c4, c6, c8, c9, cz, c1, c3, c5, c7;
    float i, k, kz, mo;

    // outline modifier
    mo = 0.2; // default: mo = 0.2

    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;

    c9 = (c0 * 5.0 + c1 * 10.0 + c2 * 5.0 + c3 * 10.0 + c4 * 4.0 + c5 * 10.0 + c6 * 5.0 + c7 * 10.0 + c8 * 5.0) / 64.0;

    o = vec3(1.0); h = vec3(0.05); hz = h; k = 0.01; kz = 0.0035;

    cz  = (c4 + h) / (dot(o, c4) + k);

    hz = (cz - ((c0 + h) / (dot(o, c0) + k))); i  = kz / (dot(hz, hz) + kz);
    hz = (cz - ((c1 + h) / (dot(o, c1) + k))); i += kz / (dot(hz, hz) + kz);
    hz = (cz - ((c2 + h) / (dot(o, c2) + k))); i += kz / (dot(hz, hz) + kz);
    hz = (cz - ((c3 + h) / (dot(o, c3) + k))); i += kz / (dot(hz, hz) + kz);
    hz = (cz - ((c5 + h) / (dot(o, c5) + k))); i += kz / (dot(hz, hz) + kz);
    hz = (cz - ((c6 + h) / (dot(o, c6) + k))); i += kz / (dot(hz, hz) + kz);
    hz = (cz - ((c7 + h) / (dot(o, c7) + k))); i += kz / (dot(hz, hz) + kz);
    hz = (cz - ((c8 + h) / (dot(o, c8) + k))); i += kz / (dot(hz, hz) + kz);

    i /= 8.0;

    if(OGL2Param.z < 2.0) {
        if(OGL2Param.z == 0.0) { // Pencil Mode
            c9 = colorAdjust(c9) * i;
            if(c9.r < 0.2) { c9.rgb = vec3(0.2); }
            gl_FragColor.rgb = c9;

        } else { // 1/3 strength
            if(i < mo) { i = mo; }
            c9 = min(o, min(c9, c9 + dot(o, c9)));
            gl_FragColor.rgb = mix(c4, colorAdjust(c9), 0.33) * i;
        }

    } else {
        if(OGL2Param.z == 2.0) { // 2/3 strength
            if(i < mo) { i = mo; }
            c9 = min(o, min(c9, c9 + dot(o, c9)));
            gl_FragColor.rgb = mix(c4, colorAdjust(c9), 0.67) * i;

        } else { // Full strength
            if(i < mo) { i = mo; }
            c9 = min(o, min(c9, c9 + dot(o, c9)));
            gl_FragColor.rgb = colorAdjust(c9) * i;
        }
    }
}


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:
27:
28:
29:
30:
31:
32:
33:
34:
35:
 

// MMJ's Cel Shader - v1.02
//
// ----------------------------------------------------------------
// Special thanks go out to Maruke for his CComic shader,
// and for allowing me to release this shader based upon his work.
// ----------------------------------------------------------------
//
// Shader Level settings will change the "mode" used
//
// 1 - Pencil Mode
// 2 - 1/3 Strength
// 3 - 2/3 Strength
// 4 - Full Strength
//
// -----------
// 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] + 2.0 * offset;
}


[Dieser Beitrag wurde am 21.10.2006 - 08:51 von MegaManJuno aktualisiert]





Signature

MegaManJuno 
Strong supporter
......

...

Status:Offline
Date registered: 28.02.2006
Post:34
Send Message
...   Created on 27.06.2006 - 22:25Jump to top Quote this post Report this post Edit Delete


I added a set of comparison shots here from Final Fantasy VIII for each of the modes.

I'll add some more shots later on that site.

If anyone has any shots they'd like to share here using this shader, by all means, please do so. I'd be interested in seeing how it looks with other games I haven't tried it with yet.





Signature

MegaManJuno 
Strong supporter
......

...

Status:Offline
Date registered: 28.02.2006
Post:34
Send Message
...   Created on 28.06.2006 - 07:00Jump to top Quote this post Report this post Edit Delete


SLF updated with some changes to the Pencil Sketch mode.





Signature

MegaManJuno 
Strong supporter
......

...

Status:Offline
Date registered: 28.02.2006
Post:34
Send Message
...   Created on 29.06.2006 - 05:21Jump to top Quote this post Report this post Edit Delete


A set of comparison shots from Tomb Raider II and Threads of Fate were added to my putfile page.

[Dieser Beitrag wurde am 29.06.2006 - 05:21 von MegaManJuno aktualisiert]





Signature

MegaManJuno 
Strong supporter
......

...

Status:Offline
Date registered: 28.02.2006
Post:34
Send Message
...   Created on 29.08.2006 - 06:03Jump to top Quote this post Report this post Edit Delete


Updated... v1.0 release!

I've not really had time to work with it lately and try to tweak it any, but thought I'd go ahead and release what I have. Just don't be suprised if it's slow...

As always, feedback is welcomed and encouraged. Also, if you find a way to speed it up without sacrificing "the look", I'd be happy to take suggestions, and give proper credit for the help.

I've not tested it with many games yet, so if you've got any screenshots to show off while using the shader, by all means link to or post them here.

Later, and enjoy!
MMJ





Signature

ZerouEx 



...

Status:Offline
Date registered: 04.09.2006
Post:3
Send Message
...   Created on 04.09.2006 - 04:32Jump to top Quote this post Report this post Edit Delete


Hello MMJ. So far, the first two versions of your shader have caused a crash upon loading any PSX game Typically windows error report etc. Your new version now gives me a syntax error during a compilation of some sort, 0,76 ; is the error apparently.

I run a 850XT and am wondering if my card is even supposed to work with your shader as I could not get any version to work. I'm currently using other cartoon book/story book shaders with ease




MegaManJuno 
Strong supporter
......

...

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


I updated the shader again above (v1.01).

Hmm... there seems to be a bug in the board software for the CODE tag. I just looked over the code after making the post and it seems like some of the closing parenthesis are being dropped.

If you copied the code directly from the post before, that's likely your problem. I'm going to mess around and see if I can modify the post so the missing parenthesis show up properly.

EDIT: OK, seems to be that the bug is when the "]" character is followed by the ")" character in the CODE tag for the forum/board software. Adding a space in between the 2 characters seems to allow the ")" to show up properly.

Please try this version and let me know if you still have problems. If so, I may need to ask someone with shader experience and an ATI card for help in tracking down the problem (don't have any ATI cards here to test with).

[Dieser Beitrag wurde am 04.09.2006 - 10:42 von MegaManJuno aktualisiert]





Signature

ZerouEx 



...

Status:Offline
Date registered: 04.09.2006
Post:3
Send Message
...   Created on 04.09.2006 - 23:24Jump to top Quote this post Report this post Edit Delete


Hi! Well, I tried your new update code, and infact got a different syntax error (3 to be exact) on the same line :P

"cHSL[2] = clamp(cHSL[2], (int(cHSL[2] / cr) - 1) * cr, (int(cHSL[2] / cr) + 1) * cr);"

is what is causing the error, clamp being undefined and some other 2 syntax. For fun I took this line out and got the same results of your previous plug-ins before (Windows ePsxe error, both 1.5.2/1.6.0. Boo. Sp2 WinXP...

But yeah I'm thinking I guess it's something with my 850XT. *Cry*




MegaManJuno 
Strong supporter
......

...

Status:Offline
Date registered: 28.02.2006
Post:34
Send Message
...   Created on 11.09.2006 - 21:24Jump to top Quote this post Report this post Edit Delete


Well, unless ATI doesn't support the clamp() function (which I doubt), the problem probably lies somewhere else on that line. I think your problem with that line may be that I forgot to include the conversion back to float (those two parts were converted to int initially so I could effectively truncate decimal points). I guess the nVidia drivers didn't complain about it and handled the conversion on it's own..?

In any event, I've got a new version that I should be posting shortly that has a partially rewritten color calculation (and does away with the clamp altogether if I recall correctly). The current one just seems a little too "harsh" to me after more testing with it flattening the colors so much. The newer one will be a little more "relaxed" on how aggressively it manipulates the colors.

I'm not sure if this will help in your case at all. One thing to ask though, have you tried a different driver release for your graphics card? From what I've heard, there have been certain versions that can cause issues due to bugs in the drivers... I have no idea if that's the case with you though. It's too bad I don't have an ATI card to test with here so I could try to reproduce the problem.





Signature

foxyshadis 



...

Status:Offline
Date registered: 18.10.2006
Post:3
Send Message
...   Created on 18.10.2006 - 05:02Jump to top Quote this post Report this post Edit Delete


I certainly hope to see this new version soon, I'm really looking forward to it.

As an aside to anyone else having trouble with the clamp() crash on ATI cards, it's a difference in implementation. Apparently ATI (at least the current drivers) won't implicitly cast from int to float, so you only need to change the line to:

Code:
1:
 
cHSL[2] = clamp(cHSL[2], float(int(cHSL[2] / cr) - 1) * cr, float(int(cHSL[2] / cr) + 1) * cr);




More : [1] [2]

Similarly threads:
Topics Created by Replies Boardname
Natural Vision Shader + AA Shader v2.o = Best Shader for 2d !! zaykho 16 pete_bernert
shader guest 2 pete_bernert
Shader Aquamarin 0 schaddi
4-in-1 Shader v1.10 MegaManJuno 3 pete_bernert
PSX shader guest 8 pete_bernert
Neuer Thread ...





Masthead

This forum is a free service of razyboard.com
Do you want a free forum in less than two minutes? Then click here!



Verwandte Suchbegriffe:
epsxe bloom shader | psx bloom shader | hdr ogl2 epsxe | epsxe bloom | epsxe make arb shading work | arb cel shader | hsl2rgb shader | hsl2rgb
blank