declare const _default: "\n\n#ifndef TBNBASIS\n #define TBNBASIS\n uniform tbnBasis: f32;\n#endif\n\n// Returns the geometric normal of the triangle the fragment belongs to, in world space. Used to\n// give the surface a faceted (flat shaded) look, instead of using the smooth normal interpolated\n// from the vertex normals.\n//\n// This is exact rather than an approximation - both screen space derivatives of the world position\n// lie in the plane of the triangle, and so their cross product is the normal of that plane. It works\n// on skinned and morphed geometry at no additional cost, as it operates on the final world space\n// positions.\n//\n// Note that the lit shader still declares the vertex normal attribute for flat shaded variants, as\n// other parts of the vertex shader depend on it, and so a mesh without normals is not supported yet.\n//\n// The returned normal is oriented to match the winding of the triangle, and so it agrees with\n// correctly authored vertex normals on both front and back faces. This keeps flat shading orthogonal\n// to cull, frontFace and two sided lighting, which all behave as they do for smooth shading.\n//\n// Note that the derivatives require uniform control flow, and so this must not be called from inside\n// a conditionally executed branch.\nfn getFlatNormal(worldPos: vec3f) -> vec3f {\n\n let normal: vec3f = cross(dpdx(worldPos), dpdy(worldPos));\n\n // Two independent sign corrections, neither of which double counts the other:\n // - tbnBasis compensates for the Y flip applied to the projection matrix when rendering with\n // flipY, and for WebGPU's Y-down framebuffer space. Both flip the sign of the screen space\n // derivatives, and correcting for them leaves the cross product pointing at the viewer. See\n // TBN.js, which uses tbnBasis for the same reason.\n // - pcFrontFacing then flips it back to the orientation implied by the winding. It is itself\n // unaffected by flipY, which reverses the window space winding but is also folded into the\n // front face state, and so cancels out.\n let basis: f32 = select(-uniform.tbnBasis, uniform.tbnBasis, pcFrontFacing);\n\n // degenerate triangles generate a zero length normal, avoid normalizing those\n let len: f32 = length(normal);\n return select(vec3f(0.0, 1.0, 0.0), normal * (basis / len), len > 0.0);\n}\n"; export default _default;