mrdoob / glsl-sandbox

Shader editor and gallery.
https://glslsandbox.com/
MIT License
1.55k stars 260 forks source link

unable to save specific code #42

Open makc opened 8 years ago

makc commented 8 years ago
#ifdef GL_ES
precision mediump float;
#endif

uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;

void main( void ) {

    vec2 position = ( gl_FragCoord.xy / resolution.xy ) - vec2(.5);

    float angle = atan(position.y / position.x) + sign(position.x) * 3.1415 * 0.5;

    // see, this looks almost like atan2
    gl_FragColor = vec4( vec3 (0.5 + angle / 3.1415), 1.0 );

    float rotx = sin(angle * 0.5) * position.x - cos(angle * 0.5) * position.y;

    gl_FragColor = vec4( vec3 (0.5 + 0.5 * cos(rotx * 700.0)), 1.0 );

}

it was saving ok until I changed sin to cos in gl_FragColor = ... line.

won't accept it as new code either.

AnastasiaDunbar commented 8 years ago

This happened to me before.

makc commented 3 years ago

Still happens in 2020, of course

#ifdef GL_ES
precision mediump float;
#endif

uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;

#define TAU 6.28318530718
#define MAX_ITER 5

void main( void ) {

    float t = time * .5+23.0;
    // uv should be the 0-1 uv of texture...
    vec2 xy = gl_FragCoord.xy / resolution.yy -vec2(0.5);

    vec2 uv = vec2(
        atan(xy.y, xy.x) * 7.0 / TAU,
        log(length(xy)) * 0.8
    );

    vec2 p = mod(uv*TAU, TAU)-250.0;
    vec2 i = vec2(p);
    float c = 0.8;
    float inten = .005;

    for (int n = 0; n < MAX_ITER; n++) 
    {
        float t = t * (1.0 - (3.5 / float(n+1)));
        i = p + vec2(cos(t - i.x) + sin(t + i.y), sin(t - i.y) + cos(t + i.x));
        c += 1.0/length(vec2(p.x / (sin(i.x+t)/inten),p.y / (cos(i.y+t)/inten)));
    }
    c /= float(MAX_ITER);
    c = 1.17-pow(c, 1.4);
    vec3 colour = vec3(pow(abs(c), 8.0));
    colour = clamp(colour + vec3(
        0.20 + 0.40 * (1.0 + cos(time * 2.0 + length(uv.y) * 3.0)),
        0.10 + 0.15 * (1.0 + sin(time * 3.0 + length(uv.y) * 7.0)),
        0.05 + 0.05 * (1.0 + cos(time * 5.0 + length(uv.y) * 9.0))
        ), 0.0, 1.0);

    gl_FragColor = vec4(colour, 1.0);
}
makc commented 3 years ago

the original code from https://github.com/mrdoob/glsl-sandbox/issues/42#issue-154226898 can be saved now, but not the code from https://github.com/mrdoob/glsl-sandbox/issues/42#issuecomment-756116512