@galacean/effects-core 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 +17 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -3
- package/dist/index.mjs.map +1 -1
- package/dist/render/global-volume.d.ts +3 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime core 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
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -8812,7 +8812,7 @@ var bloomThreshold_frag = "uniform vec4 uColorThreshold;vec4 filterMain(vec2 coo
|
|
|
8812
8812
|
|
|
8813
8813
|
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.;}";
|
|
8814
8814
|
|
|
8815
|
-
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);}";
|
|
8815
|
+
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);}";
|
|
8816
8816
|
|
|
8817
8817
|
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);}";
|
|
8818
8818
|
|
|
@@ -9031,7 +9031,7 @@ class ToneMappingPass extends RenderPass {
|
|
|
9031
9031
|
depthAction: TextureStoreAction.clear,
|
|
9032
9032
|
stencilAction: TextureStoreAction.clear
|
|
9033
9033
|
});
|
|
9034
|
-
const { bloomIntensity, brightness, saturation, contrast,
|
|
9034
|
+
const { useBloom, bloomIntensity, brightness, saturation, contrast, useToneMapping, vignetteIntensity, vignetteSmoothness, vignetteRoundness } = renderer.renderingData.currentFrame.globalVolume;
|
|
9035
9035
|
this.screenMesh.material.setTexture('_SceneTex', this.sceneTextureHandle.texture);
|
|
9036
9036
|
this.screenMesh.material.setFloat('_Brightness', brightness);
|
|
9037
9037
|
this.screenMesh.material.setFloat('_Saturation', saturation);
|
|
@@ -9041,6 +9041,13 @@ class ToneMappingPass extends RenderPass {
|
|
|
9041
9041
|
this.screenMesh.material.setTexture('_GaussianTex', this.mainTexture);
|
|
9042
9042
|
this.screenMesh.material.setFloat('_BloomIntensity', bloomIntensity);
|
|
9043
9043
|
}
|
|
9044
|
+
if (vignetteIntensity > 0) {
|
|
9045
|
+
this.screenMesh.material.setFloat('_VignetteIntensity', vignetteIntensity);
|
|
9046
|
+
this.screenMesh.material.setFloat('_VignetteSmoothness', vignetteSmoothness);
|
|
9047
|
+
this.screenMesh.material.setFloat('_VignetteRoundness', vignetteRoundness);
|
|
9048
|
+
this.screenMesh.material.setVector2('_VignetteCenter', new Vector2(0.5, 0.5));
|
|
9049
|
+
this.screenMesh.material.setVector3('_VignetteColor', new Vector3(0.0, 0.0, 0.0));
|
|
9050
|
+
}
|
|
9044
9051
|
this.screenMesh.material.setInt('_UseToneMapping', useToneMapping);
|
|
9045
9052
|
renderer.renderMeshes([
|
|
9046
9053
|
this.screenMesh
|
|
@@ -9106,6 +9113,12 @@ class ToneMappingPass extends RenderPass {
|
|
|
9106
9113
|
brightness: 1.0,
|
|
9107
9114
|
saturation: 1.0,
|
|
9108
9115
|
contrast: 1.0,
|
|
9116
|
+
// Vignette
|
|
9117
|
+
// vignetteColor: new math.Color(0, 0, 0, 1),
|
|
9118
|
+
// vignetteCenter: new math.Vector2(0.5, 0.5),
|
|
9119
|
+
vignetteIntensity: 0.2,
|
|
9120
|
+
vignetteSmoothness: 0.4,
|
|
9121
|
+
vignetteRoundness: 1.0,
|
|
9109
9122
|
// ToneMapping
|
|
9110
9123
|
useToneMapping: 1
|
|
9111
9124
|
};
|
|
@@ -19408,6 +19421,7 @@ class VFXItem extends EffectsObject {
|
|
|
19408
19421
|
//@ts-expect-error TODO 数据改造后移除 expect-error
|
|
19409
19422
|
transform.position = new Vector3().copyFrom(transform.position);
|
|
19410
19423
|
var _transform_eulerHint;
|
|
19424
|
+
// FIXME: transform.rotation待删除
|
|
19411
19425
|
//@ts-expect-error
|
|
19412
19426
|
transform.rotation = new Euler().copyFrom((_transform_eulerHint = transform.eulerHint) != null ? _transform_eulerHint : transform.rotation);
|
|
19413
19427
|
//@ts-expect-error
|