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

<Roby>
unregistried

...   Created on 20.09.2005 - 11:21Jump to top Quote this post Report this post Edit Delete


Hi Guest(r).
You could change the "if...else..." sequence in
this way:

//if (kx > 1000.0) gl_FragColor.xyz = c11; else
//if (k01 + k21 < 0.25)gl_FragColor.xyz = c11; else
//if (k10 + k12 < 0.25)gl_FragColor.xyz = c11; else
//gl_FragColor.xyz = (kx1*(c10+c21)+kx2*(c12+c21)+kx3*(c01+c12)+kx4*(c01+c10))/(2.0*kx);

vec3 color = (kx1*(c10+c21)+kx2*(c12+c21)+kx3*(c01+c12)+kx4*(c01+c10))/(2.0*kx);

float ky = k01 + k21;
float kz = k10 + k12;

kx = clamp(kx-1000.0,0.0,1.0);//if kx > 1000.0 kx = 1.0 else kx = 0.0
ky = sign(abs(0.25-ky)); //if ky < 0.25 ky = 1.0 else ky = 0.0
kz = sign(abs(0.25-kz)); //if kz < 0.25 kz = 1.0 else kz = 0.0

float a = sign(kx+ky+kz); //if kx+ky+kz > 0.0 a = 1.0 else a = 0.0

gl_FragColor.xyz = c11*(a) + color*(1.0-a); //mix(c11,color,a)




<Guest1.5>
unregistried

...   Created on 20.09.2005 - 13:12Jump to top Quote this post Report this post Edit Delete


sign(abs(..)) does not make sense. abs is too much - without it your suggestion should work. But sign is not (much) faster because internally it branches, too.




<Roby>
unregistried

...   Created on 20.09.2005 - 13:30Jump to top Quote this post Report this post Edit Delete


Hi Guest 1.5,
if you don't use sign, ky = (abs(0.25-ky)) isn't equal to 1.0... but not all tastes are as a lemon tastes...

1983




<Guest1.5>
unregistried

...   Created on 20.09.2005 - 13:45Jump to top Quote this post Report this post Edit Delete


@roby

Please re-read my previous post again! I wrote abs is too much, not sign.

the term is wrong anyway (with or without abs)

"ky = sign(abs(0.25-ky));" is equal to
"if (ky==0.25) ky=0.0; else ky=1.0;" which is NOT equal to
"if ky < 0.25 ky = 1.0 else ky = 0.0"

it should be

"ky = 1.0-step(ky,0.25);"




<Roby>
unregistried

...   Created on 20.09.2005 - 13:57Jump to top Quote this post Report this post Edit Delete


Ok, Guest1.5, you are right...





<Guest1.5>
unregistried

...   Created on 20.09.2005 - 14:40Jump to top Quote this post Report this post Edit Delete


Please note:

"c11*(a) + color*(1.0-a);" is a correct replacement for "mix" (for a in [0,1])
it still uses 1 addition, 1 substraction, 1 constant and 2 multiplications.

"(c11-color)*a+color" does the same
with 1 addition, 1 substraction and 1 multiplication - should be even faster.

but anyway - i don't think it will change much because the shader is not short enough.






Similarly threads:
Topics Created by Replies Boardname
Experimental 2x resize shader guest 0 pete_bernert
2xSaI GLSL shader guest 102 pete_bernert
Cartoon GLSL shader guest 7 pete_bernert
Scale2x Plus GLSL shader guest 0 pete_bernert
SharpSmoother GLSL shader guest 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:
glsl shader xiii
blank