-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shader Translation #31
Comments
I'm not sure I understand. Is the issue basically that
translates to
which is functionally the same, but has more parenthesis? |
If this is functionally the same, I just must have written this shader wrongly somewhere in the code. And remind myself not to file a bug being hang over on sundays :) |
Okay. Examining the original code it is clear that shadertoy.com has moved on to a new format that doesn't match with what shadertone expects. Sigh... If you try the code it will report this in stderr
|
Changing the code to match expectations for the version of GLSL shadertoy expects, it seems to work just fine. void main(void)
{
vec2 p = -1.0 + 2.0 * gl_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.)));
gl_FragColor = vec4(c1,c2,c3,1);
} |
Okay apparently you already figured this out when you did the translation since it matches what I wrote... Alright, the real issue is that there is no unary negate in my translator. Converting (trans/defshader simple2
'((uniform vec3 iResolution)
(uniform float iGlobalTime)
(defn void main []
(setq vec2 p (- (/ (* 2. gl_FragCoord.xy) iResolution.xy) 1.0))
(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.)
(* -1. mov1)
(* -1. mov2)
iGlobalTime)))
(setq float c2 (abs (sin (+ c1
(sin (+ (/ mov0 1000.) iGlobalTime))
(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)))))
(t/start (atom simple2)) |
So, I think what does need to happen is:
|
Added unary math handling & unit test. Adjusted README to note the shadertoy.com syntax change. Prep for a 0.2.6 release.
I've updated the code. Let me know if I can do anything else. |
it works perfectly now! Thanks. |
Added unary math handling & unit test. Adjusted README to note the shadertoy.com syntax change. Prep for a 0.2.6 release.
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
And make the following translation function
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.
The text was updated successfully, but these errors were encountered: