From 4a0150033fae7abab1af1a5a5a7a43e6f112f491 Mon Sep 17 00:00:00 2001 From: myownfriend Date: Tue, 20 May 2014 23:43:56 -0400 Subject: [PATCH] Update auto_toon2.glsl --- Data/Sys/Shaders/auto_toon2.glsl | 86 +++++++++++++++++--------------- 1 file changed, 45 insertions(+), 41 deletions(-) diff --git a/Data/Sys/Shaders/auto_toon2.glsl b/Data/Sys/Shaders/auto_toon2.glsl index 954bf631a5..d70de99a34 100644 --- a/Data/Sys/Shaders/auto_toon2.glsl +++ b/Data/Sys/Shaders/auto_toon2.glsl @@ -7,39 +7,40 @@ uniform vec4 resolution; void main() { - //Changethis to increase the number of colors. - int numColors =8; - float4 to_gray = float4(0.3,0.59,0.11,0); - float x1 = dot(to_gray, texture(samp9, uv0+vec2(1,1)*resolution.zw)); - float x0 = dot(to_gray, texture(samp9, uv0+vec2(-1,-1)*resolution.zw)); - float x3 = dot(to_gray, texture(samp9, uv0+vec2(1,-1)*resolution.zw)); - float x2 = dot(to_gray, texture(samp9, uv0+vec2(-1,1)*resolution.zw)); - float edge = (x1 - x0) * (x1 - x0) + (x3 - x2) * (x3 - x2); - float4 color = texture(samp9, uv0).rgba; + //Changethis to increase the number of colors. + int numColors =8; - float4 c0 = color - float4(edge, edge, edge, edge) * 12.0; + float4 to_gray = float4(0.3,0.59,0.11,0); + float x1 = dot(to_gray, texture(samp9, uv0+vec2(1,1)*resolution.zw)); + float x0 = dot(to_gray, texture(samp9, uv0+vec2(-1,-1)*resolution.zw)); + float x3 = dot(to_gray, texture(samp9, uv0+vec2(1,-1)*resolution.zw)); + float x2 = dot(to_gray, texture(samp9, uv0+vec2(-1,1)*resolution.zw)); + float edge = (x1 - x0) * (x1 - x0) + (x3 - x2) * (x3 - x2); + float4 color = texture(samp9, uv0).rgba; - + float4 c0 = color - float4(edge, edge, edge, edge) * 12.0; - float red = 0.0; - float green = 0.0; - float blue = 0.0; - bool rr = false; - bool bb = false; - bool gg = false; - int count = 1; - - float colorN = 0.0; - float colorB = 0.0; + float red = 0.0; + float green = 0.0; + float blue = 0.0; + bool rr = false; + bool bb = false; + bool gg = false; + int count = 1; - - for(count = 1; count <= numColors ; count++){ - colorN = float(count / numColors); - - if ( c0.r <= colorN && c0.r >= colorB && rr == false ){ - if (count == 1){ - if(colorN >= 0.1) + float colorN = 0.0; + float colorB = 0.0; + + for (count = 1; count <= numColors; count++) + { + colorN = float(count / numColors); + + if ( c0.r <= colorN && c0.r >= colorB && rr == false ) + { + if (count == 1) + { + if (colorN >= 0.1) red = 0.01; else red = colorN; @@ -47,13 +48,15 @@ void main() else if (count == numColors) red = 0.95; else - red = colorN ; - + red = colorN; + rr = true; } - if (c0.b <= colorN && c0.b >= colorB && bb == false){ - if (count == 1){ + if (c0.b <= colorN && c0.b >= colorB && bb == false) + { + if (count == 1) + { if(colorN >= 0.1) blue = 0.01; else @@ -67,26 +70,27 @@ void main() bb = true; } - if (c0.g <= colorN && c0.g >= colorB && gg == false){ - if (count == 1){ + if (c0.g <= colorN && c0.g >= colorB && gg == false) + { + if (count == 1) + { if(colorN >= 0.1) green = 0.01; else green = colorN; } else if (count == numColors) - green = 0.95 ; + green = 0.95; else - green = colorN ; - gg = true; + green = colorN; + gg = true; } - + colorB = float(count / numColors); + if(rr == true && bb == true && gg == true) break; } - - - ocol0 = float4(red, green, blue, c0.a); + ocol0 = float4(red, green, blue, c0.a); }