@galacean/effects-threejs 2.0.0-alpha.6 → 2.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +18 -4
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +3 -3
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +18 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime threejs plugin for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.0.0-alpha.
|
|
6
|
+
* Version: v2.0.0-alpha.7
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -9550,7 +9550,7 @@ var bloomThreshold_frag = "uniform vec4 uColorThreshold;vec4 filterMain(vec2 coo
|
|
|
9550
9550
|
|
|
9551
9551
|
var screenMeshVert = "precision highp float;attribute vec2 aPos;varying vec2 uv;void main(){gl_Position=vec4(aPos,0.,1.0);uv=(aPos+vec2(1.0))/2.;}";
|
|
9552
9552
|
|
|
9553
|
-
var colorGradingFrag = "precision highp float;\n#define HALF_MAX 60000.0\n#define ACEScc_MIDGRAY 0.4135884\nvarying vec2 uv;uniform sampler2D _GaussianTex;uniform sampler2D _SceneTex;uniform float _BloomIntensity;uniform float _Brightness;uniform float _Saturation;uniform float _Contrast;uniform bool _UseBloom;uniform bool _UseToneMapping;mat3 LinearToACES=mat3(0.59719,0.07600,0.02840,0.35458,0.90834,0.13383,0.04823,0.01566,0.83777);mat3 ACESToLinear=mat3(1.60475,-0.10208,-0.00327,-0.53108,1.10813,-0.07276,-0.07367,-0.00605,1.07602);float log10(float x){return log(x)/log(10.0);}vec3 log10(vec3 v){return vec3(log10(v.x),log10(v.y),log10(v.z));}vec3 LinearToLogC(vec3 x){return 0.244161*log10(5.555556*x+0.047996)+0.386036;}vec3 LogCToLinear(vec3 x){return(pow(vec3(10.0),(x-0.386036)/0.244161)-0.047996)/5.555556;}vec3 rrt_and_odt_fit(vec3 col){vec3 a=col*(col+0.0245786)-0.000090537;vec3 b=col*(0.983729*col+0.4329510)+0.238081;return a/b;}vec3 ACESToneMapping(vec3 col){vec3 aces=LinearToACES*col;aces=rrt_and_odt_fit(aces);col=ACESToLinear*aces;return col;}vec3 LinearToSrgb(vec3 c){return mix(1.055*pow(c,vec3(1./2.4))-0.055,12.92*c,step(c,vec3(0.0031308)));}vec3 GammaCorrection(vec3 c){return pow(c,vec3(1.0/2.2));}void main(){vec4 hdrColor=texture2D(_SceneTex,uv);hdrColor.rgb=pow(hdrColor.rgb,vec3(2.2));vec3 finalColor=hdrColor.rgb;if(_UseBloom){vec4 bloomColor=texture2D(_GaussianTex,uv);bloomColor.rgb*=_BloomIntensity;finalColor+=bloomColor.rgb;}finalColor=finalColor*_Brightness;vec3 colorLog=LinearToLogC(finalColor);colorLog=(colorLog-ACEScc_MIDGRAY)*_Contrast+ACEScc_MIDGRAY;finalColor=LogCToLinear(colorLog);finalColor=max(finalColor,0.0);float luminance=0.2125*finalColor.r+0.7154*finalColor.g+0.0721*finalColor.b;vec3 luminanceColor=vec3(luminance,luminance,luminance);finalColor=(finalColor-luminanceColor)*_Saturation+luminanceColor;finalColor=max(finalColor,0.0);if(_UseToneMapping){finalColor=max(vec3(0.0),ACESToneMapping(finalColor));}gl_FragColor=vec4(clamp(GammaCorrection(finalColor),0.0,1.0),1.0);}";
|
|
9553
|
+
var colorGradingFrag = "precision highp float;\n#define HALF_MAX 60000.0\n#define ACEScc_MIDGRAY 0.4135884\nvarying vec2 uv;uniform sampler2D _GaussianTex;uniform sampler2D _SceneTex;uniform float _BloomIntensity;uniform float _Brightness;uniform float _Saturation;uniform float _Contrast;uniform bool _UseBloom;uniform bool _UseToneMapping;uniform vec3 _VignetteColor;uniform vec2 _VignetteCenter;uniform float _VignetteIntensity;uniform float _VignetteSmoothness;uniform float _VignetteRoundness;mat3 LinearToACES=mat3(0.59719,0.07600,0.02840,0.35458,0.90834,0.13383,0.04823,0.01566,0.83777);mat3 ACESToLinear=mat3(1.60475,-0.10208,-0.00327,-0.53108,1.10813,-0.07276,-0.07367,-0.00605,1.07602);float log10(float x){return log(x)/log(10.0);}vec3 log10(vec3 v){return vec3(log10(v.x),log10(v.y),log10(v.z));}vec3 LinearToLogC(vec3 x){return 0.244161*log10(5.555556*x+0.047996)+0.386036;}vec3 LogCToLinear(vec3 x){return(pow(vec3(10.0),(x-0.386036)/0.244161)-0.047996)/5.555556;}vec3 rrt_and_odt_fit(vec3 col){vec3 a=col*(col+0.0245786)-0.000090537;vec3 b=col*(0.983729*col+0.4329510)+0.238081;return a/b;}vec3 ACESToneMapping(vec3 col){vec3 aces=LinearToACES*col;aces=rrt_and_odt_fit(aces);col=ACESToLinear*aces;return col;}vec3 LinearToSrgb(vec3 c){return mix(1.055*pow(c,vec3(1./2.4))-0.055,12.92*c,step(c,vec3(0.0031308)));}vec3 GammaCorrection(vec3 c){return pow(c,vec3(1.0/2.2));}vec3 ApplyVignette(vec3 inputColor,vec2 uv,vec2 center,float intensity,float roundness,float smoothness,vec3 color){vec2 dist=abs(uv-center)*intensity;dist.x*=roundness;float vfactor=pow(clamp((1.0-dot(dist,dist)),0.0,1.0),smoothness);return inputColor*mix(color,vec3(1.0),vfactor);}void main(){vec4 hdrColor=texture2D(_SceneTex,uv);hdrColor.rgb=pow(hdrColor.rgb,vec3(2.2));vec3 finalColor=hdrColor.rgb;if(_UseBloom){vec4 bloomColor=texture2D(_GaussianTex,uv);bloomColor.rgb*=_BloomIntensity;finalColor+=bloomColor.rgb;}if(_VignetteIntensity>0.0){finalColor=ApplyVignette(finalColor,uv,_VignetteCenter,_VignetteIntensity,_VignetteRoundness,_VignetteSmoothness,_VignetteColor);}finalColor=finalColor*_Brightness;vec3 colorLog=LinearToLogC(finalColor);colorLog=(colorLog-ACEScc_MIDGRAY)*_Contrast+ACEScc_MIDGRAY;finalColor=LogCToLinear(colorLog);finalColor=max(finalColor,0.0);float luminance=0.2125*finalColor.r+0.7154*finalColor.g+0.0721*finalColor.b;vec3 luminanceColor=vec3(luminance,luminance,luminance);finalColor=(finalColor-luminanceColor)*_Saturation+luminanceColor;finalColor=max(finalColor,0.0);if(_UseToneMapping){finalColor=max(vec3(0.0),ACESToneMapping(finalColor));}gl_FragColor=vec4(clamp(GammaCorrection(finalColor),0.0,1.0),1.0);}";
|
|
9554
9554
|
|
|
9555
9555
|
var gaussianDown_frag = "precision highp float;varying vec2 uv;uniform sampler2D _MainTex;uniform vec2 _TextureSize;float GaussWeight2D(float x,float y,float sigma){float PI=3.14159265358;float E=2.71828182846;float sigma_2=pow(sigma,2.0);float a=-(x*x+y*y)/(2.0*sigma_2);return pow(E,a)/(2.0*PI*sigma_2);}vec3 GaussNxN(sampler2D tex,vec2 uv,vec2 stride,float sigma){vec3 color=vec3(0.,0.,0.);const int r=5/2;float weight=0.0;for(int i=-r;i<=r;i++){for(int j=-r;j<=r;j++){float w=GaussWeight2D(float(i),float(j),sigma);vec2 coord=uv+vec2(i,j)*stride;color+=texture2D(tex,coord).rgb*w;weight+=w;}}color/=weight;return color;}void main(){vec4 mainColor=texture2D(_MainTex,uv);vec3 color=mainColor.rgb;color=GaussNxN(_MainTex,uv,1.0/_TextureSize,1.0);gl_FragColor=vec4(color,1.0);}";
|
|
9556
9556
|
|
|
@@ -9833,7 +9833,7 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
9833
9833
|
depthAction: exports.TextureStoreAction.clear,
|
|
9834
9834
|
stencilAction: exports.TextureStoreAction.clear
|
|
9835
9835
|
});
|
|
9836
|
-
var _renderer_renderingData_currentFrame_globalVolume = renderer.renderingData.currentFrame.globalVolume, bloomIntensity = _renderer_renderingData_currentFrame_globalVolume.bloomIntensity, brightness = _renderer_renderingData_currentFrame_globalVolume.brightness, saturation = _renderer_renderingData_currentFrame_globalVolume.saturation, contrast = _renderer_renderingData_currentFrame_globalVolume.contrast,
|
|
9836
|
+
var _renderer_renderingData_currentFrame_globalVolume = renderer.renderingData.currentFrame.globalVolume, useBloom = _renderer_renderingData_currentFrame_globalVolume.useBloom, bloomIntensity = _renderer_renderingData_currentFrame_globalVolume.bloomIntensity, brightness = _renderer_renderingData_currentFrame_globalVolume.brightness, saturation = _renderer_renderingData_currentFrame_globalVolume.saturation, contrast = _renderer_renderingData_currentFrame_globalVolume.contrast, useToneMapping = _renderer_renderingData_currentFrame_globalVolume.useToneMapping, vignetteIntensity = _renderer_renderingData_currentFrame_globalVolume.vignetteIntensity, vignetteSmoothness = _renderer_renderingData_currentFrame_globalVolume.vignetteSmoothness, vignetteRoundness = _renderer_renderingData_currentFrame_globalVolume.vignetteRoundness;
|
|
9837
9837
|
this.screenMesh.material.setTexture("_SceneTex", this.sceneTextureHandle.texture);
|
|
9838
9838
|
this.screenMesh.material.setFloat("_Brightness", brightness);
|
|
9839
9839
|
this.screenMesh.material.setFloat("_Saturation", saturation);
|
|
@@ -9843,6 +9843,13 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
9843
9843
|
this.screenMesh.material.setTexture("_GaussianTex", this.mainTexture);
|
|
9844
9844
|
this.screenMesh.material.setFloat("_BloomIntensity", bloomIntensity);
|
|
9845
9845
|
}
|
|
9846
|
+
if (vignetteIntensity > 0) {
|
|
9847
|
+
this.screenMesh.material.setFloat("_VignetteIntensity", vignetteIntensity);
|
|
9848
|
+
this.screenMesh.material.setFloat("_VignetteSmoothness", vignetteSmoothness);
|
|
9849
|
+
this.screenMesh.material.setFloat("_VignetteRoundness", vignetteRoundness);
|
|
9850
|
+
this.screenMesh.material.setVector2("_VignetteCenter", new Vector2(0.5, 0.5));
|
|
9851
|
+
this.screenMesh.material.setVector3("_VignetteColor", new Vector3(0.0, 0.0, 0.0));
|
|
9852
|
+
}
|
|
9846
9853
|
this.screenMesh.material.setInt("_UseToneMapping", useToneMapping);
|
|
9847
9854
|
renderer.renderMeshes([
|
|
9848
9855
|
this.screenMesh
|
|
@@ -9864,6 +9871,12 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
9864
9871
|
brightness: 1.0,
|
|
9865
9872
|
saturation: 1.0,
|
|
9866
9873
|
contrast: 1.0,
|
|
9874
|
+
// Vignette
|
|
9875
|
+
// vignetteColor: new math.Color(0, 0, 0, 1),
|
|
9876
|
+
// vignetteCenter: new math.Vector2(0.5, 0.5),
|
|
9877
|
+
vignetteIntensity: 0.2,
|
|
9878
|
+
vignetteSmoothness: 0.4,
|
|
9879
|
+
vignetteRoundness: 1.0,
|
|
9867
9880
|
// ToneMapping
|
|
9868
9881
|
useToneMapping: 1
|
|
9869
9882
|
};
|
|
@@ -20909,6 +20922,7 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
20909
20922
|
//@ts-expect-error TODO 数据改造后移除 expect-error
|
|
20910
20923
|
transform.position = new Vector3().copyFrom(transform.position);
|
|
20911
20924
|
var _transform_eulerHint;
|
|
20925
|
+
// FIXME: transform.rotation待删除
|
|
20912
20926
|
//@ts-expect-error
|
|
20913
20927
|
transform.rotation = new Euler().copyFrom((_transform_eulerHint = transform.eulerHint) != null ? _transform_eulerHint : transform.rotation);
|
|
20914
20928
|
//@ts-expect-error
|
|
@@ -27712,7 +27726,7 @@ setMaxSpriteMeshItemCount(8);
|
|
|
27712
27726
|
*/ Mesh.create = function(engine, props) {
|
|
27713
27727
|
return new ThreeMesh(engine, props);
|
|
27714
27728
|
};
|
|
27715
|
-
var version = "2.0.0-alpha.
|
|
27729
|
+
var version = "2.0.0-alpha.7";
|
|
27716
27730
|
logger.info("THREEJS plugin version: " + version);
|
|
27717
27731
|
|
|
27718
27732
|
exports.AbstractPlugin = AbstractPlugin;
|