Code Monkey home page Code Monkey logo

Comments (4)

mmp avatar mmp commented on August 17, 2024 1

Interestingly, this fixes a number of errors in other scenes that use normal mapping; compare the curb, bistro glass doors, and menu to the left of the doors.

old
new

from pbrt-v4.

mmp avatar mmp commented on August 17, 2024

Very interesting. Thanks for reporting this!

The underlying issue comes from pbrt being a little weird in how it handles shading normals: it wants to have surface partial derivatives that, when you take their cross product, you get the desired shading normal. Then the way it handles normal maps is a bit unusual as well: by the time the normal map is evaluated, we no longer have access to the full object space->rendering space transformation, which would be nice to have around to bring the normal map's object-space normal into rendering space...

For this case, the problem comes from this line in src/pbrt/materials.h:

Frame frame = Frame::FromZ(ctx.shading.n);

It constructs a coordinate frame about the pre-normal mapped shading normal and then calls Frame::FromLocal() to bring the normal mapped shading normal out of the tangent space coordinate system (with the normal aligned with (0,0,1)) into rendering space. The problem is that FromZ chooses arbitrary basis vectors for x and y, while we'd like at least x to be aligned with (1,0,0) in tangent space.

Sooooo..... Replacing that line with:

    Frame frame = Frame::FromXZ(Normalize(ctx.shading.dpdu), Vector3f(ctx.shading.n));

gives this image:

image

which is at least consistent regardless of the rotations, though it doesn't match blender.

I'm not sure what the discrepancy is (pbrt being left handed and blender right-handed?) and would like to figure that out, but will at least check in that fix after testing it with more scenes.

from pbrt-v4.

pbrt4bounty avatar pbrt4bounty commented on August 17, 2024

I can tested on Blender since I have a full operative plugin. BTW.. in Blender, Z is up

from pbrt-v4.

TiernoGs avatar TiernoGs commented on August 17, 2024

Hello, thank you for your reply, the updated line works just fine now :)
No need to look deeper into the light orientation, the blender cycles render was a way to highlight the normal map bug.
I'm closing the issue, thanks !

from pbrt-v4.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.