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

SSAO isn't working with model without normals #1553

Closed
Meakk opened this issue Jul 31, 2024 · 4 comments
Closed

SSAO isn't working with model without normals #1553

Meakk opened this issue Jul 31, 2024 · 4 comments
Assignees
Labels
source:VTK type:bug Something isn't working
Milestone

Comments

@Meakk
Copy link
Member

Meakk commented Jul 31, 2024

Describe the bug
When there's no normals on the model, SSAO is not working properly

image

To Reproduce
Steps to reproduce the behavior:

  1. Open a file without normals
  2. Enable SSAO

Expected behavior
SSAO should work with generated flat normals

@mwestphal mwestphal added this to F3D Jul 31, 2024
@mwestphal mwestphal added this to the 3.1.0 milestone Jul 31, 2024
@mwestphal mwestphal moved this to To do in F3D Jul 31, 2024
@mwestphal mwestphal added source:VTK type:bug Something isn't working labels Jul 31, 2024
@Meakk
Copy link
Member Author

Meakk commented Jul 31, 2024

Shader G-buffer output (last image is black but it should contain the normals)

image

Fragment output is set with:

fragOutput2 = vec4(normalVCVSOutput, 1.0);

But without normal, the shader contains:

    // Generate the normal if we are not passed in one
    vec3 primitiveNormal;
    if (primitiveSize == 1) {
        primitiveNormal = vec3(0.0, 0.0, 1.0);
    }
    else if (primitiveSize == 2) {
        float addOrSubtract = (dot(fdx, fdy) >= 0.0) ? 1.0 : -1.0;
        vec3 lineVec = addOrSubtract*fdy + fdx;
        primitiveNormal = normalize(cross(vec3(lineVec.y, -lineVec.x, 0.0), lineVec));
    }
    else {
        primitiveNormal = normalize(cross(fdx, fdy));
        if (cameraParallel == 1 && primitiveNormal.z < 0.0) {
            primitiveNormal = -1.0*primitiveNormal;
        }
        if (cameraParallel == 0 && dot(primitiveNormal, vertexVC.xyz) > 0.0) {
            primitiveNormal = -1.0*primitiveNormal;
        }

    }
    vec3 vertexNormalVCVS = primitiveNormal;
    vec3 normalizedNormalVCVSOutput = normalize(vertexNormalVCVS);

So I'd say we should do something like:

fragOutput2 = vec4(normalizedNormalVCVSOutput, 1.0);

@Meakk
Copy link
Member Author

Meakk commented Aug 21, 2024

@Meakk Meakk self-assigned this Aug 21, 2024
@Meakk Meakk moved this from To do to In review in F3D Aug 21, 2024
@Meakk Meakk modified the milestones: 3.1.0, 3.0.0 Aug 21, 2024
@Meakk
Copy link
Member Author

Meakk commented Aug 23, 2024

Fixed by updating VTK in f3d-app/f3d-docker-images#18

@Meakk Meakk closed this as completed Aug 23, 2024
@github-project-automation github-project-automation bot moved this from In review to Done in F3D Aug 23, 2024
@mwestphal
Copy link
Contributor

So this was F3DWeb specific right ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
source:VTK type:bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

2 participants