Skip to content

Commit

Permalink
shaders refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
xCollateral committed Sep 4, 2023
1 parent 8d482d6 commit 29a5fce
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ layout(location = 1) out vec4 vertexColor;
layout(location = 2) out vec2 texCoord0;
//layout(location = 3) out vec4 normal;

//Compressed Vertex
#define COMPRESSED_VERTEX
#ifdef COMPRESSED_VERTEX

const float UV_INV = 1.0 / 65536.0;
const float POSITION_INV = 1.0 / 1900.0;
Expand All @@ -43,19 +44,21 @@ void main() {
// normal = MVP * vec4(Normal, 0.0);
}

//Default Vertex
#else

//layout(location = 0) in vec3 Position;
//layout(location = 1) in vec4 Color;
//layout(location = 2) in vec2 UV0;
//layout(location = 3) in ivec2 UV2;
//layout(location = 4) in vec3 Normal;
layout(location = 0) in vec3 Position;
layout(location = 1) in vec4 Color;
layout(location = 2) in vec2 UV0;
layout(location = 3) in ivec2 UV2;
layout(location = 4) in vec3 Normal;

void main() {
gl_Position = MVP * vec4(Position + ChunkOffset[gl_DrawID], 1.0);

vertexDistance = length((ModelViewMat * vec4(Position + ChunkOffset[gl_DrawID], 1.0)).xyz);
vertexColor = Color * minecraft_sample_lightmap(Sampler2, UV2);
texCoord0 = UV0;
normal = MVP * vec4(Normal, 0.0);
}

//void main() {
// gl_Position = MVP * vec4(Position + ChunkOffset[gl_DrawID], 1.0);
//
// vertexDistance = length((ModelViewMat * vec4(Position + ChunkOffset[gl_DrawID], 1.0)).xyz);
// vertexColor = Color * minecraft_sample_lightmap(Sampler2, UV2);
// texCoord0 = UV0;
// normal = MVP * vec4(Normal, 0.0);
//}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ layout(location = 1) out vec4 vertexColor;
layout(location = 2) out vec2 texCoord0;
//layout(location = 3) out vec4 normal;

//Compressed Vertex
#define COMPRESSED_VERTEX
#ifdef COMPRESSED_VERTEX

layout(location = 0) in ivec3 Position;
layout(location = 1) in vec4 Color;
Expand All @@ -45,19 +46,21 @@ void main() {
// normal = MVP * vec4(Normal, 0.0);
}

//Default Vertex
#else

//layout(location = 0) in vec3 Position;
//layout(location = 1) in vec4 Color;
//layout(location = 2) in vec2 UV0;
//layout(location = 3) in ivec2 UV2;
//layout(location = 4) in vec3 Normal;
layout(location = 0) in vec3 Position;
layout(location = 1) in vec4 Color;
layout(location = 2) in vec2 UV0;
layout(location = 3) in ivec2 UV2;
layout(location = 4) in vec3 Normal;

void main() {
gl_Position = MVP * vec4(Position + ChunkOffset, 1.0);

vertexDistance = length((ModelViewMat * vec4(Position + ChunkOffset, 1.0)).xyz);
vertexColor = Color * minecraft_sample_lightmap(Sampler2, UV2);
texCoord0 = UV0;
// normal = MVP * vec4(Normal, 0.0);
}

//void main() {
// gl_Position = MVP * vec4(Position + ChunkOffset, 1.0);
//
// vertexDistance = length((ModelViewMat * vec4(Position + ChunkOffset, 1.0)).xyz);
// vertexColor = Color * minecraft_sample_lightmap(Sampler2, UV2);
// texCoord0 = UV0;
// // normal = MVP * vec4(Normal, 0.0);
//}
#endif

0 comments on commit 29a5fce

Please sign in to comment.