All files / engine/Source/Shaders/Voxels IntersectBox.js

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37                                                                         
//This file is automatically rebuilt by the Cesium build process.
export default "// See IntersectionUtils.glsl for the definitions of Ray, RayShapeIntersection,\n\
// NO_HIT, Intersections\n\
\n\
/* Box defines (set in Scene/VoxelBoxShape.js)\n\
#define BOX_INTERSECTION_INDEX ### // always 0\n\
*/\n\
\n\
uniform sampler2D u_renderBoundPlanesTexture;\n\
\n\
RayShapeIntersection intersectBoundPlanes(in Ray ray) {\n\
    vec4 lastEntry = vec4(ray.dir, -INF_HIT);\n\
    vec4 firstExit = vec4(-ray.dir, +INF_HIT);\n\
    for (int i = 0; i < 6; i++) {\n\
        vec4 boundPlane = getBoundPlane(u_renderBoundPlanesTexture, i);\n\
        vec4 intersection = intersectPlane(ray, boundPlane);\n\
        if (dot(ray.dir, boundPlane.xyz) < 0.0) {\n\
            lastEntry = intersection.w > lastEntry.w ? intersection : lastEntry;\n\
        } else {\n\
            firstExit = intersection.w < firstExit.w ? intersection: firstExit;\n\
        }\n\
    }\n\
\n\
    if (lastEntry.w < firstExit.w) {\n\
        return RayShapeIntersection(lastEntry, firstExit);\n\
    } else {\n\
        return RayShapeIntersection(vec4(-ray.dir, NO_HIT), vec4(ray.dir, NO_HIT));\n\
    }\n\
}\n\
\n\
void intersectShape(in Ray rayUV, in  Ray rayEC, inout Intersections ix)\n\
{\n\
    RayShapeIntersection intersection = intersectBoundPlanes(rayEC);\n\
    setShapeIntersection(ix, BOX_INTERSECTION_INDEX, intersection);\n\
}\n\
";