diff --git a/shader/root/rt.glsl b/shader/root/rt.glsl index f67849b..8c53957 100644 --- a/shader/root/rt.glsl +++ b/shader/root/rt.glsl @@ -26,7 +26,6 @@ layout (location = 13) uniform Sphere _spheres[SPHERES]; uniform vec4 _seed; - layout(rgba32f, binding = 0) uniform image2D img_output; // rgba32f defines internal format, image2d for random write to output texture layout(binding=1) uniform sampler2D _noise; // noise texture @@ -164,7 +163,10 @@ vec2 pixelUv() vec4 sampleNoise() { - return texture(_noise, pixelUv()); + vec2 uv = pixelUv(); + uv += _seed.xy; + + return texture(_noise, uv); } float random(vec2 st) @@ -242,8 +244,8 @@ void main() vec2 uv = pixelUv(); - int samples = 2; - int bounces = 2; + int samples = 1; + int bounces = 4; for (int i = 0; i < samples; i++) { diff --git a/src/main.c b/src/main.c index 6a18b9d..77651fe 100644 --- a/src/main.c +++ b/src/main.c @@ -13,17 +13,15 @@ void updateUniforms(GLuint shaderProgram); int main() { + printf("GL_TEXTURE0: %d\n", GL_TEXTURE0); + printf("GL_TEXTURE1: %d\n", GL_TEXTURE1); + randomInit(); // create a window and opengl context SDL_Window* window = gfxInit(WIDTH, HEIGHT); - // generate noise - GLuint noise = createNoiseTexture(WIDTH, HEIGHT); - // create a texture for the compute shader to write to - GLuint textureOutput = createWriteOnlyTexture(WIDTH, HEIGHT); - printWorkGroupLimits(); // compile shader programs unsigned int computeProgram = compileComputeShaderProgram( @@ -32,10 +30,16 @@ int main() "bin/shader.vert", "bin/shader.frag"); + // generate noise + GLuint noise = createNoiseTexture(WIDTH, HEIGHT); glBindTexture(GL_TEXTURE_2D, noise); int noiseLoc = glGetUniformLocation(computeProgram, "_noise"); glUniform1i(noiseLoc, noise); + // create a texture for the compute shader to write to + GLuint textureOutput = createWriteOnlyTexture(WIDTH, HEIGHT); + printWorkGroupLimits(); + // initialise quad initBuffers(); setVertexAttributes(); diff --git a/todo.md b/todo.md index 5c5c084..2c7e46c 100644 --- a/todo.md +++ b/todo.md @@ -1,3 +1,6 @@ +* [-] preprocessor + * [x] #include directives + * [ ] keep track of previously included files to avoid redefinitions * [-] render image with compute shader * [x] render a texture to a full-screen quad * [x] pass uniforms to shader to animate it