-
-
Notifications
You must be signed in to change notification settings - Fork 275
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
GPU Path Tracing: Mobile device triangle intersection precision issue #350
Comments
By computing the distance between the retrieved point and the triangle surface using the following snippet we can see that the point is relatively far off the surface in either direction (red is on the positive side of the plane, green is negative). The pattern of red on the inner curve of the torus is interesting:
Distances Visualized These images are black on a desktop machine. Adjusting Point To Surface Adjusting the point to the surface and remeasuring distances yields the following. It doesn't look a whole lot better. Some sides flip but overall it's looks very similar.
Larger Triangles Adjusting the geometry to use larger triangles doesn't change the coloring pattern or fix the issue. The red or positive distances seem to be more prominent on triangles that are facing the origin. This can be shown by creating a sphere and shifting it on the X axis which causes the portion of the normals pointing toward the origin to turn red (it's green when fully centered): TODO
|
Looking at the texture displayed raw using TODO
|
And a comparison between desktop and mobile images (done using screenshots the mobile one has compression applied):
NOTE: When displaying the triangle indices that are reported from the hit they are different. Try int textures? Compare final textures?
NOTES / TODO
eps = 1
while ( 1 + ( eps / 2 ) > 1) eps = eps / 2; |
I turns out that by using structs in a fragment shader the precision of values are truncated resulting in incorrect indices and values during the sample phase. Repro shader: #define STRUCT_TEST
struct TestStruct {
int val;
};
void main() {
#ifdef STRUCT_TEST
// displays black
TestStruct str;
str.val = 1 << 20;
gl_FragColor = vec4( str.val, str.val, str.val, 1.0 );
#else
// displays white
int val = 1 << 20;
gl_FragColor = vec4( val, val, val, 1.0 );
#endif
} Who knows how many devices are affected by this. According to this page the numbers are otherwise high precision values when not using structs. I think the only solution would be to use out variables for all hit results which is not at all ergonomic. |
On a number of Adreno chips the struct precision seems to be lower only when using structs: https://gkjohnson.github.io/webgl-precision/ Related to KhronosGroup/WebGL#3351 |
The gpu path tracing demo exhibits a lot of artifacts on Pixel 3. Increasing the ray origin offset by the geometry normal improves the rendering but it's still a problem.
Next step is to see if the reported intersection point is actually sitting on the surface of the triangle and whether thats causing subsequent path tracing issues.
The text was updated successfully, but these errors were encountered: