Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency of shadow vertex shader on matrix_normal #4971

Closed
mvaligursky opened this issue Jan 12, 2023 · 1 comment · Fixed by #4985
Closed

Remove dependency of shadow vertex shader on matrix_normal #4971

mvaligursky opened this issue Jan 12, 2023 · 1 comment · Fixed by #4985
Assignees
Labels
area: graphics Graphics related issue

Comments

@mvaligursky
Copy link
Contributor

mvaligursky commented Jan 12, 2023

This is a vertex shader we use to render to shadow map.

uniform mat4 matrix_viewProjection;
uniform mat4 matrix_model;
uniform mat3 matrix_normal;

vec3 dPositionW;
mat4 dModelMatrix;
mat3 dNormalMatrix;

mat4 getModelMatrix() {
    return matrix_model;
}

vec4 getPosition() {
    dModelMatrix = getModelMatrix();
    vec3 localPos = vertex_position;

    vec4 posW = dModelMatrix * vec4(localPos, 1.0);
    dPositionW = posW.xyz;

    vec4 screenPos;
    screenPos = matrix_viewProjection * posW;

    return screenPos;
}

vec3 getWorldPosition() {
    return dPositionW;
}

vec3 getNormal() {
    dNormalMatrix = matrix_normal;

    vec3 tempNormal = vertex_normal;
    return normalize(dNormalMatrix * tempNormal);
}

void main(void) {
    gl_Position = getPosition();
   vPositionW    = getWorldPosition();
   vNormalW = getNormal();

}

I added some new warnings to engine (commented out for now), and it triggers this:
Shader [Shader Id 0 standard] requires uniform [matrix_normal] which has not been set

When WebGL translates the shader for the platform, the uniform is not stripped out as dead code, but is compiled out on the driver level.

Ideally we'd change the shader generator to not include it to avoid - as we unnecessarily handle it. On WebGPU we need to allocate space for it in the uniform buffer as well.

When this is done, the warning should be enabled, as it's very helpful to have.

// Debug.warnOnce(`Shader [${shader.label}] requires uniform [${uniform.scopeId.name}] which has not been set, while rendering [${DebugGraphics.toString()}]`);

@mvaligursky mvaligursky added the area: graphics Graphics related issue label Jan 12, 2023
@mvaligursky
Copy link
Contributor Author

related to #4958

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants