commit c83abc7d1c98908d2de62e8b0b53a624cead465a
parent 2785631a14bd5bc2863f2f2ea6c7847189703d25
Author: Matsuda Kenji <info@mtkn.jp>
Date: Wed, 28 Jun 2023 15:34:21 +0900
delete depth
Diffstat:
3 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/main.c b/main.c
@@ -100,18 +100,16 @@ main(void)
int numCube = 3;
vec *cubePositions[numCube];
cubePositions[0] = vecMake((float []){-2.0, 0.0, -10.0}, 3);
- cubePositions[1] = vecMake((float []){0.0, 3.0, -20.0}, 3);
- cubePositions[2] = vecMake((float []){1.0, 1.0, -2.0}, 3);
+ cubePositions[1] = vecMake((float []){0.0, 3.0, -12.0}, 3);
+ cubePositions[2] = vecMake((float []){1.0, 1.0, -11.0}, 3);
mat *modelMat[numCube];
for (int i = 0; i < numCube; i++) {
modelMat[i] = scale(matMakeIdent(4), 0.1);
translate(modelMat[i], cubePositions[i]);
}
mat *viewMat = matMakeIdent(4);
- mat *projMat = matMakePers((float)M_PI*80/180, (float)width/(float)height,
+ mat *projMat = matMakePers((float)M_PI/4, (float)width/(float)height,
0.1, 100.0);
- char s[256];
- printf("%s", matStr(s, projMat));
vec *axis0 = vecMake((float[]){1.41421356/2, 1.41421356/2, 0.0}, 3);
vec *axis1 = vecMake((float[]){0.0, 0.0, 1.0}, 3);
diff --git a/shaders/fragment.sl b/shaders/fragment.sl
@@ -1,6 +1,5 @@
#version 330 core
in vec2 texCoord;
-in float depth;
out vec4 FragColor;
uniform sampler2D texture0;
uniform sampler2D texture1;
@@ -11,5 +10,4 @@ main()
{
FragColor = mix(texture(texture0, texCoord),
texture(texture1, vec2(1, 1)-texCoord), alpha);
- FragColor *= vec4(depth, depth, depth, 1.0);
}
diff --git a/shaders/vertex.sl b/shaders/vertex.sl
@@ -2,7 +2,6 @@
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec2 aTexCoord;
out vec2 texCoord;
-out float depth;
uniform mat4 model;
uniform mat4 view;
@@ -13,5 +12,4 @@ main()
{
gl_Position = proj * view * model * vec4(aPos, 1.0);
texCoord = aTexCoord;
- depth = 1.0 - gl_Position.z / 2;
}