@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
3 lines • 1.69 kB
TypeScript
declare const _default: "\n#define RECIPROCAL_PI 0.318309886\n\nvec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {\n // matrix is assumed to be orthogonal\n return normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );\n}\n\n// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n // normal is assumed to have unit length\n float x = normal.x, y = normal.y, z = normal.z;\n\n // band 0\n vec3 result = shCoefficients[ 0 ] * 0.8862269254527579;\n\n // band 1\n result -= shCoefficients[ 1 ] * 1.0233267079464885 * y;\n result += shCoefficients[ 2 ] * 1.0233267079464885 * z;\n result -= shCoefficients[ 3 ] * 1.0233267079464885 * x;\n\n // band 2\n result += shCoefficients[ 4 ] * 0.8580855308097834 * x * y;\n result -= shCoefficients[ 5 ] * 0.8580855308097834 * y * z;\n result += shCoefficients[ 6 ] * ( 0.7431238683011272 * z * z - 0.24770795610037571 );\n result -= shCoefficients[ 7 ] * 0.8580855308097834 * x * z;\n result += shCoefficients[ 8 ] * 0.4290427654048917 * ( x * x - y * y );\n\n return result;\n}\n\nuniform vec3 sh[ 9 ]; // sh coefficients\nuniform float intensity; // light probe intensity\nvarying vec3 vNormal;\n\nvoid main() {\n vec3 normal = normalize( vNormal );\n vec3 worldNormal = normalize(inverseTransformDirection( normal, viewMatrix ));\n vec3 irradiance = shGetIrradianceAt( worldNormal, sh );\n vec3 outgoingLight = 1.0 * irradiance * intensity;\n gl_FragColor = linearToOutputTexel( vec4( outgoingLight, 1.0 ) );\n}\n";
export default _default;
//# sourceMappingURL=visualize.frag.d.ts.map