Open tigrazone opened 2 days ago
one more idea. I commented this line https://github.com/nvpro-samples/nvpro_core/blob/2991ba62e3e800a7f416a4ea9ad2d10b86454b1a/nvvkhl/shaders/pbr_mat_eval.h#L108
and change https://github.com/nvpro-samples/nvpro_core/blob/2991ba62e3e800a7f416a4ea9ad2d10b86454b1a/nvvkhl/shaders/ggx.h#L86 with
float val = M_1_PI * invRoughness.x * invRoughness.y * h.z / (f * f);
return isnan(val) ? 0.0f : val;
Results:
In theory, a perfectly smooth surface (roughness = 0) would act like a perfect mirror, reflecting light in a single direction determined by the law of reflection. This is called specular reflection.
Division by zero: The GGX distribution function involves dividing by the roughness squared. If roughness is zero, this leads to a division by zero error.
Numerical instability: Even with very small non-zero values, the calculations can become numerically unstable, leading to artifacts or incorrect rendering.
Physical reality: In the real world, no surface is perfectly smooth at a microscopic level. Even highly polished surfaces have some degree of roughness.
Rendering implications: A roughness of zero would result in an infinitely bright and infinitely small specular highlight, which is not physically accurate and can cause rendering artifacts. It would also make importance sampling for global illumination extremely difficult, as the probability of hitting the exact reflection angle becomes infinitesimally small.
Solution in practice: Most PBR implementations use a small epsilon value (e.g., 0.0014142) as the minimum roughness to avoid these issues. This allows for very smooth surfaces without running into mathematical or rendering problems.
In summary, while a roughness of zero might seem theoretically possible, it's avoided in GGX PBR due to mathematical limitations, physical inaccuracy, and rendering challenges. Using a very small non-zero value allows for highly specular surfaces while maintaining stability and accuracy in the rendering process.
But textures is interesting. Where is come from?
Sorry, can you be more specific?
I mean textures from my screenshot. Doesnt mean. Maybe it is glitches
- small epsilon value (e.g., 0.0014142) as the minimum roughness to avoid these issues
why this value, not smaller?
I tryed to preprocess zero roughness. If use MICROFACET_MIN_ROUGHNESS for smaller then MICROFACET_MIN_ROUGHNESS values hvd_ggx_eval() return very small, near zero value.
I make some changes https://github.com/nvpro-samples/nvpro_core/blob/2991ba62e3e800a7f416a4ea9ad2d10b86454b1a/nvvkhl/shaders/bsdf_functions.h#L525 to
data.pdf = mat.roughness == MICROFACET_MIN_ROUGHNESS ? 0.0f : hvd_ggx_eval(1.0f / mat.roughness, h0) * G1; // * prob;
I have interesting images. Is my approaches is correct?
original rendering w/o my changes scene GlassHurricaneCandleHolder.glb
my changes
original rendering w/o my changes scene GlassBrokenWindow.glb