feat: added sin distortions

This commit is contained in:
2025-09-03 12:59:38 +02:00
parent 8349039167
commit b5f6758400
2 changed files with 6 additions and 1 deletions

View File

@@ -112,8 +112,12 @@ int main(int argc, char **argv) {
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glUseProgram(shaderProgram); glUseProgram(shaderProgram);
int aspectLocation = glGetUniformLocation(shaderProgram, "aspect"); int aspectLocation = glGetUniformLocation(shaderProgram, "aspect");
glUniform1f(aspectLocation, aspect); glUniform1f(aspectLocation, aspect);
int timeLocation = glGetUniformLocation(shaderProgram, "t");
glUniform1f(timeLocation, 2. * glfwGetTime());
glBindVertexArray(fsq.getVAO()); glBindVertexArray(fsq.getVAO());
glDrawArrays(GL_TRIANGLES, 0, 6); glDrawArrays(GL_TRIANGLES, 0, 6);

View File

@@ -5,6 +5,7 @@ out vec4 FragColor;
in vec2 texCoords; in vec2 texCoords;
uniform float aspect; uniform float aspect;
uniform float t;
vec3 center = vec3(0.0,-4.0,20.0); vec3 center = vec3(0.0,-4.0,20.0);
float radius = 5.0; float radius = 5.0;
@@ -55,7 +56,7 @@ float planeMin(vec3 pos){
} }
float sphereMin(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){ Ray minFn(Ray ray){