26 lines
576 B
GLSL
26 lines
576 B
GLSL
#version 330 core
|
|
out vec4 FragColor;
|
|
|
|
in vec3 FragPos;
|
|
in vec3 Normal;
|
|
|
|
uniform vec3 objectColor;
|
|
|
|
// Function to map normal vector components from [-1, 1] to [0, 1]
|
|
vec3 NormalizeNormalToColor(vec3 normal)
|
|
{
|
|
return normal * 0.5 + 0.5;
|
|
}
|
|
|
|
void main()
|
|
{
|
|
// Option 1: Visualize normals as colors
|
|
vec3 colorFromNormal = NormalizeNormalToColor(normalize(Normal));
|
|
|
|
// Option 2: Combine with object color
|
|
// vec3 color = objectColor * colorFromNormal;
|
|
|
|
// Choose either option based on your preference
|
|
FragColor = vec4(colorFromNormal, 1.0);
|
|
}
|