knightcrawler25 / GLSL-PathTracer

A toy physically based GPU path tracer (C++/OpenGL/GLSL)
MIT License
1.87k stars 176 forks source link

Feature Request: importance sampling visible normal of anisotropic ggx #69

Closed f1shel closed 2 years ago

f1shel commented 2 years ago

Hi! I notice that SampleGGXVNDF is used to sample ggx distribution and this method is for isotropic ggx. In some cases (anisotopic != 0) ggx distribution will be anisotropic. Could you please add the anisotropic version of importance sampling?

knightcrawler25 commented 2 years ago

Sure. I had some issues earlier getting anisotropy to work correctly so it's disabled in the code right now. Will have another go at it.

knightcrawler25 commented 2 years ago

I've added it in:

img_1036

Limitation: The Tangent and Bitangent are not calculated from the mesh UVs so rotating the mesh will have no effect on the anisotropic specular highlights. However, that won't effect the importance sampling. Let me know if you notice any issues.

tigrazone commented 2 years ago

Please add demo file to repo

knightcrawler25 commented 2 years ago

The scene is already available (cornell_box_sphere.scene). Just set anisotropic and metallic to 1.0 for the sphere material