playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
21 lines (20 loc) • 671 B
JavaScript
var reflectionSphere_default = `
uniform mat4 matrix_view;
uniform sampler2D texture_sphereMap;
uniform float material_reflectivity;
vec3 calcReflection(vec3 reflDir, float gloss) {
vec3 reflDirV = (mat3(matrix_view) * reflDir);
float m = 2.0 * sqrt(dot(reflDirV.xy, reflDirV.xy) + (reflDirV.z + 1.0) * (reflDirV.z + 1.0));
vec2 sphereMapUv = reflDirV.xy / m + 0.5;
return {reflectionDecode}(texture2D(texture_sphereMap, sphereMapUv));
}
void addReflection(vec3 reflDir, float gloss) {
dReflection += vec4(calcReflection(reflDir, gloss), material_reflectivity);
}
`;
export {
reflectionSphere_default as default
};