added voxel types
This commit is contained in:
1 parent
1ee72dae9a
commit
46be697e2f
10 files changed
+91
-38
No files matched your search
+13
-1
@@ -2,11 +2,23 @@
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
flat in float v_VoxelKind;
|
||||
|
||||
// [NEW] This variable will be set from your C++ code
|
||||
uniform vec3 u_Color;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Use the color from C++
|
||||
FragColor = vec4(u_Color, 1.0);
|
||||
// You can now use v_VoxelKind to modify the color
|
||||
// Example: Different colors for different voxel types
|
||||
vec3 color = u_Color;
|
||||
if (v_VoxelKind == 0.0) {
|
||||
// Dirt - brownish
|
||||
color *= vec3(0.6, 0.4, 0.2);
|
||||
} else if (v_VoxelKind == 1.0) {
|
||||
// Stone - grayish (keep as is)
|
||||
}
|
||||
|
||||
FragColor = vec4(color, 1.0);
|
||||
}
|
||||
@@ -4,12 +4,14 @@
|
||||
// 'layout (location = 0)' matches the first attribute you enable.
|
||||
layout (location = 0) in vec3 aPos;
|
||||
layout (location = 1) in vec3 aNormal;
|
||||
layout (location = 2) in float aVoxelKind;
|
||||
|
||||
// A "uniform" is a global variable you set from your C++/Java/etc. code.
|
||||
// This matrix combines your model, view, and projection matrices.
|
||||
uniform mat4 u_mvp;
|
||||
|
||||
flat out vec3 v_Normal;
|
||||
flat out float v_VoxelKind;
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -18,4 +20,5 @@ void main()
|
||||
gl_Position = u_mvp * vec4(aPos, 1.0);
|
||||
|
||||
v_Normal = aNormal;
|
||||
v_VoxelKind = aVoxelKind;
|
||||
}
|
||||
Reference in new issue
Block a user