@onerjs/core 8.54.5 → 8.54.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/Engines/Native/nativeHelpers.js +5 -0
- package/Engines/Native/nativeHelpers.js.map +1 -1
- package/Engines/abstractEngine.pure.js +2 -2
- package/Engines/abstractEngine.pure.js.map +1 -1
- package/Engines/engineCapabilities.d.ts +5 -0
- package/Engines/engineCapabilities.js.map +1 -1
- package/Engines/thinNativeEngine.pure.js +23 -4
- package/Engines/thinNativeEngine.pure.js.map +1 -1
- package/Engines/webgpuEngine.pure.js +1 -0
- package/Engines/webgpuEngine.pure.js.map +1 -1
- package/Materials/Node/nodeMaterial.pure.d.ts +3 -1
- package/Materials/Node/nodeMaterial.pure.js +18 -1
- package/Materials/Node/nodeMaterial.pure.js.map +1 -1
- package/Materials/Textures/envCubeTexture.pure.js +7 -2
- package/Materials/Textures/envCubeTexture.pure.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +14 -0
- package/Materials/materialHelper.functions.js +67 -0
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Maths/math.vector.pure.d.ts +1 -1
- package/Maths/math.vector.pure.js.map +1 -1
- package/Meshes/abstractMesh.pure.js +1 -0
- package/Meshes/abstractMesh.pure.js.map +1 -1
- package/Meshes/mesh.pure.js +11 -0
- package/Meshes/mesh.pure.js.map +1 -1
- package/Meshes/transformNode.pure.js +1 -0
- package/Meshes/transformNode.pure.js.map +1 -1
- package/Misc/areaLightsTextureTools.js +1 -1
- package/Misc/areaLightsTextureTools.js.map +1 -1
- package/Misc/tools.pure.js +1 -1
- package/Misc/tools.pure.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/fsr1RenderingPipeline.d.ts +79 -0
- package/PostProcesses/RenderPipeline/Pipelines/fsr1RenderingPipeline.js +171 -0
- package/PostProcesses/RenderPipeline/Pipelines/fsr1RenderingPipeline.js.map +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/index.d.ts +5 -0
- package/PostProcesses/RenderPipeline/Pipelines/index.js +6 -0
- package/PostProcesses/RenderPipeline/Pipelines/index.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/pure.d.ts +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/pure.js +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/pure.js.map +1 -1
- package/PostProcesses/thinFSR1SharpenPostProcess.d.ts +32 -0
- package/PostProcesses/thinFSR1SharpenPostProcess.js +58 -0
- package/PostProcesses/thinFSR1SharpenPostProcess.js.map +1 -0
- package/PostProcesses/thinFSR1UpscalePostProcess.d.ts +37 -0
- package/PostProcesses/thinFSR1UpscalePostProcess.js +68 -0
- package/PostProcesses/thinFSR1UpscalePostProcess.js.map +1 -0
- package/Shaders/ShadersInclude/ffxFunctions.d.ts +5 -0
- package/Shaders/ShadersInclude/ffxFunctions.js +18 -0
- package/Shaders/ShadersInclude/ffxFunctions.js.map +1 -0
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js +2 -2
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrIblFunctions.js +1 -6
- package/Shaders/ShadersInclude/openpbrIblFunctions.js.map +1 -1
- package/Shaders/fsr1Sharpen.fragment.d.ts +5 -0
- package/Shaders/fsr1Sharpen.fragment.js +26 -0
- package/Shaders/fsr1Sharpen.fragment.js.map +1 -0
- package/Shaders/fsr1Upscale.fragment.d.ts +5 -0
- package/Shaders/fsr1Upscale.fragment.js +77 -0
- package/Shaders/fsr1Upscale.fragment.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/ffxFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/ffxFunctions.js +18 -0
- package/ShadersWGSL/ShadersInclude/ffxFunctions.js.map +1 -0
- package/ShadersWGSL/fsr1Sharpen.fragment.d.ts +5 -0
- package/ShadersWGSL/fsr1Sharpen.fragment.js +34 -0
- package/ShadersWGSL/fsr1Sharpen.fragment.js.map +1 -0
- package/ShadersWGSL/fsr1Upscale.fragment.d.ts +5 -0
- package/ShadersWGSL/fsr1Upscale.fragment.js +68 -0
- package/ShadersWGSL/fsr1Upscale.fragment.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hdrFilteringFunctions.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/hdrFilteringFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,MAAM,IAAI,GAAG,uBAAuB,CAAC;AACrC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiJd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC1C,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACpD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\nconst name = \"hdrFilteringFunctions\";\nconst shader = `#if NUM_SAMPLES\n#if NUM_SAMPLES>0\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nfloat radicalInverse_VdC(uint bits) \n{bits=(bits<<16u) | (bits>>16u);bits=((bits & 0x55555555u)<<1u) | ((bits & 0xAAAAAAAAu)>>1u);bits=((bits & 0x33333333u)<<2u) | ((bits & 0xCCCCCCCCu)>>2u);bits=((bits & 0x0F0F0F0Fu)<<4u) | ((bits & 0xF0F0F0F0u)>>4u);bits=((bits & 0x00FF00FFu)<<8u) | ((bits & 0xFF00FF00u)>>8u);return float(bits)*2.3283064365386963e-10; }\nvec2 hammersley(uint i,uint N)\n{return vec2(float(i)/float(N),radicalInverse_VdC(i));}\n#else\nfloat vanDerCorpus(int n,int base)\n{float invBase=1.0/float(base);float denom =1.0;float result =0.0;for(int i=0; i<32; ++i)\n{if(n>0)\n{denom =mod(float(n),2.0);result+=denom*invBase;invBase=invBase/2.0;n =int(float(n)/2.0);}}\nreturn result;}\nvec2 hammersley(int i,int N)\n{return vec2(float(i)/float(N),vanDerCorpus(i,2));}\n#endif\nfloat log4(float x) {return log2(x)/2.;}\nvec3 uv_to_normal(vec2 uv) {vec3 N;vec2 uvRange=uv;float theta=uvRange.x*2.*PI;float phi=uvRange.y*PI;float sinPhi=sin(phi);N.x=cos(theta)*sinPhi;N.z=sin(theta)*sinPhi;N.y=cos(phi);return N;}\nconst float NUM_SAMPLES_FLOAT=float(NUM_SAMPLES);const float NUM_SAMPLES_FLOAT_INVERSED=1./NUM_SAMPLES_FLOAT;const float K=4.;\n#define inline\nvec3 irradiance(\n#ifdef CUSTOM_IRRADIANCE_FILTERING_INPUT\nCUSTOM_IRRADIANCE_FILTERING_INPUT\n#else\nsamplerCube inputTexture,\n#endif\nvec3 inputN,vec2 filteringInfo,\nfloat diffuseRoughness,\nvec3 surfaceAlbedo,\nvec3 inputV\n#if IBL_CDF_FILTERING\n,sampler2D icdfSampler\n#endif\n)\n{vec3 n=normalize(inputN);vec3 result=vec3(0.);\n#ifndef IBL_CDF_FILTERING\nvec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);tangent=normalize(cross(tangent,n));vec3 bitangent=cross(n,tangent);mat3 tbn=mat3(tangent,bitangent,n);mat3 tbnInverse=mat3(tangent.x,bitangent.x,n.x,tangent.y,bitangent.y,n.y,tangent.z,bitangent.z,n.z);\n#endif\nfloat maxLevel=filteringInfo.y;float dim0=filteringInfo.x;float omegaP=(4.*PI)/(6.*dim0*dim0);vec3 clampedAlbedo=clamp(surfaceAlbedo,vec3(0.1),vec3(1.0));\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nfor(uint i=0u; i<NUM_SAMPLES; ++i)\n#else\nfor(int i=0; i<NUM_SAMPLES; ++i)\n#endif\n{vec2 Xi=hammersley(i,NUM_SAMPLES);\n#if IBL_CDF_FILTERING\nvec2 T;T.x=texture2D(icdfSampler,vec2(Xi.x,0.)).x;T.y=texture2D(icdfSampler,vec2(T.x,Xi.y)).y;vec3 Ls=uv_to_normal(vec2(1.0-fract(T.x+0.25),T.y));float NoL=dot(n,Ls);float NoV=dot(n,inputV);\n#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON\nfloat LoV=dot (Ls,inputV);\n#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY\nvec3 H=(inputV+Ls)*0.5;float VoH=dot(inputV,H);\n#endif\n#else\nvec3 Ls=hemisphereCosSample(Xi);Ls=normalize(Ls);float NoL=Ls.z; \nvec3 V=tbnInverse*inputV;float NoV=V.z; \n#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON\nfloat LoV=dot (Ls,V);\n#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY\nvec3 H=(V+Ls)*0.5;float VoH=dot(V,H);\n#endif\n#endif\nif (NoL>0.) {\n#if IBL_CDF_FILTERING\nfloat pdf=texture2D(icdfSampler,T).z;vec3 c=textureCubeLodEXT(inputTexture,Ls,0.).rgb;\n#else\nfloat pdf_inversed=PI/NoL;float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;float l=log4(omegaS)-log4(omegaP)+log4(K);float mipLevel=clamp(l,0.,maxLevel);\n#ifdef CUSTOM_IRRADIANCE_FILTERING_FUNCTION\nCUSTOM_IRRADIANCE_FILTERING_FUNCTION\n#else\nvec3 c=textureCubeLodEXT(inputTexture,tbn*Ls,mipLevel).rgb;\n#endif\n#endif\n#if GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nvec3 diffuseRoughnessTerm=vec3(1.0);\n#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON\ndiffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI;\n#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY\ndiffuseRoughnessTerm=vec3(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI);\n#endif\n#if IBL_CDF_FILTERING\nvec3 light=pdf<1e-6 ? vec3(0.0) : vec3(1.0)/vec3(pdf)*c;result+=NoL*diffuseRoughnessTerm*light;\n#else\nresult+=c*diffuseRoughnessTerm;\n#endif\n}}\nresult=result*NUM_SAMPLES_FLOAT_INVERSED;\n#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON\nresult=result/clampedAlbedo;\n#endif\nreturn result;}\n#define inline\nvec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)\n{vec3 n=normalize(inputN);vec3 c=textureCubeLodEXT(inputTexture,n,0.).rgb; \nif (alphaG==0.) {\n#if GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nreturn c;} else {vec3 result=vec3(0.);vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);tangent=normalize(cross(tangent,n));vec3 bitangent=cross(n,tangent);mat3 tbn=mat3(tangent,bitangent,n);float maxLevel=filteringInfo.y;float dim0=filteringInfo.x;float omegaP=(4.*PI)/(6.*dim0*dim0);float weight=0.;\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nfor(uint i=0u; i<NUM_SAMPLES; ++i)\n#else\nfor(int i=0; i<NUM_SAMPLES; ++i)\n#endif\n{vec2 Xi=hammersley(i,NUM_SAMPLES);vec3 H=hemisphereImportanceSampleDggx(Xi,alphaG);float NoV=1.;float NoH=H.z;float NoH2=H.z*H.z;float NoL=2.*NoH2-1.;vec3 L=vec3(2.*NoH*H.x,2.*NoH*H.y,NoL);L=normalize(L);if (NoL>0.) {float pdf_inversed=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;float l=log4(omegaS)-log4(omegaP)+log4(K);float mipLevel=clamp(float(l),0.0,maxLevel);weight+=NoL;vec3 c=textureCubeLodEXT(inputTexture,tbn*L,mipLevel).rgb;\n#if GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nresult+=c*NoL;}}\nresult=result/weight;return result;}}\n#ifdef ANISOTROPIC\n#define inline\nvec3 radianceAnisotropic(\nfloat alphaTangent, \nfloat alphaBitangent, \nsamplerCube inputTexture,\nvec3 inputView, \nvec3 inputTangent, \nvec3 inputBitangent, \nvec3 inputNormal, \nvec2 filteringInfo,\nvec2 noiseInput, \nbool isRefraction,\nfloat ior \n)\n{vec3 V=inputView;vec3 N=inputNormal;vec3 T=inputTangent;vec3 B=inputBitangent;vec3 result=vec3(0.);float maxLevel=filteringInfo.y;float dim0=filteringInfo.x;float clampedAlphaT=max(alphaTangent,MINIMUMVARIANCE);float clampedAlphaB=max(alphaBitangent,MINIMUMVARIANCE);float effectiveDim=dim0*sqrt(clampedAlphaT*clampedAlphaB);float omegaP=(4.*PI)/(6.*effectiveDim*effectiveDim);const float noiseScale=clamp(log2(float(NUM_SAMPLES))/12.
|
|
1
|
+
{"version":3,"file":"hdrFilteringFunctions.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/hdrFilteringFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,MAAM,IAAI,GAAG,uBAAuB,CAAC;AACrC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiJd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC1C,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACpD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\nconst name = \"hdrFilteringFunctions\";\nconst shader = `#if NUM_SAMPLES\n#if NUM_SAMPLES>0\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nfloat radicalInverse_VdC(uint bits) \n{bits=(bits<<16u) | (bits>>16u);bits=((bits & 0x55555555u)<<1u) | ((bits & 0xAAAAAAAAu)>>1u);bits=((bits & 0x33333333u)<<2u) | ((bits & 0xCCCCCCCCu)>>2u);bits=((bits & 0x0F0F0F0Fu)<<4u) | ((bits & 0xF0F0F0F0u)>>4u);bits=((bits & 0x00FF00FFu)<<8u) | ((bits & 0xFF00FF00u)>>8u);return float(bits)*2.3283064365386963e-10; }\nvec2 hammersley(uint i,uint N)\n{return vec2(float(i)/float(N),radicalInverse_VdC(i));}\n#else\nfloat vanDerCorpus(int n,int base)\n{float invBase=1.0/float(base);float denom =1.0;float result =0.0;for(int i=0; i<32; ++i)\n{if(n>0)\n{denom =mod(float(n),2.0);result+=denom*invBase;invBase=invBase/2.0;n =int(float(n)/2.0);}}\nreturn result;}\nvec2 hammersley(int i,int N)\n{return vec2(float(i)/float(N),vanDerCorpus(i,2));}\n#endif\nfloat log4(float x) {return log2(x)/2.;}\nvec3 uv_to_normal(vec2 uv) {vec3 N;vec2 uvRange=uv;float theta=uvRange.x*2.*PI;float phi=uvRange.y*PI;float sinPhi=sin(phi);N.x=cos(theta)*sinPhi;N.z=sin(theta)*sinPhi;N.y=cos(phi);return N;}\nconst float NUM_SAMPLES_FLOAT=float(NUM_SAMPLES);const float NUM_SAMPLES_FLOAT_INVERSED=1./NUM_SAMPLES_FLOAT;const float K=4.;\n#define inline\nvec3 irradiance(\n#ifdef CUSTOM_IRRADIANCE_FILTERING_INPUT\nCUSTOM_IRRADIANCE_FILTERING_INPUT\n#else\nsamplerCube inputTexture,\n#endif\nvec3 inputN,vec2 filteringInfo,\nfloat diffuseRoughness,\nvec3 surfaceAlbedo,\nvec3 inputV\n#if IBL_CDF_FILTERING\n,sampler2D icdfSampler\n#endif\n)\n{vec3 n=normalize(inputN);vec3 result=vec3(0.);\n#ifndef IBL_CDF_FILTERING\nvec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);tangent=normalize(cross(tangent,n));vec3 bitangent=cross(n,tangent);mat3 tbn=mat3(tangent,bitangent,n);mat3 tbnInverse=mat3(tangent.x,bitangent.x,n.x,tangent.y,bitangent.y,n.y,tangent.z,bitangent.z,n.z);\n#endif\nfloat maxLevel=filteringInfo.y;float dim0=filteringInfo.x;float omegaP=(4.*PI)/(6.*dim0*dim0);vec3 clampedAlbedo=clamp(surfaceAlbedo,vec3(0.1),vec3(1.0));\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nfor(uint i=0u; i<NUM_SAMPLES; ++i)\n#else\nfor(int i=0; i<NUM_SAMPLES; ++i)\n#endif\n{vec2 Xi=hammersley(i,NUM_SAMPLES);\n#if IBL_CDF_FILTERING\nvec2 T;T.x=texture2D(icdfSampler,vec2(Xi.x,0.)).x;T.y=texture2D(icdfSampler,vec2(T.x,Xi.y)).y;vec3 Ls=uv_to_normal(vec2(1.0-fract(T.x+0.25),T.y));float NoL=dot(n,Ls);float NoV=dot(n,inputV);\n#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON\nfloat LoV=dot (Ls,inputV);\n#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY\nvec3 H=(inputV+Ls)*0.5;float VoH=dot(inputV,H);\n#endif\n#else\nvec3 Ls=hemisphereCosSample(Xi);Ls=normalize(Ls);float NoL=Ls.z; \nvec3 V=tbnInverse*inputV;float NoV=V.z; \n#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON\nfloat LoV=dot (Ls,V);\n#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY\nvec3 H=(V+Ls)*0.5;float VoH=dot(V,H);\n#endif\n#endif\nif (NoL>0.) {\n#if IBL_CDF_FILTERING\nfloat pdf=texture2D(icdfSampler,T).z;vec3 c=textureCubeLodEXT(inputTexture,Ls,0.).rgb;\n#else\nfloat pdf_inversed=PI/NoL;float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;float l=log4(omegaS)-log4(omegaP)+log4(K);float mipLevel=clamp(l,0.,maxLevel);\n#ifdef CUSTOM_IRRADIANCE_FILTERING_FUNCTION\nCUSTOM_IRRADIANCE_FILTERING_FUNCTION\n#else\nvec3 c=textureCubeLodEXT(inputTexture,tbn*Ls,mipLevel).rgb;\n#endif\n#endif\n#if GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nvec3 diffuseRoughnessTerm=vec3(1.0);\n#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON\ndiffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI;\n#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY\ndiffuseRoughnessTerm=vec3(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI);\n#endif\n#if IBL_CDF_FILTERING\nvec3 light=pdf<1e-6 ? vec3(0.0) : vec3(1.0)/vec3(pdf)*c;result+=NoL*diffuseRoughnessTerm*light;\n#else\nresult+=c*diffuseRoughnessTerm;\n#endif\n}}\nresult=result*NUM_SAMPLES_FLOAT_INVERSED;\n#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON\nresult=result/clampedAlbedo;\n#endif\nreturn result;}\n#define inline\nvec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)\n{vec3 n=normalize(inputN);vec3 c=textureCubeLodEXT(inputTexture,n,0.).rgb; \nif (alphaG==0.) {\n#if GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nreturn c;} else {vec3 result=vec3(0.);vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);tangent=normalize(cross(tangent,n));vec3 bitangent=cross(n,tangent);mat3 tbn=mat3(tangent,bitangent,n);float maxLevel=filteringInfo.y;float dim0=filteringInfo.x;float omegaP=(4.*PI)/(6.*dim0*dim0);float weight=0.;\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nfor(uint i=0u; i<NUM_SAMPLES; ++i)\n#else\nfor(int i=0; i<NUM_SAMPLES; ++i)\n#endif\n{vec2 Xi=hammersley(i,NUM_SAMPLES);vec3 H=hemisphereImportanceSampleDggx(Xi,alphaG);float NoV=1.;float NoH=H.z;float NoH2=H.z*H.z;float NoL=2.*NoH2-1.;vec3 L=vec3(2.*NoH*H.x,2.*NoH*H.y,NoL);L=normalize(L);if (NoL>0.) {float pdf_inversed=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;float l=log4(omegaS)-log4(omegaP)+log4(K);float mipLevel=clamp(float(l),0.0,maxLevel);weight+=NoL;vec3 c=textureCubeLodEXT(inputTexture,tbn*L,mipLevel).rgb;\n#if GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nresult+=c*NoL;}}\nresult=result/weight;return result;}}\n#ifdef ANISOTROPIC\n#define inline\nvec3 radianceAnisotropic(\nfloat alphaTangent, \nfloat alphaBitangent, \nsamplerCube inputTexture,\nvec3 inputView, \nvec3 inputTangent, \nvec3 inputBitangent, \nvec3 inputNormal, \nvec2 filteringInfo,\nvec2 noiseInput, \nbool isRefraction,\nfloat ior \n)\n{vec3 V=inputView;vec3 N=inputNormal;vec3 T=inputTangent;vec3 B=inputBitangent;vec3 result=vec3(0.);float maxLevel=filteringInfo.y;float dim0=filteringInfo.x;float clampedAlphaT=max(alphaTangent,MINIMUMVARIANCE);float clampedAlphaB=max(alphaBitangent,MINIMUMVARIANCE);float effectiveDim=dim0*sqrt(clampedAlphaT*clampedAlphaB);float omegaP=(4.*PI)/(6.*effectiveDim*effectiveDim);const float noiseScale=clamp(log2(float(NUM_SAMPLES))/12.0,0.0,1.0);float weight=0.;\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nfor(uint i=0u; i<NUM_SAMPLES; ++i)\n#else\nfor(int i=0; i<NUM_SAMPLES; ++i)\n#endif\n{vec2 Xi=hammersley(i,NUM_SAMPLES);Xi=fract(Xi+noiseInput*mix(0.5,0.015,noiseScale)); \nvec3 H_tangent=hemisphereImportanceSampleDggxAnisotropic(Xi,clampedAlphaT,clampedAlphaB);vec3 H=normalize(H_tangent.x*T+H_tangent.y*B+H_tangent.z*N);vec3 L;if (isRefraction) {L=refract(-V,H,1.0/ior);} else {L=reflect(-V,H);}\nfloat NoH=max(dot(N,H),0.001);float VoH=max(dot(V,H),0.001);float NoL=max(dot(N,L),0.001);if (NoL>0.) {float pdf_inversed=4./normalDistributionFunction_BurleyGGX_Anisotropic(\nH_tangent.z,H_tangent.x,H_tangent.y,vec2(clampedAlphaT,clampedAlphaB)\n);float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;float l=log4(omegaS)-log4(omegaP)+log4(K);float mipLevel=clamp(float(l),0.0,maxLevel);weight+=NoL;vec3 c=textureCubeLodEXT(inputTexture,L,mipLevel).rgb;\n#if GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nresult+=c*NoL;}}\nresult=result/weight;return result;}\n#endif\n#endif\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStore[name]) {\n ShaderStore.IncludesShadersStore[name] = shader;\n}\n/** @internal */\nexport const hdrFilteringFunctions = { name, shader };\n"]}
|
|
@@ -182,12 +182,7 @@ vec3 view=(reflectionMatrix*vec4(viewDirectionW,0.0)).xyz;vec3 tangent=(reflecti
|
|
|
182
182
|
#ifdef REFLECTIONMAP_OPPOSITEZ
|
|
183
183
|
view.z*=-1.0;tangent.z*=-1.0;bitangent.z*=-1.0;normal.z*=-1.0;
|
|
184
184
|
#endif
|
|
185
|
-
environmentRadiance
|
|
186
|
-
vec4(radianceAnisotropic(alphaT,alphaB,reflectionSampler,
|
|
187
|
-
view,tangent,
|
|
188
|
-
bitangent,normal,
|
|
189
|
-
vReflectionFilteringInfo,noise.xy,isRefraction,ior),
|
|
190
|
-
1.0);
|
|
185
|
+
environmentRadiance=vec4(radianceAnisotropic(alphaT,alphaB,reflectionSampler,view,tangent,bitangent,normal,vReflectionFilteringInfo,noise.xy,isRefraction,ior),1.0);
|
|
191
186
|
#else
|
|
192
187
|
const int samples=16;vec4 radianceSample=vec4(0.0);vec3 reflectionCoords=vec3(0.0);float sample_weight=0.0;float total_weight=0.0;float step=1.0/float(max(samples-1,1));for (int i=0; i<samples; ++i) {float t=mix(-1.0,1.0,float(i)*step);t+=step*2.0*noise.x;sample_weight=max(1.0-abs(t),0.001);sample_weight*=sample_weight;t*=min(4.0*alphaT*geoInfo.anisotropy,1.0);vec3 bentNormal;if (t<0.0) {float blend=t+1.0;bentNormal=normalize(mix(-geoInfo.anisotropicTangent,normalW,blend));} else if (t>0.0) {float blend=t;bentNormal=normalize(mix(normalW,geoInfo.anisotropicTangent,blend));} else {bentNormal=normalW;}
|
|
193
188
|
if (isRefraction) {reflectionCoords=double_refract(-viewDirectionW,bentNormal,ior);} else {reflectionCoords=reflect(-viewDirectionW,bentNormal);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openpbrIblFunctions.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/openpbrIblFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,MAAM,IAAI,GAAG,qBAAqB,CAAC;AACnC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Nd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC1C,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACpD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\nconst name = \"openpbrIblFunctions\";\nconst shader = `#ifdef REFLECTION\nvec3 sampleIrradiance(\nin vec3 surfaceNormal\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\n,in vec3 vEnvironmentIrradianceSH\n#endif\n#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))\n,in mat4 iblMatrix\n#endif\n#ifdef USEIRRADIANCEMAP\n#ifdef REFLECTIONMAP_3D\n,in samplerCube irradianceSampler\n#else\n,in sampler2D irradianceSampler\n#endif\n#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION\n,in vec3 reflectionDominantDirection\n#endif\n#endif\n#ifdef REALTIME_FILTERING\n,in vec2 vReflectionFilteringInfo\n#ifdef IBL_CDF_FILTERING\n,in sampler2D icdfSampler\n#endif\n#endif\n,in vec2 vReflectionInfos\n,in vec3 viewDirectionW\n,in float diffuseRoughness\n,in vec3 surfaceAlbedo\n) {vec3 environmentIrradiance=vec3(0.,0.,0.);\n#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))\nvec3 irradianceVector=(iblMatrix*vec4(surfaceNormal,0)).xyz;vec3 irradianceView=(iblMatrix*vec4(viewDirectionW,0)).xyz;\n#if !defined(USE_IRRADIANCE_DOMINANT_DIRECTION) && !defined(REALTIME_FILTERING)\n#if BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LAMBERT && BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LEGACY\n{float NdotV=max(dot(surfaceNormal,viewDirectionW),0.0);irradianceVector=mix(irradianceVector,irradianceView,(0.5*(1.0-NdotV))*diffuseRoughness);}\n#endif\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;irradianceView.z*=-1.0;\n#endif\n#ifdef INVERTCUBICMAP\nirradianceVector.y*=-1.0;irradianceView.y*=-1.0;\n#endif\n#endif\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nenvironmentIrradiance=vEnvironmentIrradianceSH;\n#else\n#if defined(REALTIME_FILTERING)\nenvironmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo,diffuseRoughness,surfaceAlbedo,irradianceView\n#ifdef IBL_CDF_FILTERING\n,icdfSampler\n#endif\n);\n#else\nenvironmentIrradiance=computeEnvironmentIrradiance(irradianceVector);\n#endif\n#endif\n#elif defined(USEIRRADIANCEMAP)\n#ifdef REFLECTIONMAP_3D\nvec4 environmentIrradianceFromTexture=sampleReflection(irradianceSampler,irradianceVector);\n#else\nvec4 environmentIrradianceFromTexture=sampleReflection(irradianceSampler,reflectionCoords);\n#endif\nenvironmentIrradiance=environmentIrradianceFromTexture.rgb;\n#ifdef RGBDREFLECTION\nenvironmentIrradiance.rgb=fromRGBD(environmentIrradianceFromTexture);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb);\n#endif\n#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION\nvec3 Ls=normalize(reflectionDominantDirection);float NoL=dot(irradianceVector,Ls);float NoV=dot(irradianceVector,irradianceView);vec3 diffuseRoughnessTerm=vec3(1.0);\n#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON\nfloat LoV=dot (Ls,irradianceView);float mag=length(reflectionDominantDirection)*2.0;vec3 clampedAlbedo=clamp(surfaceAlbedo,vec3(0.1),vec3(1.0));diffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI;diffuseRoughnessTerm=diffuseRoughnessTerm/clampedAlbedo;diffuseRoughnessTerm=mix(vec3(1.0),diffuseRoughnessTerm,sqrt(clamp(mag*NoV,0.0,1.0)));\n#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY\nvec3 H=(irradianceView+Ls)*0.5;float VoH=dot(irradianceView,H);diffuseRoughnessTerm=vec3(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI);\n#endif\nenvironmentIrradiance=environmentIrradiance.rgb*diffuseRoughnessTerm;\n#endif\n#endif\nenvironmentIrradiance*=vReflectionInfos.x;return environmentIrradiance;}\n#define pbr_inline\n#ifdef REFLECTIONMAP_3D\nvec3 createReflectionCoords(\n#else\nvec2 createReflectionCoords(\n#endif\nin vec3 vPositionW\n,in vec3 normalW\n)\n{vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\nreturn reflectionCoords;}\n#define pbr_inline\n#define inline\nvec3 sampleRadiance(\nin float alphaG\n,in vec3 vReflectionMicrosurfaceInfos\n,in vec2 vReflectionInfos\n,in geometryInfoOutParams geoInfo\n#ifdef REFLECTIONMAP_3D\n,in samplerCube reflectionSampler\n,const vec3 reflectionCoords\n#else\n,in sampler2D reflectionSampler\n,const vec2 reflectionCoords\n#endif\n#ifdef REALTIME_FILTERING\n,in vec2 vReflectionFilteringInfo\n#endif\n)\n{vec4 environmentRadiance=vec4(0.,0.,0.,0.);\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,geoInfo.NdotVUnclamped);\n#elif defined(LINEARSPECULARREFLECTION)\nfloat reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);\n#endif\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef REALTIME_FILTERING\nenvironmentRadiance=vec4(radiance(alphaG,reflectionSampler,reflectionCoords,vReflectionFilteringInfo),1.0);\n#else\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\n#endif\n#ifdef RGBDREFLECTION\nenvironmentRadiance.rgb=fromRGBD(environmentRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);\n#endif\nenvironmentRadiance.rgb*=vec3(vReflectionInfos.x);return environmentRadiance.rgb;}\n#if defined(ANISOTROPIC)\n#define pbr_inline\n#define inline\nvec3 sampleRadianceAnisotropic(\nin float alphaG\n,in vec3 vReflectionMicrosurfaceInfos\n,in vec2 vReflectionInfos\n,in geometryInfoAnisoOutParams geoInfo\n,const vec3 normalW\n,const vec3 viewDirectionW\n,const vec3 positionW\n,const vec3 noise\n,bool isRefraction\n,float ior\n#ifdef REFLECTIONMAP_3D\n,in samplerCube reflectionSampler\n#else\n,in sampler2D reflectionSampler\n#endif\n#ifdef REALTIME_FILTERING\n,in vec2 vReflectionFilteringInfo\n#endif\n)\n{vec4 environmentRadiance=vec4(0.,0.,0.,0.);float alphaT=alphaG*sqrt(2.0/(1.0+(1.0-geoInfo.anisotropy)*(1.0-geoInfo.anisotropy)));float alphaB=(1.0-geoInfo.anisotropy)*alphaT;alphaG=alphaB;\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,geoInfo.NdotVUnclamped);\n#elif defined(LINEARSPECULARREFLECTION)\nfloat reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);\n#endif\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef REALTIME_FILTERING\nvec3 view=(reflectionMatrix*vec4(viewDirectionW,0.0)).xyz;vec3 tangent=(reflectionMatrix*vec4(geoInfo.anisotropicTangent,0.0)).xyz;vec3 bitangent=(reflectionMatrix*vec4(geoInfo.anisotropicBitangent,0.0)).xyz;vec3 normal=(reflectionMatrix*vec4(normalW,0.0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nview.z*=-1.0;tangent.z*=-1.0;bitangent.z*=-1.0;normal.z*=-1.0;\n#endif\nenvironmentRadiance =\nvec4(radianceAnisotropic(alphaT,alphaB,reflectionSampler,\nview,tangent,\nbitangent,normal,\nvReflectionFilteringInfo,noise.xy,isRefraction,ior),\n1.0);\n#else\nconst int samples=16;vec4 radianceSample=vec4(0.0);vec3 reflectionCoords=vec3(0.0);float sample_weight=0.0;float total_weight=0.0;float step=1.0/float(max(samples-1,1));for (int i=0; i<samples; ++i) {float t=mix(-1.0,1.0,float(i)*step);t+=step*2.0*noise.x;sample_weight=max(1.0-abs(t),0.001);sample_weight*=sample_weight;t*=min(4.0*alphaT*geoInfo.anisotropy,1.0);vec3 bentNormal;if (t<0.0) {float blend=t+1.0;bentNormal=normalize(mix(-geoInfo.anisotropicTangent,normalW,blend));} else if (t>0.0) {float blend=t;bentNormal=normalize(mix(normalW,geoInfo.anisotropicTangent,blend));} else {bentNormal=normalW;}\nif (isRefraction) {reflectionCoords=double_refract(-viewDirectionW,bentNormal,ior);} else {reflectionCoords=reflect(-viewDirectionW,bentNormal);}\nreflectionCoords=vec3(reflectionMatrix*vec4(reflectionCoords,0));\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionCoords.z*=-1.0;\n#endif\nradianceSample=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\n#ifdef RGBDREFLECTION\nenvironmentRadiance.rgb+=sample_weight*fromRGBD(radianceSample);\n#elif defined(GAMMAREFLECTION)\nenvironmentRadiance.rgb+=sample_weight*toLinearSpace(radianceSample.rgb);\n#else\nenvironmentRadiance.rgb+=sample_weight*radianceSample.rgb;\n#endif\ntotal_weight+=sample_weight;}\nenvironmentRadiance=vec4(environmentRadiance.xyz/float(total_weight),1.0);\n#endif\nenvironmentRadiance.rgb*=vec3(vReflectionInfos.x);return environmentRadiance.rgb;}\n#endif\n#endif\n#if defined(ENVIRONMENTBRDF)\n#define pbr_inline\nfloat computeDielectricIblFresnel(in ReflectanceParams reflectance,in vec3 environmentBrdf)\n{float dielectricIblFresnel=getReflectanceFromBRDFLookup(vec3(reflectance.F0),vec3(reflectance.F90),environmentBrdf).r;float dielectricECF=1.0+reflectance.F0*(1.0/environmentBrdf.y-1.0);return clamp(dielectricIblFresnel*dielectricECF,0.0,1.0);}\n#define pbr_inline\nvec3 computeConductorIblFresnel(in ReflectanceParams reflectance,in vec3 environmentBrdf)\n{\n#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR) && defined(ENVIRONMENTBRDF)\nvec3 openPBRBrdf=vec3(environmentBrdf.xy,environmentBrdf.z/BRDF_Z_SCALE);vec3 b =getF82B(reflectance.coloredF0,reflectance.coloredF90);vec3 E_F82=getF82DirectionalAlbedo(reflectance.coloredF0,vec3(1.0),b,openPBRBrdf);vec3 F_avg=getF82AverageFresnel(reflectance.coloredF0,b);vec3 ECF =vec3(1.0)+F_avg*(vec3(1.0)/openPBRBrdf.y-vec3(1.0));return clamp(E_F82*ECF,vec3(0.0),vec3(1.0));\n#else\nreturn getReflectanceFromBRDFLookup(reflectance.coloredF0,reflectance.coloredF90,environmentBrdf);\n#endif\n}\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStore[name]) {\n ShaderStore.IncludesShadersStore[name] = shader;\n}\n/** @internal */\nexport const openpbrIblFunctions = { name, shader };\n"]}
|
|
1
|
+
{"version":3,"file":"openpbrIblFunctions.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/openpbrIblFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,MAAM,IAAI,GAAG,qBAAqB,CAAC;AACnC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyNd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC1C,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACpD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\nconst name = \"openpbrIblFunctions\";\nconst shader = `#ifdef REFLECTION\nvec3 sampleIrradiance(\nin vec3 surfaceNormal\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\n,in vec3 vEnvironmentIrradianceSH\n#endif\n#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))\n,in mat4 iblMatrix\n#endif\n#ifdef USEIRRADIANCEMAP\n#ifdef REFLECTIONMAP_3D\n,in samplerCube irradianceSampler\n#else\n,in sampler2D irradianceSampler\n#endif\n#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION\n,in vec3 reflectionDominantDirection\n#endif\n#endif\n#ifdef REALTIME_FILTERING\n,in vec2 vReflectionFilteringInfo\n#ifdef IBL_CDF_FILTERING\n,in sampler2D icdfSampler\n#endif\n#endif\n,in vec2 vReflectionInfos\n,in vec3 viewDirectionW\n,in float diffuseRoughness\n,in vec3 surfaceAlbedo\n) {vec3 environmentIrradiance=vec3(0.,0.,0.);\n#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))\nvec3 irradianceVector=(iblMatrix*vec4(surfaceNormal,0)).xyz;vec3 irradianceView=(iblMatrix*vec4(viewDirectionW,0)).xyz;\n#if !defined(USE_IRRADIANCE_DOMINANT_DIRECTION) && !defined(REALTIME_FILTERING)\n#if BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LAMBERT && BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LEGACY\n{float NdotV=max(dot(surfaceNormal,viewDirectionW),0.0);irradianceVector=mix(irradianceVector,irradianceView,(0.5*(1.0-NdotV))*diffuseRoughness);}\n#endif\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;irradianceView.z*=-1.0;\n#endif\n#ifdef INVERTCUBICMAP\nirradianceVector.y*=-1.0;irradianceView.y*=-1.0;\n#endif\n#endif\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nenvironmentIrradiance=vEnvironmentIrradianceSH;\n#else\n#if defined(REALTIME_FILTERING)\nenvironmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo,diffuseRoughness,surfaceAlbedo,irradianceView\n#ifdef IBL_CDF_FILTERING\n,icdfSampler\n#endif\n);\n#else\nenvironmentIrradiance=computeEnvironmentIrradiance(irradianceVector);\n#endif\n#endif\n#elif defined(USEIRRADIANCEMAP)\n#ifdef REFLECTIONMAP_3D\nvec4 environmentIrradianceFromTexture=sampleReflection(irradianceSampler,irradianceVector);\n#else\nvec4 environmentIrradianceFromTexture=sampleReflection(irradianceSampler,reflectionCoords);\n#endif\nenvironmentIrradiance=environmentIrradianceFromTexture.rgb;\n#ifdef RGBDREFLECTION\nenvironmentIrradiance.rgb=fromRGBD(environmentIrradianceFromTexture);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb);\n#endif\n#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION\nvec3 Ls=normalize(reflectionDominantDirection);float NoL=dot(irradianceVector,Ls);float NoV=dot(irradianceVector,irradianceView);vec3 diffuseRoughnessTerm=vec3(1.0);\n#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON\nfloat LoV=dot (Ls,irradianceView);float mag=length(reflectionDominantDirection)*2.0;vec3 clampedAlbedo=clamp(surfaceAlbedo,vec3(0.1),vec3(1.0));diffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI;diffuseRoughnessTerm=diffuseRoughnessTerm/clampedAlbedo;diffuseRoughnessTerm=mix(vec3(1.0),diffuseRoughnessTerm,sqrt(clamp(mag*NoV,0.0,1.0)));\n#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY\nvec3 H=(irradianceView+Ls)*0.5;float VoH=dot(irradianceView,H);diffuseRoughnessTerm=vec3(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI);\n#endif\nenvironmentIrradiance=environmentIrradiance.rgb*diffuseRoughnessTerm;\n#endif\n#endif\nenvironmentIrradiance*=vReflectionInfos.x;return environmentIrradiance;}\n#define pbr_inline\n#ifdef REFLECTIONMAP_3D\nvec3 createReflectionCoords(\n#else\nvec2 createReflectionCoords(\n#endif\nin vec3 vPositionW\n,in vec3 normalW\n)\n{vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\nreturn reflectionCoords;}\n#define pbr_inline\n#define inline\nvec3 sampleRadiance(\nin float alphaG\n,in vec3 vReflectionMicrosurfaceInfos\n,in vec2 vReflectionInfos\n,in geometryInfoOutParams geoInfo\n#ifdef REFLECTIONMAP_3D\n,in samplerCube reflectionSampler\n,const vec3 reflectionCoords\n#else\n,in sampler2D reflectionSampler\n,const vec2 reflectionCoords\n#endif\n#ifdef REALTIME_FILTERING\n,in vec2 vReflectionFilteringInfo\n#endif\n)\n{vec4 environmentRadiance=vec4(0.,0.,0.,0.);\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,geoInfo.NdotVUnclamped);\n#elif defined(LINEARSPECULARREFLECTION)\nfloat reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);\n#endif\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef REALTIME_FILTERING\nenvironmentRadiance=vec4(radiance(alphaG,reflectionSampler,reflectionCoords,vReflectionFilteringInfo),1.0);\n#else\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\n#endif\n#ifdef RGBDREFLECTION\nenvironmentRadiance.rgb=fromRGBD(environmentRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);\n#endif\nenvironmentRadiance.rgb*=vec3(vReflectionInfos.x);return environmentRadiance.rgb;}\n#if defined(ANISOTROPIC)\n#define pbr_inline\n#define inline\nvec3 sampleRadianceAnisotropic(\nin float alphaG\n,in vec3 vReflectionMicrosurfaceInfos\n,in vec2 vReflectionInfos\n,in geometryInfoAnisoOutParams geoInfo\n,const vec3 normalW\n,const vec3 viewDirectionW\n,const vec3 positionW\n,const vec3 noise\n,bool isRefraction\n,float ior\n#ifdef REFLECTIONMAP_3D\n,in samplerCube reflectionSampler\n#else\n,in sampler2D reflectionSampler\n#endif\n#ifdef REALTIME_FILTERING\n,in vec2 vReflectionFilteringInfo\n#endif\n)\n{vec4 environmentRadiance=vec4(0.,0.,0.,0.);float alphaT=alphaG*sqrt(2.0/(1.0+(1.0-geoInfo.anisotropy)*(1.0-geoInfo.anisotropy)));float alphaB=(1.0-geoInfo.anisotropy)*alphaT;alphaG=alphaB;\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,geoInfo.NdotVUnclamped);\n#elif defined(LINEARSPECULARREFLECTION)\nfloat reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);\n#endif\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef REALTIME_FILTERING\nvec3 view=(reflectionMatrix*vec4(viewDirectionW,0.0)).xyz;vec3 tangent=(reflectionMatrix*vec4(geoInfo.anisotropicTangent,0.0)).xyz;vec3 bitangent=(reflectionMatrix*vec4(geoInfo.anisotropicBitangent,0.0)).xyz;vec3 normal=(reflectionMatrix*vec4(normalW,0.0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nview.z*=-1.0;tangent.z*=-1.0;bitangent.z*=-1.0;normal.z*=-1.0;\n#endif\nenvironmentRadiance=vec4(radianceAnisotropic(alphaT,alphaB,reflectionSampler,view,tangent,bitangent,normal,vReflectionFilteringInfo,noise.xy,isRefraction,ior),1.0);\n#else\nconst int samples=16;vec4 radianceSample=vec4(0.0);vec3 reflectionCoords=vec3(0.0);float sample_weight=0.0;float total_weight=0.0;float step=1.0/float(max(samples-1,1));for (int i=0; i<samples; ++i) {float t=mix(-1.0,1.0,float(i)*step);t+=step*2.0*noise.x;sample_weight=max(1.0-abs(t),0.001);sample_weight*=sample_weight;t*=min(4.0*alphaT*geoInfo.anisotropy,1.0);vec3 bentNormal;if (t<0.0) {float blend=t+1.0;bentNormal=normalize(mix(-geoInfo.anisotropicTangent,normalW,blend));} else if (t>0.0) {float blend=t;bentNormal=normalize(mix(normalW,geoInfo.anisotropicTangent,blend));} else {bentNormal=normalW;}\nif (isRefraction) {reflectionCoords=double_refract(-viewDirectionW,bentNormal,ior);} else {reflectionCoords=reflect(-viewDirectionW,bentNormal);}\nreflectionCoords=vec3(reflectionMatrix*vec4(reflectionCoords,0));\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionCoords.z*=-1.0;\n#endif\nradianceSample=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\n#ifdef RGBDREFLECTION\nenvironmentRadiance.rgb+=sample_weight*fromRGBD(radianceSample);\n#elif defined(GAMMAREFLECTION)\nenvironmentRadiance.rgb+=sample_weight*toLinearSpace(radianceSample.rgb);\n#else\nenvironmentRadiance.rgb+=sample_weight*radianceSample.rgb;\n#endif\ntotal_weight+=sample_weight;}\nenvironmentRadiance=vec4(environmentRadiance.xyz/float(total_weight),1.0);\n#endif\nenvironmentRadiance.rgb*=vec3(vReflectionInfos.x);return environmentRadiance.rgb;}\n#endif\n#endif\n#if defined(ENVIRONMENTBRDF)\n#define pbr_inline\nfloat computeDielectricIblFresnel(in ReflectanceParams reflectance,in vec3 environmentBrdf)\n{float dielectricIblFresnel=getReflectanceFromBRDFLookup(vec3(reflectance.F0),vec3(reflectance.F90),environmentBrdf).r;float dielectricECF=1.0+reflectance.F0*(1.0/environmentBrdf.y-1.0);return clamp(dielectricIblFresnel*dielectricECF,0.0,1.0);}\n#define pbr_inline\nvec3 computeConductorIblFresnel(in ReflectanceParams reflectance,in vec3 environmentBrdf)\n{\n#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR) && defined(ENVIRONMENTBRDF)\nvec3 openPBRBrdf=vec3(environmentBrdf.xy,environmentBrdf.z/BRDF_Z_SCALE);vec3 b =getF82B(reflectance.coloredF0,reflectance.coloredF90);vec3 E_F82=getF82DirectionalAlbedo(reflectance.coloredF0,vec3(1.0),b,openPBRBrdf);vec3 F_avg=getF82AverageFresnel(reflectance.coloredF0,b);vec3 ECF =vec3(1.0)+F_avg*(vec3(1.0)/openPBRBrdf.y-vec3(1.0));return clamp(E_F82*ECF,vec3(0.0),vec3(1.0));\n#else\nreturn getReflectanceFromBRDFLookup(reflectance.coloredF0,reflectance.coloredF90,environmentBrdf);\n#endif\n}\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStore[name]) {\n ShaderStore.IncludesShadersStore[name] = shader;\n}\n/** @internal */\nexport const openpbrIblFunctions = { name, shader };\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../Engines/shaderStore.js";
|
|
3
|
+
import { ffxFunctions } from "./ShadersInclude/ffxFunctions.js";
|
|
4
|
+
const name = "fsr1SharpenPixelShader";
|
|
5
|
+
const shader = `#include<ffxFunctions>
|
|
6
|
+
#define FSR_RCAS_LIMIT (0.25-(1.0/16.0))
|
|
7
|
+
uniform sampler2D textureSampler;varying vec2 vUV;uniform vec4 con;vec3 FsrRcasLoadF(ivec2 p) {return texelFetch(textureSampler,clamp(p,ivec2(0),textureSize(textureSampler,0)-ivec2(1)),0).rgb;}
|
|
8
|
+
void main() {ivec2 sp=ivec2(gl_FragCoord.xy);vec3 b=FsrRcasLoadF(sp+ivec2( 0,-1));vec3 d=FsrRcasLoadF(sp+ivec2(-1, 0));vec3 e=FsrRcasLoadF(sp);vec3 f=FsrRcasLoadF(sp+ivec2( 1, 0));vec3 h=FsrRcasLoadF(sp+ivec2( 0, 1));float bR=b.r; float bG=b.g; float bB=b.b;float dR=d.r; float dG=d.g; float dB=d.b;float eR=e.r; float eG=e.g; float eB=e.b;float fR=f.r; float fG=f.g; float fB=f.b;float hR=h.r; float hG=h.g; float hB=h.b;float bL=bB*0.5+(bR*0.5+bG);float dL=dB*0.5+(dR*0.5+dG);float eL=eB*0.5+(eR*0.5+eG);float fL=fB*0.5+(fR*0.5+fG);float hL=hB*0.5+(hR*0.5+hG);float nz=0.25*bL+0.25*dL+0.25*fL+0.25*hL-eL;nz=clamp(abs(nz)*APrxMedRcpF1(AMax3F1(AMax3F1(bL,dL,eL),fL,hL)-AMin3F1(AMin3F1(bL,dL,eL),fL,hL)),0.0,1.0);nz=-0.5*nz+1.0;float mn4R=min(AMin3F1(bR,dR,fR),hR);float mn4G=min(AMin3F1(bG,dG,fG),hG);float mn4B=min(AMin3F1(bB,dB,fB),hB);float mx4R=max(AMax3F1(bR,dR,fR),hR);float mx4G=max(AMax3F1(bG,dG,fG),hG);float mx4B=max(AMax3F1(bB,dB,fB),hB);vec2 peakC=vec2(1.0,-1.0*4.0);float hitMinR=min(mn4R,eR)*(1.0/(4.0*mx4R));float hitMinG=min(mn4G,eG)*(1.0/(4.0*mx4G));float hitMinB=min(mn4B,eB)*(1.0/(4.0*mx4B));float hitMaxR=(peakC.x-max(mx4R,eR))*(1.0/(4.0*mn4R+peakC.y));float hitMaxG=(peakC.x-max(mx4G,eG))*(1.0/(4.0*mn4G+peakC.y));float hitMaxB=(peakC.x-max(mx4B,eB))*(1.0/(4.0*mn4B+peakC.y));float lobeR=max(-hitMinR,hitMaxR);float lobeG=max(-hitMinG,hitMaxG);float lobeB=max(-hitMinB,hitMaxB);float lobe=max(-FSR_RCAS_LIMIT,min(AMax3F1(lobeR,lobeG,lobeB),0.0))*con.x;
|
|
9
|
+
#ifdef FSR_RCAS_DENOISE
|
|
10
|
+
lobe*=nz;
|
|
11
|
+
#endif
|
|
12
|
+
float rcpL=APrxMedRcpF1(4.0*lobe+1.0);float pixR=(lobe*bR+lobe*dR+lobe*hR+lobe*fR+eR)*rcpL;float pixG=(lobe*bG+lobe*dG+lobe*hG+lobe*fG+eG)*rcpL;float pixB=(lobe*bB+lobe*dB+lobe*hB+lobe*fB+eB)*rcpL;gl_FragColor=vec4(pixR,pixG,pixB,1.0);}
|
|
13
|
+
`;
|
|
14
|
+
// Sideeffect
|
|
15
|
+
if (!ShaderStore.ShadersStore[name]) {
|
|
16
|
+
ShaderStore.ShadersStore[name] = shader;
|
|
17
|
+
}
|
|
18
|
+
const includes = [ffxFunctions];
|
|
19
|
+
for (const inc of includes) {
|
|
20
|
+
if (!ShaderStore.IncludesShadersStore[inc.name]) {
|
|
21
|
+
ShaderStore.IncludesShadersStore[inc.name] = inc.shader;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** @internal */
|
|
25
|
+
export const fsr1SharpenPixelShader = { name, shader };
|
|
26
|
+
//# sourceMappingURL=fsr1Sharpen.fragment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fsr1Sharpen.fragment.js","sourceRoot":"","sources":["../../../../dev/core/src/Shaders/fsr1Sharpen.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,MAAM,IAAI,GAAG,wBAAwB,CAAC;AACtC,MAAM,MAAM,GAAG;;;;;;;;CAQd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;IAClC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAC5C,CAAC;AACD,MAAM,QAAQ,GAAG,CAAC,YAAY,CAAC,CAAC;AAChC,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;IACzB,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9C,WAAW,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC;IAC5D,CAAC;AACL,CAAC;AAED,gBAAgB;AAChB,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\nimport { ffxFunctions } from \"./ShadersInclude/ffxFunctions\";\n\nconst name = \"fsr1SharpenPixelShader\";\nconst shader = `#include<ffxFunctions>\n#define FSR_RCAS_LIMIT (0.25-(1.0/16.0))\nuniform sampler2D textureSampler;varying vec2 vUV;uniform vec4 con;vec3 FsrRcasLoadF(ivec2 p) {return texelFetch(textureSampler,clamp(p,ivec2(0),textureSize(textureSampler,0)-ivec2(1)),0).rgb;}\nvoid main() {ivec2 sp=ivec2(gl_FragCoord.xy);vec3 b=FsrRcasLoadF(sp+ivec2( 0,-1));vec3 d=FsrRcasLoadF(sp+ivec2(-1, 0));vec3 e=FsrRcasLoadF(sp);vec3 f=FsrRcasLoadF(sp+ivec2( 1, 0));vec3 h=FsrRcasLoadF(sp+ivec2( 0, 1));float bR=b.r; float bG=b.g; float bB=b.b;float dR=d.r; float dG=d.g; float dB=d.b;float eR=e.r; float eG=e.g; float eB=e.b;float fR=f.r; float fG=f.g; float fB=f.b;float hR=h.r; float hG=h.g; float hB=h.b;float bL=bB*0.5+(bR*0.5+bG);float dL=dB*0.5+(dR*0.5+dG);float eL=eB*0.5+(eR*0.5+eG);float fL=fB*0.5+(fR*0.5+fG);float hL=hB*0.5+(hR*0.5+hG);float nz=0.25*bL+0.25*dL+0.25*fL+0.25*hL-eL;nz=clamp(abs(nz)*APrxMedRcpF1(AMax3F1(AMax3F1(bL,dL,eL),fL,hL)-AMin3F1(AMin3F1(bL,dL,eL),fL,hL)),0.0,1.0);nz=-0.5*nz+1.0;float mn4R=min(AMin3F1(bR,dR,fR),hR);float mn4G=min(AMin3F1(bG,dG,fG),hG);float mn4B=min(AMin3F1(bB,dB,fB),hB);float mx4R=max(AMax3F1(bR,dR,fR),hR);float mx4G=max(AMax3F1(bG,dG,fG),hG);float mx4B=max(AMax3F1(bB,dB,fB),hB);vec2 peakC=vec2(1.0,-1.0*4.0);float hitMinR=min(mn4R,eR)*(1.0/(4.0*mx4R));float hitMinG=min(mn4G,eG)*(1.0/(4.0*mx4G));float hitMinB=min(mn4B,eB)*(1.0/(4.0*mx4B));float hitMaxR=(peakC.x-max(mx4R,eR))*(1.0/(4.0*mn4R+peakC.y));float hitMaxG=(peakC.x-max(mx4G,eG))*(1.0/(4.0*mn4G+peakC.y));float hitMaxB=(peakC.x-max(mx4B,eB))*(1.0/(4.0*mn4B+peakC.y));float lobeR=max(-hitMinR,hitMaxR);float lobeG=max(-hitMinG,hitMaxG);float lobeB=max(-hitMinB,hitMaxB);float lobe=max(-FSR_RCAS_LIMIT,min(AMax3F1(lobeR,lobeG,lobeB),0.0))*con.x;\n#ifdef FSR_RCAS_DENOISE\nlobe*=nz;\n#endif\nfloat rcpL=APrxMedRcpF1(4.0*lobe+1.0);float pixR=(lobe*bR+lobe*dR+lobe*hR+lobe*fR+eR)*rcpL;float pixG=(lobe*bG+lobe*dG+lobe*hG+lobe*fG+eG)*rcpL;float pixB=(lobe*bB+lobe*dB+lobe*hB+lobe*fB+eB)*rcpL;gl_FragColor=vec4(pixR,pixG,pixB,1.0);}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\nconst includes = [ffxFunctions];\nfor (const inc of includes) {\n if (!ShaderStore.IncludesShadersStore[inc.name]) {\n ShaderStore.IncludesShadersStore[inc.name] = inc.shader;\n }\n}\n\n/** @internal */\nexport const fsr1SharpenPixelShader = { name, shader };\n"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../Engines/shaderStore.js";
|
|
3
|
+
import { ffxFunctions } from "./ShadersInclude/ffxFunctions.js";
|
|
4
|
+
const name = "fsr1UpscalePixelShader";
|
|
5
|
+
const shader = `#include<ffxFunctions>
|
|
6
|
+
uniform sampler2D textureSampler;varying vec2 vUV;uniform vec4 con0;uniform vec4 con1;uniform vec4 con2;uniform vec4 con3;vec4 FsrEasuRF(vec2 p) {ivec2 texSize=textureSize(textureSampler,0);ivec2 mx=texSize-ivec2(1);ivec2 base=ivec2(floor(p*vec2(texSize)-0.5));return vec4(
|
|
7
|
+
texelFetch(textureSampler,clamp(base+ivec2(0,1),ivec2(0),mx),0).r,
|
|
8
|
+
texelFetch(textureSampler,clamp(base+ivec2(1,1),ivec2(0),mx),0).r,
|
|
9
|
+
texelFetch(textureSampler,clamp(base+ivec2(1,0),ivec2(0),mx),0).r,
|
|
10
|
+
texelFetch(textureSampler,clamp(base+ivec2(0,0),ivec2(0),mx),0).r);}
|
|
11
|
+
vec4 FsrEasuGF(vec2 p) {ivec2 texSize=textureSize(textureSampler,0);ivec2 mx=texSize-ivec2(1);ivec2 base=ivec2(floor(p*vec2(texSize)-0.5));return vec4(
|
|
12
|
+
texelFetch(textureSampler,clamp(base+ivec2(0,1),ivec2(0),mx),0).g,
|
|
13
|
+
texelFetch(textureSampler,clamp(base+ivec2(1,1),ivec2(0),mx),0).g,
|
|
14
|
+
texelFetch(textureSampler,clamp(base+ivec2(1,0),ivec2(0),mx),0).g,
|
|
15
|
+
texelFetch(textureSampler,clamp(base+ivec2(0,0),ivec2(0),mx),0).g);}
|
|
16
|
+
vec4 FsrEasuBF(vec2 p) {ivec2 texSize=textureSize(textureSampler,0);ivec2 mx=texSize-ivec2(1);ivec2 base=ivec2(floor(p*vec2(texSize)-0.5));return vec4(
|
|
17
|
+
texelFetch(textureSampler,clamp(base+ivec2(0,1),ivec2(0),mx),0).b,
|
|
18
|
+
texelFetch(textureSampler,clamp(base+ivec2(1,1),ivec2(0),mx),0).b,
|
|
19
|
+
texelFetch(textureSampler,clamp(base+ivec2(1,0),ivec2(0),mx),0).b,
|
|
20
|
+
texelFetch(textureSampler,clamp(base+ivec2(0,0),ivec2(0),mx),0).b);}
|
|
21
|
+
void FsrEasuTapF(
|
|
22
|
+
inout vec3 aC,
|
|
23
|
+
inout float aW,
|
|
24
|
+
vec2 off,
|
|
25
|
+
vec2 dir,
|
|
26
|
+
vec2 len,
|
|
27
|
+
float lob,
|
|
28
|
+
float clp,
|
|
29
|
+
vec3 c
|
|
30
|
+
) {vec2 v;v.x=(off.x*( dir.x))+(off.y*dir.y);v.y=(off.x*(-dir.y))+(off.y*dir.x);v*=len;float d2=v.x*v.x+v.y*v.y;d2=min(d2,clp);float wB=2.0/5.0*d2+-1.0;float wA=lob*d2+-1.0;wB*=wB;wA*=wA;wB=25.0/16.0*wB+-(25.0/16.0-1.0);float w=wB*wA;aC+=c*w;aW+=w;}
|
|
31
|
+
void FsrEasuSetF(
|
|
32
|
+
inout vec2 dir,
|
|
33
|
+
inout float len,
|
|
34
|
+
vec2 pp,
|
|
35
|
+
bool biS,bool biT,bool biU,bool biV,
|
|
36
|
+
float lA,float lB,float lC,float lD,float lE
|
|
37
|
+
) {float w=0.0;if (biS) {w=(1.0-pp.x)*(1.0-pp.y);}
|
|
38
|
+
if (biT) {w=pp.x*(1.0-pp.y);}
|
|
39
|
+
if (biU) {w=(1.0-pp.x)*pp.y;}
|
|
40
|
+
if (biV) {w=pp.x*pp.y;}
|
|
41
|
+
float dc=lD-lC;float cb=lC-lB;float lenX=max(abs(dc),abs(cb));lenX=APrxLoRcpF1(lenX);float dirX=lD-lB;dir.x+=dirX*w;lenX=clamp(abs(dirX)*lenX,0.0,1.0);lenX*=lenX;len+=lenX*w;float ec=lE-lC;float ca=lC-lA;float lenY=max(abs(ec),abs(ca));lenY=APrxLoRcpF1(lenY);float dirY=lE-lA;dir.y+=dirY*w;lenY=clamp(abs(dirY)*lenY,0.0,1.0);lenY*=lenY;len+=lenY*w;}
|
|
42
|
+
vec3 FsrEasuF(
|
|
43
|
+
ivec2 ip,
|
|
44
|
+
vec4 con0,
|
|
45
|
+
vec4 con1,
|
|
46
|
+
vec4 con2,
|
|
47
|
+
vec4 con3
|
|
48
|
+
) {vec2 pp=vec2(ip)*con0.xy+con0.zw;vec2 fp=floor(pp);pp-=fp;vec2 p0=fp*con1.xy+con1.zw;vec2 p1=p0+con2.xy;vec2 p2=p0+con2.zw;vec2 p3=p0+con3.xy;vec4 bczzR=FsrEasuRF(p0);vec4 bczzG=FsrEasuGF(p0);vec4 bczzB=FsrEasuBF(p0);vec4 ijfeR=FsrEasuRF(p1);vec4 ijfeG=FsrEasuGF(p1);vec4 ijfeB=FsrEasuBF(p1);vec4 klhgR=FsrEasuRF(p2);vec4 klhgG=FsrEasuGF(p2);vec4 klhgB=FsrEasuBF(p2);vec4 zzonR=FsrEasuRF(p3);vec4 zzonG=FsrEasuGF(p3);vec4 zzonB=FsrEasuBF(p3);vec4 bczzL=bczzB*vec4(0.5)+(bczzR*vec4(0.5)+bczzG);vec4 ijfeL=ijfeB*vec4(0.5)+(ijfeR*vec4(0.5)+ijfeG);vec4 klhgL=klhgB*vec4(0.5)+(klhgR*vec4(0.5)+klhgG);vec4 zzonL=zzonB*vec4(0.5)+(zzonR*vec4(0.5)+zzonG);float bL=bczzL.x;float cL=bczzL.y;float iL=ijfeL.x;float jL=ijfeL.y;float fL=ijfeL.z;float eL=ijfeL.w;float kL=klhgL.x;float lL=klhgL.y;float hL=klhgL.z;float gL=klhgL.w;float oL=zzonL.z;float nL=zzonL.w;vec2 dir=vec2(0.0);float len=0.0;FsrEasuSetF(dir,len,pp,true, false,false,false,bL,eL,fL,gL,jL);FsrEasuSetF(dir,len,pp,false,true, false,false,cL,fL,gL,hL,kL);FsrEasuSetF(dir,len,pp,false,false,true, false,fL,iL,jL,kL,nL);FsrEasuSetF(dir,len,pp,false,false,false,true, gL,jL,kL,lL,oL);vec2 dir2=dir*dir;float dirR=dir2.x+dir2.y;bool zro=dirR<(1.0/32768.0);dirR=APrxLoRsqF1(dirR);dirR=zro ? 1.0 : dirR;dir.x=zro ? 1.0 : dir.x;dir*=vec2(dirR);len=len*0.5;len*=len;float stretch=(dir.x*dir.x+dir.y*dir.y)*APrxLoRcpF1(max(abs(dir.x),abs(dir.y)));vec2 len2=vec2(1.0+(stretch-1.0)*len,1.0+-0.5*len);float lob=0.5+((1.0/4.0-0.04)-0.5)*len;float clp=APrxLoRcpF1(lob);vec3 min4=min(AMin3F3(vec3(ijfeR.z,ijfeG.z,ijfeB.z),vec3(klhgR.w,klhgG.w,klhgB.w),vec3(ijfeR.y,ijfeG.y,ijfeB.y)),
|
|
49
|
+
vec3(klhgR.x,klhgG.x,klhgB.x));vec3 max4=max(AMax3F3(vec3(ijfeR.z,ijfeG.z,ijfeB.z),vec3(klhgR.w,klhgG.w,klhgB.w),vec3(ijfeR.y,ijfeG.y,ijfeB.y)),
|
|
50
|
+
vec3(klhgR.x,klhgG.x,klhgB.x));vec3 aC=vec3(0.0);float aW=0.0;FsrEasuTapF(aC,aW,vec2( 0.0,-1.0)-pp,dir,len2,lob,clp,vec3(bczzR.x,bczzG.x,bczzB.x));
|
|
51
|
+
FsrEasuTapF(aC,aW,vec2( 1.0,-1.0)-pp,dir,len2,lob,clp,vec3(bczzR.y,bczzG.y,bczzB.y));
|
|
52
|
+
FsrEasuTapF(aC,aW,vec2(-1.0, 1.0)-pp,dir,len2,lob,clp,vec3(ijfeR.x,ijfeG.x,ijfeB.x));
|
|
53
|
+
FsrEasuTapF(aC,aW,vec2( 0.0, 1.0)-pp,dir,len2,lob,clp,vec3(ijfeR.y,ijfeG.y,ijfeB.y));
|
|
54
|
+
FsrEasuTapF(aC,aW,vec2( 0.0, 0.0)-pp,dir,len2,lob,clp,vec3(ijfeR.z,ijfeG.z,ijfeB.z));
|
|
55
|
+
FsrEasuTapF(aC,aW,vec2(-1.0, 0.0)-pp,dir,len2,lob,clp,vec3(ijfeR.w,ijfeG.w,ijfeB.w));
|
|
56
|
+
FsrEasuTapF(aC,aW,vec2( 1.0, 1.0)-pp,dir,len2,lob,clp,vec3(klhgR.x,klhgG.x,klhgB.x));
|
|
57
|
+
FsrEasuTapF(aC,aW,vec2( 2.0, 1.0)-pp,dir,len2,lob,clp,vec3(klhgR.y,klhgG.y,klhgB.y));
|
|
58
|
+
FsrEasuTapF(aC,aW,vec2( 2.0, 0.0)-pp,dir,len2,lob,clp,vec3(klhgR.z,klhgG.z,klhgB.z));
|
|
59
|
+
FsrEasuTapF(aC,aW,vec2( 1.0, 0.0)-pp,dir,len2,lob,clp,vec3(klhgR.w,klhgG.w,klhgB.w));
|
|
60
|
+
FsrEasuTapF(aC,aW,vec2( 1.0, 2.0)-pp,dir,len2,lob,clp,vec3(zzonR.z,zzonG.z,zzonB.z));
|
|
61
|
+
FsrEasuTapF(aC,aW,vec2( 0.0, 2.0)-pp,dir,len2,lob,clp,vec3(zzonR.w,zzonG.w,zzonB.w));
|
|
62
|
+
return min(max4,max(min4,aC*vec3(1.0/aW)));}
|
|
63
|
+
void main() {ivec2 ip=ivec2(gl_FragCoord.xy);vec3 pix=FsrEasuF(ip,con0,con1,con2,con3);gl_FragColor=vec4(pix,1.0);}
|
|
64
|
+
`;
|
|
65
|
+
// Sideeffect
|
|
66
|
+
if (!ShaderStore.ShadersStore[name]) {
|
|
67
|
+
ShaderStore.ShadersStore[name] = shader;
|
|
68
|
+
}
|
|
69
|
+
const includes = [ffxFunctions];
|
|
70
|
+
for (const inc of includes) {
|
|
71
|
+
if (!ShaderStore.IncludesShadersStore[inc.name]) {
|
|
72
|
+
ShaderStore.IncludesShadersStore[inc.name] = inc.shader;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** @internal */
|
|
76
|
+
export const fsr1UpscalePixelShader = { name, shader };
|
|
77
|
+
//# sourceMappingURL=fsr1Upscale.fragment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fsr1Upscale.fragment.js","sourceRoot":"","sources":["../../../../dev/core/src/Shaders/fsr1Upscale.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,MAAM,IAAI,GAAG,wBAAwB,CAAC;AACtC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Dd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;IAClC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAC5C,CAAC;AACD,MAAM,QAAQ,GAAG,CAAC,YAAY,CAAC,CAAC;AAChC,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;IACzB,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9C,WAAW,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC;IAC5D,CAAC;AACL,CAAC;AAED,gBAAgB;AAChB,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\nimport { ffxFunctions } from \"./ShadersInclude/ffxFunctions\";\n\nconst name = \"fsr1UpscalePixelShader\";\nconst shader = `#include<ffxFunctions>\nuniform sampler2D textureSampler;varying vec2 vUV;uniform vec4 con0;uniform vec4 con1;uniform vec4 con2;uniform vec4 con3;vec4 FsrEasuRF(vec2 p) {ivec2 texSize=textureSize(textureSampler,0);ivec2 mx=texSize-ivec2(1);ivec2 base=ivec2(floor(p*vec2(texSize)-0.5));return vec4(\ntexelFetch(textureSampler,clamp(base+ivec2(0,1),ivec2(0),mx),0).r,\ntexelFetch(textureSampler,clamp(base+ivec2(1,1),ivec2(0),mx),0).r,\ntexelFetch(textureSampler,clamp(base+ivec2(1,0),ivec2(0),mx),0).r,\ntexelFetch(textureSampler,clamp(base+ivec2(0,0),ivec2(0),mx),0).r);}\nvec4 FsrEasuGF(vec2 p) {ivec2 texSize=textureSize(textureSampler,0);ivec2 mx=texSize-ivec2(1);ivec2 base=ivec2(floor(p*vec2(texSize)-0.5));return vec4(\ntexelFetch(textureSampler,clamp(base+ivec2(0,1),ivec2(0),mx),0).g,\ntexelFetch(textureSampler,clamp(base+ivec2(1,1),ivec2(0),mx),0).g,\ntexelFetch(textureSampler,clamp(base+ivec2(1,0),ivec2(0),mx),0).g,\ntexelFetch(textureSampler,clamp(base+ivec2(0,0),ivec2(0),mx),0).g);}\nvec4 FsrEasuBF(vec2 p) {ivec2 texSize=textureSize(textureSampler,0);ivec2 mx=texSize-ivec2(1);ivec2 base=ivec2(floor(p*vec2(texSize)-0.5));return vec4(\ntexelFetch(textureSampler,clamp(base+ivec2(0,1),ivec2(0),mx),0).b,\ntexelFetch(textureSampler,clamp(base+ivec2(1,1),ivec2(0),mx),0).b,\ntexelFetch(textureSampler,clamp(base+ivec2(1,0),ivec2(0),mx),0).b,\ntexelFetch(textureSampler,clamp(base+ivec2(0,0),ivec2(0),mx),0).b);}\nvoid FsrEasuTapF(\ninout vec3 aC,\ninout float aW,\nvec2 off,\nvec2 dir,\nvec2 len,\nfloat lob,\nfloat clp,\nvec3 c \n) {vec2 v;v.x=(off.x*( dir.x))+(off.y*dir.y);v.y=(off.x*(-dir.y))+(off.y*dir.x);v*=len;float d2=v.x*v.x+v.y*v.y;d2=min(d2,clp);float wB=2.0/5.0*d2+-1.0;float wA=lob*d2+-1.0;wB*=wB;wA*=wA;wB=25.0/16.0*wB+-(25.0/16.0-1.0);float w=wB*wA;aC+=c*w;aW+=w;}\nvoid FsrEasuSetF(\ninout vec2 dir,\ninout float len,\nvec2 pp,\nbool biS,bool biT,bool biU,bool biV,\nfloat lA,float lB,float lC,float lD,float lE\n) {float w=0.0;if (biS) {w=(1.0-pp.x)*(1.0-pp.y);}\nif (biT) {w=pp.x*(1.0-pp.y);}\nif (biU) {w=(1.0-pp.x)*pp.y;}\nif (biV) {w=pp.x*pp.y;}\nfloat dc=lD-lC;float cb=lC-lB;float lenX=max(abs(dc),abs(cb));lenX=APrxLoRcpF1(lenX);float dirX=lD-lB;dir.x+=dirX*w;lenX=clamp(abs(dirX)*lenX,0.0,1.0);lenX*=lenX;len+=lenX*w;float ec=lE-lC;float ca=lC-lA;float lenY=max(abs(ec),abs(ca));lenY=APrxLoRcpF1(lenY);float dirY=lE-lA;dir.y+=dirY*w;lenY=clamp(abs(dirY)*lenY,0.0,1.0);lenY*=lenY;len+=lenY*w;}\nvec3 FsrEasuF(\nivec2 ip,\nvec4 con0,\nvec4 con1,\nvec4 con2,\nvec4 con3\n) {vec2 pp=vec2(ip)*con0.xy+con0.zw;vec2 fp=floor(pp);pp-=fp;vec2 p0=fp*con1.xy+con1.zw;vec2 p1=p0+con2.xy;vec2 p2=p0+con2.zw;vec2 p3=p0+con3.xy;vec4 bczzR=FsrEasuRF(p0);vec4 bczzG=FsrEasuGF(p0);vec4 bczzB=FsrEasuBF(p0);vec4 ijfeR=FsrEasuRF(p1);vec4 ijfeG=FsrEasuGF(p1);vec4 ijfeB=FsrEasuBF(p1);vec4 klhgR=FsrEasuRF(p2);vec4 klhgG=FsrEasuGF(p2);vec4 klhgB=FsrEasuBF(p2);vec4 zzonR=FsrEasuRF(p3);vec4 zzonG=FsrEasuGF(p3);vec4 zzonB=FsrEasuBF(p3);vec4 bczzL=bczzB*vec4(0.5)+(bczzR*vec4(0.5)+bczzG);vec4 ijfeL=ijfeB*vec4(0.5)+(ijfeR*vec4(0.5)+ijfeG);vec4 klhgL=klhgB*vec4(0.5)+(klhgR*vec4(0.5)+klhgG);vec4 zzonL=zzonB*vec4(0.5)+(zzonR*vec4(0.5)+zzonG);float bL=bczzL.x;float cL=bczzL.y;float iL=ijfeL.x;float jL=ijfeL.y;float fL=ijfeL.z;float eL=ijfeL.w;float kL=klhgL.x;float lL=klhgL.y;float hL=klhgL.z;float gL=klhgL.w;float oL=zzonL.z;float nL=zzonL.w;vec2 dir=vec2(0.0);float len=0.0;FsrEasuSetF(dir,len,pp,true, false,false,false,bL,eL,fL,gL,jL);FsrEasuSetF(dir,len,pp,false,true, false,false,cL,fL,gL,hL,kL);FsrEasuSetF(dir,len,pp,false,false,true, false,fL,iL,jL,kL,nL);FsrEasuSetF(dir,len,pp,false,false,false,true, gL,jL,kL,lL,oL);vec2 dir2=dir*dir;float dirR=dir2.x+dir2.y;bool zro=dirR<(1.0/32768.0);dirR=APrxLoRsqF1(dirR);dirR=zro ? 1.0 : dirR;dir.x=zro ? 1.0 : dir.x;dir*=vec2(dirR);len=len*0.5;len*=len;float stretch=(dir.x*dir.x+dir.y*dir.y)*APrxLoRcpF1(max(abs(dir.x),abs(dir.y)));vec2 len2=vec2(1.0+(stretch-1.0)*len,1.0+-0.5*len);float lob=0.5+((1.0/4.0-0.04)-0.5)*len;float clp=APrxLoRcpF1(lob);vec3 min4=min(AMin3F3(vec3(ijfeR.z,ijfeG.z,ijfeB.z),vec3(klhgR.w,klhgG.w,klhgB.w),vec3(ijfeR.y,ijfeG.y,ijfeB.y)),\nvec3(klhgR.x,klhgG.x,klhgB.x));vec3 max4=max(AMax3F3(vec3(ijfeR.z,ijfeG.z,ijfeB.z),vec3(klhgR.w,klhgG.w,klhgB.w),vec3(ijfeR.y,ijfeG.y,ijfeB.y)),\nvec3(klhgR.x,klhgG.x,klhgB.x));vec3 aC=vec3(0.0);float aW=0.0;FsrEasuTapF(aC,aW,vec2( 0.0,-1.0)-pp,dir,len2,lob,clp,vec3(bczzR.x,bczzG.x,bczzB.x)); \nFsrEasuTapF(aC,aW,vec2( 1.0,-1.0)-pp,dir,len2,lob,clp,vec3(bczzR.y,bczzG.y,bczzB.y)); \nFsrEasuTapF(aC,aW,vec2(-1.0, 1.0)-pp,dir,len2,lob,clp,vec3(ijfeR.x,ijfeG.x,ijfeB.x)); \nFsrEasuTapF(aC,aW,vec2( 0.0, 1.0)-pp,dir,len2,lob,clp,vec3(ijfeR.y,ijfeG.y,ijfeB.y)); \nFsrEasuTapF(aC,aW,vec2( 0.0, 0.0)-pp,dir,len2,lob,clp,vec3(ijfeR.z,ijfeG.z,ijfeB.z)); \nFsrEasuTapF(aC,aW,vec2(-1.0, 0.0)-pp,dir,len2,lob,clp,vec3(ijfeR.w,ijfeG.w,ijfeB.w)); \nFsrEasuTapF(aC,aW,vec2( 1.0, 1.0)-pp,dir,len2,lob,clp,vec3(klhgR.x,klhgG.x,klhgB.x)); \nFsrEasuTapF(aC,aW,vec2( 2.0, 1.0)-pp,dir,len2,lob,clp,vec3(klhgR.y,klhgG.y,klhgB.y)); \nFsrEasuTapF(aC,aW,vec2( 2.0, 0.0)-pp,dir,len2,lob,clp,vec3(klhgR.z,klhgG.z,klhgB.z)); \nFsrEasuTapF(aC,aW,vec2( 1.0, 0.0)-pp,dir,len2,lob,clp,vec3(klhgR.w,klhgG.w,klhgB.w)); \nFsrEasuTapF(aC,aW,vec2( 1.0, 2.0)-pp,dir,len2,lob,clp,vec3(zzonR.z,zzonG.z,zzonB.z)); \nFsrEasuTapF(aC,aW,vec2( 0.0, 2.0)-pp,dir,len2,lob,clp,vec3(zzonR.w,zzonG.w,zzonB.w)); \nreturn min(max4,max(min4,aC*vec3(1.0/aW)));}\nvoid main() {ivec2 ip=ivec2(gl_FragCoord.xy);vec3 pix=FsrEasuF(ip,con0,con1,con2,con3);gl_FragColor=vec4(pix,1.0);}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStore[name]) {\n ShaderStore.ShadersStore[name] = shader;\n}\nconst includes = [ffxFunctions];\nfor (const inc of includes) {\n if (!ShaderStore.IncludesShadersStore[inc.name]) {\n ShaderStore.IncludesShadersStore[inc.name] = inc.shader;\n }\n}\n\n/** @internal */\nexport const fsr1UpscalePixelShader = { name, shader };\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../../Engines/shaderStore.js";
|
|
3
|
+
const name = "ffxFunctions";
|
|
4
|
+
const shader = `fn AMax3F1(x: f32,y: f32,z: f32)->f32 {return max(x,max(y,z));}
|
|
5
|
+
fn AMax3F3(x: vec3f,y: vec3f,z: vec3f)->vec3f {return max(x,max(y,z));}
|
|
6
|
+
fn AMin3F1(x: f32,y: f32,z: f32)->f32 {return min(x,min(y,z));}
|
|
7
|
+
fn AMin3F3(x: vec3f,y: vec3f,z: vec3f)->vec3f {return min(x,min(y,z));}
|
|
8
|
+
fn APrxLoRcpF1(a: f32)->f32 {return bitcast<f32>(u32(0x7ef07ebb)-bitcast<u32>(a));}
|
|
9
|
+
fn APrxMedRcpF1(a: f32)->f32 {let b=bitcast<f32>(u32(0x7ef19fff)-bitcast<u32>(a));return b*(-b*a+f32(2.0));}
|
|
10
|
+
fn APrxLoRsqF1(a: f32)->f32 {return bitcast<f32>(u32(0x5f347d74)-(bitcast<u32>(a)>>1));}
|
|
11
|
+
`;
|
|
12
|
+
// Sideeffect
|
|
13
|
+
if (!ShaderStore.IncludesShadersStoreWGSL[name]) {
|
|
14
|
+
ShaderStore.IncludesShadersStoreWGSL[name] = shader;
|
|
15
|
+
}
|
|
16
|
+
/** @internal */
|
|
17
|
+
export const ffxFunctionsWGSL = { name, shader };
|
|
18
|
+
//# sourceMappingURL=ffxFunctions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ffxFunctions.js","sourceRoot":"","sources":["../../../../../dev/core/src/ShadersWGSL/ShadersInclude/ffxFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,MAAM,IAAI,GAAG,cAAc,CAAC;AAC5B,MAAM,MAAM,GAAG;;;;;;;CAOd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC9C,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\nconst name = \"ffxFunctions\";\nconst shader = `fn AMax3F1(x: f32,y: f32,z: f32)->f32 {return max(x,max(y,z));}\nfn AMax3F3(x: vec3f,y: vec3f,z: vec3f)->vec3f {return max(x,max(y,z));}\nfn AMin3F1(x: f32,y: f32,z: f32)->f32 {return min(x,min(y,z));}\nfn AMin3F3(x: vec3f,y: vec3f,z: vec3f)->vec3f {return min(x,min(y,z));}\nfn APrxLoRcpF1(a: f32)->f32 {return bitcast<f32>(u32(0x7ef07ebb)-bitcast<u32>(a));}\nfn APrxMedRcpF1(a: f32)->f32 {let b=bitcast<f32>(u32(0x7ef19fff)-bitcast<u32>(a));return b*(-b*a+f32(2.0));}\nfn APrxLoRsqF1(a: f32)->f32 {return bitcast<f32>(u32(0x5f347d74)-(bitcast<u32>(a)>>1));}\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const ffxFunctionsWGSL = { name, shader };\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../Engines/shaderStore.js";
|
|
3
|
+
import { ffxFunctionsWGSL } from "./ShadersInclude/ffxFunctions.js";
|
|
4
|
+
const name = "fsr1SharpenPixelShader";
|
|
5
|
+
const shader = `#include<ffxFunctions>
|
|
6
|
+
#define FSR_RCAS_LIMIT (0.25-(1.0/16.0))
|
|
7
|
+
var textureSampler: texture_2d<f32>;uniform con: vec4f;fn FsrRcasLoadF(p: vec2i)->vec4f {return textureLoad(textureSampler,clamp(p,vec2i(0),vec2i(textureDimensions(textureSampler,0))-vec2i(1)),0);}
|
|
8
|
+
fn FsrRcasF(
|
|
9
|
+
pixR: ptr<function,f32>,
|
|
10
|
+
pixG: ptr<function,f32>,
|
|
11
|
+
pixB: ptr<function,f32>,
|
|
12
|
+
ip: vec2u,
|
|
13
|
+
con: vec4f
|
|
14
|
+
) {let sp=vec2i(ip);let b=FsrRcasLoadF(sp+vec2i( 0,-1)).rgb;let d=FsrRcasLoadF(sp+vec2i(-1,0)).rgb;let e=FsrRcasLoadF(sp).rgb;let f=FsrRcasLoadF(sp+vec2i( 1,0)).rgb;let h=FsrRcasLoadF(sp+vec2i( 0,1)).rgb;let bR=b.r;let bG=b.g;let bB=b.b;let dR=d.r;let dG=d.g;let dB=d.b;let eR=e.r;let eG=e.g;let eB=e.b;let fR=f.r;let fG=f.g;let fB=f.b;let hR=h.r;let hG=h.g;let hB=h.b;let bL=bB*f32(0.5)+(bR*f32(0.5)+bG);let dL=dB*f32(0.5)+(dR*f32(0.5)+dG);let eL=eB*f32(0.5)+(eR*f32(0.5)+eG);let fL=fB*f32(0.5)+(fR*f32(0.5)+fG);let hL=hB*f32(0.5)+(hR*f32(0.5)+hG);var nz=f32(0.25)*bL+f32(0.25)*dL+f32(0.25)*fL+f32(0.25)*hL-eL;nz=saturate(abs(nz)*APrxMedRcpF1(AMax3F1(AMax3F1(bL,dL,eL),fL,hL)-AMin3F1(AMin3F1(bL,dL,eL),fL,hL)));nz=f32(-0.5)*nz+f32(1.0);let mn4R=min(AMin3F1(bR,dR,fR),hR);let mn4G=min(AMin3F1(bG,dG,fG),hG);let mn4B=min(AMin3F1(bB,dB,fB),hB);let mx4R=max(AMax3F1(bR,dR,fR),hR);let mx4G=max(AMax3F1(bG,dG,fG),hG);let mx4B=max(AMax3F1(bB,dB,fB),hB);let peakC=vec2f(1.0,-1.0*4.0);let hitMinR=min(mn4R,eR)*(1.0/(f32(4.0)*mx4R));let hitMinG=min(mn4G,eG)*(1.0/(f32(4.0)*mx4G));let hitMinB=min(mn4B,eB)*(1.0/(f32(4.0)*mx4B));let hitMaxR=(peakC.x-max(mx4R,eR))*(1.0/(f32(4.0)*mn4R+peakC.y));let hitMaxG=(peakC.x-max(mx4G,eG))*(1.0/(f32(4.0)*mn4G+peakC.y));let hitMaxB=(peakC.x-max(mx4B,eB))*(1.0/(f32(4.0)*mn4B+peakC.y));let lobeR=max(-hitMinR,hitMaxR);let lobeG=max(-hitMinG,hitMaxG);let lobeB=max(-hitMinB,hitMaxB);var lobe=max(f32(-FSR_RCAS_LIMIT),min(AMax3F1(lobeR,lobeG,lobeB),f32(0.0)))*con.x;
|
|
15
|
+
#ifdef FSR_RCAS_DENOISE
|
|
16
|
+
lobe*=nz;
|
|
17
|
+
#endif
|
|
18
|
+
let rcpL=APrxMedRcpF1(f32(4.0)*lobe+f32(1.0));*pixR=(lobe*bR+lobe*dR+lobe*hR+lobe*fR+eR)*rcpL;*pixG=(lobe*bG+lobe*dG+lobe*hG+lobe*fG+eG)*rcpL;*pixB=(lobe*bB+lobe*dB+lobe*hB+lobe*fB+eB)*rcpL;return;}
|
|
19
|
+
@fragment
|
|
20
|
+
fn main(input: FragmentInputs)->FragmentOutputs {var pixR: f32;var pixG: f32;var pixB: f32;let ip=vec2u(fragmentInputs.position.xy);FsrRcasF(&pixR,&pixG,&pixB,ip,uniforms.con);fragmentOutputs.color=vec4f(pixR,pixG,pixB,1);}
|
|
21
|
+
`;
|
|
22
|
+
// Sideeffect
|
|
23
|
+
if (!ShaderStore.ShadersStoreWGSL[name]) {
|
|
24
|
+
ShaderStore.ShadersStoreWGSL[name] = shader;
|
|
25
|
+
}
|
|
26
|
+
const includes = [ffxFunctionsWGSL];
|
|
27
|
+
for (const inc of includes) {
|
|
28
|
+
if (!ShaderStore.IncludesShadersStoreWGSL[inc.name]) {
|
|
29
|
+
ShaderStore.IncludesShadersStoreWGSL[inc.name] = inc.shader;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** @internal */
|
|
33
|
+
export const fsr1SharpenPixelShaderWGSL = { name, shader };
|
|
34
|
+
//# sourceMappingURL=fsr1Sharpen.fragment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fsr1Sharpen.fragment.js","sourceRoot":"","sources":["../../../../dev/core/src/ShadersWGSL/fsr1Sharpen.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,MAAM,IAAI,GAAG,wBAAwB,CAAC;AACtC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;CAgBd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;IACtC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,CAAC;AACD,MAAM,QAAQ,GAAG,CAAC,gBAAgB,CAAC,CAAC;AACpC,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;IACzB,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAClD,WAAW,CAAC,wBAAwB,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC;IAChE,CAAC;AACL,CAAC;AAED,gBAAgB;AAChB,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\nimport { ffxFunctionsWGSL } from \"./ShadersInclude/ffxFunctions\";\n\nconst name = \"fsr1SharpenPixelShader\";\nconst shader = `#include<ffxFunctions>\n#define FSR_RCAS_LIMIT (0.25-(1.0/16.0))\nvar textureSampler: texture_2d<f32>;uniform con: vec4f;fn FsrRcasLoadF(p: vec2i)->vec4f {return textureLoad(textureSampler,clamp(p,vec2i(0),vec2i(textureDimensions(textureSampler,0))-vec2i(1)),0);}\nfn FsrRcasF(\npixR: ptr<function,f32>,\npixG: ptr<function,f32>,\npixB: ptr<function,f32>,\nip: vec2u,\ncon: vec4f \n) {let sp=vec2i(ip);let b=FsrRcasLoadF(sp+vec2i( 0,-1)).rgb;let d=FsrRcasLoadF(sp+vec2i(-1,0)).rgb;let e=FsrRcasLoadF(sp).rgb;let f=FsrRcasLoadF(sp+vec2i( 1,0)).rgb;let h=FsrRcasLoadF(sp+vec2i( 0,1)).rgb;let bR=b.r;let bG=b.g;let bB=b.b;let dR=d.r;let dG=d.g;let dB=d.b;let eR=e.r;let eG=e.g;let eB=e.b;let fR=f.r;let fG=f.g;let fB=f.b;let hR=h.r;let hG=h.g;let hB=h.b;let bL=bB*f32(0.5)+(bR*f32(0.5)+bG);let dL=dB*f32(0.5)+(dR*f32(0.5)+dG);let eL=eB*f32(0.5)+(eR*f32(0.5)+eG);let fL=fB*f32(0.5)+(fR*f32(0.5)+fG);let hL=hB*f32(0.5)+(hR*f32(0.5)+hG);var nz=f32(0.25)*bL+f32(0.25)*dL+f32(0.25)*fL+f32(0.25)*hL-eL;nz=saturate(abs(nz)*APrxMedRcpF1(AMax3F1(AMax3F1(bL,dL,eL),fL,hL)-AMin3F1(AMin3F1(bL,dL,eL),fL,hL)));nz=f32(-0.5)*nz+f32(1.0);let mn4R=min(AMin3F1(bR,dR,fR),hR);let mn4G=min(AMin3F1(bG,dG,fG),hG);let mn4B=min(AMin3F1(bB,dB,fB),hB);let mx4R=max(AMax3F1(bR,dR,fR),hR);let mx4G=max(AMax3F1(bG,dG,fG),hG);let mx4B=max(AMax3F1(bB,dB,fB),hB);let peakC=vec2f(1.0,-1.0*4.0);let hitMinR=min(mn4R,eR)*(1.0/(f32(4.0)*mx4R));let hitMinG=min(mn4G,eG)*(1.0/(f32(4.0)*mx4G));let hitMinB=min(mn4B,eB)*(1.0/(f32(4.0)*mx4B));let hitMaxR=(peakC.x-max(mx4R,eR))*(1.0/(f32(4.0)*mn4R+peakC.y));let hitMaxG=(peakC.x-max(mx4G,eG))*(1.0/(f32(4.0)*mn4G+peakC.y));let hitMaxB=(peakC.x-max(mx4B,eB))*(1.0/(f32(4.0)*mn4B+peakC.y));let lobeR=max(-hitMinR,hitMaxR);let lobeG=max(-hitMinG,hitMaxG);let lobeB=max(-hitMinB,hitMaxB);var lobe=max(f32(-FSR_RCAS_LIMIT),min(AMax3F1(lobeR,lobeG,lobeB),f32(0.0)))*con.x;\n#ifdef FSR_RCAS_DENOISE\nlobe*=nz;\n#endif\nlet rcpL=APrxMedRcpF1(f32(4.0)*lobe+f32(1.0));*pixR=(lobe*bR+lobe*dR+lobe*hR+lobe*fR+eR)*rcpL;*pixG=(lobe*bG+lobe*dG+lobe*hG+lobe*fG+eG)*rcpL;*pixB=(lobe*bB+lobe*dB+lobe*hB+lobe*fB+eB)*rcpL;return;}\n@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {var pixR: f32;var pixG: f32;var pixB: f32;let ip=vec2u(fragmentInputs.position.xy);FsrRcasF(&pixR,&pixG,&pixB,ip,uniforms.con);fragmentOutputs.color=vec4f(pixR,pixG,pixB,1);}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStoreWGSL[name]) {\n ShaderStore.ShadersStoreWGSL[name] = shader;\n}\nconst includes = [ffxFunctionsWGSL];\nfor (const inc of includes) {\n if (!ShaderStore.IncludesShadersStoreWGSL[inc.name]) {\n ShaderStore.IncludesShadersStoreWGSL[inc.name] = inc.shader;\n }\n}\n\n/** @internal */\nexport const fsr1SharpenPixelShaderWGSL = { name, shader };\n"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Do not edit.
|
|
2
|
+
import { ShaderStore } from "../Engines/shaderStore.js";
|
|
3
|
+
import { ffxFunctionsWGSL } from "./ShadersInclude/ffxFunctions.js";
|
|
4
|
+
const name = "fsr1UpscalePixelShader";
|
|
5
|
+
const shader = `#include<ffxFunctions>
|
|
6
|
+
var textureSampler: texture_2d<f32>;var textureSamplerSampler: sampler;uniform con0: vec4f;uniform con1: vec4f;uniform con2: vec4f;uniform con3: vec4f;fn FsrEasuRF(p: vec2f)->vec4f {return textureGather(0,textureSampler,textureSamplerSampler,p);}
|
|
7
|
+
fn FsrEasuGF(p: vec2f)->vec4f {return textureGather(1,textureSampler,textureSamplerSampler,p);}
|
|
8
|
+
fn FsrEasuBF(p: vec2f)->vec4f {return textureGather(2,textureSampler,textureSamplerSampler,p);}
|
|
9
|
+
fn FsrEasuTapF(
|
|
10
|
+
aC: ptr<function,vec3f>,
|
|
11
|
+
aW: ptr<function,f32>,
|
|
12
|
+
off: vec2f,
|
|
13
|
+
dir: vec2f,
|
|
14
|
+
len: vec2f,
|
|
15
|
+
lob: f32,
|
|
16
|
+
clp: f32,
|
|
17
|
+
c: vec3f
|
|
18
|
+
) {
|
|
19
|
+
var v: vec2f;v.x=(off.x*( dir.x))+(off.y*dir.y);v.y=(off.x*(-dir.y))+(off.y*dir.x);v*=len;var d2=v.x*v.x+v.y*v.y;d2=min(d2,clp);var wB=f32(2.0/5.0)*d2+f32(-1.0);var wA=lob*d2+(-1.0);wB*=wB;wA*=wA;wB=f32(25.0/16.0)*wB+f32(-(25.0/16.0-1.0));let w=wB*wA;*aC+=c*w;*aW+=w;}
|
|
20
|
+
fn FsrEasuSetF(
|
|
21
|
+
dir: ptr<function,vec2f>,
|
|
22
|
+
len: ptr<function,f32>,
|
|
23
|
+
pp: vec2f,
|
|
24
|
+
biS: bool,biT: bool,biU: bool,biV: bool,
|
|
25
|
+
lA: f32,lB: f32,lC: f32,lD: f32,lE: f32
|
|
26
|
+
) {var w=f32(0.0);if biS {w=(f32(1.0)-pp.x)*(f32(1.0)-pp.y);}
|
|
27
|
+
if biT {w= pp.x *(f32(1.0)-pp.y);}
|
|
28
|
+
if biU {w=(f32(1.0)-pp.x)* pp.y ;}
|
|
29
|
+
if biV {w= pp.x* pp.y ;}
|
|
30
|
+
let dc=lD-lC;let cb=lC-lB;var lenX=max(abs(dc),abs(cb));lenX=APrxLoRcpF1(lenX);let dirX=lD-lB;dir.x+=dirX*w;lenX=saturate(abs(dirX)*lenX);lenX*=lenX;*len+=lenX*w;let ec=lE-lC;let ca=lC-lA;var lenY=max(abs(ec),abs(ca));lenY=APrxLoRcpF1(lenY);let dirY=lE-lA;dir.y+=dirY*w;lenY=saturate(abs(dirY)*lenY);lenY*=lenY;*len+=lenY*w;}
|
|
31
|
+
fn FsrEasuF(
|
|
32
|
+
pix: ptr<function,vec3f>,
|
|
33
|
+
ip: vec2u,
|
|
34
|
+
con0: vec4f,
|
|
35
|
+
con1: vec4f,
|
|
36
|
+
con2: vec4f,
|
|
37
|
+
con3: vec4f
|
|
38
|
+
) {var pp=vec2f(ip)*con0.xy+con0.zw;let fp=floor(pp);pp-=fp;let p0=fp*con1.xy+con1.zw;let p1=p0+con2.xy;let p2=p0+con2.zw;let p3=p0+con3.xy;let bczzR=FsrEasuRF(p0);let bczzG=FsrEasuGF(p0);let bczzB=FsrEasuBF(p0);let ijfeR=FsrEasuRF(p1);let ijfeG=FsrEasuGF(p1);let ijfeB=FsrEasuBF(p1);let klhgR=FsrEasuRF(p2);let klhgG=FsrEasuGF(p2);let klhgB=FsrEasuBF(p2);let zzonR=FsrEasuRF(p3);let zzonG=FsrEasuGF(p3);let zzonB=FsrEasuBF(p3);let bczzL=bczzB*vec4f(0.5)+(bczzR*vec4f(0.5)+bczzG);let ijfeL=ijfeB*vec4f(0.5)+(ijfeR*vec4f(0.5)+ijfeG);let klhgL=klhgB*vec4f(0.5)+(klhgR*vec4f(0.5)+klhgG);let zzonL=zzonB*vec4f(0.5)+(zzonR*vec4f(0.5)+zzonG);let bL=bczzL.x;let cL=bczzL.y;let iL=ijfeL.x;let jL=ijfeL.y;let fL=ijfeL.z;let eL=ijfeL.w;let kL=klhgL.x;let lL=klhgL.y;let hL=klhgL.z;let gL=klhgL.w;let oL=zzonL.z;let nL=zzonL.w;var dir=vec2f(0.0);var len=f32(0.0);FsrEasuSetF(&dir,&len,pp,true,false,false,false,bL,eL,fL,gL,jL);FsrEasuSetF(&dir,&len,pp,false,true ,false,false,cL,fL,gL,hL,kL);FsrEasuSetF(&dir,&len,pp,false,false,true ,false,fL,iL,jL,kL,nL);FsrEasuSetF(&dir,&len,pp,false,false,false,true ,gL,jL,kL,lL,oL);let dir2=dir*dir;var dirR=dir2.x+dir2.y;var zro=dirR<f32(1.0/32768.0);dirR=APrxLoRsqF1(dirR);dirR=select(dirR,f32(1.0),zro);dir.x=select(dir.x,f32(1.0),zro);dir*=vec2f(dirR);len=len*f32(0.5);len*=len;let stretch=(dir.x*dir.x+dir.y*dir.y)*APrxLoRcpF1(max(abs(dir.x),abs(dir.y)));let len2=vec2f(f32(1.0)+(stretch-f32(1.0))*len,f32(1.0)+f32(-0.5)*len);let lob=f32(0.5)+f32((1.0/4.0-0.04)-0.5)*len;let clp=APrxLoRcpF1(lob);let min4=min(AMin3F3(vec3f(ijfeR.z,ijfeG.z,ijfeB.z),vec3f(klhgR.w,klhgG.w,klhgB.w),vec3f(ijfeR.y,ijfeG.y,ijfeB.y)),
|
|
39
|
+
vec3f(klhgR.x,klhgG.x,klhgB.x));let max4=max(AMax3F3(vec3f(ijfeR.z,ijfeG.z,ijfeB.z),vec3f(klhgR.w,klhgG.w,klhgB.w),vec3f(ijfeR.y,ijfeG.y,ijfeB.y)),
|
|
40
|
+
vec3f(klhgR.x,klhgG.x,klhgB.x));var aC=vec3f(0.0);var aW=f32(0.0);FsrEasuTapF(&aC,&aW,vec2f( 0.0,-1.0)-pp,dir,len2,lob,clp,vec3f(bczzR.x,bczzG.x,bczzB.x));
|
|
41
|
+
FsrEasuTapF(&aC,&aW,vec2f( 1.0,-1.0)-pp,dir,len2,lob,clp,vec3f(bczzR.y,bczzG.y,bczzB.y));
|
|
42
|
+
FsrEasuTapF(&aC,&aW,vec2f(-1.0,1.0)-pp,dir,len2,lob,clp,vec3f(ijfeR.x,ijfeG.x,ijfeB.x));
|
|
43
|
+
FsrEasuTapF(&aC,&aW,vec2f( 0.0,1.0)-pp,dir,len2,lob,clp,vec3f(ijfeR.y,ijfeG.y,ijfeB.y));
|
|
44
|
+
FsrEasuTapF(&aC,&aW,vec2f( 0.0,0.0)-pp,dir,len2,lob,clp,vec3f(ijfeR.z,ijfeG.z,ijfeB.z));
|
|
45
|
+
FsrEasuTapF(&aC,&aW,vec2f(-1.0,0.0)-pp,dir,len2,lob,clp,vec3f(ijfeR.w,ijfeG.w,ijfeB.w));
|
|
46
|
+
FsrEasuTapF(&aC,&aW,vec2f( 1.0,1.0)-pp,dir,len2,lob,clp,vec3f(klhgR.x,klhgG.x,klhgB.x));
|
|
47
|
+
FsrEasuTapF(&aC,&aW,vec2f( 2.0,1.0)-pp,dir,len2,lob,clp,vec3f(klhgR.y,klhgG.y,klhgB.y));
|
|
48
|
+
FsrEasuTapF(&aC,&aW,vec2f( 2.0,0.0)-pp,dir,len2,lob,clp,vec3f(klhgR.z,klhgG.z,klhgB.z));
|
|
49
|
+
FsrEasuTapF(&aC,&aW,vec2f( 1.0,0.0)-pp,dir,len2,lob,clp,vec3f(klhgR.w,klhgG.w,klhgB.w));
|
|
50
|
+
FsrEasuTapF(&aC,&aW,vec2f( 1.0,2.0)-pp,dir,len2,lob,clp,vec3f(zzonR.z,zzonG.z,zzonB.z));
|
|
51
|
+
FsrEasuTapF(&aC,&aW,vec2f( 0.0,2.0)-pp,dir,len2,lob,clp,vec3f(zzonR.w,zzonG.w,zzonB.w));
|
|
52
|
+
*pix=min(max4,max(min4,aC*vec3f(1.0/aW)));}
|
|
53
|
+
@fragment
|
|
54
|
+
fn main(input: FragmentInputs)->FragmentOutputs {var pix: vec3f;let ip=vec2u(fragmentInputs.position.xy);FsrEasuF(&pix,ip,uniforms.con0,uniforms.con1,uniforms.con2,uniforms.con3);fragmentOutputs.color=vec4f(pix,1);}
|
|
55
|
+
`;
|
|
56
|
+
// Sideeffect
|
|
57
|
+
if (!ShaderStore.ShadersStoreWGSL[name]) {
|
|
58
|
+
ShaderStore.ShadersStoreWGSL[name] = shader;
|
|
59
|
+
}
|
|
60
|
+
const includes = [ffxFunctionsWGSL];
|
|
61
|
+
for (const inc of includes) {
|
|
62
|
+
if (!ShaderStore.IncludesShadersStoreWGSL[inc.name]) {
|
|
63
|
+
ShaderStore.IncludesShadersStoreWGSL[inc.name] = inc.shader;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** @internal */
|
|
67
|
+
export const fsr1UpscalePixelShaderWGSL = { name, shader };
|
|
68
|
+
//# sourceMappingURL=fsr1Upscale.fragment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fsr1Upscale.fragment.js","sourceRoot":"","sources":["../../../../dev/core/src/ShadersWGSL/fsr1Upscale.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,MAAM,IAAI,GAAG,wBAAwB,CAAC;AACtC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;IACtC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,CAAC;AACD,MAAM,QAAQ,GAAG,CAAC,gBAAgB,CAAC,CAAC;AACpC,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;IACzB,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAClD,WAAW,CAAC,wBAAwB,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC;IAChE,CAAC;AACL,CAAC;AAED,gBAAgB;AAChB,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\nimport { ffxFunctionsWGSL } from \"./ShadersInclude/ffxFunctions\";\n\nconst name = \"fsr1UpscalePixelShader\";\nconst shader = `#include<ffxFunctions>\nvar textureSampler: texture_2d<f32>;var textureSamplerSampler: sampler;uniform con0: vec4f;uniform con1: vec4f;uniform con2: vec4f;uniform con3: vec4f;fn FsrEasuRF(p: vec2f)->vec4f {return textureGather(0,textureSampler,textureSamplerSampler,p);}\nfn FsrEasuGF(p: vec2f)->vec4f {return textureGather(1,textureSampler,textureSamplerSampler,p);}\nfn FsrEasuBF(p: vec2f)->vec4f {return textureGather(2,textureSampler,textureSamplerSampler,p);}\nfn FsrEasuTapF(\naC: ptr<function,vec3f>,\naW: ptr<function,f32>,\noff: vec2f,\ndir: vec2f,\nlen: vec2f,\nlob: f32,\nclp: f32,\nc: vec3f \n) { \nvar v: vec2f;v.x=(off.x*( dir.x))+(off.y*dir.y);v.y=(off.x*(-dir.y))+(off.y*dir.x);v*=len;var d2=v.x*v.x+v.y*v.y;d2=min(d2,clp);var wB=f32(2.0/5.0)*d2+f32(-1.0);var wA=lob*d2+(-1.0);wB*=wB;wA*=wA;wB=f32(25.0/16.0)*wB+f32(-(25.0/16.0-1.0));let w=wB*wA;*aC+=c*w;*aW+=w;}\nfn FsrEasuSetF(\ndir: ptr<function,vec2f>,\nlen: ptr<function,f32>,\npp: vec2f,\nbiS: bool,biT: bool,biU: bool,biV: bool,\nlA: f32,lB: f32,lC: f32,lD: f32,lE: f32\n) {var w=f32(0.0);if biS {w=(f32(1.0)-pp.x)*(f32(1.0)-pp.y);}\nif biT {w= pp.x *(f32(1.0)-pp.y);}\nif biU {w=(f32(1.0)-pp.x)* pp.y ;}\nif biV {w= pp.x* pp.y ;}\nlet dc=lD-lC;let cb=lC-lB;var lenX=max(abs(dc),abs(cb));lenX=APrxLoRcpF1(lenX);let dirX=lD-lB;dir.x+=dirX*w;lenX=saturate(abs(dirX)*lenX);lenX*=lenX;*len+=lenX*w;let ec=lE-lC;let ca=lC-lA;var lenY=max(abs(ec),abs(ca));lenY=APrxLoRcpF1(lenY);let dirY=lE-lA;dir.y+=dirY*w;lenY=saturate(abs(dirY)*lenY);lenY*=lenY;*len+=lenY*w;}\nfn FsrEasuF(\npix: ptr<function,vec3f>,\nip: vec2u,\ncon0: vec4f,\ncon1: vec4f,\ncon2: vec4f,\ncon3: vec4f\n) {var pp=vec2f(ip)*con0.xy+con0.zw;let fp=floor(pp);pp-=fp;let p0=fp*con1.xy+con1.zw;let p1=p0+con2.xy;let p2=p0+con2.zw;let p3=p0+con3.xy;let bczzR=FsrEasuRF(p0);let bczzG=FsrEasuGF(p0);let bczzB=FsrEasuBF(p0);let ijfeR=FsrEasuRF(p1);let ijfeG=FsrEasuGF(p1);let ijfeB=FsrEasuBF(p1);let klhgR=FsrEasuRF(p2);let klhgG=FsrEasuGF(p2);let klhgB=FsrEasuBF(p2);let zzonR=FsrEasuRF(p3);let zzonG=FsrEasuGF(p3);let zzonB=FsrEasuBF(p3);let bczzL=bczzB*vec4f(0.5)+(bczzR*vec4f(0.5)+bczzG);let ijfeL=ijfeB*vec4f(0.5)+(ijfeR*vec4f(0.5)+ijfeG);let klhgL=klhgB*vec4f(0.5)+(klhgR*vec4f(0.5)+klhgG);let zzonL=zzonB*vec4f(0.5)+(zzonR*vec4f(0.5)+zzonG);let bL=bczzL.x;let cL=bczzL.y;let iL=ijfeL.x;let jL=ijfeL.y;let fL=ijfeL.z;let eL=ijfeL.w;let kL=klhgL.x;let lL=klhgL.y;let hL=klhgL.z;let gL=klhgL.w;let oL=zzonL.z;let nL=zzonL.w;var dir=vec2f(0.0);var len=f32(0.0);FsrEasuSetF(&dir,&len,pp,true,false,false,false,bL,eL,fL,gL,jL);FsrEasuSetF(&dir,&len,pp,false,true ,false,false,cL,fL,gL,hL,kL);FsrEasuSetF(&dir,&len,pp,false,false,true ,false,fL,iL,jL,kL,nL);FsrEasuSetF(&dir,&len,pp,false,false,false,true ,gL,jL,kL,lL,oL);let dir2=dir*dir;var dirR=dir2.x+dir2.y;var zro=dirR<f32(1.0/32768.0);dirR=APrxLoRsqF1(dirR);dirR=select(dirR,f32(1.0),zro);dir.x=select(dir.x,f32(1.0),zro);dir*=vec2f(dirR);len=len*f32(0.5);len*=len;let stretch=(dir.x*dir.x+dir.y*dir.y)*APrxLoRcpF1(max(abs(dir.x),abs(dir.y)));let len2=vec2f(f32(1.0)+(stretch-f32(1.0))*len,f32(1.0)+f32(-0.5)*len);let lob=f32(0.5)+f32((1.0/4.0-0.04)-0.5)*len;let clp=APrxLoRcpF1(lob);let min4=min(AMin3F3(vec3f(ijfeR.z,ijfeG.z,ijfeB.z),vec3f(klhgR.w,klhgG.w,klhgB.w),vec3f(ijfeR.y,ijfeG.y,ijfeB.y)),\nvec3f(klhgR.x,klhgG.x,klhgB.x));let max4=max(AMax3F3(vec3f(ijfeR.z,ijfeG.z,ijfeB.z),vec3f(klhgR.w,klhgG.w,klhgB.w),vec3f(ijfeR.y,ijfeG.y,ijfeB.y)),\nvec3f(klhgR.x,klhgG.x,klhgB.x));var aC=vec3f(0.0);var aW=f32(0.0);FsrEasuTapF(&aC,&aW,vec2f( 0.0,-1.0)-pp,dir,len2,lob,clp,vec3f(bczzR.x,bczzG.x,bczzB.x)); \nFsrEasuTapF(&aC,&aW,vec2f( 1.0,-1.0)-pp,dir,len2,lob,clp,vec3f(bczzR.y,bczzG.y,bczzB.y)); \nFsrEasuTapF(&aC,&aW,vec2f(-1.0,1.0)-pp,dir,len2,lob,clp,vec3f(ijfeR.x,ijfeG.x,ijfeB.x)); \nFsrEasuTapF(&aC,&aW,vec2f( 0.0,1.0)-pp,dir,len2,lob,clp,vec3f(ijfeR.y,ijfeG.y,ijfeB.y)); \nFsrEasuTapF(&aC,&aW,vec2f( 0.0,0.0)-pp,dir,len2,lob,clp,vec3f(ijfeR.z,ijfeG.z,ijfeB.z)); \nFsrEasuTapF(&aC,&aW,vec2f(-1.0,0.0)-pp,dir,len2,lob,clp,vec3f(ijfeR.w,ijfeG.w,ijfeB.w)); \nFsrEasuTapF(&aC,&aW,vec2f( 1.0,1.0)-pp,dir,len2,lob,clp,vec3f(klhgR.x,klhgG.x,klhgB.x)); \nFsrEasuTapF(&aC,&aW,vec2f( 2.0,1.0)-pp,dir,len2,lob,clp,vec3f(klhgR.y,klhgG.y,klhgB.y)); \nFsrEasuTapF(&aC,&aW,vec2f( 2.0,0.0)-pp,dir,len2,lob,clp,vec3f(klhgR.z,klhgG.z,klhgB.z)); \nFsrEasuTapF(&aC,&aW,vec2f( 1.0,0.0)-pp,dir,len2,lob,clp,vec3f(klhgR.w,klhgG.w,klhgB.w)); \nFsrEasuTapF(&aC,&aW,vec2f( 1.0,2.0)-pp,dir,len2,lob,clp,vec3f(zzonR.z,zzonG.z,zzonB.z)); \nFsrEasuTapF(&aC,&aW,vec2f( 0.0,2.0)-pp,dir,len2,lob,clp,vec3f(zzonR.w,zzonG.w,zzonB.w)); \n*pix=min(max4,max(min4,aC*vec3f(1.0/aW)));}\n@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {var pix: vec3f;let ip=vec2u(fragmentInputs.position.xy);FsrEasuF(&pix,ip,uniforms.con0,uniforms.con1,uniforms.con2,uniforms.con3);fragmentOutputs.color=vec4f(pix,1);}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStoreWGSL[name]) {\n ShaderStore.ShadersStoreWGSL[name] = shader;\n}\nconst includes = [ffxFunctionsWGSL];\nfor (const inc of includes) {\n if (!ShaderStore.IncludesShadersStoreWGSL[inc.name]) {\n ShaderStore.IncludesShadersStoreWGSL[inc.name] = inc.shader;\n }\n}\n\n/** @internal */\nexport const fsr1UpscalePixelShaderWGSL = { name, shader };\n"]}
|