-
Notifications
You must be signed in to change notification settings - Fork 38
Closed
Description
This is not really an issue or error, just a minor bug. I was trying out the glsl translate functions and noticed how some of the parenthesis are translated wrongly. Maybe there's nothing wrong with this and my code is just wrong. I'll just post the code and maybe you can tell me what's wrong, translation or not.
So I wanted to take this shadertoy shader https://www.shadertoy.com/view/ldBGRR
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 p = -1.0 + 2.0 * fragCoord.xy / iResolution.xy;
// main code, *original shader by: 'Plasma' by Viktor Korsun (2011)
float x = p.x;
float y = p.y;
float mov0 = x+y+cos(sin(iGlobalTime)*2.0)*100.+sin(x/100.)*1000.;
float mov1 = y / 0.9 + iGlobalTime;
float mov2 = x / 0.2;
float c1 = abs(sin(mov1+iGlobalTime)/2.+mov2/2.-mov1-mov2+iGlobalTime);
float c2 = abs(sin(c1+sin(mov0/1000.+iGlobalTime)+sin(y/40.+iGlobalTime)+sin((x+y)/100.)*3.));
float c3 = abs(sin(c2+cos(mov1+mov2+c2)+cos(mov2)+sin(x/1000.)));
fragColor = vec4(c1,c2,c3,1);
} And make the following translation function
(trans/defshader simple2
'((uniform vec3 iResolution)
(uniform float iGlobalTime)
(defn void main []
(setq vec2 p (- 1.0 (/ (* 2. gl_FragCoord.xy) iResolution.xy)))
(setq float x p.x)
(setq float y p.y)
(setq float mov0 (+ x y (* 100. (cos (* 2.0 (sin iGlobalTime))))
(* 1000. (sin (/ x 100.)))))
(setq float mov1 (+ iGlobalTime (/ y 0.9)))
(setq float mov2 (/ x 0.2))
(setq float c1 (abs (sin (+ (/ (+ mov1 iGlobalTime) 2.)
(/ mov2 2.)
(- mov1)
(- mov2)
iGlobalTime))))
(setq float c2 (abs (sin (+ (+ c1 (sin (/ mov0 (+ iGlobalTime 1000.))))
(sin (/ y (+ 40. iGlobalTime)))
(sin (* (/ (+ x y) 100.) 3.0))))))
(setq float c3 (abs (sin (+ c2
(cos (+ mov1 mov2 c2))
(cos mov2)
(sin (/ x 1000.))))))
(setq gl_FragColor (vec4 c1 c2 c3 1.0))))) It will output a shader, but not like the one on shadertoy, they look different. Also the print function prints out the following, making all these extra parenthesis suspicious.
uniform vec3 iResolution;
uniform float iGlobalTime;
void main(void) {
vec2 p = (1.0 - ((2.0 * gl_FragCoord.xy) / iResolution.xy));
float x = p.x;
float y = p.y;
float mov0 = (x + y + (100.0 * cos((2.0 * sin(iGlobalTime)))) + (1000.0 * sin((x / 100.0))));
float mov1 = (iGlobalTime + (y / 0.9));
float mov2 = (x / 0.2);
float c1 = abs(sin((((mov1 + iGlobalTime) / 2.0) + (mov2 / 2.0) + (mov1) + (mov2) + iGlobalTime)));
float c2 = abs(sin(((c1 + sin((mov0 / (iGlobalTime + 1000.0)))) + sin((y / (40.0 + iGlobalTime))) + sin((((x + y) / 100.0) * 3.0)))));
float c3 = abs(sin((c2 + cos((mov1 + mov2 + c2)) + cos(mov2) + sin((x / 1000.0)))));
gl_FragColor = vec4(c1,c2,c3,1.0);
}Metadata
Metadata
Assignees
Labels
No labels