docstring_tokens
stringlengths
0
76.5k
code_tokens
stringlengths
75
1.81M
label_window
listlengths
4
2.12k
html_url
stringlengths
74
116
file_name
stringlengths
3
311
// Setup the default processing configuration to the scene. this._attachImageProcessingConfiguration(null);
<mask> null, textureType, "postprocess", null, true); <mask> <mask> this._updateParameters(); <mask> <mask> this.onApply = (effect: Effect) => { <mask> this.imageProcessingConfiguration.bind(effect, this.aspectRatio); </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove super(name, "imageProcessing", [ 'contrast', 'vignetteSettings1', 'vignetteSettings2', 'cameraExposureLinear', 'vCameraColorCurveNegative', 'vCameraColorCurveNeutral', 'vCameraColorCurvePositive', 'colorTransformSettings' ], ["txColorTransform"], options, camera, samplingMode, engine, reusable, </s> add super(name, "imageProcessing", [], [], options, camera, samplingMode, engine, reusable, </s> remove let aspectRatio = this.aspectRatio; // Color if (this._colorCurvesEnabled) { ColorCurves.Bind(this.colorCurves, effect); } if (this._vignetteEnabled) { // Vignette let vignetteScaleY = Math.tan(this.cameraFov * 0.5); let vignetteScaleX = vignetteScaleY * aspectRatio; let vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY); vignetteScaleX = Tools.Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch); vignetteScaleY = Tools.Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch); effect.setFloat4('vignetteSettings1', vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY); let vignettePower = -2.0 * this.vignetteWeight; effect.setFloat4('vignetteSettings2', this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower); } // Contrast and exposure effect.setFloat('contrast', this.cameraContrast); effect.setFloat('cameraExposureLinear', Math.pow(2.0, -this.cameraExposure) * Math.PI); // Color transform settings if (this._colorGradingTexture) { effect.setTexture('txColorTransform', this.colorGradingTexture); let textureSize = this.colorGradingTexture.getSize().height; effect.setFloat4("colorTransformSettings", (textureSize - 1) / textureSize, // textureScale 0.5 / textureSize, // textureOffset textureSize, // textureSize this.colorGradingWeight // weight ); } </s> add this.imageProcessingConfiguration.bind(effect, this.aspectRatio); </s> remove if (this.cameraToneMappingEnabled) { defines += "#define TONEMAPPING\r\n"; } if (this._colorCurvesEnabled && this.colorCurves) { defines += "#define COLORCURVES\r\n"; } if (this._fromLinearSpace) { defines += "#define FROMLINEARSPACE\r\n"; } this.updateEffect(defines, null, samplers); } // Statics private static _VIGNETTEMODE_MULTIPLY = 0; private static _VIGNETTEMODE_OPAQUE = 1; </s> add var samplers = ["textureSampler"]; ImageProcessing.PrepareSamplers(samplers, this._defines); </s> remove public get colorGradingTexture(): BaseTexture { return this._colorGradingTexture; </s> add /** * Sets the Default image processing configuration used either in the this material. * * If sets to null, the scene one is in use. */ public set imageProcessingConfiguration(value: ImageProcessing) { this._attachImageProcessingConfiguration(value); </s> remove this._colorGradingTexture = value; </s> add // Detaches observer. if (this._imageProcessingConfiguration && this._imageProcessingObserver) { this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver); } // Pick the scene configuration if needed. if (!configuration) { var camera = this.getCamera(); var scene = camera ? camera.getScene() : BABYLON.Engine.LastCreatedScene; this._imageProcessingConfiguration = scene.imageProcessingConfiguration; } else { this._imageProcessingConfiguration = configuration; } // Attaches observer. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(conf => { this._updateParameters(); }); // Ensure the effect will be rebuilt.
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/PostProcess/babylon.imageProcessingPostProcess.ts
this.imageProcessingConfiguration.bind(effect, this.aspectRatio);
<mask> <mask> this._updateParameters(); <mask> <mask> this.onApply = (effect: Effect) => { <mask> let aspectRatio = this.aspectRatio; <mask> <mask> // Color <mask> if (this._colorCurvesEnabled) { <mask> ColorCurves.Bind(this.colorCurves, effect); <mask> } <mask> <mask> if (this._vignetteEnabled) { <mask> // Vignette <mask> let vignetteScaleY = Math.tan(this.cameraFov * 0.5); <mask> let vignetteScaleX = vignetteScaleY * aspectRatio; <mask> <mask> let vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY); <mask> vignetteScaleX = Tools.Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch); <mask> vignetteScaleY = Tools.Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch); <mask> <mask> effect.setFloat4('vignetteSettings1', vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY); <mask> <mask> let vignettePower = -2.0 * this.vignetteWeight; <mask> effect.setFloat4('vignetteSettings2', this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower); <mask> } <mask> <mask> // Contrast and exposure <mask> effect.setFloat('contrast', this.cameraContrast); <mask> effect.setFloat('cameraExposureLinear', Math.pow(2.0, -this.cameraExposure) * Math.PI); <mask> <mask> // Color transform settings <mask> if (this._colorGradingTexture) { <mask> effect.setTexture('txColorTransform', this.colorGradingTexture); <mask> let textureSize = this.colorGradingTexture.getSize().height; <mask> <mask> effect.setFloat4("colorTransformSettings", <mask> (textureSize - 1) / textureSize, // textureScale <mask> 0.5 / textureSize, // textureOffset <mask> textureSize, // textureSize <mask> this.colorGradingWeight // weight <mask> ); <mask> } <mask> }; <mask> } <mask> <mask> protected _updateParameters(): void { <mask> var defines = ""; </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove /** * Binds the color grading to the shader. * @param colorGrading The texture to bind * @param effect The effect to bind to */ public static Bind(colorGrading: BaseTexture, effect: Effect) : void { effect.setTexture("cameraColorGrading2DSampler", colorGrading); let x = colorGrading.level; // Texture Level let y = colorGrading.getSize().height; // Texture Size example with 8 let z = y - 1.0; // SizeMinusOne 8 - 1 let w = 1 / y; // Space of 1 slice 1 / 8 effect.setFloat4("vCameraColorGradingInfos", x, y, z, w); let slicePixelSizeU = w / y; // Space of 1 pixel in U direction, e.g. 1/64 let slicePixelSizeV = w; // Space of 1 pixel in V direction, e.g. 1/8 // Space of 1 pixel in V direction, e.g. 1/8 let x2 = z * slicePixelSizeU; // Extent of lookup range in U for a single slice so that range corresponds to (size-1) texels, for example 7/64 let y2 = z / y; // Extent of lookup range in V for a single slice so that range corresponds to (size-1) texels, for example 7/8 let z2 = 0.5 * slicePixelSizeU; // Offset of lookup range in U to align sample position with texel centre, for example 0.5/64 let w2 = 0.5 * slicePixelSizeV; // Offset of lookup range in V to align sample position with texel centre, for example 0.5/8 effect.setFloat4("vCameraColorGradingScaleOffset", x2, y2, z2, w2); } /** * Prepare the list of uniforms associated with the ColorGrading effects. * @param uniformsList The list of uniforms used in the effect * @param samplersList The list of samplers used in the effect */ public static PrepareUniformsAndSamplers(uniformsList: string[], samplersList: string[]): void { uniformsList.push( "vCameraColorGradingInfos", "vCameraColorGradingScaleOffset" ); samplersList.push( "cameraColorGrading2DSampler" ); } </s> add </s> remove var samplers = ["textureSampler"]; if (this.colorGradingTexture) { defines = "#define COLORGRADING\r\n"; samplers.push("txColorTransform"); } if (this._vignetteEnabled) { defines += "#define VIGNETTE\r\n"; if (this.vignetteBlendMode === ImageProcessingPostProcess._VIGNETTEMODE_MULTIPLY) { defines += "#define VIGNETTEBLENDMODEMULTIPLY\r\n"; } else { defines += "#define VIGNETTEBLENDMODEOPAQUE\r\n"; </s> add for (const define in this._defines) { if (this._defines[define]) { defines += `#define ${define};\r\n`; </s> remove private static _scaledEmissive = new Color3(); private static _scaledReflection = new Color3(); public static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: MaterialDefines, useScalarInLinearSpace: boolean, maxSimultaneousLights: number, usePhysicalLightFalloff: boolean) { var lightIndex = 0; for (var light of mesh._lightSources) { let useUbo = light._uniformBuffer.useUbo; let scaledIntensity = light.getScaledIntensity(); light._uniformBuffer.bindToEffect(effect, "Light" + lightIndex); MaterialHelper.BindLightProperties(light, effect, lightIndex); // GAMMA CORRECTION. this.convertColorToLinearSpaceToRef(light.diffuse, PBRMaterial._scaledAlbedo, useScalarInLinearSpace); PBRMaterial._scaledAlbedo.scaleToRef(scaledIntensity, PBRMaterial._scaledAlbedo); light._uniformBuffer.updateColor4(useUbo ? "vLightDiffuse" : "vLightDiffuse" + lightIndex, PBRMaterial._scaledAlbedo, usePhysicalLightFalloff ? light.radius : light.range); if (defines["SPECULARTERM"]) { this.convertColorToLinearSpaceToRef(light.specular, PBRMaterial._scaledReflectivity, useScalarInLinearSpace); PBRMaterial._scaledReflectivity.scaleToRef(scaledIntensity, PBRMaterial._scaledReflectivity); light._uniformBuffer.updateColor3(useUbo ? "vLightSpecular" : "vLightSpecular" + lightIndex, PBRMaterial._scaledReflectivity); } // Shadows if (scene.shadowsEnabled) { MaterialHelper.BindLightShadow(light, scene, mesh, lightIndex + "", effect); } light._uniformBuffer.update(); lightIndex++; if (lightIndex === maxSimultaneousLights) break; } } </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "re...
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/PostProcess/babylon.imageProcessingPostProcess.ts
this._defines.FROMLINEARSPACE = this._fromLinearSpace; this.imageProcessingConfiguration.prepareDefines(this._defines);
<mask> } <mask> <mask> protected _updateParameters(): void { <mask> var defines = ""; <mask> for (const define in this._defines) { <mask> if (this._defines[define]) { <mask> defines += `#define ${define};\r\n`; </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove var samplers = ["textureSampler"]; if (this.colorGradingTexture) { defines = "#define COLORGRADING\r\n"; samplers.push("txColorTransform"); } if (this._vignetteEnabled) { defines += "#define VIGNETTE\r\n"; if (this.vignetteBlendMode === ImageProcessingPostProcess._VIGNETTEMODE_MULTIPLY) { defines += "#define VIGNETTEBLENDMODEMULTIPLY\r\n"; } else { defines += "#define VIGNETTEBLENDMODEOPAQUE\r\n"; </s> add for (const define in this._defines) { if (this._defines[define]) { defines += `#define ${define};\r\n`; </s> remove if (this.cameraToneMappingEnabled) { defines += "#define TONEMAPPING\r\n"; } if (this._colorCurvesEnabled && this.colorCurves) { defines += "#define COLORCURVES\r\n"; } if (this._fromLinearSpace) { defines += "#define FROMLINEARSPACE\r\n"; } this.updateEffect(defines, null, samplers); } // Statics private static _VIGNETTEMODE_MULTIPLY = 0; private static _VIGNETTEMODE_OPAQUE = 1; </s> add var samplers = ["textureSampler"]; ImageProcessing.PrepareSamplers(samplers, this._defines); </s> remove let aspectRatio = this.aspectRatio; // Color if (this._colorCurvesEnabled) { ColorCurves.Bind(this.colorCurves, effect); } if (this._vignetteEnabled) { // Vignette let vignetteScaleY = Math.tan(this.cameraFov * 0.5); let vignetteScaleX = vignetteScaleY * aspectRatio; let vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY); vignetteScaleX = Tools.Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch); vignetteScaleY = Tools.Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch); effect.setFloat4('vignetteSettings1', vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY); let vignettePower = -2.0 * this.vignetteWeight; effect.setFloat4('vignetteSettings2', this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower); } // Contrast and exposure effect.setFloat('contrast', this.cameraContrast); effect.setFloat('cameraExposureLinear', Math.pow(2.0, -this.cameraExposure) * Math.PI); // Color transform settings if (this._colorGradingTexture) { effect.setTexture('txColorTransform', this.colorGradingTexture); let textureSize = this.colorGradingTexture.getSize().height; effect.setFloat4("colorTransformSettings", (textureSize - 1) / textureSize, // textureScale 0.5 / textureSize, // textureOffset textureSize, // textureSize this.colorGradingWeight // weight ); } </s> add this.imageProcessingConfiguration.bind(effect, this.aspectRatio); </s> remove protected _ldrOutput = true; </s> add protected _useAlphaFresnel = false; @serialize() protected _hdrLinearOutput = false; /** * Default configuration related to image processing available in the PBR Material. */ @serializeAsImageProcessing() protected _imageProcessingConfiguration: ImageProcessing; /** * Keep track of the image processing observer to allow dispose and replace. */ private _imageProcessingObserver: Observer<ImageProcessing>; /** * Attaches a new image processing configuration to the PBR Material. * @param configuration */ protected _attachImageProcessingConfiguration(configuration: ImageProcessing): void { if (configuration === this._imageProcessingConfiguration) { return; } // Detaches observer. if (this._imageProcessingConfiguration && this._imageProcessingObserver) { this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver); } // Pick the scene configuration if needed. if (!configuration) { this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration; } else { this._imageProcessingConfiguration = configuration; } // Attaches observer. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(conf => { this._markAllSubMeshesAsTexturesDirty(); }); // Ensure the effect will be rebuilt. this._markAllSubMeshesAsTexturesDirty(); } </s> remove public static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: MaterialDefines, maxSimultaneousLights = 4) { </s> add public static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: MaterialDefines, maxSimultaneousLights = 4, , usePhysicalLightFalloff = false) {
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/PostProcess/babylon.imageProcessingPostProcess.ts
for (const define in this._defines) { if (this._defines[define]) { defines += `#define ${define};\r\n`;
<mask> } <mask> <mask> protected _updateParameters(): void { <mask> var defines = ""; <mask> var samplers = ["textureSampler"]; <mask> <mask> if (this.colorGradingTexture) { <mask> defines = "#define COLORGRADING\r\n"; <mask> samplers.push("txColorTransform"); <mask> } <mask> <mask> if (this._vignetteEnabled) { <mask> defines += "#define VIGNETTE\r\n"; <mask> <mask> if (this.vignetteBlendMode === ImageProcessingPostProcess._VIGNETTEMODE_MULTIPLY) { <mask> defines += "#define VIGNETTEBLENDMODEMULTIPLY\r\n"; <mask> } else { <mask> defines += "#define VIGNETTEBLENDMODEOPAQUE\r\n"; <mask> } <mask> } <mask> <mask> if (this.cameraToneMappingEnabled) { <mask> defines += "#define TONEMAPPING\r\n"; </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove if (this.cameraToneMappingEnabled) { defines += "#define TONEMAPPING\r\n"; } if (this._colorCurvesEnabled && this.colorCurves) { defines += "#define COLORCURVES\r\n"; } if (this._fromLinearSpace) { defines += "#define FROMLINEARSPACE\r\n"; } this.updateEffect(defines, null, samplers); } // Statics private static _VIGNETTEMODE_MULTIPLY = 0; private static _VIGNETTEMODE_OPAQUE = 1; </s> add var samplers = ["textureSampler"]; ImageProcessing.PrepareSamplers(samplers, this._defines); </s> remove let aspectRatio = this.aspectRatio; // Color if (this._colorCurvesEnabled) { ColorCurves.Bind(this.colorCurves, effect); } if (this._vignetteEnabled) { // Vignette let vignetteScaleY = Math.tan(this.cameraFov * 0.5); let vignetteScaleX = vignetteScaleY * aspectRatio; let vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY); vignetteScaleX = Tools.Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch); vignetteScaleY = Tools.Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch); effect.setFloat4('vignetteSettings1', vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY); let vignettePower = -2.0 * this.vignetteWeight; effect.setFloat4('vignetteSettings2', this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower); } // Contrast and exposure effect.setFloat('contrast', this.cameraContrast); effect.setFloat('cameraExposureLinear', Math.pow(2.0, -this.cameraExposure) * Math.PI); // Color transform settings if (this._colorGradingTexture) { effect.setTexture('txColorTransform', this.colorGradingTexture); let textureSize = this.colorGradingTexture.getSize().height; effect.setFloat4("colorTransformSettings", (textureSize - 1) / textureSize, // textureScale 0.5 / textureSize, // textureOffset textureSize, // textureSize this.colorGradingWeight // weight ); } </s> add this.imageProcessingConfiguration.bind(effect, this.aspectRatio); </s> remove this._colorGradingTexture = value; </s> add // Detaches observer. if (this._imageProcessingConfiguration && this._imageProcessingObserver) { this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver); } // Pick the scene configuration if needed. if (!configuration) { var camera = this.getCamera(); var scene = camera ? camera.getScene() : BABYLON.Engine.LastCreatedScene; this._imageProcessingConfiguration = scene.imageProcessingConfiguration; } else { this._imageProcessingConfiguration = configuration; } // Attaches observer. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(conf => { this._updateParameters(); }); // Ensure the effect will be rebuilt. </s> remove if (this._cameraColorGradingTexture && StandardMaterial.ColorGradingTextureEnabled) { // Camera Color Grading can not be none blocking. if (!this._cameraColorGradingTexture.isReady()) { return false; } else { defines.CAMERACOLORGRADING = true; } } else { defines.CAMERACOLORGRADING = false; } </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/PostProcess/babylon.imageProcessingPostProcess.ts
var samplers = ["textureSampler"]; ImageProcessing.PrepareSamplers(samplers, this._defines);
<mask> defines += "#define VIGNETTEBLENDMODEOPAQUE\r\n"; <mask> } <mask> } <mask> <mask> if (this.cameraToneMappingEnabled) { <mask> defines += "#define TONEMAPPING\r\n"; <mask> } <mask> <mask> if (this._colorCurvesEnabled && this.colorCurves) { <mask> defines += "#define COLORCURVES\r\n"; <mask> } <mask> <mask> if (this._fromLinearSpace) { <mask> defines += "#define FROMLINEARSPACE\r\n"; <mask> } <mask> <mask> this.updateEffect(defines, null, samplers); <mask> } <mask> <mask> // Statics <mask> private static _VIGNETTEMODE_MULTIPLY = 0; <mask> private static _VIGNETTEMODE_OPAQUE = 1; <mask> <mask> public static get VIGNETTEMODE_MULTIPLY(): number { <mask> return ImageProcessingPostProcess._VIGNETTEMODE_MULTIPLY; <mask> } <mask> </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove var samplers = ["textureSampler"]; if (this.colorGradingTexture) { defines = "#define COLORGRADING\r\n"; samplers.push("txColorTransform"); } if (this._vignetteEnabled) { defines += "#define VIGNETTE\r\n"; if (this.vignetteBlendMode === ImageProcessingPostProcess._VIGNETTEMODE_MULTIPLY) { defines += "#define VIGNETTEBLENDMODEMULTIPLY\r\n"; } else { defines += "#define VIGNETTEBLENDMODEOPAQUE\r\n"; </s> add for (const define in this._defines) { if (this._defines[define]) { defines += `#define ${define};\r\n`; </s> remove public static get VIGNETTEMODE_MULTIPLY(): number { return ImageProcessingPostProcess._VIGNETTEMODE_MULTIPLY; } </s> add var uniforms = []; ImageProcessing.PrepareUniforms(uniforms, this._defines); </s> remove public static get VIGNETTEMODE_OPAQUE(): number { return ImageProcessingPostProcess._VIGNETTEMODE_OPAQUE; </s> add this.updateEffect(defines, uniforms, samplers); </s> remove private convertColorToLinearSpaceToRef(color: Color3, ref: Color3): void { PBRMaterial.convertColorToLinearSpaceToRef(color, ref, this._useScalarInLinearSpace); } private static convertColorToLinearSpaceToRef(color: Color3, ref: Color3, useScalarInLinear: boolean): void { if (!useScalarInLinear) { color.toLinearSpaceToRef(ref); } else { ref.r = color.r; ref.g = color.g; ref.b = color.b; } } private static _scaledAlbedo = new Color3(); </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "k...
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/PostProcess/babylon.imageProcessingPostProcess.ts
var uniforms = []; ImageProcessing.PrepareUniforms(uniforms, this._defines);
<mask> // Statics <mask> private static _VIGNETTEMODE_MULTIPLY = 0; <mask> private static _VIGNETTEMODE_OPAQUE = 1; <mask> <mask> public static get VIGNETTEMODE_MULTIPLY(): number { <mask> return ImageProcessingPostProcess._VIGNETTEMODE_MULTIPLY; <mask> } <mask> <mask> public static get VIGNETTEMODE_OPAQUE(): number { <mask> return ImageProcessingPostProcess._VIGNETTEMODE_OPAQUE; <mask> } <mask> } </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove if (this.cameraToneMappingEnabled) { defines += "#define TONEMAPPING\r\n"; } if (this._colorCurvesEnabled && this.colorCurves) { defines += "#define COLORCURVES\r\n"; } if (this._fromLinearSpace) { defines += "#define FROMLINEARSPACE\r\n"; } this.updateEffect(defines, null, samplers); } // Statics private static _VIGNETTEMODE_MULTIPLY = 0; private static _VIGNETTEMODE_OPAQUE = 1; </s> add var samplers = ["textureSampler"]; ImageProcessing.PrepareSamplers(samplers, this._defines); </s> remove public static get VIGNETTEMODE_OPAQUE(): number { return ImageProcessingPostProcess._VIGNETTEMODE_OPAQUE; </s> add this.updateEffect(defines, uniforms, samplers); </s> remove private convertColorToLinearSpaceToRef(color: Color3, ref: Color3): void { PBRMaterial.convertColorToLinearSpaceToRef(color, ref, this._useScalarInLinearSpace); } private static convertColorToLinearSpaceToRef(color: Color3, ref: Color3, useScalarInLinear: boolean): void { if (!useScalarInLinear) { color.toLinearSpaceToRef(ref); } else { ref.r = color.r; ref.g = color.g; ref.b = color.b; } } private static _scaledAlbedo = new Color3(); </s> add </s> remove private static _scaledEmissive = new Color3(); private static _scaledReflection = new Color3(); public static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: MaterialDefines, useScalarInLinearSpace: boolean, maxSimultaneousLights: number, usePhysicalLightFalloff: boolean) { var lightIndex = 0; for (var light of mesh._lightSources) { let useUbo = light._uniformBuffer.useUbo; let scaledIntensity = light.getScaledIntensity(); light._uniformBuffer.bindToEffect(effect, "Light" + lightIndex); MaterialHelper.BindLightProperties(light, effect, lightIndex); // GAMMA CORRECTION. this.convertColorToLinearSpaceToRef(light.diffuse, PBRMaterial._scaledAlbedo, useScalarInLinearSpace); PBRMaterial._scaledAlbedo.scaleToRef(scaledIntensity, PBRMaterial._scaledAlbedo); light._uniformBuffer.updateColor4(useUbo ? "vLightDiffuse" : "vLightDiffuse" + lightIndex, PBRMaterial._scaledAlbedo, usePhysicalLightFalloff ? light.radius : light.range); if (defines["SPECULARTERM"]) { this.convertColorToLinearSpaceToRef(light.specular, PBRMaterial._scaledReflectivity, useScalarInLinearSpace); PBRMaterial._scaledReflectivity.scaleToRef(scaledIntensity, PBRMaterial._scaledReflectivity); light._uniformBuffer.updateColor3(useUbo ? "vLightSpecular" : "vLightSpecular" + lightIndex, PBRMaterial._scaledReflectivity); } // Shadows if (scene.shadowsEnabled) { MaterialHelper.BindLightShadow(light, scene, mesh, lightIndex + "", effect); } light._uniformBuffer.update(); lightIndex++; if (lightIndex === maxSimultaneousLights) break; } } </s> add </s> remove public static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: MaterialDefines, maxSimultaneousLights = 4) { </s> add public static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: MaterialDefines, maxSimultaneousLights = 4, , usePhysicalLightFalloff = false) {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/PostProcess/babylon.imageProcessingPostProcess.ts
this.updateEffect(defines, uniforms, samplers);
<mask> public static get VIGNETTEMODE_MULTIPLY(): number { <mask> return ImageProcessingPostProcess._VIGNETTEMODE_MULTIPLY; <mask> } <mask> <mask> public static get VIGNETTEMODE_OPAQUE(): number { <mask> return ImageProcessingPostProcess._VIGNETTEMODE_OPAQUE; <mask> } <mask> } <mask> } </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove public static get VIGNETTEMODE_MULTIPLY(): number { return ImageProcessingPostProcess._VIGNETTEMODE_MULTIPLY; } </s> add var uniforms = []; ImageProcessing.PrepareUniforms(uniforms, this._defines); </s> remove if (this.cameraToneMappingEnabled) { defines += "#define TONEMAPPING\r\n"; } if (this._colorCurvesEnabled && this.colorCurves) { defines += "#define COLORCURVES\r\n"; } if (this._fromLinearSpace) { defines += "#define FROMLINEARSPACE\r\n"; } this.updateEffect(defines, null, samplers); } // Statics private static _VIGNETTEMODE_MULTIPLY = 0; private static _VIGNETTEMODE_OPAQUE = 1; </s> add var samplers = ["textureSampler"]; ImageProcessing.PrepareSamplers(samplers, this._defines); </s> remove this._vignetteEnabled = value; this._updateParameters(); } </s> add /** * Gets Vignette centre Y Offset. */ public get vignetteCentreY(): number { return this.imageProcessingConfiguration.vignetteCentreY; } /** * Sets Vignette centre Y Offset. */ public set vignetteCentreY(value: number) { this.imageProcessingConfiguration.vignetteCentreY = value; } /** * Gets Vignette weight or intensity of the vignette effect. */ public get vignetteWeight(): number { return this.imageProcessingConfiguration.vignetteWeight; } /** * Sets Vignette weight or intensity of the vignette effect. */ public set vignetteWeight(value: number) { this.imageProcessingConfiguration.vignetteWeight = value; } </s> remove public set vignetteEnabled(value: boolean) { if (this._vignetteEnabled === value) { return; } </s> add /** * Gets Vignette centre X Offset. */ public get vignetteCentreX(): number { return this.imageProcessingConfiguration.vignetteCentreX; } /** * Sets Vignette centre X Offset. */ public set vignetteCentreX(value: number) { this.imageProcessingConfiguration.vignetteCentreX = value; } </s> remove this._colorCurvesEnabled = value; this._updateParameters(); } </s> add /** * Gets Camera contrast used in the effect. */ public get cameraContrast(): number { return this.imageProcessingConfiguration.cameraContrast; } /** * Sets Camera contrast used in the effect. */ public set cameraContrast(value: number) { this.imageProcessingConfiguration.cameraContrast = value; }
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/PostProcess/babylon.imageProcessingPostProcess.ts
<mask> #ifdef MICROSURFACEMAP <mask> uniform vec2 vMicroSurfaceSamplerInfos; <mask> #endif <mask> <mask> #ifdef OPACITYFRESNEL <mask> uniform vec4 opacityParts; <mask> #endif <mask> <mask> #ifdef EMISSIVEFRESNEL <mask> uniform vec4 emissiveLeftColor; <mask> uniform vec4 emissiveRightColor; <mask> #endif <mask> <mask> // Refraction Reflection <mask> #if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION) <mask> uniform mat4 view; <mask> #endif <mask> </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove uniform vec4 opacityParts; uniform vec4 emissiveLeftColor; uniform vec4 emissiveRightColor; </s> add </s> remove #ifdef REFLECTIONMAP_3D uniform samplerCube reflectionCubeSampler; #else uniform sampler2D reflection2DSampler; #endif </s> add #ifdef REFLECTIONMAP_SKYBOX varying vec3 vPositionUVW; #else #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) varying vec3 vDirectionW; #endif </s> remove uniform float contrast; uniform vec4 vignetteSettings1; uniform vec4 vignetteSettings2; uniform float cameraExposureLinear; uniform vec4 vCameraColorCurveNegative; uniform vec4 vCameraColorCurveNeutral; uniform vec4 vCameraColorCurvePositive; uniform sampler2D txColorTransform; uniform vec4 colorTransformSettings; </s> add #include<helperFunctions> </s> remove #ifdef REFLECTIONMAP_SKYBOX varying vec3 vPositionUVW; #else #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) varying vec3 vDirectionW; #endif </s> add #endif
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/ShadersInclude/pbrFragmentDeclaration.fx
<mask> #define RECIPROCAL_PI2 0.15915494 <mask> #define FRESNEL_MAXIMUM_ON_ROUGH 0.25 <mask> <mask> // PBR CUSTOM CONSTANTS <mask> const float kPi = 3.1415926535897932384626433832795; <mask> const float kRougnhessToAlphaScale = 0.1; <mask> const float kRougnhessToAlphaOffset = 0.29248125; <mask> <mask> float Square(float value) <mask> { </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove float Square(float value) { return value * value; } float getLuminance(vec3 color) { return clamp(dot(color, vec3(0.2126, 0.7152, 0.0722)), 0., 1.); } </s> add </s> remove uniform float contrast; uniform vec4 vignetteSettings1; uniform vec4 vignetteSettings2; uniform float cameraExposureLinear; uniform vec4 vCameraColorCurveNegative; uniform vec4 vCameraColorCurveNeutral; uniform vec4 vCameraColorCurvePositive; uniform sampler2D txColorTransform; uniform vec4 colorTransformSettings; </s> add #include<helperFunctions> </s> remove float alphaG = Square(roughness) + kMinimumVariance; </s> add float alphaG = square(roughness) + kMinimumVariance; </s> remove return fresnel * NdotL / kPi; </s> add return fresnel * NdotL / PI; </s> remove /** * Polyfill for SAMPLE_TEXTURE_3D, which is unsupported in WebGL. * colorTransformSettings.y = textureOffset (0.5 / textureSize). * colorTransformSettings.z = textureSize. */ vec3 sampleTexture3D(sampler2D colorTransform, vec3 color) </s> add void main(void)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/ShadersInclude/pbrFunctions.fx
<mask> const float kPi = 3.1415926535897932384626433832795; <mask> const float kRougnhessToAlphaScale = 0.1; <mask> const float kRougnhessToAlphaOffset = 0.29248125; <mask> <mask> float Square(float value) <mask> { <mask> return value * value; <mask> } <mask> <mask> float getLuminance(vec3 color) <mask> { <mask> return clamp(dot(color, vec3(0.2126, 0.7152, 0.0722)), 0., 1.); <mask> } <mask> <mask> float convertRoughnessToAverageSlope(float roughness) <mask> { <mask> // Calculate AlphaG as square of roughness; add epsilon to avoid numerical issues <mask> const float kMinimumVariance = 0.0005; <mask> float alphaG = Square(roughness) + kMinimumVariance; </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove float alphaG = Square(roughness) + kMinimumVariance; </s> add float alphaG = square(roughness) + kMinimumVariance; </s> remove const float kPi = 3.1415926535897932384626433832795; </s> add </s> remove uniform float contrast; uniform vec4 vignetteSettings1; uniform vec4 vignetteSettings2; uniform float cameraExposureLinear; uniform vec4 vCameraColorCurveNegative; uniform vec4 vCameraColorCurveNeutral; uniform vec4 vCameraColorCurvePositive; uniform sampler2D txColorTransform; uniform vec4 colorTransformSettings; </s> add #include<helperFunctions> </s> remove return fresnel * NdotL / kPi; </s> add return fresnel * NdotL / PI; </s> remove float a2 = Square(alphaG); </s> add float a2 = square(alphaG);
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/ShadersInclude/pbrFunctions.fx
float alphaG = square(roughness) + kMinimumVariance;
<mask> float convertRoughnessToAverageSlope(float roughness) <mask> { <mask> // Calculate AlphaG as square of roughness; add epsilon to avoid numerical issues <mask> const float kMinimumVariance = 0.0005; <mask> float alphaG = Square(roughness) + kMinimumVariance; <mask> return alphaG; <mask> } <mask> <mask> // Based on Beckamm roughness to Blinn exponent + http://casual-effects.blogspot.ca/2011/08/plausible-environment-lighting-in-two.html <mask> float getMipMapIndexFromAverageSlope(float maxMipLevel, float alpha) </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove float Square(float value) { return value * value; } float getLuminance(vec3 color) { return clamp(dot(color, vec3(0.2126, 0.7152, 0.0722)), 0., 1.); } </s> add </s> remove float a2 = Square(alphaG); </s> add float a2 = square(alphaG); </s> remove const float kPi = 3.1415926535897932384626433832795; </s> add </s> remove return fresnel * NdotL / kPi; </s> add return fresnel * NdotL / PI; </s> remove // Compute N dot V. float NdotV = clamp(dot(normalW, viewDirectionW),0., 1.) + 0.00001; </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/ShadersInclude/pbrFunctions.fx
float a2 = square(alphaG);
<mask> { <mask> // Note: alphaG is average slope (gradient) of the normals in slope-space. <mask> // It is also the (trigonometric) tangent of the median distribution value, i.e. 50% of normals have <mask> // a tangent (gradient) closer to the macrosurface than this slope. <mask> float a2 = Square(alphaG); <mask> float d = NdotH * NdotH * (a2 - 1.0) + 1.0; <mask> return a2 / (kPi * d * d); <mask> } <mask> <mask> vec3 fresnelSchlickGGX(float VdotH, vec3 reflectance0, vec3 reflectance90) </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove return a2 / (kPi * d * d); </s> add return a2 / (PI * d * d); </s> remove /** * Polyfill for SAMPLE_TEXTURE_3D, which is unsupported in WebGL. * colorTransformSettings.y = textureOffset (0.5 / textureSize). * colorTransformSettings.z = textureSize. */ vec3 sampleTexture3D(sampler2D colorTransform, vec3 color) </s> add void main(void) </s> remove float sliceSize = 2.0 * colorTransformSettings.y; // Size of 1 slice relative to the texture, for example 1/8 float sliceContinuous = (color.y - colorTransformSettings.y) * colorTransformSettings.z; float sliceInteger = floor(sliceContinuous); // Note: this is mathematically equivalent to fract(sliceContinuous); but we use explicit subtract // rather than separate fract() for correct results near slice boundaries (matching sliceInteger choice) float sliceFraction = sliceContinuous - sliceInteger; vec2 sliceUV = color.xz; sliceUV.x *= sliceSize; sliceUV.x += sliceInteger * sliceSize; vec4 slice0Color = texture2D(colorTransform, sliceUV); sliceUV.x += sliceSize; vec4 slice1Color = texture2D(colorTransform, sliceUV); vec3 result = mix(slice0Color.rgb, slice1Color.rgb, sliceFraction); color.rgb = result.bgr; return color; } vec4 applyImageProcessing(vec4 result, vec2 viewportXY){ #ifndef FROMLINEARSPACE // Need to move to linear space for subsequent operations result.rgb = pow(result.rgb, vec3(LinearEncodePowerApprox)); #endif result.rgb *= cameraExposureLinear; #ifdef VIGNETTE //vignette vec3 vignetteXY1 = vec3(viewportXY * vignetteSettings1.xy + vignetteSettings1.zw, 1.0); float vignetteTerm = dot(vignetteXY1, vignetteXY1); float vignette = pow(vignetteTerm, vignetteSettings2.w); // Interpolate between the artist 'color' and white based on the physical transmission value 'vignette'. vec3 vignetteColor = vignetteSettings2.rgb; </s> add vec4 result = texture2D(textureSampler, vUV); </s> remove vec3 FresnelSchlickEnvironmentGGX(float VdotN, vec3 reflectance0, vec3 reflectance90, float smoothness) </s> add vec3 fresnelSchlickEnvironmentGGX(float VdotN, vec3 reflectance0, vec3 reflectance90, float smoothness) </s> remove * If false, it allows the output of the shader to be in hdr space (e.g. more than one) which is useful * in combination of post process in float or half float mode. </s> add * Secifies that the alpha is premultiplied before output (this enables alpha premultiplied blending). * in your scene composition. */ protected _premultiplyAlpha = false; /** * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested. * And/Or ocllude the blended part.
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/ShadersInclude/pbrFunctions.fx
return a2 / (PI * d * d);
<mask> // It is also the (trigonometric) tangent of the median distribution value, i.e. 50% of normals have <mask> // a tangent (gradient) closer to the macrosurface than this slope. <mask> float a2 = Square(alphaG); <mask> float d = NdotH * NdotH * (a2 - 1.0) + 1.0; <mask> return a2 / (kPi * d * d); <mask> } <mask> <mask> vec3 fresnelSchlickGGX(float VdotH, vec3 reflectance0, vec3 reflectance90) <mask> { <mask> return reflectance0 + (reflectance90 - reflectance0) * pow(clamp(1.0 - VdotH, 0., 1.), 5.0); </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove float a2 = Square(alphaG); </s> add float a2 = square(alphaG); </s> remove vec3 FresnelSchlickEnvironmentGGX(float VdotN, vec3 reflectance0, vec3 reflectance90, float smoothness) </s> add vec3 fresnelSchlickEnvironmentGGX(float VdotN, vec3 reflectance0, vec3 reflectance90, float smoothness) </s> remove return fresnel * NdotL / kPi; </s> add return fresnel * NdotL / PI; </s> remove /** * Polyfill for SAMPLE_TEXTURE_3D, which is unsupported in WebGL. * colorTransformSettings.y = textureOffset (0.5 / textureSize). * colorTransformSettings.z = textureSize. */ vec3 sampleTexture3D(sampler2D colorTransform, vec3 color) </s> add void main(void) </s> remove #ifdef TONEMAPPING float tonemappingCalibration = 1.590579; result.rgb = 1.0 - exp2(-tonemappingCalibration * result.rgb); #endif // Going back to gamma space result.rgb = pow(result.rgb, vec3(GammaEncodePowerApprox)); result.rgb = clamp(result.rgb, 0.0, 1.0); // Contrast vec3 resultHighContrast = applyEaseInOut(result.rgb); if (contrast < 1.0) { result.rgb = mix(vec3(0.5, 0.5, 0.5), result.rgb, contrast); } else { result.rgb = mix(result.rgb, resultHighContrast, contrast - 1.0); } // Apply Color Transform #ifdef COLORGRADING vec3 colorTransformInput = result.rgb * colorTransformSettings.xxx + colorTransformSettings.yyy; vec3 colorTransformOutput = sampleTexture3D(txColorTransform, colorTransformInput).rgb; result.rgb = mix(result.rgb, colorTransformOutput, colorTransformSettings.www); #endif #ifdef COLORCURVES // Apply Color Curves float luma = dot(result.rgb, RGBLuminanceCoefficients); vec2 curveMix = clamp(vec2(luma * 3.0 - 1.5, luma * -3.0 + 1.5), vec2(0.0), vec2(1.0)); vec4 colorCurve = vCameraColorCurveNeutral + curveMix.x * vCameraColorCurvePositive - curveMix.y * vCameraColorCurveNegative; result.rgb *= colorCurve.rgb; result.rgb = mix(vec3(luma), result.rgb, colorCurve.a); #endif return result; } void main(void) { vec4 result = texture2D(textureSampler, vUV); vec2 viewportXY = vUV * 2.0 - 1.0; result = applyImageProcessing(result, viewportXY); </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/ShadersInclude/pbrFunctions.fx
vec3 fresnelSchlickEnvironmentGGX(float VdotN, vec3 reflectance0, vec3 reflectance90, float smoothness)
<mask> { <mask> return reflectance0 + (reflectance90 - reflectance0) * pow(clamp(1.0 - VdotH, 0., 1.), 5.0); <mask> } <mask> <mask> vec3 FresnelSchlickEnvironmentGGX(float VdotN, vec3 reflectance0, vec3 reflectance90, float smoothness) <mask> { <mask> // Schlick fresnel approximation, extended with basic smoothness term so that rough surfaces do not approach reflectance90 at grazing angle <mask> float weight = mix(FRESNEL_MAXIMUM_ON_ROUGH, 1.0, smoothness); <mask> return reflectance0 + weight * (reflectance90 - reflectance0) * pow(clamp(1.0 - VdotN, 0., 1.), 5.0); <mask> } </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove return a2 / (kPi * d * d); </s> add return a2 / (PI * d * d); </s> remove return fresnel * NdotL / kPi; </s> add return fresnel * NdotL / PI; </s> remove // For typical incident reflectance range (between 4% to 100%) set the grazing reflectance to 100% for typical fresnel effect. // For very low reflectance range on highly diffuse objects (below 4%), incrementally reduce grazing reflecance to 0%. float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0); vec3 specularEnvironmentR0 = surfaceReflectivityColor.rgb; vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90; // Lighting vec3 diffuseBase = vec3(0., 0., 0.); #ifdef SPECULARTERM vec3 specularBase = vec3(0., 0., 0.); #endif </s> add // Calculate the appropriate linear opacity for the current viewing angle (formally, this quantity is the "directional absorptance"). alpha = fresnelSchlickEnvironmentGGX(clamp(dot(V, normalForward), 0.0, 1.0), vec3(opacity0), vec3(opacity90), sqrt(microSurface)).x; </s> remove float a2 = Square(alphaG); </s> add float a2 = square(alphaG); </s> remove #ifdef TONEMAPPING float tonemappingCalibration = 1.590579; result.rgb = 1.0 - exp2(-tonemappingCalibration * result.rgb); #endif // Going back to gamma space result.rgb = pow(result.rgb, vec3(GammaEncodePowerApprox)); result.rgb = clamp(result.rgb, 0.0, 1.0); // Contrast vec3 resultHighContrast = applyEaseInOut(result.rgb); if (contrast < 1.0) { result.rgb = mix(vec3(0.5, 0.5, 0.5), result.rgb, contrast); } else { result.rgb = mix(result.rgb, resultHighContrast, contrast - 1.0); } // Apply Color Transform #ifdef COLORGRADING vec3 colorTransformInput = result.rgb * colorTransformSettings.xxx + colorTransformSettings.yyy; vec3 colorTransformOutput = sampleTexture3D(txColorTransform, colorTransformInput).rgb; result.rgb = mix(result.rgb, colorTransformOutput, colorTransformSettings.www); #endif #ifdef COLORCURVES // Apply Color Curves float luma = dot(result.rgb, RGBLuminanceCoefficients); vec2 curveMix = clamp(vec2(luma * 3.0 - 1.5, luma * -3.0 + 1.5), vec2(0.0), vec2(1.0)); vec4 colorCurve = vCameraColorCurveNeutral + curveMix.x * vCameraColorCurvePositive - curveMix.y * vCameraColorCurveNegative; result.rgb *= colorCurve.rgb; result.rgb = mix(vec3(luma), result.rgb, colorCurve.a); #endif return result; } void main(void) { vec4 result = texture2D(textureSampler, vUV); vec2 viewportXY = vUV * 2.0 - 1.0; result = applyImageProcessing(result, viewportXY); </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/ShadersInclude/pbrFunctions.fx
return fresnel * NdotL / PI;
<mask> float fresnel = <mask> (1.0 + (diffuseFresnel90 - 1.0) * diffuseFresnelNL) * <mask> (1.0 + (diffuseFresnel90 - 1.0) * diffuseFresnelNV); <mask> <mask> return fresnel * NdotL / kPi; <mask> } <mask> <mask> float adjustRoughnessFromLightProperties(float roughness, float lightRadius, float lightDistance) <mask> { <mask> #ifdef USEPHYSICALLIGHTFALLOFF </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove return a2 / (kPi * d * d); </s> add return a2 / (PI * d * d); </s> remove vec3 FresnelSchlickEnvironmentGGX(float VdotN, vec3 reflectance0, vec3 reflectance90, float smoothness) </s> add vec3 fresnelSchlickEnvironmentGGX(float VdotN, vec3 reflectance0, vec3 reflectance90, float smoothness) </s> remove float a2 = Square(alphaG); </s> add float a2 = square(alphaG); </s> remove #ifdef VERTEXALPHA alpha *= vColor.a; #endif #ifdef OPACITYFRESNEL float opacityFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, opacityParts.z, opacityParts.w); alpha += opacityParts.x * (1.0 - opacityFresnelTerm) + opacityFresnelTerm * opacityParts.y; #endif // Refraction vec3 surfaceRefractionColor = vec3(0., 0., 0.); // Go mat -> blurry reflexion according to microSurface </s> add // _____________________________ Compute LODs Fetch ____________________________________ </s> remove vec3 toLinearSpace(vec3 color) { return vec3(pow(color.r, 2.2), pow(color.g, 2.2), pow(color.b, 2.2)); } vec3 toGammaSpace(vec3 color) { return vec3(pow(color.r, 1.0 / 2.2), pow(color.g, 1.0 / 2.2), pow(color.b, 1.0 / 2.2)); } #ifdef CAMERATONEMAP vec3 toneMaps(vec3 color) { color = max(color, 0.0); // TONE MAPPING / EXPOSURE color.rgb = color.rgb * vCameraInfos.x; float tuning = 1.5; // TODO: sync up so e.g. 18% greys are matched to exposure appropriately // PI Test // tuning *= kPi; vec3 tonemapped = 1.0 - exp2(-color.rgb * tuning); // simple local photographic tonemapper color.rgb = mix(color.rgb, tonemapped, 1.0); return color; } #endif #ifdef CAMERACONTRAST vec4 contrasts(vec4 color) { color = clamp(color, 0.0, 1.0); vec3 resultHighContrast = color.rgb * color.rgb * (3.0 - 2.0 * color.rgb); float contrast = vCameraInfos.y; if (contrast < 1.0) { // Decrease contrast: interpolate towards zero-contrast image (flat grey) color.rgb = mix(vec3(0.5, 0.5, 0.5), color.rgb, contrast); } else { // Increase contrast: apply simple shoulder-toe high contrast curve color.rgb = mix(color.rgb, resultHighContrast, contrast - 1.0); } return color; } #endif </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/ShadersInclude/pbrFunctions.fx
<mask> <mask> return microSurface; <mask> } <mask> <mask> vec3 toLinearSpace(vec3 color) <mask> { <mask> return vec3(pow(color.r, 2.2), pow(color.g, 2.2), pow(color.b, 2.2)); <mask> } <mask> <mask> vec3 toGammaSpace(vec3 color) <mask> { <mask> return vec3(pow(color.r, 1.0 / 2.2), pow(color.g, 1.0 / 2.2), pow(color.b, 1.0 / 2.2)); <mask> } <mask> <mask> #ifdef CAMERATONEMAP <mask> vec3 toneMaps(vec3 color) <mask> { <mask> color = max(color, 0.0); <mask> <mask> // TONE MAPPING / EXPOSURE <mask> color.rgb = color.rgb * vCameraInfos.x; <mask> <mask> float tuning = 1.5; // TODO: sync up so e.g. 18% greys are matched to exposure appropriately <mask> // PI Test <mask> // tuning *= kPi; <mask> vec3 tonemapped = 1.0 - exp2(-color.rgb * tuning); // simple local photographic tonemapper <mask> color.rgb = mix(color.rgb, tonemapped, 1.0); <mask> return color; <mask> } <mask> #endif <mask> <mask> #ifdef CAMERACONTRAST <mask> vec4 contrasts(vec4 color) <mask> { <mask> color = clamp(color, 0.0, 1.0); <mask> <mask> vec3 resultHighContrast = color.rgb * color.rgb * (3.0 - 2.0 * color.rgb); <mask> float contrast = vCameraInfos.y; <mask> if (contrast < 1.0) <mask> { <mask> // Decrease contrast: interpolate towards zero-contrast image (flat grey) <mask> color.rgb = mix(vec3(0.5, 0.5, 0.5), color.rgb, contrast); <mask> } <mask> else <mask> { <mask> // Increase contrast: apply simple shoulder-toe high contrast curve <mask> color.rgb = mix(color.rgb, resultHighContrast, contrast - 1.0); <mask> } <mask> <mask> return color; <mask> } <mask> #endif </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef TONEMAPPING float tonemappingCalibration = 1.590579; result.rgb = 1.0 - exp2(-tonemappingCalibration * result.rgb); #endif // Going back to gamma space result.rgb = pow(result.rgb, vec3(GammaEncodePowerApprox)); result.rgb = clamp(result.rgb, 0.0, 1.0); // Contrast vec3 resultHighContrast = applyEaseInOut(result.rgb); if (contrast < 1.0) { result.rgb = mix(vec3(0.5, 0.5, 0.5), result.rgb, contrast); } else { result.rgb = mix(result.rgb, resultHighContrast, contrast - 1.0); } // Apply Color Transform #ifdef COLORGRADING vec3 colorTransformInput = result.rgb * colorTransformSettings.xxx + colorTransformSettings.yyy; vec3 colorTransformOutput = sampleTexture3D(txColorTransform, colorTransformInput).rgb; result.rgb = mix(result.rgb, colorTransformOutput, colorTransformSettings.www); #endif #ifdef COLORCURVES // Apply Color Curves float luma = dot(result.rgb, RGBLuminanceCoefficients); vec2 curveMix = clamp(vec2(luma * 3.0 - 1.5, luma * -3.0 + 1.5), vec2(0.0), vec2(1.0)); vec4 colorCurve = vCameraColorCurveNeutral + curveMix.x * vCameraColorCurvePositive - curveMix.y * vCameraColorCurveNegative; result.rgb *= colorCurve.rgb; result.rgb = mix(vec3(luma), result.rgb, colorCurve.a); #endif return result; } void main(void) { vec4 result = texture2D(textureSampler, vUV); vec2 viewportXY = vUV * 2.0 - 1.0; result = applyImageProcessing(result, viewportXY); </s> add </s> remove /** * Polyfill for SAMPLE_TEXTURE_3D, which is unsupported in WebGL. * colorTransformSettings.y = textureOffset (0.5 / textureSize). * colorTransformSettings.z = textureSize. */ vec3 sampleTexture3D(sampler2D colorTransform, vec3 color) </s> add void main(void) </s> remove #ifdef CAMERACOLORCURVES color.rgb = applyColorCurves(color.rgb); #endif </s> add </s> remove float sliceSize = 2.0 * colorTransformSettings.y; // Size of 1 slice relative to the texture, for example 1/8 float sliceContinuous = (color.y - colorTransformSettings.y) * colorTransformSettings.z; float sliceInteger = floor(sliceContinuous); // Note: this is mathematically equivalent to fract(sliceContinuous); but we use explicit subtract // rather than separate fract() for correct results near slice boundaries (matching sliceInteger choice) float sliceFraction = sliceContinuous - sliceInteger; vec2 sliceUV = color.xz; sliceUV.x *= sliceSize; sliceUV.x += sliceInteger * sliceSize; vec4 slice0Color = texture2D(colorTransform, sliceUV); sliceUV.x += sliceSize; vec4 slice1Color = texture2D(colorTransform, sliceUV); vec3 result = mix(slice0Color.rgb, slice1Color.rgb, sliceFraction); color.rgb = result.bgr; return color; } vec4 applyImageProcessing(vec4 result, vec2 viewportXY){ #ifndef FROMLINEARSPACE // Need to move to linear space for subsequent operations result.rgb = pow(result.rgb, vec3(LinearEncodePowerApprox)); #endif result.rgb *= cameraExposureLinear; #ifdef VIGNETTE //vignette vec3 vignetteXY1 = vec3(viewportXY * vignetteSettings1.xy + vignetteSettings1.zw, 1.0); float vignetteTerm = dot(vignetteXY1, vignetteXY1); float vignette = pow(vignetteTerm, vignetteSettings2.w); // Interpolate between the artist 'color' and white based on the physical transmission value 'vignette'. vec3 vignetteColor = vignetteSettings2.rgb; </s> add vec4 result = texture2D(textureSampler, vUV); </s> remove uniform float contrast; uniform vec4 vignetteSettings1; uniform vec4 vignetteSettings2; uniform float cameraExposureLinear; uniform vec4 vCameraColorCurveNegative; uniform vec4 vCameraColorCurveNeutral; uniform vec4 vCameraColorCurvePositive; uniform sampler2D txColorTransform; uniform vec4 colorTransformSettings; </s> add #include<helperFunctions>
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "re...
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/ShadersInclude/pbrFunctions.fx
<mask> <mask> uniform vec2 vMicrosurfaceTextureLods; <mask> uniform vec4 vReflectivityColor; <mask> uniform vec3 vEmissiveColor; <mask> uniform vec4 opacityParts; <mask> uniform vec4 emissiveLeftColor; <mask> uniform vec4 emissiveRightColor; <mask> <mask> uniform float pointSize; <mask> }; <mask> <mask> uniform Scene { </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef OPACITYFRESNEL uniform vec4 opacityParts; #endif #ifdef EMISSIVEFRESNEL uniform vec4 emissiveLeftColor; uniform vec4 emissiveRightColor; #endif </s> add </s> remove uniform float contrast; uniform vec4 vignetteSettings1; uniform vec4 vignetteSettings2; uniform float cameraExposureLinear; uniform vec4 vCameraColorCurveNegative; uniform vec4 vCameraColorCurveNeutral; uniform vec4 vCameraColorCurvePositive; uniform sampler2D txColorTransform; uniform vec4 colorTransformSettings; </s> add #include<helperFunctions> </s> remove vec3 applyEaseInOut(vec3 x){ return x * x * (3.0 - 2.0 * x); } </s> add #include<imageProcessingFunctions> </s> remove #ifdef REFLECTIONMAP_3D uniform samplerCube reflectionCubeSampler; #else uniform sampler2D reflection2DSampler; #endif </s> add #ifdef REFLECTIONMAP_SKYBOX varying vec3 vPositionUVW; #else #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) varying vec3 vDirectionW; #endif
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/ShadersInclude/pbrUboDeclaration.fx
#include<imageProcessingDeclaration>
<mask> #include<reflectionFunction> <mask> <mask> #endif <mask> <mask> #ifdef CAMERACOLORGRADING <mask> #include<colorGradingDefinition> <mask> #include<colorGrading> <mask> #endif <mask> <mask> #ifdef CAMERACOLORCURVES <mask> #include<colorCurvesDefinition> <mask> #include<colorCurves> <mask> #endif </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef CAMERACOLORGRADING #include<colorGradingDefinition> #endif </s> add #include<imageProcessingDeclaration> </s> remove #ifdef CAMERACOLORCURVES #include<colorCurvesDefinition> #include<colorCurves> #endif </s> add #include<helperFunctions> #include<imageProcessingFunctions> </s> remove #include<colorGrading> </s> add #include<legacyColorGrading> </s> remove #include<colorGradingDefinition> </s> add #include<legacyColorGradingDefinition> </s> remove #ifdef CAMERACOLORGRADING #include<colorGrading> #endif #ifdef CAMERACOLORCURVES #include<colorCurves> #endif </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/default.fragment.fx
#include<helperFunctions> #include<imageProcessingFunctions>
<mask> #include<colorGradingDefinition> <mask> #include<colorGrading> <mask> #endif <mask> <mask> #ifdef CAMERACOLORCURVES <mask> #include<colorCurvesDefinition> <mask> #include<colorCurves> <mask> #endif <mask> <mask> #include<bumpFragmentFunctions> <mask> #include<clipPlaneFragmentDeclaration> <mask> #include<logDepthDeclaration> <mask> #include<fogFragmentDeclaration> </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef CAMERACOLORGRADING #include<colorGradingDefinition> #include<colorGrading> #endif </s> add #include<imageProcessingDeclaration> </s> remove #ifdef CAMERACOLORGRADING #include<colorGrading> #endif #ifdef CAMERACOLORCURVES #include<colorCurves> #endif </s> add </s> remove #include<colorCurves> </s> add #include<legacyColorCurves> </s> remove #include<colorGrading> </s> add #include<legacyColorGrading> </s> remove #include<colorGradingDefinition> </s> add #include<legacyColorGradingDefinition>
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/default.fragment.fx
// Apply image processing if relevant. As this applies in linear space, // We first move from gamma to linear. #ifdef IMAGEPROCESSING color.rgb = toLinearSpace(result.rgb); color.rgb = applyImageProcessing(color);
<mask> <mask> #include<logDepthFragment> <mask> #include<fogFragment> <mask> <mask> #ifdef CAMERACOLORGRADING <mask> color = colorGrades(color); <mask> #endif <mask> <mask> #ifdef CAMERACOLORCURVES <mask> color.rgb = applyColorCurves(color.rgb); <mask> #endif </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef CAMERACOLORCURVES color.rgb = applyColorCurves(color.rgb); #endif </s> add </s> remove #include<colorGradingDefinition> </s> add #include<legacyColorGradingDefinition> </s> remove #ifdef CAMERACOLORGRADING #include<colorGradingDefinition> #endif </s> add #include<imageProcessingDeclaration> </s> remove #ifdef CAMERACOLORGRADING #include<colorGradingDefinition> #include<colorGrading> #endif </s> add #include<imageProcessingDeclaration> </s> remove #include<colorGrading> </s> add #include<legacyColorGrading>
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/default.fragment.fx
<mask> #ifdef CAMERACOLORGRADING <mask> color = colorGrades(color); <mask> #endif <mask> <mask> #ifdef CAMERACOLORCURVES <mask> color.rgb = applyColorCurves(color.rgb); <mask> #endif <mask> gl_FragColor = color; <mask> } </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef CAMERACOLORGRADING color = colorGrades(color); </s> add // Apply image processing if relevant. As this applies in linear space, // We first move from gamma to linear. #ifdef IMAGEPROCESSING color.rgb = toLinearSpace(result.rgb); color.rgb = applyImageProcessing(color); </s> remove vec3 toLinearSpace(vec3 color) { return vec3(pow(color.r, 2.2), pow(color.g, 2.2), pow(color.b, 2.2)); } vec3 toGammaSpace(vec3 color) { return vec3(pow(color.r, 1.0 / 2.2), pow(color.g, 1.0 / 2.2), pow(color.b, 1.0 / 2.2)); } #ifdef CAMERATONEMAP vec3 toneMaps(vec3 color) { color = max(color, 0.0); // TONE MAPPING / EXPOSURE color.rgb = color.rgb * vCameraInfos.x; float tuning = 1.5; // TODO: sync up so e.g. 18% greys are matched to exposure appropriately // PI Test // tuning *= kPi; vec3 tonemapped = 1.0 - exp2(-color.rgb * tuning); // simple local photographic tonemapper color.rgb = mix(color.rgb, tonemapped, 1.0); return color; } #endif #ifdef CAMERACONTRAST vec4 contrasts(vec4 color) { color = clamp(color, 0.0, 1.0); vec3 resultHighContrast = color.rgb * color.rgb * (3.0 - 2.0 * color.rgb); float contrast = vCameraInfos.y; if (contrast < 1.0) { // Decrease contrast: interpolate towards zero-contrast image (flat grey) color.rgb = mix(vec3(0.5, 0.5, 0.5), color.rgb, contrast); } else { // Increase contrast: apply simple shoulder-toe high contrast curve color.rgb = mix(color.rgb, resultHighContrast, contrast - 1.0); } return color; } #endif </s> add </s> remove #include<colorGradingDefinition> </s> add #include<legacyColorGradingDefinition> </s> remove #ifdef CAMERACOLORGRADING #include<colorGradingDefinition> #endif </s> add #include<imageProcessingDeclaration> </s> remove #ifdef CAMERACOLORGRADING #include<colorGradingDefinition> #include<colorGrading> #endif </s> add #include<imageProcessingDeclaration>
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/default.fragment.fx
#include<helperFunctions>
<mask> const float GammaEncodePowerApprox = 1.0 / 2.2; <mask> const float LinearEncodePowerApprox = 2.2; <mask> const vec3 RGBLuminanceCoefficients = vec3(0.2126, 0.7152, 0.0722); <mask> <mask> uniform float contrast; <mask> uniform vec4 vignetteSettings1; <mask> uniform vec4 vignetteSettings2; <mask> uniform float cameraExposureLinear; <mask> uniform vec4 vCameraColorCurveNegative; <mask> uniform vec4 vCameraColorCurveNeutral; <mask> uniform vec4 vCameraColorCurvePositive; <mask> uniform sampler2D txColorTransform; <mask> uniform vec4 colorTransformSettings; <mask> <mask> vec3 applyEaseInOut(vec3 x){ <mask> return x * x * (3.0 - 2.0 * x); <mask> } <mask> </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove vec3 applyEaseInOut(vec3 x){ return x * x * (3.0 - 2.0 * x); } </s> add #include<imageProcessingFunctions> </s> remove uniform vec4 opacityParts; uniform vec4 emissiveLeftColor; uniform vec4 emissiveRightColor; </s> add </s> remove #ifdef OPACITYFRESNEL uniform vec4 opacityParts; #endif #ifdef EMISSIVEFRESNEL uniform vec4 emissiveLeftColor; uniform vec4 emissiveRightColor; #endif </s> add </s> remove /** * Polyfill for SAMPLE_TEXTURE_3D, which is unsupported in WebGL. * colorTransformSettings.y = textureOffset (0.5 / textureSize). * colorTransformSettings.z = textureSize. */ vec3 sampleTexture3D(sampler2D colorTransform, vec3 color) </s> add void main(void)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/imageProcessing.fragment.fx
#include<imageProcessingFunctions>
<mask> uniform vec4 vCameraColorCurvePositive; <mask> uniform sampler2D txColorTransform; <mask> uniform vec4 colorTransformSettings; <mask> <mask> vec3 applyEaseInOut(vec3 x){ <mask> return x * x * (3.0 - 2.0 * x); <mask> } <mask> <mask> /** <mask> * Polyfill for SAMPLE_TEXTURE_3D, which is unsupported in WebGL. <mask> * colorTransformSettings.y = textureOffset (0.5 / textureSize). <mask> * colorTransformSettings.z = textureSize. </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove /** * Polyfill for SAMPLE_TEXTURE_3D, which is unsupported in WebGL. * colorTransformSettings.y = textureOffset (0.5 / textureSize). * colorTransformSettings.z = textureSize. */ vec3 sampleTexture3D(sampler2D colorTransform, vec3 color) </s> add void main(void) </s> remove uniform float contrast; uniform vec4 vignetteSettings1; uniform vec4 vignetteSettings2; uniform float cameraExposureLinear; uniform vec4 vCameraColorCurveNegative; uniform vec4 vCameraColorCurveNeutral; uniform vec4 vCameraColorCurvePositive; uniform sampler2D txColorTransform; uniform vec4 colorTransformSettings; </s> add #include<helperFunctions> </s> remove uniform vec4 opacityParts; uniform vec4 emissiveLeftColor; uniform vec4 emissiveRightColor; </s> add </s> remove float sliceSize = 2.0 * colorTransformSettings.y; // Size of 1 slice relative to the texture, for example 1/8 float sliceContinuous = (color.y - colorTransformSettings.y) * colorTransformSettings.z; float sliceInteger = floor(sliceContinuous); // Note: this is mathematically equivalent to fract(sliceContinuous); but we use explicit subtract // rather than separate fract() for correct results near slice boundaries (matching sliceInteger choice) float sliceFraction = sliceContinuous - sliceInteger; vec2 sliceUV = color.xz; sliceUV.x *= sliceSize; sliceUV.x += sliceInteger * sliceSize; vec4 slice0Color = texture2D(colorTransform, sliceUV); sliceUV.x += sliceSize; vec4 slice1Color = texture2D(colorTransform, sliceUV); vec3 result = mix(slice0Color.rgb, slice1Color.rgb, sliceFraction); color.rgb = result.bgr; return color; } vec4 applyImageProcessing(vec4 result, vec2 viewportXY){ #ifndef FROMLINEARSPACE // Need to move to linear space for subsequent operations result.rgb = pow(result.rgb, vec3(LinearEncodePowerApprox)); #endif result.rgb *= cameraExposureLinear; #ifdef VIGNETTE //vignette vec3 vignetteXY1 = vec3(viewportXY * vignetteSettings1.xy + vignetteSettings1.zw, 1.0); float vignetteTerm = dot(vignetteXY1, vignetteXY1); float vignette = pow(vignetteTerm, vignetteSettings2.w); // Interpolate between the artist 'color' and white based on the physical transmission value 'vignette'. vec3 vignetteColor = vignetteSettings2.rgb; </s> add vec4 result = texture2D(textureSampler, vUV); </s> remove #ifdef OPACITYFRESNEL uniform vec4 opacityParts; #endif #ifdef EMISSIVEFRESNEL uniform vec4 emissiveLeftColor; uniform vec4 emissiveRightColor; #endif </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/imageProcessing.fragment.fx
void main(void)
<mask> vec3 applyEaseInOut(vec3 x){ <mask> return x * x * (3.0 - 2.0 * x); <mask> } <mask> <mask> /** <mask> * Polyfill for SAMPLE_TEXTURE_3D, which is unsupported in WebGL. <mask> * colorTransformSettings.y = textureOffset (0.5 / textureSize). <mask> * colorTransformSettings.z = textureSize. <mask> */ <mask> vec3 sampleTexture3D(sampler2D colorTransform, vec3 color) <mask> { <mask> float sliceSize = 2.0 * colorTransformSettings.y; // Size of 1 slice relative to the texture, for example 1/8 <mask> <mask> float sliceContinuous = (color.y - colorTransformSettings.y) * colorTransformSettings.z; <mask> float sliceInteger = floor(sliceContinuous); </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove vec3 applyEaseInOut(vec3 x){ return x * x * (3.0 - 2.0 * x); } </s> add #include<imageProcessingFunctions> </s> remove float sliceSize = 2.0 * colorTransformSettings.y; // Size of 1 slice relative to the texture, for example 1/8 float sliceContinuous = (color.y - colorTransformSettings.y) * colorTransformSettings.z; float sliceInteger = floor(sliceContinuous); // Note: this is mathematically equivalent to fract(sliceContinuous); but we use explicit subtract // rather than separate fract() for correct results near slice boundaries (matching sliceInteger choice) float sliceFraction = sliceContinuous - sliceInteger; vec2 sliceUV = color.xz; sliceUV.x *= sliceSize; sliceUV.x += sliceInteger * sliceSize; vec4 slice0Color = texture2D(colorTransform, sliceUV); sliceUV.x += sliceSize; vec4 slice1Color = texture2D(colorTransform, sliceUV); vec3 result = mix(slice0Color.rgb, slice1Color.rgb, sliceFraction); color.rgb = result.bgr; return color; } vec4 applyImageProcessing(vec4 result, vec2 viewportXY){ #ifndef FROMLINEARSPACE // Need to move to linear space for subsequent operations result.rgb = pow(result.rgb, vec3(LinearEncodePowerApprox)); #endif result.rgb *= cameraExposureLinear; #ifdef VIGNETTE //vignette vec3 vignetteXY1 = vec3(viewportXY * vignetteSettings1.xy + vignetteSettings1.zw, 1.0); float vignetteTerm = dot(vignetteXY1, vignetteXY1); float vignette = pow(vignetteTerm, vignetteSettings2.w); // Interpolate between the artist 'color' and white based on the physical transmission value 'vignette'. vec3 vignetteColor = vignetteSettings2.rgb; </s> add vec4 result = texture2D(textureSampler, vUV); </s> remove uniform float contrast; uniform vec4 vignetteSettings1; uniform vec4 vignetteSettings2; uniform float cameraExposureLinear; uniform vec4 vCameraColorCurveNegative; uniform vec4 vCameraColorCurveNeutral; uniform vec4 vCameraColorCurvePositive; uniform sampler2D txColorTransform; uniform vec4 colorTransformSettings; </s> add #include<helperFunctions> </s> remove /** * Binds the color grading to the shader. * @param colorGrading The texture to bind * @param effect The effect to bind to */ public static Bind(colorGrading: BaseTexture, effect: Effect) : void { effect.setTexture("cameraColorGrading2DSampler", colorGrading); let x = colorGrading.level; // Texture Level let y = colorGrading.getSize().height; // Texture Size example with 8 let z = y - 1.0; // SizeMinusOne 8 - 1 let w = 1 / y; // Space of 1 slice 1 / 8 effect.setFloat4("vCameraColorGradingInfos", x, y, z, w); let slicePixelSizeU = w / y; // Space of 1 pixel in U direction, e.g. 1/64 let slicePixelSizeV = w; // Space of 1 pixel in V direction, e.g. 1/8 // Space of 1 pixel in V direction, e.g. 1/8 let x2 = z * slicePixelSizeU; // Extent of lookup range in U for a single slice so that range corresponds to (size-1) texels, for example 7/64 let y2 = z / y; // Extent of lookup range in V for a single slice so that range corresponds to (size-1) texels, for example 7/8 let z2 = 0.5 * slicePixelSizeU; // Offset of lookup range in U to align sample position with texel centre, for example 0.5/64 let w2 = 0.5 * slicePixelSizeV; // Offset of lookup range in V to align sample position with texel centre, for example 0.5/8 effect.setFloat4("vCameraColorGradingScaleOffset", x2, y2, z2, w2); } /** * Prepare the list of uniforms associated with the ColorGrading effects. * @param uniformsList The list of uniforms used in the effect * @param samplersList The list of samplers used in the effect */ public static PrepareUniformsAndSamplers(uniformsList: string[], samplersList: string[]): void { uniformsList.push( "vCameraColorGradingInfos", "vCameraColorGradingScaleOffset" ); samplersList.push( "cameraColorGrading2DSampler" ); } </s> add </s> remove vec3 toLinearSpace(vec3 color) { return vec3(pow(color.r, 2.2), pow(color.g, 2.2), pow(color.b, 2.2)); } vec3 toGammaSpace(vec3 color) { return vec3(pow(color.r, 1.0 / 2.2), pow(color.g, 1.0 / 2.2), pow(color.b, 1.0 / 2.2)); } #ifdef CAMERATONEMAP vec3 toneMaps(vec3 color) { color = max(color, 0.0); // TONE MAPPING / EXPOSURE color.rgb = color.rgb * vCameraInfos.x; float tuning = 1.5; // TODO: sync up so e.g. 18% greys are matched to exposure appropriately // PI Test // tuning *= kPi; vec3 tonemapped = 1.0 - exp2(-color.rgb * tuning); // simple local photographic tonemapper color.rgb = mix(color.rgb, tonemapped, 1.0); return color; } #endif #ifdef CAMERACONTRAST vec4 contrasts(vec4 color) { color = clamp(color, 0.0, 1.0); vec3 resultHighContrast = color.rgb * color.rgb * (3.0 - 2.0 * color.rgb); float contrast = vCameraInfos.y; if (contrast < 1.0) { // Decrease contrast: interpolate towards zero-contrast image (flat grey) color.rgb = mix(vec3(0.5, 0.5, 0.5), color.rgb, contrast); } else { // Increase contrast: apply simple shoulder-toe high contrast curve color.rgb = mix(color.rgb, resultHighContrast, contrast - 1.0); } return color; } #endif </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/imageProcessing.fragment.fx
vec4 result = texture2D(textureSampler, vUV);
<mask> * colorTransformSettings.z = textureSize. <mask> */ <mask> vec3 sampleTexture3D(sampler2D colorTransform, vec3 color) <mask> { <mask> float sliceSize = 2.0 * colorTransformSettings.y; // Size of 1 slice relative to the texture, for example 1/8 <mask> <mask> float sliceContinuous = (color.y - colorTransformSettings.y) * colorTransformSettings.z; <mask> float sliceInteger = floor(sliceContinuous); <mask> <mask> // Note: this is mathematically equivalent to fract(sliceContinuous); but we use explicit subtract <mask> // rather than separate fract() for correct results near slice boundaries (matching sliceInteger choice) <mask> float sliceFraction = sliceContinuous - sliceInteger; <mask> <mask> vec2 sliceUV = color.xz; <mask> <mask> sliceUV.x *= sliceSize; <mask> sliceUV.x += sliceInteger * sliceSize; <mask> <mask> vec4 slice0Color = texture2D(colorTransform, sliceUV); <mask> <mask> sliceUV.x += sliceSize; <mask> vec4 slice1Color = texture2D(colorTransform, sliceUV); <mask> <mask> vec3 result = mix(slice0Color.rgb, slice1Color.rgb, sliceFraction); <mask> color.rgb = result.bgr; <mask> <mask> return color; <mask> } <mask> <mask> vec4 applyImageProcessing(vec4 result, vec2 viewportXY){ <mask> <mask> #ifndef FROMLINEARSPACE <mask> // Need to move to linear space for subsequent operations <mask> result.rgb = pow(result.rgb, vec3(LinearEncodePowerApprox)); <mask> #endif <mask> <mask> result.rgb *= cameraExposureLinear; <mask> <mask> #ifdef VIGNETTE <mask> //vignette <mask> vec3 vignetteXY1 = vec3(viewportXY * vignetteSettings1.xy + vignetteSettings1.zw, 1.0); <mask> float vignetteTerm = dot(vignetteXY1, vignetteXY1); <mask> float vignette = pow(vignetteTerm, vignetteSettings2.w); <mask> <mask> // Interpolate between the artist 'color' and white based on the physical transmission value 'vignette'. <mask> vec3 vignetteColor = vignetteSettings2.rgb; <mask> <mask> #ifdef VIGNETTEBLENDMODEMULTIPLY <mask> vec3 vignetteColorMultiplier = mix(vignetteColor, vec3(1, 1, 1), vignette); <mask> result.rgb *= vignetteColorMultiplier; <mask> #endif </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef VIGNETTEBLENDMODEMULTIPLY vec3 vignetteColorMultiplier = mix(vignetteColor, vec3(1, 1, 1), vignette); result.rgb *= vignetteColorMultiplier; </s> add #ifdef IMAGEPROCESSING #ifndef FROMLINEARSPACE // Need to move to linear space for subsequent operations. result.rgb = toLinearSpace(result.rgb); </s> remove /** * Polyfill for SAMPLE_TEXTURE_3D, which is unsupported in WebGL. * colorTransformSettings.y = textureOffset (0.5 / textureSize). * colorTransformSettings.z = textureSize. */ vec3 sampleTexture3D(sampler2D colorTransform, vec3 color) </s> add void main(void) </s> remove #ifdef TONEMAPPING float tonemappingCalibration = 1.590579; result.rgb = 1.0 - exp2(-tonemappingCalibration * result.rgb); #endif // Going back to gamma space result.rgb = pow(result.rgb, vec3(GammaEncodePowerApprox)); result.rgb = clamp(result.rgb, 0.0, 1.0); // Contrast vec3 resultHighContrast = applyEaseInOut(result.rgb); if (contrast < 1.0) { result.rgb = mix(vec3(0.5, 0.5, 0.5), result.rgb, contrast); } else { result.rgb = mix(result.rgb, resultHighContrast, contrast - 1.0); } // Apply Color Transform #ifdef COLORGRADING vec3 colorTransformInput = result.rgb * colorTransformSettings.xxx + colorTransformSettings.yyy; vec3 colorTransformOutput = sampleTexture3D(txColorTransform, colorTransformInput).rgb; result.rgb = mix(result.rgb, colorTransformOutput, colorTransformSettings.www); #endif #ifdef COLORCURVES // Apply Color Curves float luma = dot(result.rgb, RGBLuminanceCoefficients); vec2 curveMix = clamp(vec2(luma * 3.0 - 1.5, luma * -3.0 + 1.5), vec2(0.0), vec2(1.0)); vec4 colorCurve = vCameraColorCurveNeutral + curveMix.x * vCameraColorCurvePositive - curveMix.y * vCameraColorCurveNegative; result.rgb *= colorCurve.rgb; result.rgb = mix(vec3(luma), result.rgb, colorCurve.a); #endif return result; } void main(void) { vec4 result = texture2D(textureSampler, vUV); vec2 viewportXY = vUV * 2.0 - 1.0; result = applyImageProcessing(result, viewportXY); </s> add </s> remove #ifdef VIGNETTEBLENDMODEOPAQUE result.rgb = mix(vignetteColor, result.rgb, vignette); </s> add result = applyImageProcessing(result); #else // In case where the input is in linear space we at least need to put it back in gamma. #ifdef FROMLINEARSPACE result = applyImageProcessing(result); </s> remove vec3 toLinearSpace(vec3 color) { return vec3(pow(color.r, 2.2), pow(color.g, 2.2), pow(color.b, 2.2)); } vec3 toGammaSpace(vec3 color) { return vec3(pow(color.r, 1.0 / 2.2), pow(color.g, 1.0 / 2.2), pow(color.b, 1.0 / 2.2)); } #ifdef CAMERATONEMAP vec3 toneMaps(vec3 color) { color = max(color, 0.0); // TONE MAPPING / EXPOSURE color.rgb = color.rgb * vCameraInfos.x; float tuning = 1.5; // TODO: sync up so e.g. 18% greys are matched to exposure appropriately // PI Test // tuning *= kPi; vec3 tonemapped = 1.0 - exp2(-color.rgb * tuning); // simple local photographic tonemapper color.rgb = mix(color.rgb, tonemapped, 1.0); return color; } #endif #ifdef CAMERACONTRAST vec4 contrasts(vec4 color) { color = clamp(color, 0.0, 1.0); vec3 resultHighContrast = color.rgb * color.rgb * (3.0 - 2.0 * color.rgb); float contrast = vCameraInfos.y; if (contrast < 1.0) { // Decrease contrast: interpolate towards zero-contrast image (flat grey) color.rgb = mix(vec3(0.5, 0.5, 0.5), color.rgb, contrast); } else { // Increase contrast: apply simple shoulder-toe high contrast curve color.rgb = mix(color.rgb, resultHighContrast, contrast - 1.0); } return color; } #endif </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "re...
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/imageProcessing.fragment.fx
#ifdef IMAGEPROCESSING #ifndef FROMLINEARSPACE // Need to move to linear space for subsequent operations. result.rgb = toLinearSpace(result.rgb);
<mask> <mask> // Interpolate between the artist 'color' and white based on the physical transmission value 'vignette'. <mask> vec3 vignetteColor = vignetteSettings2.rgb; <mask> <mask> #ifdef VIGNETTEBLENDMODEMULTIPLY <mask> vec3 vignetteColorMultiplier = mix(vignetteColor, vec3(1, 1, 1), vignette); <mask> result.rgb *= vignetteColorMultiplier; <mask> #endif <mask> <mask> #ifdef VIGNETTEBLENDMODEOPAQUE <mask> result.rgb = mix(vignetteColor, result.rgb, vignette); <mask> #endif </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef VIGNETTEBLENDMODEOPAQUE result.rgb = mix(vignetteColor, result.rgb, vignette); </s> add result = applyImageProcessing(result); #else // In case where the input is in linear space we at least need to put it back in gamma. #ifdef FROMLINEARSPACE result = applyImageProcessing(result); </s> remove float sliceSize = 2.0 * colorTransformSettings.y; // Size of 1 slice relative to the texture, for example 1/8 float sliceContinuous = (color.y - colorTransformSettings.y) * colorTransformSettings.z; float sliceInteger = floor(sliceContinuous); // Note: this is mathematically equivalent to fract(sliceContinuous); but we use explicit subtract // rather than separate fract() for correct results near slice boundaries (matching sliceInteger choice) float sliceFraction = sliceContinuous - sliceInteger; vec2 sliceUV = color.xz; sliceUV.x *= sliceSize; sliceUV.x += sliceInteger * sliceSize; vec4 slice0Color = texture2D(colorTransform, sliceUV); sliceUV.x += sliceSize; vec4 slice1Color = texture2D(colorTransform, sliceUV); vec3 result = mix(slice0Color.rgb, slice1Color.rgb, sliceFraction); color.rgb = result.bgr; return color; } vec4 applyImageProcessing(vec4 result, vec2 viewportXY){ #ifndef FROMLINEARSPACE // Need to move to linear space for subsequent operations result.rgb = pow(result.rgb, vec3(LinearEncodePowerApprox)); #endif result.rgb *= cameraExposureLinear; #ifdef VIGNETTE //vignette vec3 vignetteXY1 = vec3(viewportXY * vignetteSettings1.xy + vignetteSettings1.zw, 1.0); float vignetteTerm = dot(vignetteXY1, vignetteXY1); float vignette = pow(vignetteTerm, vignetteSettings2.w); // Interpolate between the artist 'color' and white based on the physical transmission value 'vignette'. vec3 vignetteColor = vignetteSettings2.rgb; </s> add vec4 result = texture2D(textureSampler, vUV); </s> remove #ifdef TONEMAPPING float tonemappingCalibration = 1.590579; result.rgb = 1.0 - exp2(-tonemappingCalibration * result.rgb); #endif // Going back to gamma space result.rgb = pow(result.rgb, vec3(GammaEncodePowerApprox)); result.rgb = clamp(result.rgb, 0.0, 1.0); // Contrast vec3 resultHighContrast = applyEaseInOut(result.rgb); if (contrast < 1.0) { result.rgb = mix(vec3(0.5, 0.5, 0.5), result.rgb, contrast); } else { result.rgb = mix(result.rgb, resultHighContrast, contrast - 1.0); } // Apply Color Transform #ifdef COLORGRADING vec3 colorTransformInput = result.rgb * colorTransformSettings.xxx + colorTransformSettings.yyy; vec3 colorTransformOutput = sampleTexture3D(txColorTransform, colorTransformInput).rgb; result.rgb = mix(result.rgb, colorTransformOutput, colorTransformSettings.www); #endif #ifdef COLORCURVES // Apply Color Curves float luma = dot(result.rgb, RGBLuminanceCoefficients); vec2 curveMix = clamp(vec2(luma * 3.0 - 1.5, luma * -3.0 + 1.5), vec2(0.0), vec2(1.0)); vec4 colorCurve = vCameraColorCurveNeutral + curveMix.x * vCameraColorCurvePositive - curveMix.y * vCameraColorCurveNegative; result.rgb *= colorCurve.rgb; result.rgb = mix(vec3(luma), result.rgb, colorCurve.a); #endif return result; } void main(void) { vec4 result = texture2D(textureSampler, vUV); vec2 viewportXY = vUV * 2.0 - 1.0; result = applyImageProcessing(result, viewportXY); </s> add </s> remove lightingInfo info; float shadow = 1.; // 1 - shadowLevel #include<lightFragment>[0..maxSimultaneousLights] vec3 lightDiffuseContribution = diffuseBase; #ifdef SPECULARTERM vec3 lightSpecularContribution = specularBase * vLightingIntensity.w; #endif #ifdef OPACITY vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); </s> add #ifdef ALPHATEST if (alpha <= ALPHATESTVALUE) discard; </s> remove // Ambient color </s> add // _____________________________ AO Information _______________________________
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/imageProcessing.fragment.fx
result = applyImageProcessing(result); #else // In case where the input is in linear space we at least need to put it back in gamma. #ifdef FROMLINEARSPACE result = applyImageProcessing(result);
<mask> vec3 vignetteColorMultiplier = mix(vignetteColor, vec3(1, 1, 1), vignette); <mask> result.rgb *= vignetteColorMultiplier; <mask> #endif <mask> <mask> #ifdef VIGNETTEBLENDMODEOPAQUE <mask> result.rgb = mix(vignetteColor, result.rgb, vignette); <mask> #endif <mask> <mask> #endif <mask> <mask> #ifdef TONEMAPPING </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef VIGNETTEBLENDMODEMULTIPLY vec3 vignetteColorMultiplier = mix(vignetteColor, vec3(1, 1, 1), vignette); result.rgb *= vignetteColorMultiplier; </s> add #ifdef IMAGEPROCESSING #ifndef FROMLINEARSPACE // Need to move to linear space for subsequent operations. result.rgb = toLinearSpace(result.rgb); </s> remove #ifdef TONEMAPPING float tonemappingCalibration = 1.590579; result.rgb = 1.0 - exp2(-tonemappingCalibration * result.rgb); #endif // Going back to gamma space result.rgb = pow(result.rgb, vec3(GammaEncodePowerApprox)); result.rgb = clamp(result.rgb, 0.0, 1.0); // Contrast vec3 resultHighContrast = applyEaseInOut(result.rgb); if (contrast < 1.0) { result.rgb = mix(vec3(0.5, 0.5, 0.5), result.rgb, contrast); } else { result.rgb = mix(result.rgb, resultHighContrast, contrast - 1.0); } // Apply Color Transform #ifdef COLORGRADING vec3 colorTransformInput = result.rgb * colorTransformSettings.xxx + colorTransformSettings.yyy; vec3 colorTransformOutput = sampleTexture3D(txColorTransform, colorTransformInput).rgb; result.rgb = mix(result.rgb, colorTransformOutput, colorTransformSettings.www); #endif #ifdef COLORCURVES // Apply Color Curves float luma = dot(result.rgb, RGBLuminanceCoefficients); vec2 curveMix = clamp(vec2(luma * 3.0 - 1.5, luma * -3.0 + 1.5), vec2(0.0), vec2(1.0)); vec4 colorCurve = vCameraColorCurveNeutral + curveMix.x * vCameraColorCurvePositive - curveMix.y * vCameraColorCurveNegative; result.rgb *= colorCurve.rgb; result.rgb = mix(vec3(luma), result.rgb, colorCurve.a); #endif return result; } void main(void) { vec4 result = texture2D(textureSampler, vUV); vec2 viewportXY = vUV * 2.0 - 1.0; result = applyImageProcessing(result, viewportXY); </s> add </s> remove float sliceSize = 2.0 * colorTransformSettings.y; // Size of 1 slice relative to the texture, for example 1/8 float sliceContinuous = (color.y - colorTransformSettings.y) * colorTransformSettings.z; float sliceInteger = floor(sliceContinuous); // Note: this is mathematically equivalent to fract(sliceContinuous); but we use explicit subtract // rather than separate fract() for correct results near slice boundaries (matching sliceInteger choice) float sliceFraction = sliceContinuous - sliceInteger; vec2 sliceUV = color.xz; sliceUV.x *= sliceSize; sliceUV.x += sliceInteger * sliceSize; vec4 slice0Color = texture2D(colorTransform, sliceUV); sliceUV.x += sliceSize; vec4 slice1Color = texture2D(colorTransform, sliceUV); vec3 result = mix(slice0Color.rgb, slice1Color.rgb, sliceFraction); color.rgb = result.bgr; return color; } vec4 applyImageProcessing(vec4 result, vec2 viewportXY){ #ifndef FROMLINEARSPACE // Need to move to linear space for subsequent operations result.rgb = pow(result.rgb, vec3(LinearEncodePowerApprox)); #endif result.rgb *= cameraExposureLinear; #ifdef VIGNETTE //vignette vec3 vignetteXY1 = vec3(viewportXY * vignetteSettings1.xy + vignetteSettings1.zw, 1.0); float vignetteTerm = dot(vignetteXY1, vignetteXY1); float vignette = pow(vignetteTerm, vignetteSettings2.w); // Interpolate between the artist 'color' and white based on the physical transmission value 'vignette'. vec3 vignetteColor = vignetteSettings2.rgb; </s> add vec4 result = texture2D(textureSampler, vUV); </s> remove #ifdef VERTEXALPHA alpha *= vColor.a; #endif #ifdef OPACITYFRESNEL float opacityFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, opacityParts.z, opacityParts.w); alpha += opacityParts.x * (1.0 - opacityFresnelTerm) + opacityFresnelTerm * opacityParts.y; #endif // Refraction vec3 surfaceRefractionColor = vec3(0., 0., 0.); // Go mat -> blurry reflexion according to microSurface </s> add // _____________________________ Compute LODs Fetch ____________________________________ </s> remove lightingInfo info; float shadow = 1.; // 1 - shadowLevel #include<lightFragment>[0..maxSimultaneousLights] vec3 lightDiffuseContribution = diffuseBase; #ifdef SPECULARTERM vec3 lightSpecularContribution = specularBase * vLightingIntensity.w; #endif #ifdef OPACITY vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); </s> add #ifdef ALPHATEST if (alpha <= ALPHATESTVALUE) discard;
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/imageProcessing.fragment.fx
<mask> result.rgb = mix(vignetteColor, result.rgb, vignette); <mask> #endif <mask> <mask> #endif <mask> <mask> #ifdef TONEMAPPING <mask> float tonemappingCalibration = 1.590579; <mask> result.rgb = 1.0 - exp2(-tonemappingCalibration * result.rgb); <mask> #endif <mask> <mask> // Going back to gamma space <mask> result.rgb = pow(result.rgb, vec3(GammaEncodePowerApprox)); <mask> result.rgb = clamp(result.rgb, 0.0, 1.0); <mask> <mask> // Contrast <mask> vec3 resultHighContrast = applyEaseInOut(result.rgb); <mask> <mask> if (contrast < 1.0) { <mask> result.rgb = mix(vec3(0.5, 0.5, 0.5), result.rgb, contrast); <mask> } else { <mask> result.rgb = mix(result.rgb, resultHighContrast, contrast - 1.0); <mask> } <mask> <mask> // Apply Color Transform <mask> #ifdef COLORGRADING <mask> vec3 colorTransformInput = result.rgb * colorTransformSettings.xxx + colorTransformSettings.yyy; <mask> vec3 colorTransformOutput = sampleTexture3D(txColorTransform, colorTransformInput).rgb; <mask> <mask> result.rgb = mix(result.rgb, colorTransformOutput, colorTransformSettings.www); <mask> #endif <mask> <mask> #ifdef COLORCURVES <mask> // Apply Color Curves <mask> float luma = dot(result.rgb, RGBLuminanceCoefficients); <mask> vec2 curveMix = clamp(vec2(luma * 3.0 - 1.5, luma * -3.0 + 1.5), vec2(0.0), vec2(1.0)); <mask> vec4 colorCurve = vCameraColorCurveNeutral + curveMix.x * vCameraColorCurvePositive - curveMix.y * vCameraColorCurveNegative; <mask> <mask> result.rgb *= colorCurve.rgb; <mask> result.rgb = mix(vec3(luma), result.rgb, colorCurve.a); <mask> #endif <mask> <mask> return result; <mask> } <mask> <mask> void main(void) <mask> { <mask> vec4 result = texture2D(textureSampler, vUV); <mask> <mask> vec2 viewportXY = vUV * 2.0 - 1.0; <mask> result = applyImageProcessing(result, viewportXY); <mask> <mask> gl_FragColor = result; <mask> } </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef VIGNETTEBLENDMODEOPAQUE result.rgb = mix(vignetteColor, result.rgb, vignette); </s> add result = applyImageProcessing(result); #else // In case where the input is in linear space we at least need to put it back in gamma. #ifdef FROMLINEARSPACE result = applyImageProcessing(result); </s> remove float sliceSize = 2.0 * colorTransformSettings.y; // Size of 1 slice relative to the texture, for example 1/8 float sliceContinuous = (color.y - colorTransformSettings.y) * colorTransformSettings.z; float sliceInteger = floor(sliceContinuous); // Note: this is mathematically equivalent to fract(sliceContinuous); but we use explicit subtract // rather than separate fract() for correct results near slice boundaries (matching sliceInteger choice) float sliceFraction = sliceContinuous - sliceInteger; vec2 sliceUV = color.xz; sliceUV.x *= sliceSize; sliceUV.x += sliceInteger * sliceSize; vec4 slice0Color = texture2D(colorTransform, sliceUV); sliceUV.x += sliceSize; vec4 slice1Color = texture2D(colorTransform, sliceUV); vec3 result = mix(slice0Color.rgb, slice1Color.rgb, sliceFraction); color.rgb = result.bgr; return color; } vec4 applyImageProcessing(vec4 result, vec2 viewportXY){ #ifndef FROMLINEARSPACE // Need to move to linear space for subsequent operations result.rgb = pow(result.rgb, vec3(LinearEncodePowerApprox)); #endif result.rgb *= cameraExposureLinear; #ifdef VIGNETTE //vignette vec3 vignetteXY1 = vec3(viewportXY * vignetteSettings1.xy + vignetteSettings1.zw, 1.0); float vignetteTerm = dot(vignetteXY1, vignetteXY1); float vignette = pow(vignetteTerm, vignetteSettings2.w); // Interpolate between the artist 'color' and white based on the physical transmission value 'vignette'. vec3 vignetteColor = vignetteSettings2.rgb; </s> add vec4 result = texture2D(textureSampler, vUV); </s> remove #ifdef VIGNETTEBLENDMODEMULTIPLY vec3 vignetteColorMultiplier = mix(vignetteColor, vec3(1, 1, 1), vignette); result.rgb *= vignetteColorMultiplier; </s> add #ifdef IMAGEPROCESSING #ifndef FROMLINEARSPACE // Need to move to linear space for subsequent operations. result.rgb = toLinearSpace(result.rgb); </s> remove vec3 toLinearSpace(vec3 color) { return vec3(pow(color.r, 2.2), pow(color.g, 2.2), pow(color.b, 2.2)); } vec3 toGammaSpace(vec3 color) { return vec3(pow(color.r, 1.0 / 2.2), pow(color.g, 1.0 / 2.2), pow(color.b, 1.0 / 2.2)); } #ifdef CAMERATONEMAP vec3 toneMaps(vec3 color) { color = max(color, 0.0); // TONE MAPPING / EXPOSURE color.rgb = color.rgb * vCameraInfos.x; float tuning = 1.5; // TODO: sync up so e.g. 18% greys are matched to exposure appropriately // PI Test // tuning *= kPi; vec3 tonemapped = 1.0 - exp2(-color.rgb * tuning); // simple local photographic tonemapper color.rgb = mix(color.rgb, tonemapped, 1.0); return color; } #endif #ifdef CAMERACONTRAST vec4 contrasts(vec4 color) { color = clamp(color, 0.0, 1.0); vec3 resultHighContrast = color.rgb * color.rgb * (3.0 - 2.0 * color.rgb); float contrast = vCameraInfos.y; if (contrast < 1.0) { // Decrease contrast: interpolate towards zero-contrast image (flat grey) color.rgb = mix(vec3(0.5, 0.5, 0.5), color.rgb, contrast); } else { // Increase contrast: apply simple shoulder-toe high contrast curve color.rgb = mix(color.rgb, resultHighContrast, contrast - 1.0); } return color; } #endif </s> add </s> remove lightingInfo info; float shadow = 1.; // 1 - shadowLevel #include<lightFragment>[0..maxSimultaneousLights] vec3 lightDiffuseContribution = diffuseBase; #ifdef SPECULARTERM vec3 lightSpecularContribution = specularBase * vLightingIntensity.w; #endif #ifdef OPACITY vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); </s> add #ifdef ALPHATEST if (alpha <= ALPHATESTVALUE) discard;
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "re...
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/imageProcessing.fragment.fx
<mask> varying vec2 vMicroSurfaceSamplerUV; <mask> uniform sampler2D microSurfaceSampler; <mask> #endif <mask> <mask> // Fresnel <mask> #include<fresnelFunction> <mask> <mask> // Refraction <mask> #ifdef REFRACTION <mask> <mask> <mask> #ifdef REFRACTIONMAP_3D </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef REFLECTIONMAP_3D uniform samplerCube reflectionCubeSampler; #else uniform sampler2D reflection2DSampler; #endif </s> add #ifdef REFLECTIONMAP_SKYBOX varying vec3 vPositionUVW; #else #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) varying vec3 vDirectionW; #endif </s> remove #ifdef OPACITYFRESNEL uniform vec4 opacityParts; #endif #ifdef EMISSIVEFRESNEL uniform vec4 emissiveLeftColor; uniform vec4 emissiveRightColor; #endif </s> add </s> remove #ifdef REFLECTIONMAP_SKYBOX varying vec3 vPositionUVW; #else #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) varying vec3 vDirectionW; #endif </s> add #endif
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
#ifdef REFLECTIONMAP_3D uniform samplerCube reflectionCubeSampler; #else uniform sampler2D reflection2DSampler; #endif
<mask> // Reflection <mask> #ifdef REFLECTION <mask> <mask> #ifdef REFLECTIONMAP_SKYBOX <mask> varying vec3 vPositionUVW; <mask> #else <mask> #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) <mask> varying vec3 vDirectionW; </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef REFLECTIONMAP_3D uniform samplerCube reflectionCubeSampler; #else uniform sampler2D reflection2DSampler; #endif </s> add #ifdef REFLECTIONMAP_SKYBOX varying vec3 vPositionUVW; #else #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) varying vec3 vDirectionW; #endif </s> remove #ifdef REFLECTIONMAP_SKYBOX varying vec3 vPositionUVW; #else #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) varying vec3 vDirectionW; #endif </s> add #endif </s> remove // Reflection </s> add // _____________________________ Reflection Info _______________________________________ #ifdef REFLECTION </s> remove #ifdef REFLECTION </s> add </s> remove #ifdef OPACITYFRESNEL uniform vec4 opacityParts; #endif #ifdef EMISSIVEFRESNEL uniform vec4 emissiveLeftColor; uniform vec4 emissiveRightColor; #endif </s> add
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
#ifdef REFLECTIONMAP_SKYBOX varying vec3 vPositionUVW; #else #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) varying vec3 vDirectionW; #endif
<mask> <mask> // Reflection <mask> #ifdef REFLECTION <mask> <mask> #ifdef REFLECTIONMAP_3D <mask> uniform samplerCube reflectionCubeSampler; <mask> #else <mask> uniform sampler2D reflection2DSampler; <mask> #endif <mask> <mask> #ifdef REFLECTIONMAP_SKYBOX <mask> varying vec3 vPositionUVW; <mask> #else <mask> #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef REFLECTIONMAP_SKYBOX varying vec3 vPositionUVW; #else #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) varying vec3 vDirectionW; #endif </s> add #endif </s> remove #ifdef OPACITYFRESNEL uniform vec4 opacityParts; #endif #ifdef EMISSIVEFRESNEL uniform vec4 emissiveLeftColor; uniform vec4 emissiveRightColor; #endif </s> add </s> remove // Fresnel #include<fresnelFunction> </s> add </s> remove // Reflection </s> add // _____________________________ Reflection Info _______________________________________ #ifdef REFLECTION
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
#endif
<mask> #else <mask> uniform sampler2D reflection2DSampler; <mask> #endif <mask> <mask> #ifdef REFLECTIONMAP_SKYBOX <mask> varying vec3 vPositionUVW; <mask> #else <mask> #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) <mask> varying vec3 vDirectionW; <mask> #endif <mask> <mask> #endif <mask> <mask> #include<reflectionFunction> <mask> </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef REFLECTIONMAP_3D uniform samplerCube reflectionCubeSampler; #else uniform sampler2D reflection2DSampler; #endif </s> add #ifdef REFLECTIONMAP_SKYBOX varying vec3 vPositionUVW; #else #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) varying vec3 vDirectionW; #endif </s> remove // Fresnel #include<fresnelFunction> </s> add </s> remove #ifdef OPACITYFRESNEL uniform vec4 opacityParts; #endif #ifdef EMISSIVEFRESNEL uniform vec4 emissiveLeftColor; uniform vec4 emissiveRightColor; #endif </s> add </s> remove // Bump </s> add
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
#include<reflectionFunction>
<mask> <mask> #endif <mask> <mask> #endif <mask> <mask> // Forces linear space for image processing <mask> #ifndef FROMLINEARSPACE <mask> #define FROMLINEARSPACE; </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #include<reflectionFunction> </s> add // Forces linear space for image processing #ifndef FROMLINEARSPACE #define FROMLINEARSPACE; </s> remove #ifdef VIGNETTEBLENDMODEMULTIPLY vec3 vignetteColorMultiplier = mix(vignetteColor, vec3(1, 1, 1), vignette); result.rgb *= vignetteColorMultiplier; </s> add #ifdef IMAGEPROCESSING #ifndef FROMLINEARSPACE // Need to move to linear space for subsequent operations. result.rgb = toLinearSpace(result.rgb); </s> remove #ifdef VIGNETTEBLENDMODEOPAQUE result.rgb = mix(vignetteColor, result.rgb, vignette); </s> add result = applyImageProcessing(result); #else // In case where the input is in linear space we at least need to put it back in gamma. #ifdef FROMLINEARSPACE result = applyImageProcessing(result); </s> remove #ifdef CAMERACOLORGRADING color = colorGrades(color); </s> add // Apply image processing if relevant. As this applies in linear space, // We first move from gamma to linear. #ifdef IMAGEPROCESSING color.rgb = toLinearSpace(result.rgb); color.rgb = applyImageProcessing(color); </s> remove float sliceSize = 2.0 * colorTransformSettings.y; // Size of 1 slice relative to the texture, for example 1/8 float sliceContinuous = (color.y - colorTransformSettings.y) * colorTransformSettings.z; float sliceInteger = floor(sliceContinuous); // Note: this is mathematically equivalent to fract(sliceContinuous); but we use explicit subtract // rather than separate fract() for correct results near slice boundaries (matching sliceInteger choice) float sliceFraction = sliceContinuous - sliceInteger; vec2 sliceUV = color.xz; sliceUV.x *= sliceSize; sliceUV.x += sliceInteger * sliceSize; vec4 slice0Color = texture2D(colorTransform, sliceUV); sliceUV.x += sliceSize; vec4 slice1Color = texture2D(colorTransform, sliceUV); vec3 result = mix(slice0Color.rgb, slice1Color.rgb, sliceFraction); color.rgb = result.bgr; return color; } vec4 applyImageProcessing(vec4 result, vec2 viewportXY){ #ifndef FROMLINEARSPACE // Need to move to linear space for subsequent operations result.rgb = pow(result.rgb, vec3(LinearEncodePowerApprox)); #endif result.rgb *= cameraExposureLinear; #ifdef VIGNETTE //vignette vec3 vignetteXY1 = vec3(viewportXY * vignetteSettings1.xy + vignetteSettings1.zw, 1.0); float vignetteTerm = dot(vignetteXY1, vignetteXY1); float vignette = pow(vignetteTerm, vignetteSettings2.w); // Interpolate between the artist 'color' and white based on the physical transmission value 'vignette'. vec3 vignetteColor = vignetteSettings2.rgb; </s> add vec4 result = texture2D(textureSampler, vUV);
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
// Forces linear space for image processing #ifndef FROMLINEARSPACE #define FROMLINEARSPACE;
<mask> #endif <mask> <mask> #endif <mask> <mask> #include<reflectionFunction> <mask> <mask> #endif <mask> <mask> #ifdef CAMERACOLORGRADING <mask> #include<colorGradingDefinition> <mask> #endif </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef CAMERACOLORGRADING #include<colorGradingDefinition> #endif </s> add #include<imageProcessingDeclaration> </s> remove #ifdef CAMERACOLORGRADING #include<colorGradingDefinition> #include<colorGrading> #endif </s> add #include<imageProcessingDeclaration> </s> remove #include<colorGradingDefinition> </s> add #include<legacyColorGradingDefinition> </s> remove #ifdef CAMERACOLORCURVES #include<colorCurvesDefinition> #endif </s> add #include<helperFunctions> #include<imageProcessingFunctions> </s> remove #ifdef REFLECTIONMAP_SKYBOX varying vec3 vPositionUVW; #else #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) varying vec3 vDirectionW; #endif </s> add #endif
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
#include<imageProcessingDeclaration>
<mask> #include<reflectionFunction> <mask> <mask> #endif <mask> <mask> #ifdef CAMERACOLORGRADING <mask> #include<colorGradingDefinition> <mask> #endif <mask> <mask> #ifdef CAMERACOLORCURVES <mask> #include<colorCurvesDefinition> <mask> #endif <mask> </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef CAMERACOLORGRADING #include<colorGradingDefinition> #include<colorGrading> #endif </s> add #include<imageProcessingDeclaration> </s> remove #include<colorGradingDefinition> </s> add #include<legacyColorGradingDefinition> </s> remove #ifdef CAMERACOLORCURVES #include<colorCurvesDefinition> #endif </s> add #include<helperFunctions> #include<imageProcessingFunctions> </s> remove #include<colorCurvesDefinition> </s> add #include<legacyColorCurvesDefinition> </s> remove #include<reflectionFunction> </s> add // Forces linear space for image processing #ifndef FROMLINEARSPACE #define FROMLINEARSPACE;
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
#include<helperFunctions> #include<imageProcessingFunctions>
<mask> #ifdef CAMERACOLORGRADING <mask> #include<colorGradingDefinition> <mask> #endif <mask> <mask> #ifdef CAMERACOLORCURVES <mask> #include<colorCurvesDefinition> <mask> #endif <mask> <mask> // PBR <mask> #include<shadowsFragmentFunctions> <mask> #include<pbrFunctions> <mask> </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #include<colorCurvesDefinition> </s> add #include<legacyColorCurvesDefinition> </s> remove #ifdef CAMERACOLORGRADING #include<colorGrading> #endif #ifdef CAMERACOLORCURVES #include<colorCurves> #endif </s> add </s> remove #include<colorGradingDefinition> </s> add #include<legacyColorGradingDefinition> </s> remove #ifdef CAMERACOLORGRADING #include<colorGradingDefinition> #endif </s> add #include<imageProcessingDeclaration> </s> remove #ifdef CAMERACOLORGRADING #include<colorGradingDefinition> #include<colorGrading> #endif </s> add #include<imageProcessingDeclaration>
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
<mask> <mask> // PBR <mask> #include<shadowsFragmentFunctions> <mask> #include<pbrFunctions> <mask> <mask> #ifdef CAMERACOLORGRADING <mask> #include<colorGrading> <mask> #endif <mask> <mask> #ifdef CAMERACOLORCURVES <mask> #include<colorCurves> <mask> #endif <mask> <mask> #include<harmonicsFunctions> <mask> #include<pbrLightFunctions> <mask> <mask> #include<helperFunctions> <mask> #include<bumpFragmentFunctions> </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef CAMERACOLORCURVES #include<colorCurvesDefinition> #endif </s> add #include<helperFunctions> #include<imageProcessingFunctions> </s> remove #include<colorGrading> </s> add #include<legacyColorGrading> </s> remove #ifdef CAMERACOLORCURVES #include<colorCurvesDefinition> #include<colorCurves> #endif </s> add #include<helperFunctions> #include<imageProcessingFunctions> </s> remove #include<colorCurves> </s> add #include<legacyColorCurves> </s> remove #ifdef CAMERACOLORGRADING #include<colorGradingDefinition> #include<colorGrading> #endif </s> add #include<imageProcessingDeclaration>
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
<mask> <mask> #include<harmonicsFunctions> <mask> #include<pbrLightFunctions> <mask> <mask> #include<helperFunctions> <mask> #include<bumpFragmentFunctions> <mask> #include<clipPlaneFragmentDeclaration> <mask> #include<logDepthDeclaration> <mask> <mask> // Fog </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #include<helperFunctions> </s> add mat3 transposeMat3(mat3 inMatrix) { vec3 i0 = inMatrix[0]; vec3 i1 = inMatrix[1]; vec3 i2 = inMatrix[2]; mat3 outMatrix = mat3( vec3(i0.x, i1.x, i2.x), vec3(i0.y, i1.y, i2.y), vec3(i0.z, i1.z, i2.z) ); return outMatrix; } </s> remove #ifdef CAMERACOLORCURVES #include<colorCurvesDefinition> #include<colorCurves> #endif </s> add #include<helperFunctions> #include<imageProcessingFunctions> </s> remove #ifdef CAMERACOLORGRADING #include<colorGrading> #endif #ifdef CAMERACOLORCURVES #include<colorCurves> #endif </s> add </s> remove #include<colorCurves> </s> add #include<legacyColorCurves> </s> remove #ifdef CAMERACOLORCURVES #include<colorCurvesDefinition> #endif </s> add #include<helperFunctions> #include<imageProcessingFunctions>
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
// _______________________________________________________________________________ // _____________________________ Geometry Information ____________________________
<mask> <mask> void main(void) { <mask> #include<clipPlaneFragment> <mask> <mask> vec3 viewDirectionW = normalize(vEyePosition - vPositionW); <mask> <mask> #ifdef NORMAL <mask> vec3 normalW = normalize(vNormalW); <mask> #else </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove // Bump </s> add </s> remove /** * Polyfill for SAMPLE_TEXTURE_3D, which is unsupported in WebGL. * colorTransformSettings.y = textureOffset (0.5 / textureSize). * colorTransformSettings.z = textureSize. */ vec3 sampleTexture3D(sampler2D colorTransform, vec3 color) </s> add void main(void) </s> remove #ifdef TONEMAPPING float tonemappingCalibration = 1.590579; result.rgb = 1.0 - exp2(-tonemappingCalibration * result.rgb); #endif // Going back to gamma space result.rgb = pow(result.rgb, vec3(GammaEncodePowerApprox)); result.rgb = clamp(result.rgb, 0.0, 1.0); // Contrast vec3 resultHighContrast = applyEaseInOut(result.rgb); if (contrast < 1.0) { result.rgb = mix(vec3(0.5, 0.5, 0.5), result.rgb, contrast); } else { result.rgb = mix(result.rgb, resultHighContrast, contrast - 1.0); } // Apply Color Transform #ifdef COLORGRADING vec3 colorTransformInput = result.rgb * colorTransformSettings.xxx + colorTransformSettings.yyy; vec3 colorTransformOutput = sampleTexture3D(txColorTransform, colorTransformInput).rgb; result.rgb = mix(result.rgb, colorTransformOutput, colorTransformSettings.www); #endif #ifdef COLORCURVES // Apply Color Curves float luma = dot(result.rgb, RGBLuminanceCoefficients); vec2 curveMix = clamp(vec2(luma * 3.0 - 1.5, luma * -3.0 + 1.5), vec2(0.0), vec2(1.0)); vec4 colorCurve = vCameraColorCurveNeutral + curveMix.x * vCameraColorCurvePositive - curveMix.y * vCameraColorCurveNegative; result.rgb *= colorCurve.rgb; result.rgb = mix(vec3(luma), result.rgb, colorCurve.a); #endif return result; } void main(void) { vec4 result = texture2D(textureSampler, vUV); vec2 viewportXY = vUV * 2.0 - 1.0; result = applyImageProcessing(result, viewportXY); </s> add </s> remove lightingInfo info; float shadow = 1.; // 1 - shadowLevel #include<lightFragment>[0..maxSimultaneousLights] vec3 lightDiffuseContribution = diffuseBase; #ifdef SPECULARTERM vec3 lightSpecularContribution = specularBase * vLightingIntensity.w; #endif #ifdef OPACITY vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); </s> add #ifdef ALPHATEST if (alpha <= ALPHATESTVALUE) discard;
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
<mask> #include<clipPlaneFragment> <mask> <mask> vec3 viewDirectionW = normalize(vEyePosition - vPositionW); <mask> <mask> // Bump <mask> #ifdef NORMAL <mask> vec3 normalW = normalize(vNormalW); <mask> #else <mask> vec3 normalW = normalize(cross(dFdx(vPositionW), dFdy(vPositionW))); <mask> #endif </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove lightingInfo info; float shadow = 1.; // 1 - shadowLevel #include<lightFragment>[0..maxSimultaneousLights] vec3 lightDiffuseContribution = diffuseBase; #ifdef SPECULARTERM vec3 lightSpecularContribution = specularBase * vLightingIntensity.w; #endif #ifdef OPACITY vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); </s> add #ifdef ALPHATEST if (alpha <= ALPHATESTVALUE) discard; </s> remove // Reflection </s> add // _____________________________ Reflection Info _______________________________________ #ifdef REFLECTION </s> remove #ifdef TONEMAPPING float tonemappingCalibration = 1.590579; result.rgb = 1.0 - exp2(-tonemappingCalibration * result.rgb); #endif // Going back to gamma space result.rgb = pow(result.rgb, vec3(GammaEncodePowerApprox)); result.rgb = clamp(result.rgb, 0.0, 1.0); // Contrast vec3 resultHighContrast = applyEaseInOut(result.rgb); if (contrast < 1.0) { result.rgb = mix(vec3(0.5, 0.5, 0.5), result.rgb, contrast); } else { result.rgb = mix(result.rgb, resultHighContrast, contrast - 1.0); } // Apply Color Transform #ifdef COLORGRADING vec3 colorTransformInput = result.rgb * colorTransformSettings.xxx + colorTransformSettings.yyy; vec3 colorTransformOutput = sampleTexture3D(txColorTransform, colorTransformInput).rgb; result.rgb = mix(result.rgb, colorTransformOutput, colorTransformSettings.www); #endif #ifdef COLORCURVES // Apply Color Curves float luma = dot(result.rgb, RGBLuminanceCoefficients); vec2 curveMix = clamp(vec2(luma * 3.0 - 1.5, luma * -3.0 + 1.5), vec2(0.0), vec2(1.0)); vec4 colorCurve = vCameraColorCurveNeutral + curveMix.x * vCameraColorCurvePositive - curveMix.y * vCameraColorCurveNegative; result.rgb *= colorCurve.rgb; result.rgb = mix(vec3(luma), result.rgb, colorCurve.a); #endif return result; } void main(void) { vec4 result = texture2D(textureSampler, vUV); vec2 viewportXY = vUV * 2.0 - 1.0; result = applyImageProcessing(result, viewportXY); </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
// _____________________________ Albedo Information ______________________________
<mask> #if defined(TWOSIDEDLIGHTING) && defined(NORMAL) <mask> normalW = gl_FrontFacing ? normalW : -normalW; <mask> #endif <mask> <mask> // Albedo <mask> vec3 surfaceAlbedo = vAlbedoColor.rgb; <mask> <mask> // Alpha <mask> float alpha = vAlbedoColor.a; </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifndef LINKREFRACTIONTOTRANSPARENCY #if defined(ALPHATEST) && defined(ALPHATESTVALUE) </s> add // _____________________________ Alpha Information _______________________________ #ifdef OPACITY vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); #ifdef OPACITYRGB alpha = getLuminance(opacityMap.rgb); #else alpha *= opacityMap.a; #endif alpha *= vOpacityInfos.y; #endif #ifdef VERTEXALPHA alpha *= vColor.a; #endif #if !defined(LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL) #ifdef ALPHATEST </s> remove // Bump </s> add </s> remove #ifndef ALPHABLEND // Prevent to blend with the canvas. alpha = 1.0; #endif </s> add #ifndef ALPHABLEND // Prevent to blend with the canvas. alpha = 1.0; #endif </s> remove #ifdef VERTEXALPHA alpha *= vColor.a; #endif #ifdef OPACITYFRESNEL float opacityFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, opacityParts.z, opacityParts.w); alpha += opacityParts.x * (1.0 - opacityFresnelTerm) + opacityFresnelTerm * opacityParts.y; #endif // Refraction vec3 surfaceRefractionColor = vec3(0., 0., 0.); // Go mat -> blurry reflexion according to microSurface </s> add // _____________________________ Compute LODs Fetch ____________________________________
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
// _____________________________ Alpha Information _______________________________ #ifdef OPACITY vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); #ifdef OPACITYRGB alpha = getLuminance(opacityMap.rgb); #else alpha *= opacityMap.a; #endif alpha *= vOpacityInfos.y; #endif #ifdef VERTEXALPHA alpha *= vColor.a; #endif #if !defined(LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL) #ifdef ALPHATEST
<mask> surfaceAlbedo *= toLinearSpace(albedoTexture.rgb); <mask> surfaceAlbedo *= vAlbedoInfos.y; <mask> #endif <mask> <mask> #ifndef LINKREFRACTIONTOTRANSPARENCY <mask> #if defined(ALPHATEST) && defined(ALPHATESTVALUE) <mask> if (alpha <= ALPHATESTVALUE) <mask> discard; <mask> <mask> #ifndef ALPHABLEND <mask> // Prevent to blend with the canvas. </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifndef ALPHABLEND // Prevent to blend with the canvas. alpha = 1.0; #endif </s> add #ifndef ALPHABLEND // Prevent to blend with the canvas. alpha = 1.0; #endif </s> remove #ifdef OPACITYRGB opacityMap.rgb = opacityMap.rgb * vec3(0.3, 0.59, 0.11); alpha *= (opacityMap.x + opacityMap.y + opacityMap.z)* vOpacityInfos.y; #else alpha *= opacityMap.a * vOpacityInfos.y; </s> add #ifndef ALPHABLEND // Prevent to blend with the canvas. alpha = 1.0; #endif </s> remove lightingInfo info; float shadow = 1.; // 1 - shadowLevel #include<lightFragment>[0..maxSimultaneousLights] vec3 lightDiffuseContribution = diffuseBase; #ifdef SPECULARTERM vec3 lightSpecularContribution = specularBase * vLightingIntensity.w; #endif #ifdef OPACITY vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); </s> add #ifdef ALPHATEST if (alpha <= ALPHATESTVALUE) discard; </s> remove // Ambient color </s> add // _____________________________ AO Information _______________________________
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
#ifndef ALPHABLEND // Prevent to blend with the canvas. alpha = 1.0; #endif
<mask> #ifndef LINKREFRACTIONTOTRANSPARENCY <mask> #if defined(ALPHATEST) && defined(ALPHATESTVALUE) <mask> if (alpha <= ALPHATESTVALUE) <mask> discard; <mask> <mask> #ifndef ALPHABLEND <mask> // Prevent to blend with the canvas. <mask> alpha = 1.0; <mask> #endif <mask> #endif <mask> #endif <mask> <mask> #ifdef VERTEXCOLOR <mask> surfaceAlbedo *= vColor.rgb; </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifndef LINKREFRACTIONTOTRANSPARENCY #if defined(ALPHATEST) && defined(ALPHATESTVALUE) </s> add // _____________________________ Alpha Information _______________________________ #ifdef OPACITY vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); #ifdef OPACITYRGB alpha = getLuminance(opacityMap.rgb); #else alpha *= opacityMap.a; #endif alpha *= vOpacityInfos.y; #endif #ifdef VERTEXALPHA alpha *= vColor.a; #endif #if !defined(LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL) #ifdef ALPHATEST </s> remove #ifdef OPACITYRGB opacityMap.rgb = opacityMap.rgb * vec3(0.3, 0.59, 0.11); alpha *= (opacityMap.x + opacityMap.y + opacityMap.z)* vOpacityInfos.y; #else alpha *= opacityMap.a * vOpacityInfos.y; </s> add #ifndef ALPHABLEND // Prevent to blend with the canvas. alpha = 1.0; #endif </s> remove lightingInfo info; float shadow = 1.; // 1 - shadowLevel #include<lightFragment>[0..maxSimultaneousLights] vec3 lightDiffuseContribution = diffuseBase; #ifdef SPECULARTERM vec3 lightSpecularContribution = specularBase * vLightingIntensity.w; #endif #ifdef OPACITY vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); </s> add #ifdef ALPHATEST if (alpha <= ALPHATESTVALUE) discard; </s> remove // Ambient color </s> add // _____________________________ AO Information _______________________________
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
// _____________________________ AO Information _______________________________
<mask> #ifdef VERTEXCOLOR <mask> surfaceAlbedo *= vColor.rgb; <mask> #endif <mask> <mask> // Ambient color <mask> vec3 ambientOcclusionColor = vec3(1., 1., 1.); <mask> <mask> #ifdef AMBIENT <mask> vec3 ambientOcclusionColorMap = texture2D(ambientSampler, vAmbientUV + uvOffset).rgb * vAmbientInfos.y; <mask> #ifdef AMBIENTINGRAYSCALE </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifndef ALPHABLEND // Prevent to blend with the canvas. alpha = 1.0; #endif </s> add #ifndef ALPHABLEND // Prevent to blend with the canvas. alpha = 1.0; #endif </s> remove lightingInfo info; float shadow = 1.; // 1 - shadowLevel #include<lightFragment>[0..maxSimultaneousLights] vec3 lightDiffuseContribution = diffuseBase; #ifdef SPECULARTERM vec3 lightSpecularContribution = specularBase * vLightingIntensity.w; #endif #ifdef OPACITY vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); </s> add #ifdef ALPHATEST if (alpha <= ALPHATESTVALUE) discard; </s> remove #ifndef LINKREFRACTIONTOTRANSPARENCY #if defined(ALPHATEST) && defined(ALPHATESTVALUE) </s> add // _____________________________ Alpha Information _______________________________ #ifdef OPACITY vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); #ifdef OPACITYRGB alpha = getLuminance(opacityMap.rgb); #else alpha *= opacityMap.a; #endif alpha *= vOpacityInfos.y; #endif #ifdef VERTEXALPHA alpha *= vColor.a; #endif #if !defined(LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL) #ifdef ALPHATEST </s> remove #ifdef VERTEXALPHA alpha *= vColor.a; #endif #ifdef OPACITYFRESNEL float opacityFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, opacityParts.z, opacityParts.w); alpha += opacityParts.x * (1.0 - opacityFresnelTerm) + opacityFresnelTerm * opacityParts.y; #endif // Refraction vec3 surfaceRefractionColor = vec3(0., 0., 0.); // Go mat -> blurry reflexion according to microSurface </s> add // _____________________________ Compute LODs Fetch ____________________________________ </s> remove #ifdef OPACITYRGB opacityMap.rgb = opacityMap.rgb * vec3(0.3, 0.59, 0.11); alpha *= (opacityMap.x + opacityMap.y + opacityMap.z)* vOpacityInfos.y; #else alpha *= opacityMap.a * vOpacityInfos.y; </s> add #ifndef ALPHABLEND // Prevent to blend with the canvas. alpha = 1.0; #endif
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
// _____________________________ Reflectivity Info _______________________________
<mask> #endif <mask> ambientOcclusionColor = mix(ambientOcclusionColor, ambientOcclusionColorMap, vAmbientInfos.z); <mask> #endif <mask> <mask> // Reflectivity map <mask> float microSurface = vReflectivityColor.a; <mask> vec3 surfaceReflectivityColor = vReflectivityColor.rgb; <mask> <mask> #ifdef METALLICWORKFLOW <mask> vec2 metallicRoughness = surfaceReflectivityColor.rg; </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef VERTEXALPHA alpha *= vColor.a; #endif #ifdef OPACITYFRESNEL float opacityFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, opacityParts.z, opacityParts.w); alpha += opacityParts.x * (1.0 - opacityFresnelTerm) + opacityFresnelTerm * opacityParts.y; #endif // Refraction vec3 surfaceRefractionColor = vec3(0., 0., 0.); // Go mat -> blurry reflexion according to microSurface </s> add // _____________________________ Compute LODs Fetch ____________________________________ </s> remove // Compute N dot V. float NdotV = clamp(dot(normalW, viewDirectionW),0., 1.) + 0.00001; </s> add </s> remove // Ambient color </s> add // _____________________________ AO Information _______________________________ </s> remove #ifdef TONEMAPPING float tonemappingCalibration = 1.590579; result.rgb = 1.0 - exp2(-tonemappingCalibration * result.rgb); #endif // Going back to gamma space result.rgb = pow(result.rgb, vec3(GammaEncodePowerApprox)); result.rgb = clamp(result.rgb, 0.0, 1.0); // Contrast vec3 resultHighContrast = applyEaseInOut(result.rgb); if (contrast < 1.0) { result.rgb = mix(vec3(0.5, 0.5, 0.5), result.rgb, contrast); } else { result.rgb = mix(result.rgb, resultHighContrast, contrast - 1.0); } // Apply Color Transform #ifdef COLORGRADING vec3 colorTransformInput = result.rgb * colorTransformSettings.xxx + colorTransformSettings.yyy; vec3 colorTransformOutput = sampleTexture3D(txColorTransform, colorTransformInput).rgb; result.rgb = mix(result.rgb, colorTransformOutput, colorTransformSettings.www); #endif #ifdef COLORCURVES // Apply Color Curves float luma = dot(result.rgb, RGBLuminanceCoefficients); vec2 curveMix = clamp(vec2(luma * 3.0 - 1.5, luma * -3.0 + 1.5), vec2(0.0), vec2(1.0)); vec4 colorCurve = vCameraColorCurveNeutral + curveMix.x * vCameraColorCurvePositive - curveMix.y * vCameraColorCurveNegative; result.rgb *= colorCurve.rgb; result.rgb = mix(vec3(luma), result.rgb, colorCurve.a); #endif return result; } void main(void) { vec4 result = texture2D(textureSampler, vUV); vec2 viewportXY = vUV * 2.0 - 1.0; result = applyImageProcessing(result, viewportXY); </s> add </s> remove float sliceSize = 2.0 * colorTransformSettings.y; // Size of 1 slice relative to the texture, for example 1/8 float sliceContinuous = (color.y - colorTransformSettings.y) * colorTransformSettings.z; float sliceInteger = floor(sliceContinuous); // Note: this is mathematically equivalent to fract(sliceContinuous); but we use explicit subtract // rather than separate fract() for correct results near slice boundaries (matching sliceInteger choice) float sliceFraction = sliceContinuous - sliceInteger; vec2 sliceUV = color.xz; sliceUV.x *= sliceSize; sliceUV.x += sliceInteger * sliceSize; vec4 slice0Color = texture2D(colorTransform, sliceUV); sliceUV.x += sliceSize; vec4 slice1Color = texture2D(colorTransform, sliceUV); vec3 result = mix(slice0Color.rgb, slice1Color.rgb, sliceFraction); color.rgb = result.bgr; return color; } vec4 applyImageProcessing(vec4 result, vec2 viewportXY){ #ifndef FROMLINEARSPACE // Need to move to linear space for subsequent operations result.rgb = pow(result.rgb, vec3(LinearEncodePowerApprox)); #endif result.rgb *= cameraExposureLinear; #ifdef VIGNETTE //vignette vec3 vignetteXY1 = vec3(viewportXY * vignetteSettings1.xy + vignetteSettings1.zw, 1.0); float vignetteTerm = dot(vignetteXY1, vignetteXY1); float vignette = pow(vignetteTerm, vignetteSettings2.w); // Interpolate between the artist 'color' and white based on the physical transmission value 'vignette'. vec3 vignetteColor = vignetteSettings2.rgb; </s> add vec4 result = texture2D(textureSampler, vUV);
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
<mask> #endif <mask> #endif <mask> #endif <mask> <mask> // Compute N dot V. <mask> float NdotV = clamp(dot(normalW, viewDirectionW),0., 1.) + 0.00001; <mask> <mask> // Adapt microSurface. <mask> microSurface = clamp(microSurface, 0., 1.); <mask> <mask> // Compute roughness. <mask> float roughness = 1. - microSurface; </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef LIGHTMAP vec3 lightmapColor = texture2D(lightmapSampler, vLightmapUV + uvOffset).rgb * vLightmapInfos.y; #endif float NdotL = -1.; </s> add // _____________________________ Alpha Fresnel ___________________________________ #ifdef ALPHAFRESNEL // Convert approximate perceptual opacity (gamma-encoded opacity) to linear opacity (absorptance, or inverse transmission) // for use with the linear HDR render target. The final composition will be converted back to gamma encoded values for eventual display. // Uses power 2.0 rather than 2.2 for simplicity/efficiency, and because the mapping does not need to map the gamma applied to RGB. float opacityPerceptual = alpha; float opacity0 = opacityPerceptual * opacityPerceptual; float opacity90 = fresnelGrazingReflectance(opacity0); </s> remove #ifdef VERTEXALPHA alpha *= vColor.a; #endif #ifdef OPACITYFRESNEL float opacityFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, opacityParts.z, opacityParts.w); alpha += opacityParts.x * (1.0 - opacityFresnelTerm) + opacityFresnelTerm * opacityParts.y; #endif // Refraction vec3 surfaceRefractionColor = vec3(0., 0., 0.); // Go mat -> blurry reflexion according to microSurface </s> add // _____________________________ Compute LODs Fetch ____________________________________ </s> remove // For typical incident reflectance range (between 4% to 100%) set the grazing reflectance to 100% for typical fresnel effect. // For very low reflectance range on highly diffuse objects (below 4%), incrementally reduce grazing reflecance to 0%. float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0); vec3 specularEnvironmentR0 = surfaceReflectivityColor.rgb; vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90; // Lighting vec3 diffuseBase = vec3(0., 0., 0.); #ifdef SPECULARTERM vec3 specularBase = vec3(0., 0., 0.); #endif </s> add // Calculate the appropriate linear opacity for the current viewing angle (formally, this quantity is the "directional absorptance"). alpha = fresnelSchlickEnvironmentGGX(clamp(dot(V, normalForward), 0.0, 1.0), vec3(opacity0), vec3(opacity90), sqrt(microSurface)).x; </s> remove // Reflectivity map </s> add // _____________________________ Reflectivity Info _______________________________ </s> remove lightingInfo info; float shadow = 1.; // 1 - shadowLevel #include<lightFragment>[0..maxSimultaneousLights] vec3 lightDiffuseContribution = diffuseBase; #ifdef SPECULARTERM vec3 lightSpecularContribution = specularBase * vLightingIntensity.w; #endif #ifdef OPACITY vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); </s> add #ifdef ALPHATEST if (alpha <= ALPHATESTVALUE) discard;
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
// _____________________________ Alpha Fresnel ___________________________________ #ifdef ALPHAFRESNEL // Convert approximate perceptual opacity (gamma-encoded opacity) to linear opacity (absorptance, or inverse transmission) // for use with the linear HDR render target. The final composition will be converted back to gamma encoded values for eventual display. // Uses power 2.0 rather than 2.2 for simplicity/efficiency, and because the mapping does not need to map the gamma applied to RGB. float opacityPerceptual = alpha; float opacity0 = opacityPerceptual * opacityPerceptual; float opacity90 = fresnelGrazingReflectance(opacity0);
<mask> <mask> // Compute roughness. <mask> float roughness = 1. - microSurface; <mask> <mask> #ifdef LIGHTMAP <mask> vec3 lightmapColor = texture2D(lightmapSampler, vLightmapUV + uvOffset).rgb * vLightmapInfos.y; <mask> #endif <mask> <mask> float NdotL = -1.; <mask> <mask> // Compute reflectance. <mask> float reflectance = max(max(surfaceReflectivityColor.r, surfaceReflectivityColor.g), surfaceReflectivityColor.b); <mask> <mask> // For typical incident reflectance range (between 4% to 100%) set the grazing reflectance to 100% for typical fresnel effect. </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove // Compute reflectance. float reflectance = max(max(surfaceReflectivityColor.r, surfaceReflectivityColor.g), surfaceReflectivityColor.b); </s> add vec3 normalForward = faceforward(normalW, -viewDirectionW, normalW); </s> remove // For typical incident reflectance range (between 4% to 100%) set the grazing reflectance to 100% for typical fresnel effect. // For very low reflectance range on highly diffuse objects (below 4%), incrementally reduce grazing reflecance to 0%. float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0); vec3 specularEnvironmentR0 = surfaceReflectivityColor.rgb; vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90; // Lighting vec3 diffuseBase = vec3(0., 0., 0.); #ifdef SPECULARTERM vec3 specularBase = vec3(0., 0., 0.); #endif </s> add // Calculate the appropriate linear opacity for the current viewing angle (formally, this quantity is the "directional absorptance"). alpha = fresnelSchlickEnvironmentGGX(clamp(dot(V, normalForward), 0.0, 1.0), vec3(opacity0), vec3(opacity90), sqrt(microSurface)).x; </s> remove // Compute N dot V. float NdotV = clamp(dot(normalW, viewDirectionW),0., 1.) + 0.00001; </s> add </s> remove return fresnel * NdotL / kPi; </s> add return fresnel * NdotL / PI; </s> remove #ifdef VERTEXALPHA alpha *= vColor.a; #endif #ifdef OPACITYFRESNEL float opacityFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, opacityParts.z, opacityParts.w); alpha += opacityParts.x * (1.0 - opacityFresnelTerm) + opacityFresnelTerm * opacityParts.y; #endif // Refraction vec3 surfaceRefractionColor = vec3(0., 0., 0.); // Go mat -> blurry reflexion according to microSurface </s> add // _____________________________ Compute LODs Fetch ____________________________________
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
vec3 normalForward = faceforward(normalW, -viewDirectionW, normalW);
<mask> #endif <mask> <mask> float NdotL = -1.; <mask> <mask> // Compute reflectance. <mask> float reflectance = max(max(surfaceReflectivityColor.r, surfaceReflectivityColor.g), surfaceReflectivityColor.b); <mask> <mask> // For typical incident reflectance range (between 4% to 100%) set the grazing reflectance to 100% for typical fresnel effect. <mask> // For very low reflectance range on highly diffuse objects (below 4%), incrementally reduce grazing reflecance to 0%. <mask> float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0); <mask> vec3 specularEnvironmentR0 = surfaceReflectivityColor.rgb; </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove // For typical incident reflectance range (between 4% to 100%) set the grazing reflectance to 100% for typical fresnel effect. // For very low reflectance range on highly diffuse objects (below 4%), incrementally reduce grazing reflecance to 0%. float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0); vec3 specularEnvironmentR0 = surfaceReflectivityColor.rgb; vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90; // Lighting vec3 diffuseBase = vec3(0., 0., 0.); #ifdef SPECULARTERM vec3 specularBase = vec3(0., 0., 0.); #endif </s> add // Calculate the appropriate linear opacity for the current viewing angle (formally, this quantity is the "directional absorptance"). alpha = fresnelSchlickEnvironmentGGX(clamp(dot(V, normalForward), 0.0, 1.0), vec3(opacity0), vec3(opacity90), sqrt(microSurface)).x; </s> remove #ifdef LIGHTMAP vec3 lightmapColor = texture2D(lightmapSampler, vLightmapUV + uvOffset).rgb * vLightmapInfos.y; #endif float NdotL = -1.; </s> add // _____________________________ Alpha Fresnel ___________________________________ #ifdef ALPHAFRESNEL // Convert approximate perceptual opacity (gamma-encoded opacity) to linear opacity (absorptance, or inverse transmission) // for use with the linear HDR render target. The final composition will be converted back to gamma encoded values for eventual display. // Uses power 2.0 rather than 2.2 for simplicity/efficiency, and because the mapping does not need to map the gamma applied to RGB. float opacityPerceptual = alpha; float opacity0 = opacityPerceptual * opacityPerceptual; float opacity90 = fresnelGrazingReflectance(opacity0); </s> remove float sliceSize = 2.0 * colorTransformSettings.y; // Size of 1 slice relative to the texture, for example 1/8 float sliceContinuous = (color.y - colorTransformSettings.y) * colorTransformSettings.z; float sliceInteger = floor(sliceContinuous); // Note: this is mathematically equivalent to fract(sliceContinuous); but we use explicit subtract // rather than separate fract() for correct results near slice boundaries (matching sliceInteger choice) float sliceFraction = sliceContinuous - sliceInteger; vec2 sliceUV = color.xz; sliceUV.x *= sliceSize; sliceUV.x += sliceInteger * sliceSize; vec4 slice0Color = texture2D(colorTransform, sliceUV); sliceUV.x += sliceSize; vec4 slice1Color = texture2D(colorTransform, sliceUV); vec3 result = mix(slice0Color.rgb, slice1Color.rgb, sliceFraction); color.rgb = result.bgr; return color; } vec4 applyImageProcessing(vec4 result, vec2 viewportXY){ #ifndef FROMLINEARSPACE // Need to move to linear space for subsequent operations result.rgb = pow(result.rgb, vec3(LinearEncodePowerApprox)); #endif result.rgb *= cameraExposureLinear; #ifdef VIGNETTE //vignette vec3 vignetteXY1 = vec3(viewportXY * vignetteSettings1.xy + vignetteSettings1.zw, 1.0); float vignetteTerm = dot(vignetteXY1, vignetteXY1); float vignette = pow(vignetteTerm, vignetteSettings2.w); // Interpolate between the artist 'color' and white based on the physical transmission value 'vignette'. vec3 vignetteColor = vignetteSettings2.rgb; </s> add vec4 result = texture2D(textureSampler, vUV); </s> remove return fresnel * NdotL / kPi; </s> add return fresnel * NdotL / PI; </s> remove vec3 FresnelSchlickEnvironmentGGX(float VdotN, vec3 reflectance0, vec3 reflectance90, float smoothness) </s> add vec3 fresnelSchlickEnvironmentGGX(float VdotN, vec3 reflectance0, vec3 reflectance90, float smoothness)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
// Calculate the appropriate linear opacity for the current viewing angle (formally, this quantity is the "directional absorptance"). alpha = fresnelSchlickEnvironmentGGX(clamp(dot(V, normalForward), 0.0, 1.0), vec3(opacity0), vec3(opacity90), sqrt(microSurface)).x;
<mask> <mask> // Compute reflectance. <mask> float reflectance = max(max(surfaceReflectivityColor.r, surfaceReflectivityColor.g), surfaceReflectivityColor.b); <mask> <mask> // For typical incident reflectance range (between 4% to 100%) set the grazing reflectance to 100% for typical fresnel effect. <mask> // For very low reflectance range on highly diffuse objects (below 4%), incrementally reduce grazing reflecance to 0%. <mask> float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0); <mask> vec3 specularEnvironmentR0 = surfaceReflectivityColor.rgb; <mask> vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90; <mask> <mask> // Lighting <mask> vec3 diffuseBase = vec3(0., 0., 0.); <mask> <mask> #ifdef SPECULARTERM <mask> vec3 specularBase = vec3(0., 0., 0.); <mask> #endif <mask> <mask> lightingInfo info; <mask> float shadow = 1.; // 1 - shadowLevel <mask> <mask> #include<lightFragment>[0..maxSimultaneousLights] </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove // Compute reflectance. float reflectance = max(max(surfaceReflectivityColor.r, surfaceReflectivityColor.g), surfaceReflectivityColor.b); </s> add vec3 normalForward = faceforward(normalW, -viewDirectionW, normalW); </s> remove #ifdef LIGHTMAP vec3 lightmapColor = texture2D(lightmapSampler, vLightmapUV + uvOffset).rgb * vLightmapInfos.y; #endif float NdotL = -1.; </s> add // _____________________________ Alpha Fresnel ___________________________________ #ifdef ALPHAFRESNEL // Convert approximate perceptual opacity (gamma-encoded opacity) to linear opacity (absorptance, or inverse transmission) // for use with the linear HDR render target. The final composition will be converted back to gamma encoded values for eventual display. // Uses power 2.0 rather than 2.2 for simplicity/efficiency, and because the mapping does not need to map the gamma applied to RGB. float opacityPerceptual = alpha; float opacity0 = opacityPerceptual * opacityPerceptual; float opacity90 = fresnelGrazingReflectance(opacity0); </s> remove lightingInfo info; float shadow = 1.; // 1 - shadowLevel #include<lightFragment>[0..maxSimultaneousLights] vec3 lightDiffuseContribution = diffuseBase; #ifdef SPECULARTERM vec3 lightSpecularContribution = specularBase * vLightingIntensity.w; #endif #ifdef OPACITY vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); </s> add #ifdef ALPHATEST if (alpha <= ALPHATESTVALUE) discard; </s> remove #ifdef VERTEXALPHA alpha *= vColor.a; #endif #ifdef OPACITYFRESNEL float opacityFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, opacityParts.z, opacityParts.w); alpha += opacityParts.x * (1.0 - opacityFresnelTerm) + opacityFresnelTerm * opacityParts.y; #endif // Refraction vec3 surfaceRefractionColor = vec3(0., 0., 0.); // Go mat -> blurry reflexion according to microSurface </s> add // _____________________________ Compute LODs Fetch ____________________________________
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
#ifdef ALPHATEST if (alpha <= ALPHATESTVALUE) discard;
<mask> #ifdef SPECULARTERM <mask> vec3 specularBase = vec3(0., 0., 0.); <mask> #endif <mask> <mask> lightingInfo info; <mask> float shadow = 1.; // 1 - shadowLevel <mask> <mask> #include<lightFragment>[0..maxSimultaneousLights] <mask> <mask> vec3 lightDiffuseContribution = diffuseBase; <mask> <mask> #ifdef SPECULARTERM <mask> vec3 lightSpecularContribution = specularBase * vLightingIntensity.w; <mask> #endif <mask> <mask> #ifdef OPACITY <mask> vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); <mask> <mask> #ifdef OPACITYRGB <mask> opacityMap.rgb = opacityMap.rgb * vec3(0.3, 0.59, 0.11); <mask> alpha *= (opacityMap.x + opacityMap.y + opacityMap.z)* vOpacityInfos.y; <mask> #else </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef OPACITYRGB opacityMap.rgb = opacityMap.rgb * vec3(0.3, 0.59, 0.11); alpha *= (opacityMap.x + opacityMap.y + opacityMap.z)* vOpacityInfos.y; #else alpha *= opacityMap.a * vOpacityInfos.y; </s> add #ifndef ALPHABLEND // Prevent to blend with the canvas. alpha = 1.0; #endif </s> remove // For typical incident reflectance range (between 4% to 100%) set the grazing reflectance to 100% for typical fresnel effect. // For very low reflectance range on highly diffuse objects (below 4%), incrementally reduce grazing reflecance to 0%. float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0); vec3 specularEnvironmentR0 = surfaceReflectivityColor.rgb; vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90; // Lighting vec3 diffuseBase = vec3(0., 0., 0.); #ifdef SPECULARTERM vec3 specularBase = vec3(0., 0., 0.); #endif </s> add // Calculate the appropriate linear opacity for the current viewing angle (formally, this quantity is the "directional absorptance"). alpha = fresnelSchlickEnvironmentGGX(clamp(dot(V, normalForward), 0.0, 1.0), vec3(opacity0), vec3(opacity90), sqrt(microSurface)).x; </s> remove #ifndef LINKREFRACTIONTOTRANSPARENCY #if defined(ALPHATEST) && defined(ALPHATESTVALUE) </s> add // _____________________________ Alpha Information _______________________________ #ifdef OPACITY vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); #ifdef OPACITYRGB alpha = getLuminance(opacityMap.rgb); #else alpha *= opacityMap.a; #endif alpha *= vOpacityInfos.y; #endif #ifdef VERTEXALPHA alpha *= vColor.a; #endif #if !defined(LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL) #ifdef ALPHATEST </s> remove #ifdef VERTEXALPHA alpha *= vColor.a; #endif #ifdef OPACITYFRESNEL float opacityFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, opacityParts.z, opacityParts.w); alpha += opacityParts.x * (1.0 - opacityFresnelTerm) + opacityFresnelTerm * opacityParts.y; #endif // Refraction vec3 surfaceRefractionColor = vec3(0., 0., 0.); // Go mat -> blurry reflexion according to microSurface </s> add // _____________________________ Compute LODs Fetch ____________________________________
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
#ifndef ALPHABLEND // Prevent to blend with the canvas. alpha = 1.0; #endif
<mask> <mask> #ifdef OPACITY <mask> vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); <mask> <mask> #ifdef OPACITYRGB <mask> opacityMap.rgb = opacityMap.rgb * vec3(0.3, 0.59, 0.11); <mask> alpha *= (opacityMap.x + opacityMap.y + opacityMap.z)* vOpacityInfos.y; <mask> #else <mask> alpha *= opacityMap.a * vOpacityInfos.y; <mask> #endif <mask> #endif <mask> <mask> #ifdef VERTEXALPHA <mask> alpha *= vColor.a; </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove lightingInfo info; float shadow = 1.; // 1 - shadowLevel #include<lightFragment>[0..maxSimultaneousLights] vec3 lightDiffuseContribution = diffuseBase; #ifdef SPECULARTERM vec3 lightSpecularContribution = specularBase * vLightingIntensity.w; #endif #ifdef OPACITY vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); </s> add #ifdef ALPHATEST if (alpha <= ALPHATESTVALUE) discard; </s> remove #ifndef LINKREFRACTIONTOTRANSPARENCY #if defined(ALPHATEST) && defined(ALPHATESTVALUE) </s> add // _____________________________ Alpha Information _______________________________ #ifdef OPACITY vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); #ifdef OPACITYRGB alpha = getLuminance(opacityMap.rgb); #else alpha *= opacityMap.a; #endif alpha *= vOpacityInfos.y; #endif #ifdef VERTEXALPHA alpha *= vColor.a; #endif #if !defined(LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL) #ifdef ALPHATEST </s> remove #ifdef VERTEXALPHA alpha *= vColor.a; #endif #ifdef OPACITYFRESNEL float opacityFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, opacityParts.z, opacityParts.w); alpha += opacityParts.x * (1.0 - opacityFresnelTerm) + opacityFresnelTerm * opacityParts.y; #endif // Refraction vec3 surfaceRefractionColor = vec3(0., 0., 0.); // Go mat -> blurry reflexion according to microSurface </s> add // _____________________________ Compute LODs Fetch ____________________________________ </s> remove #ifndef ALPHABLEND // Prevent to blend with the canvas. alpha = 1.0; #endif </s> add #ifndef ALPHABLEND // Prevent to blend with the canvas. alpha = 1.0; #endif </s> remove // Ambient color </s> add // _____________________________ AO Information _______________________________
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
// _____________________________ Compute LODs Fetch ____________________________________
<mask> alpha *= opacityMap.a * vOpacityInfos.y; <mask> #endif <mask> #endif <mask> <mask> #ifdef VERTEXALPHA <mask> alpha *= vColor.a; <mask> #endif <mask> <mask> #ifdef OPACITYFRESNEL <mask> float opacityFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, opacityParts.z, opacityParts.w); <mask> <mask> alpha += opacityParts.x * (1.0 - opacityFresnelTerm) + opacityFresnelTerm * opacityParts.y; <mask> #endif <mask> <mask> // Refraction <mask> vec3 surfaceRefractionColor = vec3(0., 0., 0.); <mask> <mask> // Go mat -> blurry reflexion according to microSurface <mask> #ifdef LODBASEDMICROSFURACE <mask> float alphaG = convertRoughnessToAverageSlope(roughness); <mask> #endif <mask> <mask> #ifdef REFRACTION </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef OPACITYRGB opacityMap.rgb = opacityMap.rgb * vec3(0.3, 0.59, 0.11); alpha *= (opacityMap.x + opacityMap.y + opacityMap.z)* vOpacityInfos.y; #else alpha *= opacityMap.a * vOpacityInfos.y; </s> add #ifndef ALPHABLEND // Prevent to blend with the canvas. alpha = 1.0; #endif </s> remove lightingInfo info; float shadow = 1.; // 1 - shadowLevel #include<lightFragment>[0..maxSimultaneousLights] vec3 lightDiffuseContribution = diffuseBase; #ifdef SPECULARTERM vec3 lightSpecularContribution = specularBase * vLightingIntensity.w; #endif #ifdef OPACITY vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); </s> add #ifdef ALPHATEST if (alpha <= ALPHATESTVALUE) discard; </s> remove #ifndef LINKREFRACTIONTOTRANSPARENCY #if defined(ALPHATEST) && defined(ALPHATESTVALUE) </s> add // _____________________________ Alpha Information _______________________________ #ifdef OPACITY vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); #ifdef OPACITYRGB alpha = getLuminance(opacityMap.rgb); #else alpha *= opacityMap.a; #endif alpha *= vOpacityInfos.y; #endif #ifdef VERTEXALPHA alpha *= vColor.a; #endif #if !defined(LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL) #ifdef ALPHATEST
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
// _____________________________ Refraction Info _______________________________________
<mask> #endif <mask> <mask> #ifdef REFRACTION <mask> vec3 surfaceRefractionColor = vec3(0., 0., 0.); <mask> vec3 refractionVector = refract(-viewDirectionW, normalW, vRefractionInfos.y); <mask> </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef VERTEXALPHA alpha *= vColor.a; #endif #ifdef OPACITYFRESNEL float opacityFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, opacityParts.z, opacityParts.w); alpha += opacityParts.x * (1.0 - opacityFresnelTerm) + opacityFresnelTerm * opacityParts.y; #endif // Refraction vec3 surfaceRefractionColor = vec3(0., 0., 0.); // Go mat -> blurry reflexion according to microSurface </s> add // _____________________________ Compute LODs Fetch ____________________________________ </s> remove lightingInfo info; float shadow = 1.; // 1 - shadowLevel #include<lightFragment>[0..maxSimultaneousLights] vec3 lightDiffuseContribution = diffuseBase; #ifdef SPECULARTERM vec3 lightSpecularContribution = specularBase * vLightingIntensity.w; #endif #ifdef OPACITY vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); </s> add #ifdef ALPHATEST if (alpha <= ALPHATESTVALUE) discard; </s> remove // For typical incident reflectance range (between 4% to 100%) set the grazing reflectance to 100% for typical fresnel effect. // For very low reflectance range on highly diffuse objects (below 4%), incrementally reduce grazing reflecance to 0%. float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0); vec3 specularEnvironmentR0 = surfaceReflectivityColor.rgb; vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90; // Lighting vec3 diffuseBase = vec3(0., 0., 0.); #ifdef SPECULARTERM vec3 specularBase = vec3(0., 0., 0.); #endif </s> add // Calculate the appropriate linear opacity for the current viewing angle (formally, this quantity is the "directional absorptance"). alpha = fresnelSchlickEnvironmentGGX(clamp(dot(V, normalForward), 0.0, 1.0), vec3(opacity0), vec3(opacity90), sqrt(microSurface)).x; </s> remove // Reflection </s> add // _____________________________ Reflection Info _______________________________________ #ifdef REFLECTION
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
vec3 surfaceRefractionColor = vec3(0., 0., 0.);
<mask> #endif <mask> <mask> // _____________________________ Refraction Info _______________________________________ <mask> #ifdef REFRACTION <mask> vec3 refractionVector = refract(-viewDirectionW, normalW, vRefractionInfos.y); <mask> <mask> #ifdef LODBASEDMICROSFURACE <mask> #ifdef USEPMREMREFRACTION <mask> float lodRefraction = getMipMapIndexFromAverageSlopeWithPMREM(vMicrosurfaceTextureLods.y, alphaG); </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef VERTEXALPHA alpha *= vColor.a; #endif #ifdef OPACITYFRESNEL float opacityFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, opacityParts.z, opacityParts.w); alpha += opacityParts.x * (1.0 - opacityFresnelTerm) + opacityFresnelTerm * opacityParts.y; #endif // Refraction vec3 surfaceRefractionColor = vec3(0., 0., 0.); // Go mat -> blurry reflexion according to microSurface </s> add // _____________________________ Compute LODs Fetch ____________________________________ </s> remove // Reflection </s> add // _____________________________ Reflection Info _______________________________________ #ifdef REFLECTION </s> remove #ifdef REFLECTION </s> add </s> remove // Reflectivity map </s> add // _____________________________ Reflectivity Info _______________________________
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
// _____________________________ Reflection Info _______________________________________ #ifdef REFLECTION
<mask> surfaceRefractionColor = toLinearSpace(surfaceRefractionColor.rgb); <mask> #endif <mask> #endif <mask> <mask> // Reflection <mask> vec3 environmentRadiance = vReflectionColor.rgb; <mask> vec3 environmentIrradiance = vReflectionColor.rgb; <mask> <mask> #ifdef REFLECTION <mask> vec3 vReflectionUVW = computeReflectionCoords(vec4(vPositionW, 1.0), normalW); </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove #ifdef REFLECTION </s> add </s> remove // Bump </s> add </s> remove #ifdef REFLECTIONMAP_3D uniform samplerCube reflectionCubeSampler; #else uniform sampler2D reflection2DSampler; #endif </s> add #ifdef REFLECTIONMAP_SKYBOX varying vec3 vPositionUVW; #else #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) varying vec3 vDirectionW; #endif
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
<mask> <mask> // Reflection <mask> vec3 environmentRadiance = vReflectionColor.rgb; <mask> vec3 environmentIrradiance = vReflectionColor.rgb; <mask> <mask> #ifdef REFLECTION <mask> vec3 vReflectionUVW = computeReflectionCoords(vec4(vPositionW, 1.0), normalW); <mask> <mask> #ifdef LODBASEDMICROSFURACE <mask> #ifdef USEPMREMREFLECTION <mask> float lodReflection = getMipMapIndexFromAverageSlopeWithPMREM(vMicrosurfaceTextureLods.x, alphaG); </s> image processing to material integration Former-commit-id: 6f831aa9b68d14576abec6488e88ca588f2468b3 </s> remove // Reflection </s> add // _____________________________ Reflection Info _______________________________________ #ifdef REFLECTION </s> remove lightingInfo info; float shadow = 1.; // 1 - shadowLevel #include<lightFragment>[0..maxSimultaneousLights] vec3 lightDiffuseContribution = diffuseBase; #ifdef SPECULARTERM vec3 lightSpecularContribution = specularBase * vLightingIntensity.w; #endif #ifdef OPACITY vec4 opacityMap = texture2D(opacitySampler, vOpacityUV + uvOffset); </s> add #ifdef ALPHATEST if (alpha <= ALPHATESTVALUE) discard; </s> remove #ifdef VERTEXALPHA alpha *= vColor.a; #endif #ifdef OPACITYFRESNEL float opacityFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, opacityParts.z, opacityParts.w); alpha += opacityParts.x * (1.0 - opacityFresnelTerm) + opacityFresnelTerm * opacityParts.y; #endif // Refraction vec3 surfaceRefractionColor = vec3(0., 0., 0.); // Go mat -> blurry reflexion according to microSurface </s> add // _____________________________ Compute LODs Fetch ____________________________________
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f4b3f860b0ff0c111ea13cd3960c2c72ea597882
src/Shaders/pbr.fragment.fx
if (this._showUI && this._isClickInsideRect(clientRect.left * this._ratio + centerX - 5, clientRect.top * this._ratio + centerY - labelOffset - 12, textMetrics.width + 10, 17)) {
<mask> var centerX = projectedPosition.x - textMetrics.width / 2; <mask> var centerY = projectedPosition.y; <mask> var clientRect = this._drawingCanvas.getBoundingClientRect(); <mask> <mask> if (this._isClickInsideRect(clientRect.left * this._ratio + centerX - 5, clientRect.top * this._ratio + centerY - labelOffset - 12, textMetrics.width + 10, 17)) { <mask> onClick(); <mask> } <mask> <mask> this._drawingContext.beginPath(); <mask> this._drawingContext.rect(centerX - 5, centerY - labelOffset - 12, textMetrics.width + 10, 17); </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove if (this._isClickInsideRect(clientRect.left * this._ratio + centerX - 5, clientRect.top * this._ratio + centerY - labelOffset - 12, textMetrics.width + 10, 17)) { </s> add if (this._showUI && this._isClickInsideRect(clientRect.left * this._ratio + centerX - 5, clientRect.top * this._ratio + centerY - labelOffset - 12, textMetrics.width + 10, 17)) { </s> remove return clamp(variance / (variance + d * d) - 0.2, 0., 1.0); </s> add return clamp(variance / (variance + d * d) - offset, 0., 1.0); </s> remove float computeShadowWithVSM(vec4 vPositionFromLight, sampler2D shadowSampler) </s> add float computeShadowWithVSM(vec4 vPositionFromLight, sampler2D shadowSampler, float offset) </s> remove shadowMapPixelShader:"#ifdef GL_ES\nprecision highp float;\n#endif\n\nvec4 pack(float depth)\n{\n const vec4 bitOffset = vec4(255. * 255. * 255., 255. * 255., 255., 1.);\n const vec4 bitMask = vec4(0., 1. / 255., 1. / 255., 1. / 255.);\n \n vec4 comp = mod(depth * bitOffset * vec4(255.), vec4(255.)) / vec4(255.);\n comp -= comp.xxyz * bitMask;\n \n return comp;\n}\n\n// Thanks to http://devmaster.net/\nvec2 packHalf(float depth) \n{ \n const vec2 bitOffset = vec2(1.0 / 255., 0.);\n vec2 color = vec2(depth, fract(depth * 255.));\n\n return color - (color.yy * bitOffset);\n}\n\n#ifndef VSM\nvarying vec4 vPosition;\n#endif\n\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n\nvoid main(void)\n{\n#ifdef ALPHATEST\n if (texture2D(diffuseSampler, vUV).a < 0.4)\n discard;\n#endif\n\n#ifdef VSM\n float moment1 = gl_FragCoord.z;\n float moment2 = moment1 * moment1;\n gl_FragColor = vec4(packHalf(moment1), packHalf(moment2));\n#else\n gl_FragColor = pack(vPosition.z / vPosition.w);\n#endif\n}", </s> add shadowMapPixelShader:"#ifdef GL_ES\nprecision highp float;\n#endif\n\nvec4 pack(float depth)\n{\n const vec4 bit_shift = vec4(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0);\n const vec4 bit_mask = vec4(0.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0);\n\n vec4 res = fract(depth * bit_shift);\n res -= res.xxyz * bit_mask;\n\n return res;\n}\n\n// Thanks to http://devmaster.net/\nvec2 packHalf(float depth) \n{ \n const vec2 bitOffset = vec2(1.0 / 255., 0.);\n vec2 color = vec2(depth, fract(depth * 255.));\n\n return color - (color.yy * bitOffset);\n}\n\n#ifndef VSM\nvarying vec4 vPosition;\n#endif\n\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n\nvoid main(void)\n{\n#ifdef ALPHATEST\n if (texture2D(diffuseSampler, vUV).a < 0.4)\n discard;\n#endif\n\n#ifdef VSM\n float moment1 = gl_FragCoord.z;\n float moment2 = moment1 * moment1;\n gl_FragColor = vec4(packHalf(moment1), packHalf(moment2));\n#else\n gl_FragColor = pack(vPosition.z / vPosition.w);\n#endif\n}", </s> remove defaultPixelShader:"#ifdef GL_ES\nprecision highp float;\n#endif\n\n#define MAP_EXPLICIT 0.\n#define MAP_SPHERICAL 1.\n#define MAP_PLANAR 2.\n#define MAP_CUBIC 3.\n#define MAP_PROJECTION 4.\n#define MAP_SKYBOX 5.\n\n// Constants\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vDiffuseColor;\nuniform vec4 vSpecularColor;\nuniform vec3 vEmissiveColor;\n\n// Input\nvarying vec3 vPositionW;\n\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n// Lights\n#ifdef LIGHT0\nuniform vec4 vLightData0;\nuniform vec4 vLightDiffuse0;\nuniform vec3 vLightSpecular0;\n#ifdef SHADOW0\nvarying vec4 vPositionFromLight0;\nuniform sampler2D shadowSampler0;\nuniform vec3 shadowsInfo0;\n#endif\n#ifdef SPOTLIGHT0\nuniform vec4 vLightDirection0;\n#endif\n#ifdef HEMILIGHT0\nuniform vec3 vLightGround0;\n#endif\n#endif\n\n#ifdef LIGHT1\nuniform vec4 vLightData1;\nuniform vec4 vLightDiffuse1;\nuniform vec3 vLightSpecular1;\n#ifdef SHADOW1\nvarying vec4 vPositionFromLight1;\nuniform sampler2D shadowSampler1;\nuniform vec3 shadowsInfo1;\n#endif\n#ifdef SPOTLIGHT1\nuniform vec4 vLightDirection1;\n#endif\n#ifdef HEMILIGHT1\nuniform vec3 vLightGround1;\n#endif\n#endif\n\n#ifdef LIGHT2\nuniform vec4 vLightData2;\nuniform vec4 vLightDiffuse2;\nuniform vec3 vLightSpecular2;\n#ifdef SHADOW2\nvarying vec4 vPositionFromLight2;\nuniform sampler2D shadowSampler2;\nuniform vec3 shadowsInfo2;\n#endif\n#ifdef SPOTLIGHT2\nuniform vec4 vLightDirection2;\n#endif\n#ifdef HEMILIGHT2\nuniform vec3 vLightGround2;\n#endif\n#endif\n\n#ifdef LIGHT3\nuniform vec4 vLightData3;\nuniform vec4 vLightDiffuse3;\nuniform vec3 vLightSpecular3;\n#ifdef SHADOW3\nvarying vec4 vPositionFromLight3;\nuniform sampler2D shadowSampler3;\nuniform vec3 shadowsInfo3;\n#endif\n#ifdef SPOTLIGHT3\nuniform vec4 vLightDirection3;\n#endif\n#ifdef HEMILIGHT3\nuniform vec3 vLightGround3;\n#endif\n#endif\n\n// Samplers\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n\n#ifdef AMBIENT\nvarying vec2 vAmbientUV;\nuniform sampler2D ambientSampler;\nuniform vec2 vAmbientInfos;\n#endif\n\n#ifdef OPACITY \nvarying vec2 vOpacityUV;\nuniform sampler2D opacitySampler;\nuniform vec2 vOpacityInfos;\n#endif\n\n#ifdef EMISSIVE\nvarying vec2 vEmissiveUV;\nuniform vec2 vEmissiveInfos;\nuniform sampler2D emissiveSampler;\n#endif\n\n#ifdef SPECULAR\nvarying vec2 vSpecularUV;\nuniform vec2 vSpecularInfos;\nuniform sampler2D specularSampler;\n#endif\n\n// Fresnel\n#ifdef FRESNEL\nfloat computeFresnelTerm(vec3 viewDirection, vec3 worldNormal, float bias, float power)\n{\n float fresnelTerm = pow(bias + abs(dot(viewDirection, worldNormal)), power);\n return clamp(fresnelTerm, 0., 1.);\n}\n#endif\n\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n\n// Reflection\n#ifdef REFLECTION\nvarying vec3 vPositionUVW;\nuniform samplerCube reflectionCubeSampler;\nuniform sampler2D reflection2DSampler;\nuniform vec3 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform mat4 view;\n\nvec3 computeReflectionCoords(float mode, vec4 worldPos, vec3 worldNormal)\n{\n if (mode == MAP_SPHERICAL)\n {\n vec3 coords = vec3(view * vec4(worldNormal, 0.0));\n\n return vec3(reflectionMatrix * vec4(coords, 1.0));\n }\n else if (mode == MAP_PLANAR)\n {\n vec3 viewDir = worldPos.xyz - vEyePosition;\n vec3 coords = normalize(reflect(viewDir, worldNormal));\n\n return vec3(reflectionMatrix * vec4(coords, 1));\n }\n else if (mode == MAP_CUBIC)\n {\n vec3 viewDir = worldPos.xyz - vEyePosition;\n vec3 coords = reflect(viewDir, worldNormal);\n\n return vec3(reflectionMatrix * vec4(coords, 0));\n }\n else if (mode == MAP_PROJECTION)\n {\n return vec3(reflectionMatrix * (view * worldPos));\n }\n else if (mode == MAP_SKYBOX)\n {\n return vPositionUVW;\n }\n\n return vec3(0, 0, 0);\n}\n#endif\n\n// Shadows\n#ifdef SHADOWS\n\nfloat unpack(vec4 color)\n{\n const vec4 bitShift = vec4(1. / (255. * 255. * 255.), 1. / (255. * 255.), 1. / 255., 1.);\n return dot(color, bitShift);\n}\n\nfloat unpackHalf(vec2 color)\n{\n return color.x + (color.y / 255.0);\n}\n\nfloat computeShadow(vec4 vPositionFromLight, sampler2D shadowSampler, float darkness, float bias)\n{\n vec3 depth = vPositionFromLight.xyz / vPositionFromLight.w;\n vec2 uv = 0.5 * depth.xy + vec2(0.5, 0.5);\n\n if (uv.x < 0. || uv.x > 1.0 || uv.y < 0. || uv.y > 1.0)\n {\n return 1.0;\n }\n\n float shadow = unpack(texture2D(shadowSampler, uv)) + bias;\n\n if (depth.z > shadow)\n {\n return darkness;\n }\n return 1.;\n}\n\nfloat computeShadowWithPCF(vec4 vPositionFromLight, sampler2D shadowSampler, float mapSize, float bias)\n{\n vec3 depth = vPositionFromLight.xyz / vPositionFromLight.w;\n vec2 uv = 0.5 * depth.xy + vec2(0.5, 0.5);\n\n if (uv.x < 0. || uv.x > 1.0 || uv.y < 0. || uv.y > 1.0)\n {\n return 1.0;\n }\n\n float visibility = 1.;\n\n vec2 poissonDisk[4];\n poissonDisk[0] = vec2(-0.94201624, -0.39906216);\n poissonDisk[1] = vec2(0.94558609, -0.76890725);\n poissonDisk[2] = vec2(-0.094184101, -0.92938870);\n poissonDisk[3] = vec2(0.34495938, 0.29387760);\n\n // Poisson Sampling\n if (unpack(texture2D(shadowSampler, uv + poissonDisk[0] / mapSize)) + bias < depth.z) visibility -= 0.25;\n if (unpack(texture2D(shadowSampler, uv + poissonDisk[1] / mapSize)) + bias < depth.z) visibility -= 0.25;\n if (unpack(texture2D(shadowSampler, uv + poissonDisk[2] / mapSize)) + bias < depth.z) visibility -= 0.25;\n if (unpack(texture2D(shadowSampler, uv + poissonDisk[3] / mapSize)) + bias < depth.z) visibility -= 0.25;\n\n return visibility;\n}\n\n// Thanks to http://devmaster.net/\nfloat ChebychevInequality(vec2 moments, float t)\n{\n if (t <= moments.x)\n {\n return 1.0;\n }\n\n float variance = moments.y - (moments.x * moments.x);\n variance = max(variance, 0.02);\n\n float d = t - moments.x;\n return clamp(variance / (variance + d * d) - 0.2, 0., 1.0);\n}\n\nfloat computeShadowWithVSM(vec4 vPositionFromLight, sampler2D shadowSampler)\n{\n vec3 depth = vPositionFromLight.xyz / vPositionFromLight.w;\n vec2 uv = 0.5 * depth.xy + vec2(0.5, 0.5);\n\n if (uv.x < 0. || uv.x > 1.0 || uv.y < 0. || uv.y > 1.0 || depth.z > 1.0)\n {\n return 1.0;\n }\n\n vec4 texel = texture2D(shadowSampler, uv);\n\n vec2 moments = vec2(unpackHalf(texel.xy), unpackHalf(texel.zw));\n return 1.0 - ChebychevInequality(moments, depth.z);\n}\n#endif\n\n// Bump\n#ifdef BUMP\n#extension GL_OES_standard_derivatives : enable\nvarying vec2 vBumpUV;\nuniform vec2 vBumpInfos;\nuniform sampler2D bumpSampler;\n\n// Thanks to http://www.thetenthplanet.de/archives/1180\nmat3 cotangent_frame(vec3 normal, vec3 p, vec2 uv)\n{\n // get edge vectors of the pixel triangle\n vec3 dp1 = dFdx(p);\n vec3 dp2 = dFdy(p);\n vec2 duv1 = dFdx(uv);\n vec2 duv2 = dFdy(uv);\n\n // solve the linear system\n vec3 dp2perp = cross(dp2, normal);\n vec3 dp1perp = cross(normal, dp1);\n vec3 tangent = dp2perp * duv1.x + dp1perp * duv2.x;\n vec3 binormal = dp2perp * duv1.y + dp1perp * duv2.y;\n\n // construct a scale-invariant frame \n float invmax = inversesqrt(max(dot(tangent, tangent), dot(binormal, binormal)));\n return mat3(tangent * invmax, binormal * invmax, normal);\n}\n\nvec3 perturbNormal(vec3 viewDir)\n{\n vec3 map = texture2D(bumpSampler, vBumpUV).xyz;\n map = map * 255. / 127. - 128. / 127.;\n mat3 TBN = cotangent_frame(vNormalW * vBumpInfos.y, -viewDir, vBumpUV);\n return normalize(TBN * map);\n}\n#endif\n\n#ifdef CLIPPLANE\nvarying float fClipDistance;\n#endif\n\n// Fog\n#ifdef FOG\n\n#define FOGMODE_NONE 0.\n#define FOGMODE_EXP 1.\n#define FOGMODE_EXP2 2.\n#define FOGMODE_LINEAR 3.\n#define E 2.71828\n\nuniform vec4 vFogInfos;\nuniform vec3 vFogColor;\nvarying float fFogDistance;\n\nfloat CalcFogFactor()\n{\n float fogCoeff = 1.0;\n float fogStart = vFogInfos.y;\n float fogEnd = vFogInfos.z;\n float fogDensity = vFogInfos.w;\n\n if (FOGMODE_LINEAR == vFogInfos.x)\n {\n fogCoeff = (fogEnd - fFogDistance) / (fogEnd - fogStart);\n }\n else if (FOGMODE_EXP == vFogInfos.x)\n {\n fogCoeff = 1.0 / pow(E, fFogDistance * fogDensity);\n }\n else if (FOGMODE_EXP2 == vFogInfos.x)\n {\n fogCoeff = 1.0 / pow(E, fFogDistance * fFogDistance * fogDensity * fogDensity);\n }\n\n return clamp(fogCoeff, 0.0, 1.0);\n}\n#endif\n\n// Light Computing\nstruct lightingInfo\n{\n vec3 diffuse;\n vec3 specular;\n};\n\nlightingInfo computeLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec3 diffuseColor, vec3 specularColor, float range) {\n lightingInfo result;\n\n vec3 lightVectorW;\n float attenuation = 1.0;\n if (lightData.w == 0.)\n {\n vec3 direction = lightData.xyz - vPositionW;\n\n attenuation = max(0., 1.0 - length(direction) / range);\n lightVectorW = normalize(direction);\n }\n else\n {\n lightVectorW = normalize(-lightData.xyz);\n }\n\n // diffuse\n float ndl = max(0., dot(vNormal, lightVectorW));\n\n // Specular\n vec3 angleW = normalize(viewDirectionW + lightVectorW);\n float specComp = max(0., dot(vNormal, angleW));\n specComp = pow(specComp, max(1., vSpecularColor.a));\n\n result.diffuse = ndl * diffuseColor * attenuation;\n result.specular = specComp * specularColor * attenuation;\n\n return result;\n}\n\nlightingInfo computeSpotLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec4 lightDirection, vec3 diffuseColor, vec3 specularColor, float range) {\n lightingInfo result;\n\n vec3 direction = lightData.xyz - vPositionW;\n vec3 lightVectorW = normalize(direction);\n float attenuation = max(0., 1.0 - length(direction) / range);\n\n // diffuse\n float cosAngle = max(0., dot(-lightDirection.xyz, lightVectorW));\n float spotAtten = 0.0;\n\n if (cosAngle >= lightDirection.w)\n {\n cosAngle = max(0., pow(cosAngle, lightData.w));\n spotAtten = clamp((cosAngle - lightDirection.w) / (1. - cosAngle), 0.0, 1.0);\n\n // Diffuse\n float ndl = max(0., dot(vNormal, -lightDirection.xyz));\n\n // Specular\n vec3 angleW = normalize(viewDirectionW - lightDirection.xyz);\n float specComp = max(0., dot(vNormal, angleW));\n specComp = pow(specComp, vSpecularColor.a);\n\n result.diffuse = ndl * spotAtten * diffuseColor * attenuation;\n result.specular = specComp * specularColor * spotAtten * attenuation;\n\n return result;\n }\n\n result.diffuse = vec3(0.);\n result.specular = vec3(0.);\n\n return result;\n}\n\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec3 diffuseColor, vec3 specularColor, vec3 groundColor) {\n lightingInfo result;\n\n // Diffuse\n float ndl = dot(vNormal, lightData.xyz) * 0.5 + 0.5;\n\n // Specular\n vec3 angleW = normalize(viewDirectionW + lightData.xyz);\n float specComp = max(0., dot(vNormal, angleW));\n specComp = pow(specComp, vSpecularColor.a);\n\n result.diffuse = mix(groundColor, diffuseColor, ndl);\n result.specular = specComp * specularColor;\n\n return result;\n}\n\nvoid main(void) {\n // Clip plane\n#ifdef CLIPPLANE\n if (fClipDistance > 0.0)\n discard;\n#endif\n\n vec3 viewDirectionW = normalize(vEyePosition - vPositionW);\n\n // Base color\n vec4 baseColor = vec4(1., 1., 1., 1.);\n vec3 diffuseColor = vDiffuseColor.rgb;\n\n // Alpha\n float alpha = vDiffuseColor.a;\n\n#ifdef VERTEXCOLOR\n baseColor.rgb *= vColor.rgb;\n#endif\n\n#ifdef DIFFUSE\n baseColor = texture2D(diffuseSampler, vDiffuseUV);\n\n#ifdef ALPHATEST\n if (baseColor.a < 0.4)\n discard;\n#endif\n\n#ifdef ALPHAFROMDIFFUSE\n alpha *= baseColor.a;\n#endif\n\n baseColor.rgb *= vDiffuseInfos.y;\n#endif\n\n // Bump\n#ifdef NORMAL\n vec3 normalW = normalize(vNormalW);\n#else\n vec3 normalW = vec3(1.0, 1.0, 1.0);\n#endif\n\n\n#ifdef BUMP\n normalW = perturbNormal(viewDirectionW);\n#endif\n\n\n // Ambient color\n vec3 baseAmbientColor = vec3(1., 1., 1.);\n\n#ifdef AMBIENT\n baseAmbientColor = texture2D(ambientSampler, vAmbientUV).rgb * vAmbientInfos.y;\n#endif\n\n // Lighting\n vec3 diffuseBase = vec3(0., 0., 0.);\n vec3 specularBase = vec3(0., 0., 0.);\n float shadow = 1.;\n\n#ifdef LIGHT0\n#ifdef SPOTLIGHT0\n lightingInfo info = computeSpotLighting(viewDirectionW, normalW, vLightData0, vLightDirection0, vLightDiffuse0.rgb, vLightSpecular0, vLightDiffuse0.a);\n#endif\n#ifdef HEMILIGHT0\n lightingInfo info = computeHemisphericLighting(viewDirectionW, normalW, vLightData0, vLightDiffuse0.rgb, vLightSpecular0, vLightGround0);\n#endif\n#ifdef POINTDIRLIGHT0\n lightingInfo info = computeLighting(viewDirectionW, normalW, vLightData0, vLightDiffuse0.rgb, vLightSpecular0, vLightDiffuse0.a);\n#endif\n#ifdef SHADOW0\n#ifdef SHADOWVSM0\n shadow = computeShadowWithVSM(vPositionFromLight0, shadowSampler0);\n#else\n #ifdef SHADOWPCF0\n shadow = computeShadowWithPCF(vPositionFromLight0, shadowSampler0, shadowsInfo0.y, shadowsInfo0.z);\n #else\n shadow = computeShadow(vPositionFromLight0, shadowSampler0, shadowsInfo0.x, shadowsInfo0.z);\n #endif\n#endif\n#else\n shadow = 1.;\n#endif\n diffuseBase += info.diffuse * shadow;\n specularBase += info.specular * shadow;\n#endif\n\n#ifdef LIGHT1\n#ifdef SPOTLIGHT1\n info = computeSpotLighting(viewDirectionW, normalW, vLightData1, vLightDirection1, vLightDiffuse1.rgb, vLightSpecular1, vLightDiffuse1.a);\n#endif\n#ifdef HEMILIGHT1\n info = computeHemisphericLighting(viewDirectionW, normalW, vLightData1, vLightDiffuse1.rgb, vLightSpecular1, vLightGround1);\n#endif\n#ifdef POINTDIRLIGHT1\n info = computeLighting(viewDirectionW, normalW, vLightData1, vLightDiffuse1.rgb, vLightSpecular1, vLightDiffuse1.a);\n#endif\n#ifdef SHADOW1\n#ifdef SHADOWVSM1\n shadow = computeShadowWithVSM(vPositionFromLight1, shadowSampler1);\n#else\n #ifdef SHADOWPCF1\n shadow = computeShadowWithPCF(vPositionFromLight1, shadowSampler1, shadowsInfo1.y, shadowsInfo1.z);\n #else\n shadow = computeShadow(vPositionFromLight1, shadowSampler1, shadowsInfo1.x, shadowsInfo1.z);\n #endif\n#endif\n#else\n shadow = 1.;\n#endif\n diffuseBase += info.diffuse * shadow;\n specularBase += info.specular * shadow;\n#endif\n\n#ifdef LIGHT2\n#ifdef SPOTLIGHT2\n info = computeSpotLighting(viewDirectionW, normalW, vLightData2, vLightDirection2, vLightDiffuse2.rgb, vLightSpecular2, vLightDiffuse2.a);\n#endif\n#ifdef HEMILIGHT2\n info = computeHemisphericLighting(viewDirectionW, normalW, vLightData2, vLightDiffuse2.rgb, vLightSpecular2, vLightGround2);\n#endif\n#ifdef POINTDIRLIGHT2\n info = computeLighting(viewDirectionW, normalW, vLightData2, vLightDiffuse2.rgb, vLightSpecular2, vLightDiffuse2.a);\n#endif\n#ifdef SHADOW2\n#ifdef SHADOWVSM2\n shadow = computeShadowWithVSM(vPositionFromLight2, shadowSampler2);\n#else\n #ifdef SHADOWPCF2\n shadow = computeShadowWithPCF(vPositionFromLight2, shadowSampler2, shadowsInfo2.y, shadowsInfo2.z);\n #else\n shadow = computeShadow(vPositionFromLight2, shadowSampler2, shadowsInfo2.x, shadowsInfo2.z);\n #endif \n#endif \n#else\n shadow = 1.;\n#endif\n diffuseBase += info.diffuse * shadow;\n specularBase += info.specular * shadow;\n#endif\n\n#ifdef LIGHT3\n#ifdef SPOTLIGHT3\n info = computeSpotLighting(viewDirectionW, normalW, vLightData3, vLightDirection3, vLightDiffuse3.rgb, vLightSpecular3, vLightDiffuse3.a);\n#endif\n#ifdef HEMILIGHT3\n info = computeHemisphericLighting(viewDirectionW, normalW, vLightData3, vLightDiffuse3.rgb, vLightSpecular3, vLightGround3);\n#endif\n#ifdef POINTDIRLIGHT3\n info = computeLighting(viewDirectionW, normalW, vLightData3, vLightDiffuse3.rgb, vLightSpecular3, vLightDiffuse3.a);\n#endif\n#ifdef SHADOW3\n#ifdef SHADOWVSM3\n shadow = computeShadowWithVSM(vPositionFromLight3, shadowSampler3);\n#else\n #ifdef SHADOWPCF3\n shadow = computeShadowWithPCF(vPositionFromLight3, shadowSampler3, shadowsInfo3.y, shadowsInfo3.z);\n #else\n shadow = computeShadow(vPositionFromLight3, shadowSampler3, shadowsInfo3.x, shadowsInfo3.z);\n #endif \n#endif \n#else\n shadow = 1.;\n#endif\n diffuseBase += info.diffuse * shadow;\n specularBase += info.specular * shadow;\n#endif\n\n // Reflection\n vec3 reflectionColor = vec3(0., 0., 0.);\n\n#ifdef REFLECTION\n vec3 vReflectionUVW = computeReflectionCoords(vReflectionInfos.x, vec4(vPositionW, 1.0), normalW);\n\n if (vReflectionInfos.z != 0.0)\n {\n reflectionColor = textureCube(reflectionCubeSampler, vReflectionUVW).rgb * vReflectionInfos.y * shadow;\n }\n else\n {\n vec2 coords = vReflectionUVW.xy;\n\n if (vReflectionInfos.x == MAP_PROJECTION)\n {\n coords /= vReflectionUVW.z;\n }\n\n coords.y = 1.0 - coords.y;\n\n reflectionColor = texture2D(reflection2DSampler, coords).rgb * vReflectionInfos.y * shadow;\n }\n\n#ifdef REFLECTIONFRESNEL\n float reflectionFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, reflectionRightColor.a, reflectionLeftColor.a);\n\n reflectionColor *= reflectionLeftColor.rgb * (1.0 - reflectionFresnelTerm) + reflectionFresnelTerm * reflectionRightColor.rgb;\n#endif\n#endif\n\n#ifdef OPACITY\n vec4 opacityMap = texture2D(opacitySampler, vOpacityUV);\n\n#ifdef OPACITYRGB\n opacityMap.rgb = opacityMap.rgb * vec3(0.3, 0.59, 0.11);\n alpha *= (opacityMap.x + opacityMap.y + opacityMap.z)* vOpacityInfos.y;\n#else\n alpha *= opacityMap.a * vOpacityInfos.y;\n#endif\n\n#endif\n\n#ifdef VERTEXALPHA\n alpha *= vColor.a;\n#endif\n\n#ifdef OPACITYFRESNEL\n float opacityFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, opacityParts.z, opacityParts.w);\n\n alpha += opacityParts.x * (1.0 - opacityFresnelTerm) + opacityFresnelTerm * opacityParts.y;\n#endif\n\n // Emissive\n vec3 emissiveColor = vEmissiveColor;\n#ifdef EMISSIVE\n emissiveColor += texture2D(emissiveSampler, vEmissiveUV).rgb * vEmissiveInfos.y;\n#endif\n\n#ifdef EMISSIVEFRESNEL\n float emissiveFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, emissiveRightColor.a, emissiveLeftColor.a);\n\n emissiveColor *= emissiveLeftColor.rgb * (1.0 - emissiveFresnelTerm) + emissiveFresnelTerm * emissiveRightColor.rgb;\n#endif\n\n // Specular map\n vec3 specularColor = vSpecularColor.rgb;\n#ifdef SPECULAR\n specularColor = texture2D(specularSampler, vSpecularUV).rgb * vSpecularInfos.y;\n#endif\n\n // Fresnel\n#ifdef DIFFUSEFRESNEL\n float diffuseFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, diffuseRightColor.a, diffuseLeftColor.a);\n\n diffuseBase *= diffuseLeftColor.rgb * (1.0 - diffuseFresnelTerm) + diffuseFresnelTerm * diffuseRightColor.rgb;\n#endif\n\n // Composition\n vec3 finalDiffuse = clamp(diffuseBase * diffuseColor + emissiveColor + vAmbientColor, 0.0, 1.0) * baseColor.rgb;\n vec3 finalSpecular = specularBase * specularColor;\n\n#ifdef SPECULAROVERALPHA\n alpha = clamp(alpha + dot(finalSpecular, vec3(0.3, 0.59, 0.11)), 0., 1.);\n#endif\n\n vec4 color = vec4(finalDiffuse * baseAmbientColor + finalSpecular + reflectionColor, alpha);\n\n#ifdef FOG\n float fog = CalcFogFactor();\n color.rgb = fog * color.rgb + (1.0 - fog) * vFogColor;\n#endif\n\n gl_FragColor = color;\n}", </s> add defaultPixelShader:"#ifdef GL_ES\nprecision highp float;\n#endif\n\n#define MAP_EXPLICIT 0.\n#define MAP_SPHERICAL 1.\n#define MAP_PLANAR 2.\n#define MAP_CUBIC 3.\n#define MAP_PROJECTION 4.\n#define MAP_SKYBOX 5.\n\n// Constants\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vDiffuseColor;\nuniform vec4 vSpecularColor;\nuniform vec3 vEmissiveColor;\n\n// Input\nvarying vec3 vPositionW;\n\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n// Lights\n#ifdef LIGHT0\nuniform vec4 vLightData0;\nuniform vec4 vLightDiffuse0;\nuniform vec3 vLightSpecular0;\n#ifdef SHADOW0\nvarying vec4 vPositionFromLight0;\nuniform sampler2D shadowSampler0;\nuniform vec4 shadowsInfo0;\n#endif\n#ifdef SPOTLIGHT0\nuniform vec4 vLightDirection0;\n#endif\n#ifdef HEMILIGHT0\nuniform vec3 vLightGround0;\n#endif\n#endif\n\n#ifdef LIGHT1\nuniform vec4 vLightData1;\nuniform vec4 vLightDiffuse1;\nuniform vec3 vLightSpecular1;\n#ifdef SHADOW1\nvarying vec4 vPositionFromLight1;\nuniform sampler2D shadowSampler1;\nuniform vec4 shadowsInfo1;\n#endif\n#ifdef SPOTLIGHT1\nuniform vec4 vLightDirection1;\n#endif\n#ifdef HEMILIGHT1\nuniform vec3 vLightGround1;\n#endif\n#endif\n\n#ifdef LIGHT2\nuniform vec4 vLightData2;\nuniform vec4 vLightDiffuse2;\nuniform vec3 vLightSpecular2;\n#ifdef SHADOW2\nvarying vec4 vPositionFromLight2;\nuniform sampler2D shadowSampler2;\nuniform vec4 shadowsInfo2;\n#endif\n#ifdef SPOTLIGHT2\nuniform vec4 vLightDirection2;\n#endif\n#ifdef HEMILIGHT2\nuniform vec3 vLightGround2;\n#endif\n#endif\n\n#ifdef LIGHT3\nuniform vec4 vLightData3;\nuniform vec4 vLightDiffuse3;\nuniform vec3 vLightSpecular3;\n#ifdef SHADOW3\nvarying vec4 vPositionFromLight3;\nuniform sampler2D shadowSampler3;\nuniform vec4 shadowsInfo3;\n#endif\n#ifdef SPOTLIGHT3\nuniform vec4 vLightDirection3;\n#endif\n#ifdef HEMILIGHT3\nuniform vec3 vLightGround3;\n#endif\n#endif\n\n// Samplers\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n\n#ifdef AMBIENT\nvarying vec2 vAmbientUV;\nuniform sampler2D ambientSampler;\nuniform vec2 vAmbientInfos;\n#endif\n\n#ifdef OPACITY \nvarying vec2 vOpacityUV;\nuniform sampler2D opacitySampler;\nuniform vec2 vOpacityInfos;\n#endif\n\n#ifdef EMISSIVE\nvarying vec2 vEmissiveUV;\nuniform vec2 vEmissiveInfos;\nuniform sampler2D emissiveSampler;\n#endif\n\n#ifdef SPECULAR\nvarying vec2 vSpecularUV;\nuniform vec2 vSpecularInfos;\nuniform sampler2D specularSampler;\n#endif\n\n// Fresnel\n#ifdef FRESNEL\nfloat computeFresnelTerm(vec3 viewDirection, vec3 worldNormal, float bias, float power)\n{\n float fresnelTerm = pow(bias + abs(dot(viewDirection, worldNormal)), power);\n return clamp(fresnelTerm, 0., 1.);\n}\n#endif\n\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n\n// Reflection\n#ifdef REFLECTION\nvarying vec3 vPositionUVW;\nuniform samplerCube reflectionCubeSampler;\nuniform sampler2D reflection2DSampler;\nuniform vec3 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform mat4 view;\n\nvec3 computeReflectionCoords(float mode, vec4 worldPos, vec3 worldNormal)\n{\n if (mode == MAP_SPHERICAL)\n {\n vec3 coords = vec3(view * vec4(worldNormal, 0.0));\n\n return vec3(reflectionMatrix * vec4(coords, 1.0));\n }\n else if (mode == MAP_PLANAR)\n {\n vec3 viewDir = worldPos.xyz - vEyePosition;\n vec3 coords = normalize(reflect(viewDir, worldNormal));\n\n return vec3(reflectionMatrix * vec4(coords, 1));\n }\n else if (mode == MAP_CUBIC)\n {\n vec3 viewDir = worldPos.xyz - vEyePosition;\n vec3 coords = reflect(viewDir, worldNormal);\n\n return vec3(reflectionMatrix * vec4(coords, 0));\n }\n else if (mode == MAP_PROJECTION)\n {\n return vec3(reflectionMatrix * (view * worldPos));\n }\n else if (mode == MAP_SKYBOX)\n {\n return vPositionUVW;\n }\n\n return vec3(0, 0, 0);\n}\n#endif\n\n// Shadows\n#ifdef SHADOWS\n\nfloat unpack(vec4 color)\n{\n const vec4 bit_shift = vec4(1.0 / (255.0 * 255.0 * 255.0), 1.0 / (255.0 * 255.0), 1.0 / 255.0, 1.0);\n return dot(color, bit_shift);\n}\n\nfloat unpackHalf(vec2 color)\n{\n return color.x + (color.y / 255.0);\n}\n\nfloat computeShadow(vec4 vPositionFromLight, sampler2D shadowSampler, float darkness, float bias)\n{\n vec3 depth = vPositionFromLight.xyz / vPositionFromLight.w;\n vec2 uv = 0.5 * depth.xy + vec2(0.5, 0.5);\n\n if (uv.x < 0. || uv.x > 1.0 || uv.y < 0. || uv.y > 1.0)\n {\n return 1.0;\n }\n\n float shadow = unpack(texture2D(shadowSampler, uv)) + bias;\n\n if (depth.z > shadow)\n {\n return darkness;\n }\n return 1.;\n}\n\nfloat computeShadowWithPCF(vec4 vPositionFromLight, sampler2D shadowSampler, float mapSize, float bias)\n{\n vec3 depth = vPositionFromLight.xyz / vPositionFromLight.w;\n vec2 uv = 0.5 * depth.xy + vec2(0.5, 0.5);\n\n if (uv.x < 0. || uv.x > 1.0 || uv.y < 0. || uv.y > 1.0)\n {\n return 1.0;\n }\n\n float visibility = 1.;\n\n vec2 poissonDisk[4];\n poissonDisk[0] = vec2(-0.94201624, -0.39906216);\n poissonDisk[1] = vec2(0.94558609, -0.76890725);\n poissonDisk[2] = vec2(-0.094184101, -0.92938870);\n poissonDisk[3] = vec2(0.34495938, 0.29387760);\n\n // Poisson Sampling\n if (unpack(texture2D(shadowSampler, uv + poissonDisk[0] / mapSize)) + bias < depth.z) visibility -= 0.25;\n if (unpack(texture2D(shadowSampler, uv + poissonDisk[1] / mapSize)) + bias < depth.z) visibility -= 0.25;\n if (unpack(texture2D(shadowSampler, uv + poissonDisk[2] / mapSize)) + bias < depth.z) visibility -= 0.25;\n if (unpack(texture2D(shadowSampler, uv + poissonDisk[3] / mapSize)) + bias < depth.z) visibility -= 0.25;\n\n return visibility;\n}\n\n// Thanks to http://devmaster.net/\nfloat ChebychevInequality(vec2 moments, float t, float offset)\n{\n if (t <= moments.x)\n {\n return 1.0;\n }\n\n float variance = moments.y - (moments.x * moments.x);\n variance = max(variance, 0.02);\n\n float d = t - moments.x;\n return clamp(variance / (variance + d * d) - offset, 0., 1.0);\n}\n\nfloat computeShadowWithVSM(vec4 vPositionFromLight, sampler2D shadowSampler, float offset)\n{\n vec3 depth = vPositionFromLight.xyz / vPositionFromLight.w;\n vec2 uv = 0.5 * depth.xy + vec2(0.5, 0.5);\n\n if (uv.x < 0. || uv.x > 1.0 || uv.y < 0. || uv.y > 1.0 || depth.z > 1.0)\n {\n return 1.0;\n }\n\n vec4 texel = texture2D(shadowSampler, uv);\n\n vec2 moments = vec2(unpackHalf(texel.xy), unpackHalf(texel.zw));\n return 1.0 - ChebychevInequality(moments, depth.z, offset);\n}\n#endif\n\n// Bump\n#ifdef BUMP\n#extension GL_OES_standard_derivatives : enable\nvarying vec2 vBumpUV;\nuniform vec2 vBumpInfos;\nuniform sampler2D bumpSampler;\n\n// Thanks to http://www.thetenthplanet.de/archives/1180\nmat3 cotangent_frame(vec3 normal, vec3 p, vec2 uv)\n{\n // get edge vectors of the pixel triangle\n vec3 dp1 = dFdx(p);\n vec3 dp2 = dFdy(p);\n vec2 duv1 = dFdx(uv);\n vec2 duv2 = dFdy(uv);\n\n // solve the linear system\n vec3 dp2perp = cross(dp2, normal);\n vec3 dp1perp = cross(normal, dp1);\n vec3 tangent = dp2perp * duv1.x + dp1perp * duv2.x;\n vec3 binormal = dp2perp * duv1.y + dp1perp * duv2.y;\n\n // construct a scale-invariant frame \n float invmax = inversesqrt(max(dot(tangent, tangent), dot(binormal, binormal)));\n return mat3(tangent * invmax, binormal * invmax, normal);\n}\n\nvec3 perturbNormal(vec3 viewDir)\n{\n vec3 map = texture2D(bumpSampler, vBumpUV).xyz;\n map = map * 255. / 127. - 128. / 127.;\n mat3 TBN = cotangent_frame(vNormalW * vBumpInfos.y, -viewDir, vBumpUV);\n return normalize(TBN * map);\n}\n#endif\n\n#ifdef CLIPPLANE\nvarying float fClipDistance;\n#endif\n\n// Fog\n#ifdef FOG\n\n#define FOGMODE_NONE 0.\n#define FOGMODE_EXP 1.\n#define FOGMODE_EXP2 2.\n#define FOGMODE_LINEAR 3.\n#define E 2.71828\n\nuniform vec4 vFogInfos;\nuniform vec3 vFogColor;\nvarying float fFogDistance;\n\nfloat CalcFogFactor()\n{\n float fogCoeff = 1.0;\n float fogStart = vFogInfos.y;\n float fogEnd = vFogInfos.z;\n float fogDensity = vFogInfos.w;\n\n if (FOGMODE_LINEAR == vFogInfos.x)\n {\n fogCoeff = (fogEnd - fFogDistance) / (fogEnd - fogStart);\n }\n else if (FOGMODE_EXP == vFogInfos.x)\n {\n fogCoeff = 1.0 / pow(E, fFogDistance * fogDensity);\n }\n else if (FOGMODE_EXP2 == vFogInfos.x)\n {\n fogCoeff = 1.0 / pow(E, fFogDistance * fFogDistance * fogDensity * fogDensity);\n }\n\n return clamp(fogCoeff, 0.0, 1.0);\n}\n#endif\n\n// Light Computing\nstruct lightingInfo\n{\n vec3 diffuse;\n vec3 specular;\n};\n\nlightingInfo computeLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec3 diffuseColor, vec3 specularColor, float range) {\n lightingInfo result;\n\n vec3 lightVectorW;\n float attenuation = 1.0;\n if (lightData.w == 0.)\n {\n vec3 direction = lightData.xyz - vPositionW;\n\n attenuation = max(0., 1.0 - length(direction) / range);\n lightVectorW = normalize(direction);\n }\n else\n {\n lightVectorW = normalize(-lightData.xyz);\n }\n\n // diffuse\n float ndl = max(0., dot(vNormal, lightVectorW));\n\n // Specular\n vec3 angleW = normalize(viewDirectionW + lightVectorW);\n float specComp = max(0., dot(vNormal, angleW));\n specComp = pow(specComp, max(1., vSpecularColor.a));\n\n result.diffuse = ndl * diffuseColor * attenuation;\n result.specular = specComp * specularColor * attenuation;\n\n return result;\n}\n\nlightingInfo computeSpotLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec4 lightDirection, vec3 diffuseColor, vec3 specularColor, float range) {\n lightingInfo result;\n\n vec3 direction = lightData.xyz - vPositionW;\n vec3 lightVectorW = normalize(direction);\n float attenuation = max(0., 1.0 - length(direction) / range);\n\n // diffuse\n float cosAngle = max(0., dot(-lightDirection.xyz, lightVectorW));\n float spotAtten = 0.0;\n\n if (cosAngle >= lightDirection.w)\n {\n cosAngle = max(0., pow(cosAngle, lightData.w));\n spotAtten = clamp((cosAngle - lightDirection.w) / (1. - cosAngle), 0.0, 1.0);\n\n // Diffuse\n float ndl = max(0., dot(vNormal, -lightDirection.xyz));\n\n // Specular\n vec3 angleW = normalize(viewDirectionW - lightDirection.xyz);\n float specComp = max(0., dot(vNormal, angleW));\n specComp = pow(specComp, vSpecularColor.a);\n\n result.diffuse = ndl * spotAtten * diffuseColor * attenuation;\n result.specular = specComp * specularColor * spotAtten * attenuation;\n\n return result;\n }\n\n result.diffuse = vec3(0.);\n result.specular = vec3(0.);\n\n return result;\n}\n\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec3 diffuseColor, vec3 specularColor, vec3 groundColor) {\n lightingInfo result;\n\n // Diffuse\n float ndl = dot(vNormal, lightData.xyz) * 0.5 + 0.5;\n\n // Specular\n vec3 angleW = normalize(viewDirectionW + lightData.xyz);\n float specComp = max(0., dot(vNormal, angleW));\n specComp = pow(specComp, vSpecularColor.a);\n\n result.diffuse = mix(groundColor, diffuseColor, ndl);\n result.specular = specComp * specularColor;\n\n return result;\n}\n\nvoid main(void) {\n // Clip plane\n#ifdef CLIPPLANE\n if (fClipDistance > 0.0)\n discard;\n#endif\n\n vec3 viewDirectionW = normalize(vEyePosition - vPositionW);\n\n // Base color\n vec4 baseColor = vec4(1., 1., 1., 1.);\n vec3 diffuseColor = vDiffuseColor.rgb;\n\n // Alpha\n float alpha = vDiffuseColor.a;\n\n#ifdef VERTEXCOLOR\n baseColor.rgb *= vColor.rgb;\n#endif\n\n#ifdef DIFFUSE\n baseColor = texture2D(diffuseSampler, vDiffuseUV);\n\n#ifdef ALPHATEST\n if (baseColor.a < 0.4)\n discard;\n#endif\n\n#ifdef ALPHAFROMDIFFUSE\n alpha *= baseColor.a;\n#endif\n\n baseColor.rgb *= vDiffuseInfos.y;\n#endif\n\n // Bump\n#ifdef NORMAL\n vec3 normalW = normalize(vNormalW);\n#else\n vec3 normalW = vec3(1.0, 1.0, 1.0);\n#endif\n\n\n#ifdef BUMP\n normalW = perturbNormal(viewDirectionW);\n#endif\n\n\n // Ambient color\n vec3 baseAmbientColor = vec3(1., 1., 1.);\n\n#ifdef AMBIENT\n baseAmbientColor = texture2D(ambientSampler, vAmbientUV).rgb * vAmbientInfos.y;\n#endif\n\n // Lighting\n vec3 diffuseBase = vec3(0., 0., 0.);\n vec3 specularBase = vec3(0., 0., 0.);\n float shadow = 1.;\n\n#ifdef LIGHT0\n#ifdef SPOTLIGHT0\n lightingInfo info = computeSpotLighting(viewDirectionW, normalW, vLightData0, vLightDirection0, vLightDiffuse0.rgb, vLightSpecular0, vLightDiffuse0.a);\n#endif\n#ifdef HEMILIGHT0\n lightingInfo info = computeHemisphericLighting(viewDirectionW, normalW, vLightData0, vLightDiffuse0.rgb, vLightSpecular0, vLightGround0);\n#endif\n#ifdef POINTDIRLIGHT0\n lightingInfo info = computeLighting(viewDirectionW, normalW, vLightData0, vLightDiffuse0.rgb, vLightSpecular0, vLightDiffuse0.a);\n#endif\n#ifdef SHADOW0\n#ifdef SHADOWVSM0\n shadow = computeShadowWithVSM(vPositionFromLight0, shadowSampler0, shadowsInfo0.w);\n#else\n #ifdef SHADOWPCF0\n shadow = computeShadowWithPCF(vPositionFromLight0, shadowSampler0, shadowsInfo0.y, shadowsInfo0.z);\n #else\n shadow = computeShadow(vPositionFromLight0, shadowSampler0, shadowsInfo0.x, shadowsInfo0.z);\n #endif\n#endif\n#else\n shadow = 1.;\n#endif\n diffuseBase += info.diffuse * shadow;\n specularBase += info.specular * shadow;\n#endif\n\n#ifdef LIGHT1\n#ifdef SPOTLIGHT1\n info = computeSpotLighting(viewDirectionW, normalW, vLightData1, vLightDirection1, vLightDiffuse1.rgb, vLightSpecular1, vLightDiffuse1.a);\n#endif\n#ifdef HEMILIGHT1\n info = computeHemisphericLighting(viewDirectionW, normalW, vLightData1, vLightDiffuse1.rgb, vLightSpecular1, vLightGround1);\n#endif\n#ifdef POINTDIRLIGHT1\n info = computeLighting(viewDirectionW, normalW, vLightData1, vLightDiffuse1.rgb, vLightSpecular1, vLightDiffuse1.a);\n#endif\n#ifdef SHADOW1\n#ifdef SHADOWVSM1\n shadow = computeShadowWithVSM(vPositionFromLight1, shadowSampler1, shadowsInfo1.w);\n#else\n #ifdef SHADOWPCF1\n shadow = computeShadowWithPCF(vPositionFromLight1, shadowSampler1, shadowsInfo1.y, shadowsInfo1.z);\n #else\n shadow = computeShadow(vPositionFromLight1, shadowSampler1, shadowsInfo1.x, shadowsInfo1.z);\n #endif\n#endif\n#else\n shadow = 1.;\n#endif\n diffuseBase += info.diffuse * shadow;\n specularBase += info.specular * shadow;\n#endif\n\n#ifdef LIGHT2\n#ifdef SPOTLIGHT2\n info = computeSpotLighting(viewDirectionW, normalW, vLightData2, vLightDirection2, vLightDiffuse2.rgb, vLightSpecular2, vLightDiffuse2.a);\n#endif\n#ifdef HEMILIGHT2\n info = computeHemisphericLighting(viewDirectionW, normalW, vLightData2, vLightDiffuse2.rgb, vLightSpecular2, vLightGround2);\n#endif\n#ifdef POINTDIRLIGHT2\n info = computeLighting(viewDirectionW, normalW, vLightData2, vLightDiffuse2.rgb, vLightSpecular2, vLightDiffuse2.a);\n#endif\n#ifdef SHADOW2\n#ifdef SHADOWVSM2\n shadow = computeShadowWithVSM(vPositionFromLight2, shadowSampler2, shadowsInfo2.w);\n#else\n #ifdef SHADOWPCF2\n shadow = computeShadowWithPCF(vPositionFromLight2, shadowSampler2, shadowsInfo2.y, shadowsInfo2.z);\n #else\n shadow = computeShadow(vPositionFromLight2, shadowSampler2, shadowsInfo2.x, shadowsInfo2.z);\n #endif \n#endif \n#else\n shadow = 1.;\n#endif\n diffuseBase += info.diffuse * shadow;\n specularBase += info.specular * shadow;\n#endif\n\n#ifdef LIGHT3\n#ifdef SPOTLIGHT3\n info = computeSpotLighting(viewDirectionW, normalW, vLightData3, vLightDirection3, vLightDiffuse3.rgb, vLightSpecular3, vLightDiffuse3.a);\n#endif\n#ifdef HEMILIGHT3\n info = computeHemisphericLighting(viewDirectionW, normalW, vLightData3, vLightDiffuse3.rgb, vLightSpecular3, vLightGround3);\n#endif\n#ifdef POINTDIRLIGHT3\n info = computeLighting(viewDirectionW, normalW, vLightData3, vLightDiffuse3.rgb, vLightSpecular3, vLightDiffuse3.a);\n#endif\n#ifdef SHADOW3\n#ifdef SHADOWVSM3\n shadow = computeShadowWithVSM(vPositionFromLight3, shadowSampler3, shadowsInfo3.w);\n#else\n #ifdef SHADOWPCF3\n shadow = computeShadowWithPCF(vPositionFromLight3, shadowSampler3, shadowsInfo3.y, shadowsInfo3.z);\n #else\n shadow = computeShadow(vPositionFromLight3, shadowSampler3, shadowsInfo3.x, shadowsInfo3.z);\n #endif \n#endif \n#else\n shadow = 1.;\n#endif\n diffuseBase += info.diffuse * shadow;\n specularBase += info.specular * shadow;\n#endif\n\n // Reflection\n vec3 reflectionColor = vec3(0., 0., 0.);\n\n#ifdef REFLECTION\n vec3 vReflectionUVW = computeReflectionCoords(vReflectionInfos.x, vec4(vPositionW, 1.0), normalW);\n\n if (vReflectionInfos.z != 0.0)\n {\n reflectionColor = textureCube(reflectionCubeSampler, vReflectionUVW).rgb * vReflectionInfos.y * shadow;\n }\n else\n {\n vec2 coords = vReflectionUVW.xy;\n\n if (vReflectionInfos.x == MAP_PROJECTION)\n {\n coords /= vReflectionUVW.z;\n }\n\n coords.y = 1.0 - coords.y;\n\n reflectionColor = texture2D(reflection2DSampler, coords).rgb * vReflectionInfos.y * shadow;\n }\n\n#ifdef REFLECTIONFRESNEL\n float reflectionFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, reflectionRightColor.a, reflectionLeftColor.a);\n\n reflectionColor *= reflectionLeftColor.rgb * (1.0 - reflectionFresnelTerm) + reflectionFresnelTerm * reflectionRightColor.rgb;\n#endif\n#endif\n\n#ifdef OPACITY\n vec4 opacityMap = texture2D(opacitySampler, vOpacityUV);\n\n#ifdef OPACITYRGB\n opacityMap.rgb = opacityMap.rgb * vec3(0.3, 0.59, 0.11);\n alpha *= (opacityMap.x + opacityMap.y + opacityMap.z)* vOpacityInfos.y;\n#else\n alpha *= opacityMap.a * vOpacityInfos.y;\n#endif\n\n#endif\n\n#ifdef VERTEXALPHA\n alpha *= vColor.a;\n#endif\n\n#ifdef OPACITYFRESNEL\n float opacityFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, opacityParts.z, opacityParts.w);\n\n alpha += opacityParts.x * (1.0 - opacityFresnelTerm) + opacityFresnelTerm * opacityParts.y;\n#endif\n\n // Emissive\n vec3 emissiveColor = vEmissiveColor;\n#ifdef EMISSIVE\n emissiveColor += texture2D(emissiveSampler, vEmissiveUV).rgb * vEmissiveInfos.y;\n#endif\n\n#ifdef EMISSIVEFRESNEL\n float emissiveFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, emissiveRightColor.a, emissiveLeftColor.a);\n\n emissiveColor *= emissiveLeftColor.rgb * (1.0 - emissiveFresnelTerm) + emissiveFresnelTerm * emissiveRightColor.rgb;\n#endif\n\n // Specular map\n vec3 specularColor = vSpecularColor.rgb;\n#ifdef SPECULAR\n specularColor = texture2D(specularSampler, vSpecularUV).rgb * vSpecularInfos.y;\n#endif\n\n // Fresnel\n#ifdef DIFFUSEFRESNEL\n float diffuseFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, diffuseRightColor.a, diffuseLeftColor.a);\n\n diffuseBase *= diffuseLeftColor.rgb * (1.0 - diffuseFresnelTerm) + diffuseFresnelTerm * diffuseRightColor.rgb;\n#endif\n\n // Composition\n vec3 finalDiffuse = clamp(diffuseBase * diffuseColor + emissiveColor + vAmbientColor, 0.0, 1.0) * baseColor.rgb;\n vec3 finalSpecular = specularBase * specularColor;\n\n#ifdef SPECULAROVERALPHA\n alpha = clamp(alpha + dot(finalSpecular, vec3(0.3, 0.59, 0.11)), 0., 1.);\n#endif\n\n vec4 color = vec4(finalDiffuse * baseAmbientColor + finalSpecular + reflectionColor, alpha);\n\n#ifdef FOG\n float fog = CalcFogFactor();\n color.rgb = fog * color.rgb + (1.0 - fog) * vFogColor;\n#endif\n\n gl_FragColor = color;\n}",
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Debug/babylon.debugLayer.ts
this._scene.unregisterBeforeRender(this._syncData);
<mask> this._enabled = false; <mask> <mask> var engine = this._scene.getEngine(); <mask> <mask> this._scene.unregisterAfterRender(this._syncData); <mask> document.body.removeChild(this._globalDiv); <mask> <mask> window.removeEventListener("resize", this._syncPositions); <mask> <mask> this._scene.forceShowBoundingBoxes = false; </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove this._scene.unregisterAfterRender(this._syncData); </s> add this._scene.unregisterBeforeRender(this._syncData); </s> remove PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture) { var postProcesses = this._scene.activeCamera._postProcesses; </s> add PostProcessManager.prototype.directRender = function (postProcesses, targetTexture) { var engine = this._scene.getEngine(); for (var index = 0; index < postProcesses.length; index++) { if (index < postProcesses.length - 1) { postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture); } else { if (targetTexture) { engine.bindFramebuffer(targetTexture); } else { engine.restoreDefaultFramebuffer(); } } var pp = postProcesses[index]; var effect = pp.apply(); if (effect) { if (pp.onBeforeRender) { pp.onBeforeRender(effect); } // VBOs engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect); // Draw order engine.draw(true, 0, 6); } } // Restore depth buffer engine.setDepthBuffer(true); engine.setDepthWrite(true); }; PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, postProcesses) { postProcesses = postProcesses || this._scene.activeCamera._postProcesses; </s> remove PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture) { var postProcesses = this._scene.activeCamera._postProcesses; </s> add PostProcessManager.prototype.directRender = function (postProcesses, targetTexture) { var engine = this._scene.getEngine(); for (var index = 0; index < postProcesses.length; index++) { if (index < postProcesses.length - 1) { postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture); } else { if (targetTexture) { engine.bindFramebuffer(targetTexture); } else { engine.restoreDefaultFramebuffer(); } } var pp = postProcesses[index]; var effect = pp.apply(); if (effect) { if (pp.onBeforeRender) { pp.onBeforeRender(effect); } // VBOs engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect); // Draw order engine.draw(true, 0, 6); } } // Restore depth buffer engine.setDepthBuffer(true); engine.setDepthWrite(true); }; PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, postProcesses) { postProcesses = postProcesses || this._scene.activeCamera._postProcesses; </s> remove public _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture): void { var postProcesses = this._scene.activeCamera._postProcesses; </s> add public directRender(postProcesses: PostProcess[], targetTexture?: WebGLTexture): void { var engine = this._scene.getEngine(); for (var index = 0; index < postProcesses.length; index++) { if (index < postProcesses.length - 1) { postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture); } else { if (targetTexture) { engine.bindFramebuffer(targetTexture); } else { engine.restoreDefaultFramebuffer(); } } var pp = postProcesses[index]; var effect = pp.apply(); if (effect) { if (pp.onBeforeRender) { pp.onBeforeRender(effect); } // VBOs engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect); // Draw order engine.draw(true, 0, 6); } } // Restore depth buffer engine.setDepthBuffer(true); engine.setDepthWrite(true); } public _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture, postProcesses?: PostProcess[]): void { postProcesses = postProcesses || this._scene.activeCamera._postProcesses;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Debug/babylon.debugLayer.ts
this._scene.registerBeforeRender(this._syncData);
<mask> window.addEventListener("resize", this._syncPositions); <mask> engine.getRenderingCanvas().addEventListener("click", this._onCanvasClick); <mask> <mask> this._syncPositions(); <mask> this._scene.registerAfterRender(this._syncData); <mask> } <mask> <mask> private _clearLabels(): void { <mask> this._drawingContext.clearRect(0, 0, this._drawingCanvas.width, this._drawingCanvas.height); <mask> </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove this._scene.registerAfterRender(this._syncData); </s> add this._scene.registerBeforeRender(this._syncData); </s> remove public _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture): void { var postProcesses = this._scene.activeCamera._postProcesses; </s> add public directRender(postProcesses: PostProcess[], targetTexture?: WebGLTexture): void { var engine = this._scene.getEngine(); for (var index = 0; index < postProcesses.length; index++) { if (index < postProcesses.length - 1) { postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture); } else { if (targetTexture) { engine.bindFramebuffer(targetTexture); } else { engine.restoreDefaultFramebuffer(); } } var pp = postProcesses[index]; var effect = pp.apply(); if (effect) { if (pp.onBeforeRender) { pp.onBeforeRender(effect); } // VBOs engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect); // Draw order engine.draw(true, 0, 6); } } // Restore depth buffer engine.setDepthBuffer(true); engine.setDepthWrite(true); } public _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture, postProcesses?: PostProcess[]): void { postProcesses = postProcesses || this._scene.activeCamera._postProcesses; </s> remove public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void { </s> add public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>, useVSM: boolean): void {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Debug/babylon.debugLayer.ts
this.blurSize = 2;
<mask> function ShadowGenerator(mapSize, light) { <mask> var _this = this; <mask> // Members <mask> this.filter = ShadowGenerator.FILTER_NONE; <mask> this._darkness = 0; <mask> this._bias = 0.0001; <mask> this._transparencyShadow = false; <mask> this._viewMatrix = BABYLON.Matrix.Zero(); <mask> this._projectionMatrix = BABYLON.Matrix.Zero(); <mask> this._transformMatrix = BABYLON.Matrix.Zero(); </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/Shadows/babylon.shadowGenerator.js
Object.defineProperty(ShadowGenerator, "FILTER_BLURVARIANCESHADOWMAP", { get: function () { return ShadowGenerator._FILTER_BLURVARIANCESHADOWMAP; }, enumerable: true, configurable: true });
<mask> }, <mask> enumerable: true, <mask> configurable: true <mask> }); <mask> Object.defineProperty(ShadowGenerator.prototype, "useVarianceShadowMap", { <mask> get: function () { <mask> return this.filter === ShadowGenerator.FILTER_VARIANCESHADOWMAP && this._light.supportsVSM(); <mask> }, </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING || (this.filter === ShadowGenerator.FILTER_VARIANCESHADOWMAP && !this._light.supportsVSM()); </s> add return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING; </s> remove return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING || (this.filter === ShadowGenerator.FILTER_VARIANCESHADOWMAP && !this._light.supportsVSM()); </s> add return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/Shadows/babylon.shadowGenerator.js
return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
<mask> configurable: true <mask> }); <mask> Object.defineProperty(ShadowGenerator.prototype, "usePoissonSampling", { <mask> get: function () { <mask> return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING || (this.filter === ShadowGenerator.FILTER_VARIANCESHADOWMAP && !this._light.supportsVSM()); <mask> }, <mask> set: function (value) { <mask> this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE); <mask> }, <mask> enumerable: true, </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING || (this.filter === ShadowGenerator.FILTER_VARIANCESHADOWMAP && !this._light.supportsVSM()); </s> add return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/Shadows/babylon.shadowGenerator.js
Object.defineProperty(ShadowGenerator.prototype, "useBlurVarianceShadowMap", { get: function () { return this.filter === ShadowGenerator.FILTER_BLURVARIANCESHADOWMAP && this._light.supportsVSM(); }, set: function (value) { this.filter = (value ? ShadowGenerator.FILTER_BLURVARIANCESHADOWMAP : ShadowGenerator.FILTER_NONE); }, enumerable: true, configurable: true });
<mask> enumerable: true, <mask> configurable: true <mask> }); <mask> ShadowGenerator.prototype.isReady = function (subMesh, useInstances) { <mask> var defines = []; <mask> if (this.useVarianceShadowMap || this.useBlurVarianceShadowMap) { <mask> defines.push("#define VSM"); <mask> } </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove if (this.useVarianceShadowMap) { </s> add if (this.useVarianceShadowMap || this.useBlurVarianceShadowMap) { </s> remove if (this.useVarianceShadowMap) { </s> add if (this.useVarianceShadowMap || this.useBlurVarianceShadowMap) { </s> remove if (this.useVarianceShadowMap) { </s> add if (this.useVarianceShadowMap || this.useBlurVarianceShadowMap) {
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/Shadows/babylon.shadowGenerator.js
if (this.useVarianceShadowMap || this.useBlurVarianceShadowMap) {
<mask> configurable: true <mask> }); <mask> ShadowGenerator.prototype.isReady = function (subMesh, useInstances) { <mask> var defines = []; <mask> if (this.useVarianceShadowMap) { <mask> defines.push("#define VSM"); <mask> } <mask> var attribs = [BABYLON.VertexBuffer.PositionKind]; <mask> var mesh = subMesh.getMesh(); <mask> var material = subMesh.getMaterial(); </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove if (this.useVarianceShadowMap) { </s> add if (this.useVarianceShadowMap || this.useBlurVarianceShadowMap) { </s> remove if (this.useVarianceShadowMap) { </s> add if (this.useVarianceShadowMap || this.useBlurVarianceShadowMap) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/Shadows/babylon.shadowGenerator.js
ShadowGenerator.prototype.getShadowMapForRendering = function () { if (this._shadowMap2) { return this._shadowMap2; } return this._shadowMap; };
<mask> ShadowGenerator.prototype.getShadowMap = function () { <mask> return this._shadowMap; <mask> }; <mask> ShadowGenerator.prototype.getLight = function () { <mask> return this._light; <mask> }; <mask> // Methods <mask> ShadowGenerator.prototype.getTransformMatrix = function () { <mask> var scene = this._scene; </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove return false; </s> add return true; </s> remove return false; </s> add return true;
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/Shadows/babylon.shadowGenerator.js
this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, this.getShadowMap().renderList, this.filter === ShadowGenerator.FILTER_VARIANCESHADOWMAP || this.filter === ShadowGenerator.FILTER_BLURVARIANCESHADOWMAP);
<mask> if (this._light.needRefreshPerFrame() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !lightDirection.equals(this._cachedDirection)) { <mask> this._cachedPosition = lightPosition.clone(); <mask> this._cachedDirection = lightDirection.clone(); <mask> BABYLON.Matrix.LookAtLHToRef(lightPosition, this._light.position.add(lightDirection), BABYLON.Vector3.Up(), this._viewMatrix); <mask> this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, this.getShadowMap().renderList); <mask> this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix); <mask> } <mask> return this._transformMatrix; <mask> }; <mask> ShadowGenerator.prototype.getDarkness = function () { </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, this.getShadowMap().renderList); </s> add this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, this.getShadowMap().renderList, this.filter === ShadowGenerator.FILTER_VARIANCESHADOWMAP || this.filter === ShadowGenerator.FILTER_BLURVARIANCESHADOWMAP); </s> remove this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, this.getShadowMap().renderList); </s> add this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, this.getShadowMap().renderList, this.filter === ShadowGenerator.FILTER_VARIANCESHADOWMAP || this.filter === ShadowGenerator.FILTER_BLURVARIANCESHADOWMAP); </s> remove PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture) { var postProcesses = this._scene.activeCamera._postProcesses; </s> add PostProcessManager.prototype.directRender = function (postProcesses, targetTexture) { var engine = this._scene.getEngine(); for (var index = 0; index < postProcesses.length; index++) { if (index < postProcesses.length - 1) { postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture); } else { if (targetTexture) { engine.bindFramebuffer(targetTexture); } else { engine.restoreDefaultFramebuffer(); } } var pp = postProcesses[index]; var effect = pp.apply(); if (effect) { if (pp.onBeforeRender) { pp.onBeforeRender(effect); } // VBOs engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect); // Draw order engine.draw(true, 0, 6); } } // Restore depth buffer engine.setDepthBuffer(true); engine.setDepthWrite(true); }; PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, postProcesses) { postProcesses = postProcesses || this._scene.activeCamera._postProcesses; </s> remove PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture) { var postProcesses = this._scene.activeCamera._postProcesses; </s> add PostProcessManager.prototype.directRender = function (postProcesses, targetTexture) { var engine = this._scene.getEngine(); for (var index = 0; index < postProcesses.length; index++) { if (index < postProcesses.length - 1) { postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture); } else { if (targetTexture) { engine.bindFramebuffer(targetTexture); } else { engine.restoreDefaultFramebuffer(); } } var pp = postProcesses[index]; var effect = pp.apply(); if (effect) { if (pp.onBeforeRender) { pp.onBeforeRender(effect); } // VBOs engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect); // Draw order engine.draw(true, 0, 6); } } // Restore depth buffer engine.setDepthBuffer(true); engine.setDepthWrite(true); }; PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, postProcesses) { postProcesses = postProcesses || this._scene.activeCamera._postProcesses;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/Shadows/babylon.shadowGenerator.js
if (this._shadowMap2) { this._shadowMap2.dispose(); } if (this._downSamplePostprocess) { this._downSamplePostprocess.dispose(); } if (this._boxBlurPostprocess) { this._boxBlurPostprocess.dispose(); }
<mask> this._transparencyShadow = hasShadow; <mask> }; <mask> ShadowGenerator.prototype.dispose = function () { <mask> this._shadowMap.dispose(); <mask> }; <mask> ShadowGenerator._FILTER_NONE = 0; <mask> ShadowGenerator._FILTER_VARIANCESHADOWMAP = 1; <mask> ShadowGenerator._FILTER_POISSONSAMPLING = 2; </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/Shadows/babylon.shadowGenerator.js
ShadowGenerator._FILTER_BLURVARIANCESHADOWMAP = 3;
<mask> }; <mask> ShadowGenerator._FILTER_NONE = 0; <mask> ShadowGenerator._FILTER_VARIANCESHADOWMAP = 1; <mask> ShadowGenerator._FILTER_POISSONSAMPLING = 2; <mask> return ShadowGenerator; <mask> })(); <mask> BABYLON.ShadowGenerator = ShadowGenerator; <mask> })(BABYLON || (BABYLON = {})); </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/Shadows/babylon.shadowGenerator.js
private static _FILTER_BLURVARIANCESHADOWMAP = 3;
<mask> private static _FILTER_VARIANCESHADOWMAP = 1; <mask> private static _FILTER_POISSONSAMPLING = 2; <mask> <mask> // Static <mask> public static get FILTER_NONE(): number { <mask> return ShadowGenerator._FILTER_NONE; <mask> } <mask> </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove public _textures = new BABYLON.SmartArray<WebGLTexture>(2); </s> add public _textures = new SmartArray<WebGLTexture>(2);
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/Shadows/babylon.shadowGenerator.ts
public static get FILTER_BLURVARIANCESHADOWMAP(): number { return ShadowGenerator._FILTER_BLURVARIANCESHADOWMAP; }
<mask> return ShadowGenerator._FILTER_POISSONSAMPLING; <mask> } <mask> <mask> // Members <mask> public filter = ShadowGenerator.FILTER_NONE; <mask> public blurSize = 2; <mask> </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove public _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture): void { var postProcesses = this._scene.activeCamera._postProcesses; </s> add public directRender(postProcesses: PostProcess[], targetTexture?: WebGLTexture): void { var engine = this._scene.getEngine(); for (var index = 0; index < postProcesses.length; index++) { if (index < postProcesses.length - 1) { postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture); } else { if (targetTexture) { engine.bindFramebuffer(targetTexture); } else { engine.restoreDefaultFramebuffer(); } } var pp = postProcesses[index]; var effect = pp.apply(); if (effect) { if (pp.onBeforeRender) { pp.onBeforeRender(effect); } // VBOs engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect); // Draw order engine.draw(true, 0, 6); } } // Restore depth buffer engine.setDepthBuffer(true); engine.setDepthWrite(true); } public _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture, postProcesses?: PostProcess[]): void { postProcesses = postProcesses || this._scene.activeCamera._postProcesses;
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/Shadows/babylon.shadowGenerator.ts
public blurSize = 2;
<mask> <mask> // Members <mask> public filter = ShadowGenerator.FILTER_NONE; <mask> <mask> public get useVarianceShadowMap(): boolean { <mask> return this.filter === ShadowGenerator.FILTER_VARIANCESHADOWMAP && this._light.supportsVSM(); <mask> } <mask> public set useVarianceShadowMap(value: boolean) { </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING || (this.filter === ShadowGenerator.FILTER_VARIANCESHADOWMAP && !this._light.supportsVSM()); </s> add return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/Shadows/babylon.shadowGenerator.ts
return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
<mask> this.filter = (value ? ShadowGenerator.FILTER_VARIANCESHADOWMAP : ShadowGenerator.FILTER_NONE); <mask> } <mask> <mask> public get usePoissonSampling(): boolean { <mask> return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING || (this.filter === ShadowGenerator.FILTER_VARIANCESHADOWMAP && !this._light.supportsVSM()); <mask> } <mask> public set usePoissonSampling(value: boolean) { <mask> this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE); <mask> } <mask> </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING || (this.filter === ShadowGenerator.FILTER_VARIANCESHADOWMAP && !this._light.supportsVSM()); </s> add return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING; </s> remove return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING || (this.filter === ShadowGenerator.FILTER_VARIANCESHADOWMAP && !this._light.supportsVSM()); </s> add return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/Shadows/babylon.shadowGenerator.ts
public get useBlurVarianceShadowMap(): boolean { return this.filter === ShadowGenerator.FILTER_BLURVARIANCESHADOWMAP && this._light.supportsVSM(); } public set useBlurVarianceShadowMap(value: boolean) { this.filter = (value ? ShadowGenerator.FILTER_BLURVARIANCESHADOWMAP : ShadowGenerator.FILTER_NONE); }
<mask> this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE); <mask> } <mask> <mask> private _light: IShadowLight; <mask> private _scene: Scene; <mask> private _shadowMap: RenderTargetTexture; <mask> private _shadowMap2: RenderTargetTexture; <mask> private _darkness = 0; <mask> private _bias = 0.0001; </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove public _textures = new BABYLON.SmartArray<WebGLTexture>(2); </s> add public _textures = new SmartArray<WebGLTexture>(2);
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/Shadows/babylon.shadowGenerator.ts
private _shadowMap2: RenderTargetTexture;
<mask> private _light: IShadowLight; <mask> private _scene: Scene; <mask> private _shadowMap: RenderTargetTexture; <mask> private _darkness = 0; <mask> private _bias = 0.0001; <mask> private _transparencyShadow = false; <mask> private _effect: Effect; <mask> <mask> private _viewMatrix = Matrix.Zero(); </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove public _textures = new BABYLON.SmartArray<WebGLTexture>(2); </s> add public _textures = new SmartArray<WebGLTexture>(2);
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/Shadows/babylon.shadowGenerator.ts
private _downSamplePostprocess: PassPostProcess; private _boxBlurPostprocess: PostProcess;
<mask> private _cachedDirection: Vector3; <mask> private _cachedDefines: string; <mask> private _currentRenderID: number; <mask> <mask> constructor(mapSize: number, light: IShadowLight) { <mask> this._light = light; <mask> this._scene = light.getScene(); <mask> </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove public _textures = new BABYLON.SmartArray<WebGLTexture>(2); </s> add public _textures = new SmartArray<WebGLTexture>(2); </s> remove constructor(public name: string, fragmentUrl: string, parameters: string[], samplers: string[], ratio: number, camera: Camera, samplingMode: number, engine?: Engine, reusable?: boolean, defines?: string) { </s> add constructor(public name: string, fragmentUrl: string, parameters: string[], samplers: string[], ratio: number, camera: Camera, samplingMode: number = Texture.NEAREST_SAMPLINGMODE, engine?: Engine, reusable?: boolean, defines?: string) {
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/Shadows/babylon.shadowGenerator.ts
var index: number;
<mask> } <mask> }; <mask> <mask> this._shadowMap.customRenderFunction = (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>): void => { <mask> var index; <mask> <mask> for (index = 0; index < opaqueSubMeshes.length; index++) { <mask> renderSubMesh(opaqueSubMeshes.data[index]); <mask> } <mask> </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove public _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture): void { var postProcesses = this._scene.activeCamera._postProcesses; </s> add public directRender(postProcesses: PostProcess[], targetTexture?: WebGLTexture): void { var engine = this._scene.getEngine(); for (var index = 0; index < postProcesses.length; index++) { if (index < postProcesses.length - 1) { postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture); } else { if (targetTexture) { engine.bindFramebuffer(targetTexture); } else { engine.restoreDefaultFramebuffer(); } } var pp = postProcesses[index]; var effect = pp.apply(); if (effect) { if (pp.onBeforeRender) { pp.onBeforeRender(effect); } // VBOs engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect); // Draw order engine.draw(true, 0, 6); } } // Restore depth buffer engine.setDepthBuffer(true); engine.setDepthWrite(true); } public _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture, postProcesses?: PostProcess[]): void { postProcesses = postProcesses || this._scene.activeCamera._postProcesses; </s> remove PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture) { var postProcesses = this._scene.activeCamera._postProcesses; </s> add PostProcessManager.prototype.directRender = function (postProcesses, targetTexture) { var engine = this._scene.getEngine(); for (var index = 0; index < postProcesses.length; index++) { if (index < postProcesses.length - 1) { postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture); } else { if (targetTexture) { engine.bindFramebuffer(targetTexture); } else { engine.restoreDefaultFramebuffer(); } } var pp = postProcesses[index]; var effect = pp.apply(); if (effect) { if (pp.onBeforeRender) { pp.onBeforeRender(effect); } // VBOs engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect); // Draw order engine.draw(true, 0, 6); } } // Restore depth buffer engine.setDepthBuffer(true); engine.setDepthWrite(true); }; PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, postProcesses) { postProcesses = postProcesses || this._scene.activeCamera._postProcesses; </s> remove PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture) { var postProcesses = this._scene.activeCamera._postProcesses; </s> add PostProcessManager.prototype.directRender = function (postProcesses, targetTexture) { var engine = this._scene.getEngine(); for (var index = 0; index < postProcesses.length; index++) { if (index < postProcesses.length - 1) { postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture); } else { if (targetTexture) { engine.bindFramebuffer(targetTexture); } else { engine.restoreDefaultFramebuffer(); } } var pp = postProcesses[index]; var effect = pp.apply(); if (effect) { if (pp.onBeforeRender) { pp.onBeforeRender(effect); } // VBOs engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect); // Draw order engine.draw(true, 0, 6); } } // Restore depth buffer engine.setDepthBuffer(true); engine.setDepthWrite(true); }; PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, postProcesses) { postProcesses = postProcesses || this._scene.activeCamera._postProcesses; </s> remove this._scene.registerAfterRender(this._syncData); </s> add this._scene.registerBeforeRender(this._syncData);
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/Shadows/babylon.shadowGenerator.ts
if (this.useVarianceShadowMap || this.useBlurVarianceShadowMap) {
<mask> <mask> public isReady(subMesh: SubMesh, useInstances: boolean): boolean { <mask> var defines = []; <mask> <mask> if (this.useVarianceShadowMap) { <mask> defines.push("#define VSM"); <mask> } <mask> <mask> var attribs = [VertexBuffer.PositionKind]; <mask> </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove if (this.useVarianceShadowMap) { </s> add if (this.useVarianceShadowMap || this.useBlurVarianceShadowMap) { </s> remove if (this.useVarianceShadowMap) { </s> add if (this.useVarianceShadowMap || this.useBlurVarianceShadowMap) { </s> remove public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void { </s> add public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>, useVSM: boolean): void {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/Shadows/babylon.shadowGenerator.ts
public getShadowMapForRendering(): RenderTargetTexture { if (this._shadowMap2) { return this._shadowMap2; } return this._shadowMap; }
<mask> return this._shadowMap; <mask> } <mask> <mask> public getLight(): IShadowLight { <mask> return this._light; <mask> } <mask> </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove return false; </s> add return true; </s> remove public _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture): void { var postProcesses = this._scene.activeCamera._postProcesses; </s> add public directRender(postProcesses: PostProcess[], targetTexture?: WebGLTexture): void { var engine = this._scene.getEngine(); for (var index = 0; index < postProcesses.length; index++) { if (index < postProcesses.length - 1) { postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture); } else { if (targetTexture) { engine.bindFramebuffer(targetTexture); } else { engine.restoreDefaultFramebuffer(); } } var pp = postProcesses[index]; var effect = pp.apply(); if (effect) { if (pp.onBeforeRender) { pp.onBeforeRender(effect); } // VBOs engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect); // Draw order engine.draw(true, 0, 6); } } // Restore depth buffer engine.setDepthBuffer(true); engine.setDepthWrite(true); } public _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture, postProcesses?: PostProcess[]): void { postProcesses = postProcesses || this._scene.activeCamera._postProcesses;
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/Shadows/babylon.shadowGenerator.ts
this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, this.getShadowMap().renderList, this.filter === ShadowGenerator.FILTER_VARIANCESHADOWMAP || this.filter === ShadowGenerator.FILTER_BLURVARIANCESHADOWMAP);
<mask> this._cachedDirection = lightDirection.clone(); <mask> <mask> Matrix.LookAtLHToRef(lightPosition, this._light.position.add(lightDirection), Vector3.Up(), this._viewMatrix); <mask> <mask> this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, this.getShadowMap().renderList); <mask> <mask> this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix); <mask> } <mask> <mask> return this._transformMatrix; </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, this.getShadowMap().renderList); </s> add this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, this.getShadowMap().renderList, this.filter === ShadowGenerator.FILTER_VARIANCESHADOWMAP || this.filter === ShadowGenerator.FILTER_BLURVARIANCESHADOWMAP); </s> remove this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, this.getShadowMap().renderList); </s> add this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, this.getShadowMap().renderList, this.filter === ShadowGenerator.FILTER_VARIANCESHADOWMAP || this.filter === ShadowGenerator.FILTER_BLURVARIANCESHADOWMAP); </s> remove PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture) { var postProcesses = this._scene.activeCamera._postProcesses; </s> add PostProcessManager.prototype.directRender = function (postProcesses, targetTexture) { var engine = this._scene.getEngine(); for (var index = 0; index < postProcesses.length; index++) { if (index < postProcesses.length - 1) { postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture); } else { if (targetTexture) { engine.bindFramebuffer(targetTexture); } else { engine.restoreDefaultFramebuffer(); } } var pp = postProcesses[index]; var effect = pp.apply(); if (effect) { if (pp.onBeforeRender) { pp.onBeforeRender(effect); } // VBOs engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect); // Draw order engine.draw(true, 0, 6); } } // Restore depth buffer engine.setDepthBuffer(true); engine.setDepthWrite(true); }; PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, postProcesses) { postProcesses = postProcesses || this._scene.activeCamera._postProcesses; </s> remove PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture) { var postProcesses = this._scene.activeCamera._postProcesses; </s> add PostProcessManager.prototype.directRender = function (postProcesses, targetTexture) { var engine = this._scene.getEngine(); for (var index = 0; index < postProcesses.length; index++) { if (index < postProcesses.length - 1) { postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture); } else { if (targetTexture) { engine.bindFramebuffer(targetTexture); } else { engine.restoreDefaultFramebuffer(); } } var pp = postProcesses[index]; var effect = pp.apply(); if (effect) { if (pp.onBeforeRender) { pp.onBeforeRender(effect); } // VBOs engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect); // Draw order engine.draw(true, 0, 6); } } // Restore depth buffer engine.setDepthBuffer(true); engine.setDepthWrite(true); }; PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, postProcesses) { postProcesses = postProcesses || this._scene.activeCamera._postProcesses; </s> remove public _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture): void { var postProcesses = this._scene.activeCamera._postProcesses; </s> add public directRender(postProcesses: PostProcess[], targetTexture?: WebGLTexture): void { var engine = this._scene.getEngine(); for (var index = 0; index < postProcesses.length; index++) { if (index < postProcesses.length - 1) { postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture); } else { if (targetTexture) { engine.bindFramebuffer(targetTexture); } else { engine.restoreDefaultFramebuffer(); } } var pp = postProcesses[index]; var effect = pp.apply(); if (effect) { if (pp.onBeforeRender) { pp.onBeforeRender(effect); } // VBOs engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect); // Draw order engine.draw(true, 0, 6); } } // Restore depth buffer engine.setDepthBuffer(true); engine.setDepthWrite(true); } public _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture, postProcesses?: PostProcess[]): void { postProcesses = postProcesses || this._scene.activeCamera._postProcesses;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/Shadows/babylon.shadowGenerator.ts
if (this._shadowMap2) { this._shadowMap2.dispose(); } if (this._downSamplePostprocess) { this._downSamplePostprocess.dispose(); } if (this._boxBlurPostprocess) { this._boxBlurPostprocess.dispose(); }
<mask> } <mask> <mask> public dispose(): void { <mask> this._shadowMap.dispose(); <mask> } <mask> } <mask> } </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove public _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture): void { var postProcesses = this._scene.activeCamera._postProcesses; </s> add public directRender(postProcesses: PostProcess[], targetTexture?: WebGLTexture): void { var engine = this._scene.getEngine(); for (var index = 0; index < postProcesses.length; index++) { if (index < postProcesses.length - 1) { postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture); } else { if (targetTexture) { engine.bindFramebuffer(targetTexture); } else { engine.restoreDefaultFramebuffer(); } } var pp = postProcesses[index]; var effect = pp.apply(); if (effect) { if (pp.onBeforeRender) { pp.onBeforeRender(effect); } // VBOs engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect); // Draw order engine.draw(true, 0, 6); } } // Restore depth buffer engine.setDepthBuffer(true); engine.setDepthWrite(true); } public _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture, postProcesses?: PostProcess[]): void { postProcesses = postProcesses || this._scene.activeCamera._postProcesses; </s> remove public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void { </s> add public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>, useVSM: boolean): void { </s> remove public dispose(camera: Camera): void { </s> add public dispose(camera?: Camera): void {
[ "keep", "keep", "keep", "add", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/Shadows/babylon.shadowGenerator.ts
this.shadowOrthoScale = 1.1; this.shadowOrthoDepthScale = 3;
<mask> _super.call(this, name, scene); <mask> this.direction = direction; <mask> this.position = direction.scale(-1); <mask> } <mask> DirectionalLight.prototype.getAbsolutePosition = function () { <mask> return this.transformedPosition ? this.transformedPosition : this.position; </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove SpotLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) { </s> add SpotLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList, useVSM) { </s> remove SpotLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) { </s> add SpotLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList, useVSM) { </s> remove public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void { </s> add public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>, useVSM: boolean): void {
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/babylon.directionalLight.js
DirectionalLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList, useVSM) {
<mask> DirectionalLight.prototype.setDirectionToTarget = function (target) { <mask> this.direction = BABYLON.Vector3.Normalize(target.subtract(this.position)); <mask> return this.direction; <mask> }; <mask> DirectionalLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) { <mask> var orthoLeft = Number.MAX_VALUE; <mask> var orthoRight = Number.MIN_VALUE; <mask> var orthoTop = Number.MIN_VALUE; <mask> var orthoBottom = Number.MAX_VALUE; <mask> var tempVector3 = BABYLON.Vector3.Zero(); </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove DirectionalLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) { </s> add DirectionalLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList, useVSM) { </s> remove public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void { </s> add public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>, useVSM: boolean): void {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/babylon.directionalLight.js
var orthoNear = Number.MAX_VALUE; var orthoFar = Number.MIN_VALUE;
<mask> var orthoTop = Number.MIN_VALUE; <mask> var orthoBottom = Number.MAX_VALUE; <mask> var tempVector3 = BABYLON.Vector3.Zero(); <mask> var activeCamera = this.getScene().activeCamera; <mask> for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) { <mask> var boundingBox = renderList[meshIndex].getBoundingInfo().boundingBox; <mask> for (var index = 0; index < boundingBox.vectorsWorld.length; index++) { </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove this._scene.registerAfterRender(this._syncData); </s> add this._scene.registerBeforeRender(this._syncData); </s> remove PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture) { var postProcesses = this._scene.activeCamera._postProcesses; </s> add PostProcessManager.prototype.directRender = function (postProcesses, targetTexture) { var engine = this._scene.getEngine(); for (var index = 0; index < postProcesses.length; index++) { if (index < postProcesses.length - 1) { postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture); } else { if (targetTexture) { engine.bindFramebuffer(targetTexture); } else { engine.restoreDefaultFramebuffer(); } } var pp = postProcesses[index]; var effect = pp.apply(); if (effect) { if (pp.onBeforeRender) { pp.onBeforeRender(effect); } // VBOs engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect); // Draw order engine.draw(true, 0, 6); } } // Restore depth buffer engine.setDepthBuffer(true); engine.setDepthWrite(true); }; PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, postProcesses) { postProcesses = postProcesses || this._scene.activeCamera._postProcesses; </s> remove PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture) { var postProcesses = this._scene.activeCamera._postProcesses; </s> add PostProcessManager.prototype.directRender = function (postProcesses, targetTexture) { var engine = this._scene.getEngine(); for (var index = 0; index < postProcesses.length; index++) { if (index < postProcesses.length - 1) { postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture); } else { if (targetTexture) { engine.bindFramebuffer(targetTexture); } else { engine.restoreDefaultFramebuffer(); } } var pp = postProcesses[index]; var effect = pp.apply(); if (effect) { if (pp.onBeforeRender) { pp.onBeforeRender(effect); } // VBOs engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect); // Draw order engine.draw(true, 0, 6); } } // Restore depth buffer engine.setDepthBuffer(true); engine.setDepthWrite(true); }; PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, postProcesses) { postProcesses = postProcesses || this._scene.activeCamera._postProcesses;
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/babylon.directionalLight.js
if (tempVector3.z < orthoNear) orthoNear = tempVector3.z; if (tempVector3.z > orthoFar) orthoFar = tempVector3.z;
<mask> if (tempVector3.x > orthoRight) <mask> orthoRight = tempVector3.x; <mask> if (tempVector3.y > orthoTop) <mask> orthoTop = tempVector3.y; <mask> } <mask> } <mask> var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; <mask> var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * this.shadowOrthoScale; </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * 1.1; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, activeCamera.minZ, activeCamera.maxZ, matrix); </s> add var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * this.shadowOrthoScale; var orthoDepth = Math.max(Math.abs(orthoNear), Math.abs(orthoFar)) * this.shadowOrthoDepthScale; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, useVSM ? -orthoDepth : activeCamera.minZ, orthoDepth, matrix); }; DirectionalLight.prototype.getVSMOffset = function () { return 0.55; </s> remove var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * 1.1; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, activeCamera.minZ, activeCamera.maxZ, matrix); </s> add var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * this.shadowOrthoScale; var orthoDepth = Math.max(Math.abs(orthoNear), Math.abs(orthoFar)) * this.shadowOrthoDepthScale; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, useVSM ? -orthoDepth : activeCamera.minZ, orthoDepth, matrix); }; DirectionalLight.prototype.getVSMOffset = function () { return 0.55; </s> remove var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * 1.1; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; </s> add var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * this.shadowOrthoScale; var orthoDepth = Math.max(Math.abs(orthoNear), Math.abs(orthoFar)) * this.shadowOrthoDepthScale; Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, useVSM ? -orthoDepth : activeCamera.minZ, orthoDepth, matrix); }
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/babylon.directionalLight.js
var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * this.shadowOrthoScale; var orthoDepth = Math.max(Math.abs(orthoNear), Math.abs(orthoFar)) * this.shadowOrthoDepthScale; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, useVSM ? -orthoDepth : activeCamera.minZ, orthoDepth, matrix); }; DirectionalLight.prototype.getVSMOffset = function () { return 0.55;
<mask> if (tempVector3.y > orthoTop) <mask> orthoTop = tempVector3.y; <mask> } <mask> } <mask> var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * 1.1; <mask> var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; <mask> BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, activeCamera.minZ, activeCamera.maxZ, matrix); <mask> }; <mask> DirectionalLight.prototype.supportsVSM = function () { <mask> return false; <mask> }; <mask> DirectionalLight.prototype.needRefreshPerFrame = function () { </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * 1.1; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, activeCamera.minZ, activeCamera.maxZ, matrix); </s> add var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * this.shadowOrthoScale; var orthoDepth = Math.max(Math.abs(orthoNear), Math.abs(orthoFar)) * this.shadowOrthoDepthScale; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, useVSM ? -orthoDepth : activeCamera.minZ, orthoDepth, matrix); }; DirectionalLight.prototype.getVSMOffset = function () { return 0.55; </s> remove var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * 1.1; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; </s> add var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * this.shadowOrthoScale; var orthoDepth = Math.max(Math.abs(orthoNear), Math.abs(orthoFar)) * this.shadowOrthoDepthScale; Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, useVSM ? -orthoDepth : activeCamera.minZ, orthoDepth, matrix); } </s> remove return false; </s> add return true; </s> remove return false; </s> add return true; </s> remove Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, activeCamera.minZ, activeCamera.maxZ, matrix); </s> add public getVSMOffset(): number { return 0.55;
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/babylon.directionalLight.js
return true;
<mask> var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; <mask> BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, activeCamera.minZ, activeCamera.maxZ, matrix); <mask> }; <mask> DirectionalLight.prototype.supportsVSM = function () { <mask> return false; <mask> }; <mask> DirectionalLight.prototype.needRefreshPerFrame = function () { <mask> return true; <mask> }; <mask> DirectionalLight.prototype.computeTransformedPosition = function () { </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove return false; </s> add return true; </s> remove var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * 1.1; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, activeCamera.minZ, activeCamera.maxZ, matrix); </s> add var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * this.shadowOrthoScale; var orthoDepth = Math.max(Math.abs(orthoNear), Math.abs(orthoFar)) * this.shadowOrthoDepthScale; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, useVSM ? -orthoDepth : activeCamera.minZ, orthoDepth, matrix); }; DirectionalLight.prototype.getVSMOffset = function () { return 0.55; </s> remove var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * 1.1; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, activeCamera.minZ, activeCamera.maxZ, matrix); </s> add var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * this.shadowOrthoScale; var orthoDepth = Math.max(Math.abs(orthoNear), Math.abs(orthoFar)) * this.shadowOrthoDepthScale; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, useVSM ? -orthoDepth : activeCamera.minZ, orthoDepth, matrix); }; DirectionalLight.prototype.getVSMOffset = function () { return 0.55; </s> remove var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * 1.1; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; </s> add var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * this.shadowOrthoScale; var orthoDepth = Math.max(Math.abs(orthoNear), Math.abs(orthoFar)) * this.shadowOrthoDepthScale; Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, useVSM ? -orthoDepth : activeCamera.minZ, orthoDepth, matrix); } </s> remove Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, activeCamera.minZ, activeCamera.maxZ, matrix); </s> add public getVSMOffset(): number { return 0.55;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/babylon.directionalLight.js
public shadowOrthoScale = 1.1; public shadowOrthoDepthScale = 3;
<mask> private _transformedDirection: Vector3; <mask> public transformedPosition: Vector3; <mask> private _worldMatrix: Matrix; <mask> <mask> constructor(name: string, public direction: Vector3, scene: Scene) { <mask> super(name, scene); <mask> <mask> this.position = direction.scale(-1); <mask> } </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove public _textures = new BABYLON.SmartArray<WebGLTexture>(2); </s> add public _textures = new SmartArray<WebGLTexture>(2); </s> remove constructor(public name: string, fragmentUrl: string, parameters: string[], samplers: string[], ratio: number, camera: Camera, samplingMode: number, engine?: Engine, reusable?: boolean, defines?: string) { </s> add constructor(public name: string, fragmentUrl: string, parameters: string[], samplers: string[], ratio: number, camera: Camera, samplingMode: number = Texture.NEAREST_SAMPLINGMODE, engine?: Engine, reusable?: boolean, defines?: string) {
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/babylon.directionalLight.ts
public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>, useVSM: boolean): void {
<mask> this.direction = Vector3.Normalize(target.subtract(this.position)); <mask> return this.direction; <mask> } <mask> <mask> public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void { <mask> var orthoLeft = Number.MAX_VALUE; <mask> var orthoRight = Number.MIN_VALUE; <mask> var orthoTop = Number.MIN_VALUE; <mask> var orthoBottom = Number.MAX_VALUE; <mask> </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove DirectionalLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) { </s> add DirectionalLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList, useVSM) { </s> remove DirectionalLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) { </s> add DirectionalLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList, useVSM) { </s> remove public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void { </s> add public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>, useVSM: boolean): void {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/babylon.directionalLight.ts
var orthoNear = Number.MAX_VALUE; var orthoFar = Number.MIN_VALUE;
<mask> var orthoRight = Number.MIN_VALUE; <mask> var orthoTop = Number.MIN_VALUE; <mask> var orthoBottom = Number.MAX_VALUE; <mask> <mask> var tempVector3 = Vector3.Zero(); <mask> <mask> var activeCamera = this.getScene().activeCamera; </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove DirectionalLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) { </s> add DirectionalLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList, useVSM) { </s> remove DirectionalLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) { </s> add DirectionalLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList, useVSM) { </s> remove public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void { </s> add public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>, useVSM: boolean): void {
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/babylon.directionalLight.ts
if (tempVector3.z < orthoNear) orthoNear = tempVector3.z; if (tempVector3.z > orthoFar) orthoFar = tempVector3.z;
<mask> orthoRight = tempVector3.x; <mask> if (tempVector3.y > orthoTop) <mask> orthoTop = tempVector3.y; <mask> } <mask> } <mask> <mask> var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * 1.1; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, activeCamera.minZ, activeCamera.maxZ, matrix); </s> add var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * this.shadowOrthoScale; var orthoDepth = Math.max(Math.abs(orthoNear), Math.abs(orthoFar)) * this.shadowOrthoDepthScale; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, useVSM ? -orthoDepth : activeCamera.minZ, orthoDepth, matrix); }; DirectionalLight.prototype.getVSMOffset = function () { return 0.55; </s> remove var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * 1.1; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, activeCamera.minZ, activeCamera.maxZ, matrix); </s> add var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * this.shadowOrthoScale; var orthoDepth = Math.max(Math.abs(orthoNear), Math.abs(orthoFar)) * this.shadowOrthoDepthScale; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, useVSM ? -orthoDepth : activeCamera.minZ, orthoDepth, matrix); }; DirectionalLight.prototype.getVSMOffset = function () { return 0.55; </s> remove var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * 1.1; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; </s> add var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * this.shadowOrthoScale; var orthoDepth = Math.max(Math.abs(orthoNear), Math.abs(orthoFar)) * this.shadowOrthoDepthScale; Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, useVSM ? -orthoDepth : activeCamera.minZ, orthoDepth, matrix); }
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/babylon.directionalLight.ts
var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * this.shadowOrthoScale; var orthoDepth = Math.max(Math.abs(orthoNear), Math.abs(orthoFar)) * this.shadowOrthoDepthScale; Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, useVSM ? -orthoDepth : activeCamera.minZ, orthoDepth, matrix); }
<mask> orthoTop = tempVector3.y; <mask> } <mask> } <mask> <mask> var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * 1.1; <mask> var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; <mask> <mask> Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, activeCamera.minZ, activeCamera.maxZ, matrix); <mask> } <mask> <mask> public supportsVSM(): boolean { </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, activeCamera.minZ, activeCamera.maxZ, matrix); </s> add public getVSMOffset(): number { return 0.55; </s> remove var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * 1.1; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, activeCamera.minZ, activeCamera.maxZ, matrix); </s> add var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * this.shadowOrthoScale; var orthoDepth = Math.max(Math.abs(orthoNear), Math.abs(orthoFar)) * this.shadowOrthoDepthScale; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, useVSM ? -orthoDepth : activeCamera.minZ, orthoDepth, matrix); }; DirectionalLight.prototype.getVSMOffset = function () { return 0.55; </s> remove var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * 1.1; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, activeCamera.minZ, activeCamera.maxZ, matrix); </s> add var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * this.shadowOrthoScale; var orthoDepth = Math.max(Math.abs(orthoNear), Math.abs(orthoFar)) * this.shadowOrthoDepthScale; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, useVSM ? -orthoDepth : activeCamera.minZ, orthoDepth, matrix); }; DirectionalLight.prototype.getVSMOffset = function () { return 0.55; </s> remove return false; </s> add return true; </s> remove return false; </s> add return true;
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/babylon.directionalLight.ts
public getVSMOffset(): number { return 0.55;
<mask> <mask> var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * 1.1; <mask> var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; <mask> <mask> Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, activeCamera.minZ, activeCamera.maxZ, matrix); <mask> } <mask> <mask> public supportsVSM(): boolean { <mask> return false; <mask> } </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * 1.1; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; </s> add var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * this.shadowOrthoScale; var orthoDepth = Math.max(Math.abs(orthoNear), Math.abs(orthoFar)) * this.shadowOrthoDepthScale; Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, useVSM ? -orthoDepth : activeCamera.minZ, orthoDepth, matrix); } </s> remove var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * 1.1; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, activeCamera.minZ, activeCamera.maxZ, matrix); </s> add var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * this.shadowOrthoScale; var orthoDepth = Math.max(Math.abs(orthoNear), Math.abs(orthoFar)) * this.shadowOrthoDepthScale; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, useVSM ? -orthoDepth : activeCamera.minZ, orthoDepth, matrix); }; DirectionalLight.prototype.getVSMOffset = function () { return 0.55; </s> remove var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * 1.1; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, activeCamera.minZ, activeCamera.maxZ, matrix); </s> add var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * this.shadowOrthoScale; var orthoDepth = Math.max(Math.abs(orthoNear), Math.abs(orthoFar)) * this.shadowOrthoDepthScale; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, useVSM ? -orthoDepth : activeCamera.minZ, orthoDepth, matrix); }; DirectionalLight.prototype.getVSMOffset = function () { return 0.55; </s> remove return false; </s> add return true; </s> remove return false; </s> add return true;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/babylon.directionalLight.ts
return true;
<mask> Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, activeCamera.minZ, activeCamera.maxZ, matrix); <mask> } <mask> <mask> public supportsVSM(): boolean { <mask> return false; <mask> } <mask> <mask> public needRefreshPerFrame(): boolean { <mask> return true; <mask> } </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, activeCamera.minZ, activeCamera.maxZ, matrix); </s> add public getVSMOffset(): number { return 0.55; </s> remove var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * 1.1; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; </s> add var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * this.shadowOrthoScale; var orthoDepth = Math.max(Math.abs(orthoNear), Math.abs(orthoFar)) * this.shadowOrthoDepthScale; Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, useVSM ? -orthoDepth : activeCamera.minZ, orthoDepth, matrix); } </s> remove public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void { </s> add public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>, useVSM: boolean): void { </s> remove var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * 1.1; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, activeCamera.minZ, activeCamera.maxZ, matrix); </s> add var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * this.shadowOrthoScale; var orthoDepth = Math.max(Math.abs(orthoNear), Math.abs(orthoFar)) * this.shadowOrthoDepthScale; BABYLON.Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, useVSM ? -orthoDepth : activeCamera.minZ, orthoDepth, matrix); }; DirectionalLight.prototype.getVSMOffset = function () { return 0.55;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/babylon.directionalLight.ts
setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>, useVSM: boolean): void;
<mask> <mask> computeTransformedPosition(): boolean; <mask> getScene(): Scene; <mask> <mask> setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void; <mask> <mask> supportsVSM(): boolean; <mask> <mask> needRefreshPerFrame(): boolean; <mask> </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void { </s> add public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>, useVSM: boolean): void { </s> remove public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void { </s> add public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>, useVSM: boolean): void { </s> remove return false; </s> add return true;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/babylon.light.ts
getVSMOffset(): number;
<mask> getScene(): Scene; <mask> <mask> setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>, useVSM: boolean): void; <mask> <mask> supportsVSM(): boolean; <mask> needRefreshPerFrame(): boolean; <mask> <mask> _shadowGenerator: ShadowGenerator; <mask> } </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void; </s> add setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>, useVSM: boolean): void; </s> remove public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void { </s> add public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>, useVSM: boolean): void { </s> remove public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void { </s> add public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>, useVSM: boolean): void { </s> remove return false; </s> add return true;
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/babylon.light.ts
SpotLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList, useVSM) {
<mask> } <mask> SpotLight.prototype.getAbsolutePosition = function () { <mask> return this.transformedPosition ? this.transformedPosition : this.position; <mask> }; <mask> SpotLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) { <mask> var activeCamera = this.getScene().activeCamera; <mask> BABYLON.Matrix.PerspectiveFovLHToRef(this.angle, 1.0, activeCamera.minZ, activeCamera.maxZ, matrix); <mask> }; <mask> SpotLight.prototype.supportsVSM = function () { <mask> return true; </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove SpotLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) { </s> add SpotLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList, useVSM) { </s> remove public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void { </s> add public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>, useVSM: boolean): void {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/babylon.spotLight.js
SpotLight.prototype.getVSMOffset = function () { return 0.2; };
<mask> SpotLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList, useVSM) { <mask> var activeCamera = this.getScene().activeCamera; <mask> BABYLON.Matrix.PerspectiveFovLHToRef(this.angle, 1.0, activeCamera.minZ, activeCamera.maxZ, matrix); <mask> }; <mask> SpotLight.prototype.supportsVSM = function () { <mask> return true; <mask> }; <mask> SpotLight.prototype.needRefreshPerFrame = function () { <mask> return false; <mask> }; </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove SpotLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) { </s> add SpotLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList, useVSM) { </s> remove SpotLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) { </s> add SpotLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList, useVSM) { </s> remove return false; </s> add return true; </s> remove return false; </s> add return true;
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/babylon.spotLight.js
public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>, useVSM: boolean): void {
<mask> public getAbsolutePosition(): Vector3 { <mask> return this.transformedPosition ? this.transformedPosition : this.position; <mask> } <mask> <mask> public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void { <mask> var activeCamera = this.getScene().activeCamera; <mask> Matrix.PerspectiveFovLHToRef(this.angle, 1.0, activeCamera.minZ, activeCamera.maxZ, matrix); <mask> } <mask> <mask> public supportsVSM(): boolean { </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void { </s> add public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>, useVSM: boolean): void { </s> remove SpotLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) { </s> add SpotLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList, useVSM) { </s> remove SpotLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) { </s> add SpotLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList, useVSM) { </s> remove setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void; </s> add setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>, useVSM: boolean): void;
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/babylon.spotLight.ts
public getVSMOffset(): number { return 0.2; }
<mask> Matrix.PerspectiveFovLHToRef(this.angle, 1.0, activeCamera.minZ, activeCamera.maxZ, matrix); <mask> } <mask> <mask> public supportsVSM(): boolean { <mask> return true; <mask> } <mask> <mask> public needRefreshPerFrame(): boolean { </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30 </s> remove return false; </s> add return true; </s> remove public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void { </s> add public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>, useVSM: boolean): void { </s> remove Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, activeCamera.minZ, activeCamera.maxZ, matrix); </s> add public getVSMOffset(): number { return 0.55; </s> remove var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * 1.1; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * 1.1; </s> add var orthoWidth = Math.max(Math.abs(orthoRight), Math.abs(orthoLeft)) * this.shadowOrthoScale; var orthoHeight = Math.max(Math.abs(orthoTop), Math.abs(orthoBottom)) * this.shadowOrthoScale; var orthoDepth = Math.max(Math.abs(orthoNear), Math.abs(orthoFar)) * this.shadowOrthoDepthScale; Matrix.OrthoOffCenterLHToRef(-orthoWidth, orthoWidth, -orthoHeight, orthoHeight, useVSM ? -orthoDepth : activeCamera.minZ, orthoDepth, matrix); } </s> remove SpotLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) { </s> add SpotLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList, useVSM) {
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Lights/babylon.spotLight.ts
if (this.onAfterUnbind) { this.onAfterUnbind(); }
<mask> } <mask> // Unbind <mask> engine.unBindFramebuffer(this._texture); <mask> }; <mask> RenderTargetTexture.prototype.clone = function () { <mask> var textureSize = this.getSize(); <mask> var newTexture = new RenderTargetTexture(this.name, textureSize.width, this.getScene(), this._generateMipMaps); </s> new BlurVarianceShadowMap filter for shadows Former-commit-id: 51c82cb03994d5a86948873ffe9249010aacaf30
[ "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/BabylonJS/Babylon.js/commit/f5363ce348e7a18e22435850b2a8e783ebc01fdb
Babylon/Materials/Textures/babylon.renderTargetTexture.js