UNPKG

playcanvas

Version:

Open-source WebGL/WebGPU 3D engine for the web

3 lines (2 loc) 1.06 kB
declare const _default: "\nfn encodePickOutput(id: u32) -> vec4f {\n let inv: vec4f = vec4f(1.0 / 255.0);\n let shifts: vec4u = vec4u(16u, 8u, 0u, 24u);\n let col: vec4u = (vec4u(id) >> shifts) & vec4u(0xffu);\n return vec4f(col) * inv;\n}\n\n#ifndef PICK_CUSTOM_ID\n uniform meshInstanceId: u32;\n\n fn getPickOutput() -> vec4f {\n return encodePickOutput(uniform.meshInstanceId);\n }\n#endif\n\n#ifdef DEPTH_PICK_PASS\n #include \"floatAsUintPS\"\n #ifndef CAMERAPLANES\n #define CAMERAPLANES\n uniform camera_params: vec4f; // x: 1/far, y: far, z: near, w: isOrtho\n #endif\n fn getPickDepth() -> vec4f {\n var linearDepth: f32;\n if (uniform.camera_params.w > 0.5) {\n linearDepth = pcPosition.z;\n } else {\n let viewDist = 1.0 / pcPosition.w;\n linearDepth = (viewDist - uniform.camera_params.z) / (uniform.camera_params.y - uniform.camera_params.z);\n }\n return float2uint(linearDepth);\n }\n#endif\n"; export default _default;