Anonymous user
OpenGL pixel shader: Difference between revisions
→{{header|C}}: changed noise function again; adding screenshot
m (→{{header|C}}: add {{libheader|GLUT}}) |
(→{{header|C}}: changed noise function again; adding screenshot) |
||
Line 10:
=={{header|C}}==
{{libheader|GLUT}}
Getting a true (pseudo) random number is surprisingly tricky. The following code makes something noisy, but not at all random:[[image:pixel_shader_C.png|right]]
<lang c>#include <stdio.h>
#include <stdlib.h>
Line 39:
"varying float x, y, z;"
"uniform float r_mod;"
"float rand(float s, float r) { return mod(
"void main() {"
" gl_FragColor = vec4(rand(gl_FragCoord.x
"}";
const char *v =
|