Bläddra i källkod

Merge pull request #7633 from syntheticmagus/projectionTextureScaling

Added ability for spot light projection textures to respect uScaling …
David Catuhe 5 år sedan
förälder
incheckning
92d9327e90
2 ändrade filer med 11 tillägg och 1 borttagningar
  1. 1 1
      dist/preview release/what's new.md
  2. 10 0
      src/Lights/spotLight.ts

+ 1 - 1
dist/preview release/what's new.md

@@ -193,7 +193,7 @@
 - UI Button has options to set different session mode and reference type ([RaananW](https://github.com/RaananW/))
 - Added option to change the teleportation duration in the VRExperienceHelper class ([https://github.com/LeoRodz](https://github.com/LeoRodz))
 - Added support to teleport the camera at constant speed in the VRExperienceHelper class ([https://github.com/LeoRodz](https://github.com/LeoRodz))
-- VRExperienceHelper has now an XR fallback to force XR usage (Beta) ([RaananW](https://github.com/RaananW/))
+- VRExperienceHelper has now an XR fallback to force XR usage (beta) ([RaananW](https://github.com/RaananW/))
 - Added option to change the teleportation easing function in the VRExperienceHelper class ([https://github.com/LeoRodz](https://github.com/LeoRodz))
 - Windows motion controller mapping corrected to XR (xr-standard) ([RaananW](https://github.com/RaananW/))
 - Pointer-Event simulation for screen target ray mode ([RaananW](https://github.com/RaananW/))

+ 10 - 0
src/Lights/spotLight.ts

@@ -302,6 +302,16 @@ export class SpotLight extends ShadowLight {
         this._projectionTextureDirty = false;
 
         this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix);
+        if (this._projectionTexture instanceof Texture) {
+            const u = this._projectionTexture.uScale / 2.0;
+            const v = this._projectionTexture.vScale / 2.0;
+            Matrix.FromValuesToRef(
+                u,   0.0, 0.0, 0.0,
+                0.0, v,   0.0, 0.0,
+                0.0, 0.0, 0.5, 0.0,
+                0.5, 0.5, 0.5, 1.0
+            , this._projectionTextureScalingMatrix);
+        }
         this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);
     }