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:
@@ -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.
Reference in New Issue
Block a user