New Paste :: Recent Pastes:: Add Line Numbers
test shader w/ bri + sat control by taby
// ray origin // ray direction varying vec3 rO_origin, rD_origin; void main() { // limit the number of intensity levels per colour channel float shades_per_channel = 10.0; // construct color from ray direction // 3D Labs GLSL Validator complains about it because rD_origin may be read-only... rD_origin = normalize(rD_origin); float x = abs(dot(rD_origin, vec3(1.0, 0.0, 0.0))); float y = abs(dot(rD_origin, vec3(0.0, 1.0, 0.0))); float z = abs(dot(rD_origin, vec3(0.0, 0.0, 1.0))); // colour by previous calculations gl_FragColor.a = 1.0; gl_FragColor.b = 1.0 - floor(shades_per_channel * x) / shades_per_channel; gl_FragColor.g = 1.0 - floor(shades_per_channel * y) / shades_per_channel; gl_FragColor.r = floor(shades_per_channel * z) / shades_per_channel; // colour control float sat_percent = 50.0; float bri_percent = 75.0; // saturation gl_FragColor.r += ((1.0 - gl_FragColor.r) * 0.01) * (100.0 - sat_percent); gl_FragColor.g += ((1.0 - gl_FragColor.g) * 0.01) * (100.0 - sat_percent); gl_FragColor.b += ((1.0 - gl_FragColor.b) * 0.01) * (100.0 - sat_percent); // brightness gl_FragColor.r *= bri_percent * 0.01; gl_FragColor.g *= bri_percent * 0.01; gl_FragColor.b *= bri_percent * 0.01; }