voxel-engine/shaders/cube_frag.glsl
2025-11-24 13:08:22 -06:00

26 lines
618 B
GLSL

#version 330 core
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++
// You can now use v_VoxelKind to modify the color
// Example: Different colors for different voxel types
vec3 color = u_Color;
if (v_VoxelKind == 1.0) {
// Dirt - brownish
color *= vec3(0.6, 0.4, 0.2);
} else if (v_VoxelKind == 2.0) {
color *= vec3(0.2, 0.8, 0.2);
} else if (v_VoxelKind == 3.0) {
// Stone - grayish (keep as is)
}
FragColor = vec4(color, 1.0);
}