@@ -437,17 +437,18 @@ const ShaderReplacementRule GRIDCUBE_CULLPOS_FROM_CENTER(
437437 uniform vec3 u_boundMax;
438438 )" },
439439 {" GLOBAL_FRAGMENT_FILTER_PREP" , R"(
440- // NOTE: you would expect the constant below to be 0.5f , to cull from the center of the cell.
441- // We intentionally use 0.667 instead and slightly shift it, to avoid common default causes
440+ // NOTE: you would expect the constant below to be 0.f , to cull from the center of the cell.
441+ // We intentionally use 0.167 instead and slightly shift it, to avoid common default causes
442442 // where the plane slices right through the center of the cell, and you get random patterns
443443 // of cull/not-cull based on floating point error.
444- vec3 cullPosRef = (0.667f + cellInd3f) * u_gridSpacingReference;
444+ const float cull_shift = 0.167;
445+ vec3 cullPosRef = (0.5f + cull_shift + cellInd3f) * u_gridSpacingReference;
445446 vec3 cullPosWorld = mix(u_boundMin, u_boundMax, cullPosRef);
446447 vec3 cullPos = (u_modelView * vec4(cullPosWorld, 1.f)).xyz;
447448
448449 // compute the same data for the neighboring cell too
449450 // we need this due to the neighbor visibiilty filtering
450- vec3 neighCullPosRef = (0.5f + cellInd3f + a_refNormalToFrag) * u_gridSpacingReference;
451+ vec3 neighCullPosRef = (0.5f + cull_shift + cellInd3f + a_refNormalToFrag) * u_gridSpacingReference;
451452 vec3 neighCullPosWorld = mix(u_boundMin, u_boundMax, neighCullPosRef);
452453 vec3 neighCullPos = (u_modelView * vec4(neighCullPosWorld, 1.f)).xyz;
453454 )" },
0 commit comments