From b5f6758400f425310d562cffb2d1ab1a860cb467 Mon Sep 17 00:00:00 2001 From: Amy Retzerau Date: Wed, 3 Sep 2025 12:59:38 +0200 Subject: [PATCH] feat: added sin distortions --- main.cpp | 4 ++++ sdf.glsl | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 62e00fc..c4f93fb 100644 --- a/main.cpp +++ b/main.cpp @@ -112,8 +112,12 @@ int main(int argc, char **argv) { glClear(GL_COLOR_BUFFER_BIT); glUseProgram(shaderProgram); + int aspectLocation = glGetUniformLocation(shaderProgram, "aspect"); glUniform1f(aspectLocation, aspect); + int timeLocation = glGetUniformLocation(shaderProgram, "t"); + glUniform1f(timeLocation, 2. * glfwGetTime()); + glBindVertexArray(fsq.getVAO()); glDrawArrays(GL_TRIANGLES, 0, 6); diff --git a/sdf.glsl b/sdf.glsl index b6f5f75..e73a76b 100644 --- a/sdf.glsl +++ b/sdf.glsl @@ -5,6 +5,7 @@ out vec4 FragColor; in vec2 texCoords; uniform float aspect; +uniform float t; vec3 center = vec3(0.0,-4.0,20.0); float radius = 5.0; @@ -55,7 +56,7 @@ float planeMin(vec3 pos){ } float sphereMin(vec3 pos){ - return length(pos - center) - radius; + return length(pos - center) - radius + 0.2*sin(5*pos.x+t)*sin(5*pos.y+t)*sin(5*pos.z+t); } Ray minFn(Ray ray){