debug: hardcoded light in fragment shader — no UBO light data

Light at (0,10,0) hardcoded in GLSL. Tests if lighting math works.
If light works: problem is UBO layout for light data (std140 padding).
If artifacts: problem is in fragWorldPos or fragNormal.
This commit is contained in:
emil28092005
2026-06-18 19:50:20 +03:00
parent 7ed81040ed
commit ad8a14a4f7
2 changed files with 6 additions and 5 deletions
@@ -8,22 +8,23 @@ layout(location = 0) out vec4 outColor;
layout(set = 0, binding = 0) uniform CameraUBO {
mat4 vp;
vec4 pointLightPos;
vec4 pointLightColor;
};
void main()
{
vec3 N = normalize(fragNormal);
vec3 toLight = pointLightPos.xyz - fragWorldPos;
// Hardcoded light at (0, 10, 0) — test if lighting works at all
vec3 lightPos = vec3(0.0, 10.0, 0.0);
vec3 toLight = lightPos - fragWorldPos;
float dist = length(toLight);
vec3 L = normalize(toLight);
float NdotL = max(dot(N, L), 0.0);
float atten = 1.0 / (1.0 + dist * dist * 0.05);
float intensity = pointLightPos.w;
float intensity = 30.0;
vec3 color = fragAlbedo * pointLightColor.xyz * NdotL * intensity * atten;
vec3 color = fragAlbedo * vec3(1.0, 0.9, 0.7) * NdotL * intensity * atten;
color += fragAlbedo * 0.02;
outColor = vec4(color, 1.0);
Binary file not shown.