(#3596) added vertex normals to ring quad vertex attribs

This commit is contained in:
benpm
2025-04-25 16:10:33 -06:00
parent e0df6d6c2e
commit 0aa1edcfde
5 changed files with 26 additions and 6 deletions

View File

@@ -31,6 +31,7 @@
in vec2 vs_st;
in float vs_screenSpaceDepth;
in vec4 shadowCoords;
in vec3 vs_normal;
uniform sampler2DShadow shadowMapTexture;
uniform sampler1D ringTextureFwrd;

View File

@@ -28,10 +28,12 @@
layout(location = 0) in vec2 in_position;
layout(location = 1) in vec2 in_st;
layout(location = 2) in vec3 in_normal;
out vec2 vs_st;
out float vs_screenSpaceDepth;
out vec4 shadowCoords;
out vec3 vs_normal;
uniform dmat4 modelViewProjectionMatrix;
@@ -43,6 +45,7 @@ uniform dmat4 shadowMatrix;
void main() {
vs_st = in_st;
vs_normal = mat3(modelViewProjectionMatrix) * in_normal;
dvec4 positionClipSpace = modelViewProjectionMatrix * dvec4(in_position, 0.0, 1.0);
vec4 positionClipSpaceZNorm = z_normalization(vec4(positionClipSpace));

View File

@@ -31,6 +31,7 @@
in vec2 vs_st;
in float vs_screenSpaceDepth;
in vec4 shadowCoords;
in vec3 vs_normal;
uniform sampler2DShadow shadowMapTexture;
uniform sampler1D ringTexture;

View File

@@ -28,10 +28,12 @@
layout(location = 0) in vec2 in_position;
layout(location = 1) in vec2 in_st;
layout(location = 2) in vec3 in_normal;
out vec2 vs_st;
out float vs_screenSpaceDepth;
out vec4 shadowCoords;
out vec3 vs_normal;
uniform dmat4 modelViewProjectionMatrix;
@@ -43,6 +45,7 @@ uniform dmat4 shadowMatrix;
void main() {
vs_st = in_st;
vs_normal = mat3(modelViewProjectionMatrix) * in_normal;
dvec4 positionClipSpace = modelViewProjectionMatrix * dvec4(in_position, 0.0, 1.0);
vec4 positionClipSpaceZNorm = z_normalization(vec4(positionClipSpace));

View File

@@ -769,15 +769,18 @@ void RingsComponent::createPlane() {
GLfloat y;
GLfloat s;
GLfloat t;
GLfloat nx;
GLfloat ny;
GLfloat nz;
};
const std::array<VertexData, 6> vertices = {
VertexData{ -size, -size, 0.f, 0.f },
VertexData{ size, size, 1.f, 1.f },
VertexData{ -size, size, 0.f, 1.f },
VertexData{ -size, -size, 0.f, 0.f },
VertexData{ size, -size, 1.f, 0.f },
VertexData{ size, size, 1.f, 1.f },
VertexData{ -size, -size, 0.f, 0.f, 0.f, 0.f, 1.f },
VertexData{ size, size, 1.f, 1.f, 0.f, 0.f, 1.f },
VertexData{ -size, size, 0.f, 1.f, 0.f, 0.f, 1.f },
VertexData{ -size, -size, 0.f, 0.f, 0.f, 0.f, 1.f },
VertexData{ size, -size, 1.f, 0.f, 0.f, 0.f, 1.f },
VertexData{ size, size, 1.f, 1.f, 0.f, 0.f, 1.f },
};
glBindVertexArray(_quad);
@@ -801,6 +804,15 @@ void RingsComponent::createPlane() {
sizeof(VertexData),
reinterpret_cast<void*>(offsetof(VertexData, s))
);
glEnableVertexAttribArray(2);
glVertexAttribPointer(
2,
3,
GL_FLOAT,
GL_FALSE,
sizeof(VertexData),
reinterpret_cast<void*>(offsetof(VertexData, nx))
);
}
void RingsComponent::compileShadowShader() {