UNPKG

@animech-public/playcanvas

Version:
20 lines (18 loc) 646 B
var reflectionSpherePS = ` #ifndef VIEWMATRIX #define VIEWMATRIX uniform mat4 matrix_view; #endif uniform sampler2D texture_sphereMap; uniform float material_reflectivity; vec3 calcReflection(vec3 reflDir, float gloss) { vec3 reflDirV = (mat3(matrix_view) * reflDir).xyz; 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 $DECODE(texture2D(texture_sphereMap, sphereMapUv)); } void addReflection(vec3 reflDir, float gloss) { dReflection += vec4(calcReflection(reflDir, gloss), material_reflectivity); } `; export { reflectionSpherePS as default };