Paste: spheres floor color

Author: _hrrld
Mode: c
Date: Thu, 13 Nov 2008 16:31:38
Plain Text |
    gl_FragColor = fract((floor(0.125*object_position.x)+floor(0.125*object_position.z)) * 0.5) == 0.0
        ? vec4(1.0, 1.0 - distance_factor, 1.0 - distance_factor, 1.0)
        : vec4(1.0, distance_factor, distance_factor, 1.0);
}

Annotation: spheres floor color, in plain GLSL

Author: joe
Mode: c
Date: Thu, 13 Nov 2008 17:54:38
Plain Text |
uniform float checker_size_inv;
uniform vec4 checker_color_1, checker_color_2;
varying vec3 object_position;

bool
checker_color(vec3 p)
{
    vec3 pprime = checker_size_inv * object_position;
    return fract((floor(pprime.x) + floor(pprime.z)) * 0.5) == 0.0;
}

void
main()
{
    float distance_factor = (gl_FragCoord.z * 0.5 + 0.5);
    distance_factor = pow(distance_factor, 500.0)*0.5;
    
    gl_FragColor = checker_color(object_position)
        ? mix(checker_color_1, checker_color_2, distance_factor)
        : mix(checker_color_2, checker_color_1, distance_factor);
}

New Annotation

Summary:
Author:
Mode:
Body: