Prechádzať zdrojové kódy

Fix issue where vignette aspect ratio is different between offscreen and direct rendering

George Corney 5 rokov pred
rodič
commit
b2fed515bc

+ 4 - 2
src/Materials/imageProcessingConfiguration.ts

@@ -494,9 +494,9 @@ export class ImageProcessingConfiguration {
     /**
     /**
      * Binds the image processing to the shader.
      * Binds the image processing to the shader.
      * @param effect The effect to bind to
      * @param effect The effect to bind to
-     * @param aspectRatio Define the current aspect ratio of the effect
+     * @param overrideAspectRatio Override the aspect ratio of the effect
      */
      */
-    public bind(effect: Effect, aspectRatio = 1): void {
+    public bind(effect: Effect, overrideAspectRatio?: number): void {
         // Color Curves
         // Color Curves
         if (this._colorCurvesEnabled && this.colorCurves) {
         if (this._colorCurvesEnabled && this.colorCurves) {
             ColorCurves.Bind(this.colorCurves, effect);
             ColorCurves.Bind(this.colorCurves, effect);
@@ -508,6 +508,8 @@ export class ImageProcessingConfiguration {
             var inverseHeight = 1 / effect.getEngine().getRenderHeight();
             var inverseHeight = 1 / effect.getEngine().getRenderHeight();
             effect.setFloat2("vInverseScreenSize", inverseWidth, inverseHeight);
             effect.setFloat2("vInverseScreenSize", inverseWidth, inverseHeight);
 
 
+            let aspectRatio = overrideAspectRatio != null ? overrideAspectRatio : (inverseHeight/inverseWidth);
+
             let vignetteScaleY = Math.tan(this.vignetteCameraFov * 0.5);
             let vignetteScaleY = Math.tan(this.vignetteCameraFov * 0.5);
             let vignetteScaleX = vignetteScaleY * aspectRatio;
             let vignetteScaleX = vignetteScaleY * aspectRatio;