playcanvas
Version:
PlayCanvas WebGL game engine
20 lines (18 loc) • 659 B
JavaScript
var reflectionSpherePS = `
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 { reflectionSpherePS as default };