Skip to content

Commit 76ad652

Browse files
committed
Use textureLod instead of the texture
texture() compiles to OpImageSampleImplicitLod, which needs screen-space derivatives of the UV if (rayQueryGetIntersectionTypeEXT(...) != ...NoneEXT) is per pixel ray query. one pixel ray query of the quad can hit while neighor misses. So the divergent branch does not match the texture, should use textureLod which does not require the screen-space derivatives of quad pixels.
1 parent 293e828 commit 76ad652

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎shaders/mobile_nerf_rayquery/rayquery_morpheus.frag‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ void main(void)
259259

260260
// Sample feature maps and check transparency
261261
const vec2 flipped = vec2( hitpoint_uv.x, 1.0 - hitpoint_uv.y );
262-
vec4 test_pixel = texture(textureInput_0[nonuniformEXT(instanceID)], flipped);
262+
vec4 test_pixel = textureLod(textureInput_0[nonuniformEXT(instanceID)], flipped, 0);
263263

264264
if (test_pixel.r != 0.0) {
265265
rayQueryConfirmIntersectionEXT(rayQuery);
@@ -272,7 +272,7 @@ void main(void)
272272

273273
if (rayQueryGetIntersectionTypeEXT(rayQuery, true) == gl_RayQueryCommittedIntersectionTriangleEXT) {
274274
// Output feature inputs for mlp
275-
vec4 pixel_1 = texture(textureInput_1[nonuniformEXT(commited_instanceID)], commited_flipped);
275+
vec4 pixel_1 = textureLod(textureInput_1[nonuniformEXT(commited_instanceID)], commited_flipped, 0);
276276

277277
pixel_0.a = pixel_0.a*2.0-1.0;
278278
pixel_1.a = pixel_1.a*2.0-1.0;
@@ -327,8 +327,8 @@ void main(void)
327327

328328
// Sample feature maps then output to second subpass
329329
vec2 flipped = vec2( hitpoint_uv.x, 1.0 - hitpoint_uv.y );
330-
vec4 pixel_0 = texture(textureInput_0[nonuniformEXT(instanceID)], flipped);
331-
vec4 pixel_1 = texture(textureInput_1[nonuniformEXT(instanceID)], flipped);
330+
vec4 pixel_0 = textureLod(textureInput_0[nonuniformEXT(instanceID)], flipped, 0);
331+
vec4 pixel_1 = textureLod(textureInput_1[nonuniformEXT(instanceID)], flipped, 0);
332332

333333
pixel_0.a = pixel_0.a*2.0-1.0;
334334
pixel_1.a = pixel_1.a*2.0-1.0;

‎shaders/mobile_nerf_rayquery/rayquery_morpheus_combo.frag‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ void main(void)
259259

260260
// Sample feature maps and check transparency
261261
const vec2 flipped = vec2( hitpoint_uv.x, 1.0 - hitpoint_uv.y );
262-
vec4 test_pixel = texture(textureInput_0[nonuniformEXT(instanceID)], flipped);
262+
vec4 test_pixel = textureLod(textureInput_0[nonuniformEXT(instanceID)], flipped, 0);
263263

264264
if (test_pixel.r != 0.0) {
265265
rayQueryConfirmIntersectionEXT(rayQuery);
@@ -272,7 +272,7 @@ void main(void)
272272

273273
if (rayQueryGetIntersectionTypeEXT(rayQuery, true) == gl_RayQueryCommittedIntersectionTriangleEXT) {
274274
// Output feature inputs for mlp
275-
vec4 pixel_1 = texture(textureInput_1[nonuniformEXT(commited_instanceID)], commited_flipped);
275+
vec4 pixel_1 = textureLod(textureInput_1[nonuniformEXT(commited_instanceID)], commited_flipped, 0);
276276

277277
pixel_0.a = pixel_0.a*2.0-1.0;
278278
pixel_1.a = pixel_1.a*2.0-1.0;
@@ -327,16 +327,16 @@ void main(void)
327327

328328
// Sample feature maps then output to second subpass
329329
const vec2 flipped = vec2( hitpoint_uv.x, 1.0 - hitpoint_uv.y );
330-
vec4 pixel_0 = texture(textureInput_0[nonuniformEXT(instanceID)], flipped);
331-
vec4 pixel_1 = texture(textureInput_1[nonuniformEXT(instanceID)], flipped);
330+
vec4 pixel_0 = textureLod(textureInput_0[nonuniformEXT(instanceID)], flipped, 0);
331+
vec4 pixel_1 = textureLod(textureInput_1[nonuniformEXT(instanceID)], flipped, 0);
332332

333333
pixel_0.a = pixel_0.a*2.0-1.0;
334334
pixel_1.a = pixel_1.a*2.0-1.0;
335335

336336
o_color.rgb = Convert_sRGB_ToLinear(evaluateNetwork(pixel_0, pixel_1, vec4(rayDirection, 1.0f), instanceID));
337337
o_color.a = 1.0;
338338
} else {
339-
discard;
339+
discard;
340340
}
341341
}
342342
#endif
-56 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)