envmap_vertex.glsl.js 562 B

123456789101112131415161718192021222324252627
  1. export default /* glsl */`
  2. #ifdef USE_ENVMAP
  3. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( PHONG )
  4. vWorldPosition = worldPosition.xyz;
  5. #else
  6. vec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  7. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  8. #ifdef ENVMAP_MODE_REFLECTION
  9. vReflect = reflect( cameraToVertex, worldNormal );
  10. #else
  11. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  12. #endif
  13. #endif
  14. #endif
  15. `;