新增unity的牛逼shader和熊猫超级shader
This commit is contained in:
1 parent
6001f6d87a
commit
1a4cd29e7c
216 files changed
+41947
No files matched your search
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 944a1679494774748b2936893c18c9ce
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,320 @@
|
||||
#ifndef EFFECT_FLAGS
|
||||
#define EFFECT_FLAGS
|
||||
|
||||
#define FLAG_BIT_SATURABILITY_ON (1 << 0)
|
||||
#define FLAG_BIT_PARTICLE_NOISE_CHORATICABERRAT_WITH_NOISE (1 << 1)
|
||||
#define FLAG_BIT_PARTICLE_FRESNEL_FADE_ON (1 << 2)
|
||||
#define FLAG_BIT_PARTICLE_FRESNEL_COLOR_ON (1 << 3)
|
||||
#define FLAG_BIT_PARTICLE_USETEXCOORD2 (1 << 4)
|
||||
#define FLAG_BIT_PARTICLE_DISTANCEFADE_ON (1 << 5)
|
||||
#define FLAG_BIT_PARTICLE_CHORATICABERRAT (1 << 6)
|
||||
#define FLAG_BIT_PARTILCE_MASKMAPROTATIONANIMATION_ON (1 << 7)
|
||||
#define FLAG_BIT_PARTICLE_POLARCOORDINATES_ON (1 << 8)
|
||||
#define FLAG_BIT_PARTICLE_UTWIRL_ON (1 << 9)
|
||||
#define FLAG_BIT_PARTICLE_LINEARTOGAMMA_ON (1 << 10)
|
||||
#define FLAG_BIT_PARTICLE_FRESNEL_ON (1 << 11)
|
||||
#define FLAG_BIT_PARTICLE_NOISEMAP_NORMALIZEED_ON (1 << 12)
|
||||
#define FLAG_BIT_PARTICLE_FRESNEL_COLOR_AFFETCT_BY_ALPHA (1 << 13)
|
||||
#define FLAG_BIT_PARTICLE_UIEFFECT_ON (1 << 14)
|
||||
#define FLAG_BIT_PARTICLE_UNSCALETIME_ON (1 << 15)
|
||||
#define FLAG_BIT_PARTICLE_SCRIPTABLETIME_ON (1 << 16)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA1_ON (1 << 17)
|
||||
#define FLAG_BIT_PARTICLE_FRESNEL_INVERT_ON (1 << 18)
|
||||
#define FLAG_BIT_HUESHIFT_ON (1 << 19)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA2_ON (1 << 20)
|
||||
#define FLAG_BIT_PARTICLE_NORMALMAP_MASK_MODE (1 << 21)
|
||||
#define FLAG_BIT_PARTICLE_COLOR_ADJUSTMENT_ONLY_AFFECT_MAINTEX (1 << 22)
|
||||
#define FLAG_BIT_PARTICLE_RAMP_COLOR_MAP_MODE_ON (1 << 23)
|
||||
#define FLAG_BIT_PARTICLE_RAMP_COLOR_BLEND_ADD (1 << 24)
|
||||
#define FLAG_BIT_PARTICLE_COLOR_BLEND_ALPHA_MULTIPLY_MODE (1 << 25)
|
||||
#define FLAG_BIT_PARTICLE_DISSOLVE_RAMP_MAP (1 << 26)
|
||||
#define FLAG_BIT_PARTICLE_DISSOLVE_MASK (1 << 27)
|
||||
#define FLAG_BIT_PARTICLE_BACKCOLOR (1 << 28)
|
||||
#define FLAG_BIT_PARTICLE_COLOR_MULTI_ALPHA (1 << 29)
|
||||
#define FLAG_BIT_PARTICLE_VERTEX_OFFSET_ON (1 << 30)
|
||||
#define FLAG_BIT_PARTICLE_VERTEX_OFFSET_NORMAL_DIR (1 << 31)
|
||||
// uint _W9ParticleShaderFlags;
|
||||
|
||||
#define FLAG_BIT_PARTICLE_1_DEPTH_OUTLINE (1 << 0)
|
||||
#define FLAG_BIT_PARTICLE_1_PARALLAX_MAPPING (1 << 1)
|
||||
#define FLAG_BIT_PARTICLE_1_MASKMAP_GRADIENT (1 << 2)
|
||||
#define FLAG_BIT_PARTICLE_1_MASKMAP_2_GRADIENT (1 << 3)
|
||||
#define FLAG_BIT_PARTICLE_1_MASKMAP_3_GRADIENT (1 << 4)
|
||||
#define FLAG_BIT_PARTICLE_1_DISSOLVE_LINE_MASK (1 << 5)
|
||||
#define FLAG_BIT_PARTICLE_1_DISSOLVE_RAMP_MULITPLY (1 << 6)
|
||||
#define FLAG_BIT_PARTICLE_1_MASK_REFINE (1 << 7)
|
||||
#define FLAG_BIT_PARTICLE_1_SCREEN_DISTORT_ALPHA_REFINE (1 << 8)
|
||||
#define FLAG_BIT_PARTICLE_1_IGNORE_VERTEX_COLOR (1 << 9)
|
||||
#define FLAG_BIT_PARTICLE_1_PROGRAM_NOISE_SIMPLE (1 << 10)
|
||||
#define FLAG_BIT_PARTICLE_1_DISSOVLE_USE_RAMP (1 << 11)
|
||||
#define FLAG_BIT_PARTICLE_1_MASK_MAP2 (1 << 12)
|
||||
#define FLAG_BIT_PARTICLE_1_MASK_MAP3 (1 << 13)
|
||||
#define FLAG_BIT_PARTICLE_1_NOISE_MASKMAP (1 << 14)
|
||||
#define FLAG_BIT_PARTICLE_1_ANIMATION_SHEET_HELPER (1 << 15)
|
||||
#define FLAG_BIT_PARTICLE_1_PROGRAM_NOISE_VORONOI (1 << 16)
|
||||
#define FLAG_BIT_PARTICLE_1_UIEFFECT_SPRITE_MODE (1 << 17)
|
||||
#define FLAG_BIT_PARTICLE_1_USE_TEXCOORD1 (1 << 18)
|
||||
#define FLAG_BIT_PARTICLE_1_USE_TEXCOORD2 (1 << 19)
|
||||
#define FLAG_BIT_PARTICLE_1_CYLINDER_CORDINATE (1 << 20)
|
||||
#define FLAG_BIT_PARTICLE_1_UV_FROM_MESH (1 << 21)
|
||||
#define FLAG_BIT_PARTICLE_1_UIEFFECT_BASEMAP_MODE (1 << 22)
|
||||
#define FLAG_BIT_PARTICLE_1_IS_PARTICLE_SYSTEM (1 << 23)
|
||||
#define FLAG_BIT_PARTICLE_1_MAINTEX_CONTRAST (1 << 24)
|
||||
#define FLAG_BIT_PARTICLE_1_VERTEXOFFSET_START_FROM_ZERO (1 << 25)
|
||||
#define FLAG_BIT_PARTICLE_1_VERTEXOFFSET_MASKMAP (1 << 26)
|
||||
#define FLAG_BIT_PARTICLE_1_MAINTEX_COLOR_REFINE (1 << 27)
|
||||
#define FLAG_BIT_PARTICLE_1_BUMP_TEX_UV_FOLLOW_MAINTEX (1 << 28)
|
||||
#define FLAG_BIT_PARTICLE_1_SIXWAY_RAMPMAP (1 << 29)
|
||||
#define FLAG_BIT_PARTICLE_1_MATCAP_MULTY_MODE (1 << 30)
|
||||
|
||||
|
||||
//WrapMode不能够超过16位(因为会占用x和x+16两个bit位)
|
||||
#define FLAG_BIT_WRAPMODE_BASEMAP (1 << 0)
|
||||
#define FLAG_BIT_WRAPMODE_MASKMAP (1 << 1)
|
||||
#define FLAG_BIT_WRAPMODE_MASKMAP2 (1 << 2)
|
||||
#define FLAG_BIT_WRAPMODE_NOISEMAP (1 << 3)
|
||||
#define FLAG_BIT_WRAPMODE_EMISSIONMAP (1 << 4)
|
||||
#define FLAG_BIT_WRAPMODE_DISSOLVE_MAP (1 << 5)
|
||||
#define FLAG_BIT_WRAPMODE_DISSOLVE_MASKMAP (1 << 6)
|
||||
#define FLAG_BIT_WRAPMODE_DISSOLVE_RAMPMAP (1 << 7)
|
||||
#define FLAG_BIT_WRAPMODE_COLORBLENDMAP (1 << 8)
|
||||
#define FLAG_BIT_WRAPMODE_VERTEXOFFSETMAP (1 << 9)
|
||||
#define FLAG_BIT_WRAPMODE_PARALLAXMAPPINGMAP (1 << 10)
|
||||
#define FLAG_BIT_WRAPMODE_MASKMAP3 (1 << 11)
|
||||
#define FLAG_BIT_WRAPMODE_NOISE_MASKMAP (1 << 12)
|
||||
#define FLAG_BIT_WRAPMODE_VERTEXOFFSET_MASKMAP (1 << 13)
|
||||
#define FLAG_BIT_WRAPMODE_BUMPTEX (1 << 14)
|
||||
#define FLAG_BIT_WRAPMODE_RAMP_COLOR_MAP (1 << 15)
|
||||
|
||||
#define FLAGBIT_POS_0_CUSTOMDATA_MAINTEX_OFFSET_X (0*4)
|
||||
#define FLAGBIT_POS_0_CUSTOMDATA_MAINTEX_OFFSET_Y (1*4)
|
||||
#define FLAGBIT_POS_0_CUSTOMDATA_DISSOLVE_INTENSITY (2*4)
|
||||
#define FLAGBIT_POS_0_CUSTOMDATA_HUESHIFT (3*4)
|
||||
#define FLAGBIT_POS_0_CUSTOMDATA_MASK_OFFSET_X (4*4)
|
||||
#define FLAGBIT_POS_0_CUSTOMDATA_MASK_OFFSET_Y (5*4)
|
||||
#define FLAGBIT_POS_0_CUSTOMDATA_FRESNEL_OFFSET (6*4)
|
||||
#define FLAGBIT_POS_0_CUSTOMDATA_CHORATICABERRAT_INTENSITY (7*4)
|
||||
|
||||
#define FLAGBIT_POS_1_CUSTOMDATA_DISSOLVE_OFFSET_X (0*4)
|
||||
#define FLAGBIT_POS_1_CUSTOMDATA_DISSOLVE_OFFSET_Y (1*4)
|
||||
#define FLAGBIT_POS_1_CUSTOMDATA_NOISE_INTENSITY (2*4)
|
||||
#define FLAGBIT_POS_1_CUSTOMDATA_SATURATE (3*4)
|
||||
#define FLAGBIT_POS_1_CUSTOMDATA_VERTEX_OFFSET_X (4*4)
|
||||
#define FLAGBIT_POS_1_CUSTOMDATA_VERTEX_OFFSET_Y (5*4)
|
||||
#define FLAGBIT_POS_1_CUSTOMDATA_VERTEXOFFSET_INTENSITY (6*4)
|
||||
#define FLAGBIT_POS_1_CUSTOMDATA_DISSOLVE_MASK_INTENSITY (7*4)
|
||||
|
||||
#define FLAGBIT_POS_2_CUSTOMDATA_DISSOLVE_NOISE1_OFFSET_X (0*4)
|
||||
#define FLAGBIT_POS_2_CUSTOMDATA_DISSOLVE_NOISE1_OFFSET_Y (1*4)
|
||||
#define FLAGBIT_POS_2_CUSTOMDATA_DISSOLVE_NOISE2_OFFSET_X (2*4)
|
||||
#define FLAGBIT_POS_2_CUSTOMDATA_DISSOLVE_NOISE2_OFFSET_Y (3*4)
|
||||
#define FLAGBIT_POS_2_CUSTOMDATA_NOISE_DIRECTION_X (4*4)
|
||||
#define FLAGBIT_POS_2_CUSTOMDATA_NOISE_DIRECTION_Y (5*4)
|
||||
#define FLAGBIT_POS_2_CUSTOMDATA_MAINTEX_CONTRAST (6*4)
|
||||
//---->这里还有一个坑可以用哦
|
||||
|
||||
#define FLAGBIT_POS_3_CUSTOMDATA_VERTEX_OFFSET_MASK_X (0*4)
|
||||
#define FLAGBIT_POS_3_CUSTOMDATA_VERTEX_OFFSET_MASK_Y (1*4)
|
||||
#define FLAGBIT_POS_3_CUSTOMDATA_SHARED_UV_OFFSET_X (2*4)
|
||||
#define FLAGBIT_POS_3_CUSTOMDATA_SHARED_UV_OFFSET_Y (3*4)
|
||||
|
||||
#define isCustomDataBit (1 << 3)
|
||||
#define Data12Bit (1 << 2)
|
||||
#define DataXYorZWBit (1 << 1)
|
||||
#define DataXZorYWBit (1 << 0)
|
||||
|
||||
#define FLAG_BIT_UVMODE_POS_0_MAINTEX (0*2)
|
||||
#define FLAG_BIT_UVMODE_POS_0_MASKMAP (1*2)
|
||||
#define FLAG_BIT_UVMODE_POS_0_MASKMAP_2 (2*2)
|
||||
#define FLAG_BIT_UVMODE_POS_0_MASKMAP_3 (3*2)
|
||||
#define FLAG_BIT_UVMODE_POS_0_NOISE_MAP (4*2)
|
||||
#define FLAG_BIT_UVMODE_POS_0_NOISE_MASK_MAP (5*2)
|
||||
#define FLAG_BIT_UVMODE_POS_0_EMISSION_MAP (6*2)
|
||||
#define FLAG_BIT_UVMODE_POS_0_DISSOLVE_MAP (7*2)
|
||||
#define FLAG_BIT_UVMODE_POS_0_DISSOLVE_MASK_MAP (8*2)
|
||||
#define FLAG_BIT_UVMODE_POS_0_COLOR_BLEND_MAP (9*2)
|
||||
#define FLAG_BIT_UVMODE_POS_0_VERTEX_OFFSET_MAP (10*2)
|
||||
#define FLAG_BIT_UVMODE_POS_0_VERTEX_OFFSET_MASKMAP (11*2)
|
||||
#define FLAG_BIT_UVMODE_POS_0_BUMPTEX (12*2)
|
||||
#define FLAG_BIT_UVMODE_POS_0_RAMP_COLOR_MAP (13*2)
|
||||
#define FLAG_BIT_UVMODE_POS_0_PROGRAM_NOISE (14*2)
|
||||
#define FLAG_BIT_UVMODE_POS_0_SHAREDUV (15*2)
|
||||
|
||||
#define FLAG_BIT_COLOR_CHANNEL_POS_0_MAINTEX_ALPHA (0*2)
|
||||
#define FLAG_BIT_COLOR_CHANNEL_POS_0_MASKMAP1 (1*2)
|
||||
#define FLAG_BIT_COLOR_CHANNEL_POS_0_MASKMAP2 (2*2)
|
||||
#define FLAG_BIT_COLOR_CHANNEL_POS_0_MASKMAP3 (3*2)
|
||||
#define FLAG_BIT_COLOR_CHANNEL_POS_0_NOISE_MASK (4*2)
|
||||
#define FLAG_BIT_COLOR_CHANNEL_POS_0_DISSOLVE_MAP (5*2)
|
||||
#define FLAG_BIT_COLOR_CHANNEL_POS_0_DISSOLVE_MASK_MAP (6*2)
|
||||
#define FLAG_BIT_COLOR_CHANNEL_POS_0_RAMP_COLOR_MAP (7*2)
|
||||
|
||||
float GetCustomData(uint flagProperty,int flagPos,float orignValue,half4 cutstomData1,half4 customData2)
|
||||
{
|
||||
uint bit = flagProperty >> flagPos;
|
||||
|
||||
// bit &= 15;// binary 1111 这一步可能是没必要的。
|
||||
UNITY_BRANCH
|
||||
if((bit & isCustomDataBit) == 0)
|
||||
{
|
||||
return orignValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
half4 customData = 0;
|
||||
if((bit & Data12Bit))
|
||||
{
|
||||
customData = cutstomData1;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
customData = customData2;
|
||||
}
|
||||
|
||||
if(bit & DataXYorZWBit)
|
||||
{
|
||||
if(bit & DataXZorYWBit)
|
||||
{
|
||||
return customData.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
return customData.y;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(bit & DataXZorYWBit)
|
||||
{
|
||||
return customData.z;
|
||||
}
|
||||
else
|
||||
{
|
||||
return customData.w;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 999;//提示错误
|
||||
}
|
||||
|
||||
|
||||
struct BaseUVs
|
||||
{
|
||||
float2 defaultUVChannel;
|
||||
float2 specialUVChannel;
|
||||
float2 uvAfterTwirlPolar;
|
||||
float2 cylinderUV;
|
||||
float2 mainTexUV;
|
||||
float2 screenUV;
|
||||
float2 worldPosUV;
|
||||
float2 objectPosUV;
|
||||
float2 sharedUV;
|
||||
};
|
||||
|
||||
float2 GetUVByUVMode(uint flagProperty,uint flagTypeProperty,int flagPos,BaseUVs baseUVs)
|
||||
{
|
||||
flagProperty = flagProperty >> flagPos;
|
||||
flagProperty &= 3;
|
||||
flagTypeProperty = flagTypeProperty >> flagPos;
|
||||
flagTypeProperty &= 3;
|
||||
switch (flagTypeProperty)
|
||||
{
|
||||
case 0:
|
||||
switch(flagProperty)
|
||||
{
|
||||
case 0:
|
||||
return baseUVs.defaultUVChannel;
|
||||
case 1:
|
||||
return baseUVs.specialUVChannel;
|
||||
case 2:
|
||||
return baseUVs.uvAfterTwirlPolar;
|
||||
case 3:
|
||||
return baseUVs.cylinderUV;
|
||||
default:
|
||||
return baseUVs.defaultUVChannel;
|
||||
}
|
||||
case 1:
|
||||
switch(flagProperty)
|
||||
{
|
||||
case 0:
|
||||
return baseUVs.mainTexUV;
|
||||
case 1:
|
||||
return baseUVs.screenUV;
|
||||
case 2:
|
||||
return baseUVs.worldPosUV;
|
||||
case 3:
|
||||
return baseUVs.objectPosUV;
|
||||
default:
|
||||
return baseUVs.defaultUVChannel;
|
||||
}
|
||||
case 2:
|
||||
switch(flagProperty)
|
||||
{
|
||||
case 0:
|
||||
return baseUVs.sharedUV;
|
||||
default:
|
||||
return baseUVs.defaultUVChannel;
|
||||
}
|
||||
default:
|
||||
return baseUVs.defaultUVChannel;
|
||||
}
|
||||
}
|
||||
|
||||
half Blend_HardLight(half Base, half Blend)
|
||||
{
|
||||
half result1 = 1.0 - 2.0 * (1.0 - Base) * (1.0 - Blend);
|
||||
half result2 = 2.0 * Base * Blend;
|
||||
half zeroOrOne = step(Blend, 0.5);
|
||||
half Out = result2 * zeroOrOne + (1 - zeroOrOne) * result1;
|
||||
return Out;
|
||||
}
|
||||
|
||||
#define FLAG_BIT_PNOISE_BLEND_POS_0_BASE_BLEND (0*3)
|
||||
#define FLAG_BIT_PNOISE_BLEND_POS_0_MASK (1*3)
|
||||
#define FLAG_BIT_PNOISE_BLEND_POS_0_DISSOLVE (2*3)
|
||||
#define FLAG_BIT_PNOISE_BLEND_POS_0_DISTORT (3*3)
|
||||
#define FLAG_BIT_PNOISE_BLEND_POS_0_MAINTEX (4*3)
|
||||
|
||||
half BlendPNoise(uint flagProperty,int flagPos,half source,half pNoise,half opacity)
|
||||
{
|
||||
flagProperty = flagProperty >> flagPos;
|
||||
flagProperty &= 7;
|
||||
switch(flagProperty)
|
||||
{
|
||||
case 0:
|
||||
return source;
|
||||
case 1:
|
||||
return lerp(source,pNoise*source,opacity);
|
||||
case 2:
|
||||
return lerp(source,min(pNoise,source),opacity);
|
||||
case 3:
|
||||
return lerp(source,Blend_HardLight(source,pNoise),opacity);
|
||||
default:
|
||||
return source;
|
||||
}
|
||||
}
|
||||
|
||||
//ForDistort
|
||||
half2 BlendPNoise(uint flagProperty,int flagPos,half2 source,half2 pNoise,half opacity)
|
||||
{
|
||||
flagProperty = flagProperty >> flagPos;
|
||||
flagProperty &= 7;
|
||||
switch(flagProperty)
|
||||
{
|
||||
case 0:
|
||||
return source;
|
||||
case 1:
|
||||
return lerp(source,pNoise*source,opacity);
|
||||
case 2:
|
||||
return lerp(source,min(pNoise,source),opacity);
|
||||
case 3:
|
||||
return lerp(source,Blend_HardLight(source,pNoise),opacity);
|
||||
default:
|
||||
return source;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4918b275ae4dce948a5cedc6f3612066
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large.
Load diff
+7
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9187c1d488f62d9458d6ce67858a43b3
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03da5256bb8bf0b4496b10ee6b449be4
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,357 @@
|
||||
#ifndef SIX_WAY_SMOKE_LIT_HLSL
|
||||
#define SIX_WAY_SMOKE_LIT_HLSL
|
||||
//这部分尽量借鉴 UnityEditor.VFX.HDRP.SixWaySmokeLit
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
#include "ParticlesUnlitInputNew.hlsl"
|
||||
|
||||
// Generated from UnityEditor.VFX.HDRP.SixWaySmokeLit+BSDFData
|
||||
// PackingRules = Exact
|
||||
struct BSDFData
|
||||
{
|
||||
uint materialFeatures;
|
||||
float absorptionRange;
|
||||
real4 diffuseColor;
|
||||
real3 fresnel0;
|
||||
real ambientOcclusion;
|
||||
float3 normalWS;
|
||||
float4 tangentWS;
|
||||
real3 geomNormalWS;
|
||||
real3 rigRTBk;
|
||||
real3 rigLBtF;
|
||||
real3 bakeDiffuseLighting0;//rigRTBk.x
|
||||
real3 bakeDiffuseLighting1;//rigRTBk.y
|
||||
real3 bakeDiffuseLighting2;// bsdfData.tangentWS.w > 0.0f ? rigRTBk.z : rigLBtF.z
|
||||
real3 backBakeDiffuseLighting0;//rigLBtF.x
|
||||
real3 backBakeDiffuseLighting1;//rigLBtF.y
|
||||
real3 backBakeDiffuseLighting2;// bsdfData.tangentWS.w > 0.0f ? rigLBtF.z : rigRTBk.z
|
||||
|
||||
//-----NBShaders-----
|
||||
real3 emission;
|
||||
real emissionInput;//NegativeTex.a
|
||||
real alpha;//PositiveTex.a
|
||||
|
||||
};
|
||||
|
||||
#define ABSORPTION_EPSILON max(REAL_MIN, 1e-5)
|
||||
|
||||
real3 ComputeDensityScales(real3 absorptionColor)
|
||||
{
|
||||
absorptionColor.rgb = max(ABSORPTION_EPSILON, absorptionColor.rgb);
|
||||
|
||||
// Empirical value used to parametrize absorption from color
|
||||
const real absorptionStrength = 0.2f;
|
||||
return 1.0f + log2(absorptionColor.rgb) / log2(absorptionStrength);
|
||||
}
|
||||
|
||||
real3 GetTransmissionWithAbsorption(real transmission, real4 absorptionColor, real absorptionRange)
|
||||
{
|
||||
#if defined(VFX_SIX_WAY_ABSORPTION)
|
||||
real3 densityScales = ComputeDensityScales(absorptionColor.rgb);
|
||||
|
||||
#ifdef VFX_BLENDMODE_PREMULTIPLY
|
||||
absorptionRange *= (absorptionColor.a > 0) ? absorptionColor.a : 1.0f;
|
||||
#endif
|
||||
|
||||
// real3 outTransmission = GetTransmissionWithAbsorption(transmission, densityScales, absorptionRange);
|
||||
real3 outTransmission = pow(saturate(transmission / absorptionRange), densityScales);
|
||||
outTransmission *= absorptionRange;
|
||||
|
||||
return outTransmission;
|
||||
#else
|
||||
return transmission.xxx * absorptionColor.rgb; // simple multiply
|
||||
#endif
|
||||
}
|
||||
|
||||
void ModifyBakedDiffuseLighting(BSDFData bsdfData, inout float3 bakeDiffuseLighting)
|
||||
{
|
||||
bakeDiffuseLighting = 0;
|
||||
|
||||
// Scale to be energy conserving: Total energy = 4*pi; divided by 6 directions
|
||||
float scale = 4.0f * PI / 6.0f;
|
||||
|
||||
float3 frontBakeDiffuseLighting = bsdfData.tangentWS.w > 0.0f ? bsdfData.bakeDiffuseLighting2 : bsdfData.backBakeDiffuseLighting2;
|
||||
float3 backBakeDiffuseLighting = bsdfData.tangentWS.w > 0.0f ? bsdfData.backBakeDiffuseLighting2 : bsdfData.bakeDiffuseLighting2;
|
||||
|
||||
float3x3 bakeDiffuseLightingMat;
|
||||
bakeDiffuseLightingMat[0] = bsdfData.bakeDiffuseLighting0;
|
||||
bakeDiffuseLightingMat[1] = bsdfData.bakeDiffuseLighting1;
|
||||
bakeDiffuseLightingMat[2] = frontBakeDiffuseLighting;
|
||||
bakeDiffuseLighting += GetTransmissionWithAbsorption(bsdfData.rigRTBk.x, bsdfData.diffuseColor, bsdfData.absorptionRange) * bakeDiffuseLightingMat[0];
|
||||
bakeDiffuseLighting += GetTransmissionWithAbsorption(bsdfData.rigRTBk.y, bsdfData.diffuseColor, bsdfData.absorptionRange) * bakeDiffuseLightingMat[1];
|
||||
bakeDiffuseLighting += GetTransmissionWithAbsorption(bsdfData.rigRTBk.z, bsdfData.diffuseColor, bsdfData.absorptionRange) * bakeDiffuseLightingMat[2];
|
||||
|
||||
bakeDiffuseLightingMat[0] = bsdfData.backBakeDiffuseLighting0;
|
||||
bakeDiffuseLightingMat[1] = bsdfData.backBakeDiffuseLighting1;
|
||||
bakeDiffuseLightingMat[2] = backBakeDiffuseLighting;
|
||||
bakeDiffuseLighting += GetTransmissionWithAbsorption(bsdfData.rigLBtF.x, bsdfData.diffuseColor, bsdfData.absorptionRange) * bakeDiffuseLightingMat[0];
|
||||
bakeDiffuseLighting += GetTransmissionWithAbsorption(bsdfData.rigLBtF.y, bsdfData.diffuseColor, bsdfData.absorptionRange) * bakeDiffuseLightingMat[1];
|
||||
bakeDiffuseLighting += GetTransmissionWithAbsorption(bsdfData.rigLBtF.z, bsdfData.diffuseColor, bsdfData.absorptionRange) * bakeDiffuseLightingMat[2];
|
||||
|
||||
bakeDiffuseLighting *= scale;
|
||||
|
||||
}
|
||||
|
||||
//世界空间到切线空间方向转换
|
||||
float3 TransformToLocalFrame(float3 L, BSDFData bsdfData)
|
||||
{
|
||||
float3 zVec = -bsdfData.normalWS;
|
||||
float3 xVec = bsdfData.tangentWS.xyz;
|
||||
float3 yVec = -cross(zVec, xVec) * bsdfData.tangentWS.w;//原代码没有负值,实际测试需要负值
|
||||
float3x3 tbn = float3x3(xVec, yVec, zVec);
|
||||
return mul(tbn, L);
|
||||
}
|
||||
|
||||
CBSDF EvaluateBSDF(float3 L, BSDFData bsdfData)
|
||||
{
|
||||
CBSDF cbsdf;
|
||||
ZERO_INITIALIZE(CBSDF, cbsdf);
|
||||
|
||||
float3 dir = TransformToLocalFrame(L, bsdfData);
|
||||
float3 weights = dir >= 0 ? bsdfData.rigRTBk.xyz : bsdfData.rigLBtF.xyz;
|
||||
float3 sqrDir = dir*dir;
|
||||
|
||||
cbsdf.diffR = GetTransmissionWithAbsorption(dot(sqrDir, weights), bsdfData.diffuseColor, bsdfData.absorptionRange);
|
||||
|
||||
return cbsdf;
|
||||
}
|
||||
|
||||
|
||||
//这一步最好在面板上做完
|
||||
half GetAbsorptionRange(float absorptionStrenth)
|
||||
{
|
||||
return INV_PI + saturate(absorptionStrenth) * (1 - INV_PI);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//---------NBShaderUtility-----------
|
||||
|
||||
//UseInVerTex
|
||||
void GetSixWayBakeDiffuseLight(real3 normalWS,real3 tangentWS,real3 biTangentWS,
|
||||
inout half3 bakeDiffuseLighting0,inout half3 bakeDiffuseLighting1,inout half3 bakeDiffuseLighting2,
|
||||
inout half3 backBakeDiffuseLighting0,inout half3 backBakeDiffuseLighting1,inout half3 backBakeDiffuseLighting2)
|
||||
{
|
||||
bakeDiffuseLighting0 = SampleSHVertex(tangentWS);
|
||||
bakeDiffuseLighting1 = SampleSHVertex(biTangentWS);
|
||||
bakeDiffuseLighting2 = SampleSHVertex(-normalWS);
|
||||
backBakeDiffuseLighting0 = SampleSHVertex(-tangentWS);
|
||||
backBakeDiffuseLighting1 = SampleSHVertex(-biTangentWS);
|
||||
backBakeDiffuseLighting2 = SampleSHVertex(normalWS);
|
||||
}
|
||||
|
||||
LightingData CreateSixWayLightingData(InputData inputData, half3 emission)
|
||||
{
|
||||
LightingData lightingData;
|
||||
|
||||
lightingData.giColor = inputData.bakedGI;
|
||||
lightingData.emissionColor = emission;
|
||||
lightingData.vertexLightingColor = 0;
|
||||
lightingData.mainLightColor = 0;
|
||||
lightingData.additionalLightsColor = 0;
|
||||
|
||||
return lightingData;
|
||||
}
|
||||
|
||||
void GetSixWayEmission(inout BSDFData bsdfData,Texture2D rampMap,half4 emissionColor,bool isRampMap)
|
||||
{
|
||||
float input = pow(bsdfData.emissionInput,_SixWayInfo.y);
|
||||
half3 emission = emissionColor * emissionColor.a;
|
||||
if (isRampMap)
|
||||
{
|
||||
half4 rampSample = rampMap.Sample(sampler_linear_clamp,half2(input,0.5));
|
||||
emission = emission * rampSample * rampSample.a;
|
||||
}
|
||||
else
|
||||
{
|
||||
emission *= input;
|
||||
}
|
||||
bsdfData.emission = emission;
|
||||
}
|
||||
|
||||
half3 LightingSixWay(Light light,InputData inputData, BSDFData bsdfData)
|
||||
{
|
||||
half3 cbsdf_R = EvaluateBSDF(light.direction,bsdfData).diffR;
|
||||
half3 radiance = light.color * light.distanceAttenuation * light.shadowAttenuation;
|
||||
return PI * cbsdf_R * radiance;
|
||||
}
|
||||
|
||||
|
||||
//光照流程--->原型为UniversalFragmentBlinnPhong
|
||||
half4 UniversalFragmentSixWay(InputData inputData,BSDFData bsdfData)
|
||||
{
|
||||
// #if defined(DEBUG_DISPLAY)
|
||||
// half4 debugColor;
|
||||
//
|
||||
// if (CanDebugOverrideOutputColor(inputData, surfaceData, debugColor))
|
||||
// {
|
||||
// return debugColor;
|
||||
// }
|
||||
// #endif
|
||||
|
||||
#ifdef _LIGHT_LAYERS
|
||||
uint meshRenderingLayers = GetMeshRenderingLayer();
|
||||
#endif
|
||||
half4 shadowMask = CalculateShadowMask(inputData);
|
||||
// AmbientOcclusionFactor aoFactor = CreateAmbientOcclusionFactor(inputData, surfaceData);
|
||||
AmbientOcclusionFactor aoFactor;
|
||||
aoFactor.directAmbientOcclusion = 1;
|
||||
aoFactor.indirectAmbientOcclusion = 1;
|
||||
Light mainLight = GetMainLight(inputData, shadowMask, aoFactor);
|
||||
|
||||
// MixRealtimeAndBakedGI(mainLight, inputData.normalWS, inputData.bakedGI, aoFactor);
|
||||
|
||||
// inputData.bakedGI *= surfaceData.albedo;
|
||||
|
||||
// LightingData lightingData = CreateLightingData(inputData, surfaceData);
|
||||
LightingData lightingData = CreateSixWayLightingData(inputData,bsdfData.emission);
|
||||
|
||||
#ifdef _LIGHT_LAYERS
|
||||
if (IsMatchingLightLayer(mainLight.layerMask, meshRenderingLayers))
|
||||
#endif
|
||||
{
|
||||
lightingData.mainLightColor += LightingSixWay(mainLight, inputData, bsdfData);
|
||||
}
|
||||
|
||||
#if defined(_ADDITIONAL_LIGHTS)
|
||||
uint pixelLightCount = GetAdditionalLightsCount();
|
||||
|
||||
#if USE_FORWARD_PLUS
|
||||
for (uint lightIndex = 0; lightIndex < min(URP_FP_DIRECTIONAL_LIGHTS_COUNT, MAX_VISIBLE_LIGHTS); lightIndex++)
|
||||
{
|
||||
FORWARD_PLUS_SUBTRACTIVE_LIGHT_CHECK
|
||||
|
||||
Light light = GetAdditionalLight(lightIndex, inputData, shadowMask, aoFactor);
|
||||
#ifdef _LIGHT_LAYERS
|
||||
if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
|
||||
#endif
|
||||
{
|
||||
lightingData.additionalLightsColor += LightingSixWay(light, inputData, bsdfData);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
LIGHT_LOOP_BEGIN(pixelLightCount)
|
||||
Light light = GetAdditionalLight(lightIndex, inputData, shadowMask, aoFactor);
|
||||
#ifdef _LIGHT_LAYERS
|
||||
if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
|
||||
#endif
|
||||
{
|
||||
lightingData.additionalLightsColor += LightingSixWay(light, inputData, bsdfData);
|
||||
}
|
||||
LIGHT_LOOP_END
|
||||
#endif
|
||||
|
||||
#if defined(_ADDITIONAL_LIGHTS_VERTEX)
|
||||
lightingData.vertexLightingColor += inputData.vertexLighting * surfaceData.albedo;
|
||||
#endif
|
||||
|
||||
return CalculateFinalColor(lightingData, bsdfData.alpha);
|
||||
}
|
||||
half3 LightingHalfLambert(half3 lightColor, half3 lightDir, half3 normal)
|
||||
{
|
||||
half NdotL = saturate(dot(normal, lightDir));
|
||||
NdotL = NdotL*0.5 + 0.5;
|
||||
return lightColor * NdotL;
|
||||
}
|
||||
half3 CalculateHalfLambertBlinnPhong(Light light, InputData inputData, SurfaceData surfaceData)
|
||||
{
|
||||
half3 attenuatedLightColor = light.color * (light.distanceAttenuation * light.shadowAttenuation);
|
||||
half3 lightDiffuseColor = LightingHalfLambert(attenuatedLightColor, light.direction, inputData.normalWS);
|
||||
|
||||
half3 lightSpecularColor = half3(0,0,0);
|
||||
#if defined(_SPECGLOSSMAP) || defined(_SPECULAR_COLOR)
|
||||
half smoothness = exp2(10 * surfaceData.smoothness + 1);
|
||||
|
||||
lightSpecularColor += LightingSpecular(attenuatedLightColor, light.direction, inputData.normalWS, inputData.viewDirectionWS, half4(surfaceData.specular, 1), smoothness);
|
||||
#endif
|
||||
|
||||
#if _ALPHAPREMULTIPLY_ON
|
||||
return lightDiffuseColor * surfaceData.albedo * surfaceData.alpha + lightSpecularColor;
|
||||
#else
|
||||
return lightDiffuseColor * surfaceData.albedo + lightSpecularColor;
|
||||
#endif
|
||||
}
|
||||
half4 UniversalFragmentHalfLambert(InputData inputData, half3 diffuse, half4 specularGloss, half smoothness, half3 emission, half alpha, half3 normalTS)
|
||||
{
|
||||
|
||||
SurfaceData surfaceData;
|
||||
|
||||
surfaceData.albedo = diffuse;
|
||||
surfaceData.alpha = alpha;
|
||||
surfaceData.emission = emission;
|
||||
surfaceData.metallic = 0;
|
||||
surfaceData.occlusion = 1;
|
||||
surfaceData.smoothness = smoothness;
|
||||
surfaceData.specular = specularGloss.rgb;
|
||||
surfaceData.clearCoatMask = 0;
|
||||
surfaceData.clearCoatSmoothness = 1;
|
||||
surfaceData.normalTS = normalTS;
|
||||
|
||||
|
||||
// #if defined(DEBUG_DISPLAY)
|
||||
// half4 debugColor;
|
||||
//
|
||||
// if (CanDebugOverrideOutputColor(inputData, surfaceData, debugColor))
|
||||
// {
|
||||
// return debugColor;
|
||||
// }
|
||||
// #endif
|
||||
|
||||
#ifdef _LIGHT_LAYERS
|
||||
uint meshRenderingLayers = GetMeshRenderingLayer();
|
||||
#endif
|
||||
|
||||
half4 shadowMask = CalculateShadowMask(inputData);
|
||||
AmbientOcclusionFactor aoFactor = CreateAmbientOcclusionFactor(inputData, surfaceData);
|
||||
Light mainLight = GetMainLight(inputData, shadowMask, aoFactor);
|
||||
|
||||
MixRealtimeAndBakedGI(mainLight, inputData.normalWS, inputData.bakedGI, aoFactor);
|
||||
|
||||
inputData.bakedGI *= surfaceData.albedo;
|
||||
|
||||
LightingData lightingData = CreateLightingData(inputData, surfaceData);
|
||||
#ifdef _LIGHT_LAYERS
|
||||
if (IsMatchingLightLayer(mainLight.layerMask, meshRenderingLayers))
|
||||
#endif
|
||||
{
|
||||
lightingData.mainLightColor += CalculateHalfLambertBlinnPhong(mainLight, inputData, surfaceData);
|
||||
}
|
||||
|
||||
#if defined(_ADDITIONAL_LIGHTS)
|
||||
uint pixelLightCount = GetAdditionalLightsCount();
|
||||
|
||||
#if USE_FORWARD_PLUS
|
||||
for (uint lightIndex = 0; lightIndex < min(URP_FP_DIRECTIONAL_LIGHTS_COUNT, MAX_VISIBLE_LIGHTS); lightIndex++)
|
||||
{
|
||||
FORWARD_PLUS_SUBTRACTIVE_LIGHT_CHECK
|
||||
|
||||
Light light = GetAdditionalLight(lightIndex, inputData, shadowMask, aoFactor);
|
||||
#ifdef _LIGHT_LAYERS
|
||||
if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
|
||||
#endif
|
||||
{
|
||||
lightingData.additionalLightsColor += CalculateBlinnPhong(light, inputData, surfaceData);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
LIGHT_LOOP_BEGIN(pixelLightCount)
|
||||
Light light = GetAdditionalLight(lightIndex, inputData, shadowMask, aoFactor);
|
||||
#ifdef _LIGHT_LAYERS
|
||||
if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
|
||||
#endif
|
||||
{
|
||||
lightingData.additionalLightsColor += CalculateHalfLambertBlinnPhong(light, inputData, surfaceData);
|
||||
}
|
||||
LIGHT_LOOP_END
|
||||
#endif
|
||||
|
||||
#if defined(_ADDITIONAL_LIGHTS_VERTEX)
|
||||
lightingData.vertexLightingColor += inputData.vertexLighting * surfaceData.albedo;
|
||||
#endif
|
||||
|
||||
return CalculateFinalColor(lightingData, surfaceData.alpha);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70e94bdedafe40bfb7f8e77cdc4bef0f
|
||||
timeCreated: 1751704445
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7184a95c20fc1a441a8815af4c795ccd
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,75 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 9177edf81a5b2354490ec4d66c4c069d, type: 3}
|
||||
m_Name: StencilConfig
|
||||
m_EditorClassIdentifier: Assembly-CSharp-Editor:stencilTestHelper:StencilValuesConfig
|
||||
Config:
|
||||
- key: ParticleBaseDefault
|
||||
Values:
|
||||
DefaultQueue: 3100
|
||||
Ref: 0
|
||||
Comp: 8
|
||||
Pass: 0
|
||||
Fail: 0
|
||||
ZFail: 0
|
||||
ReadMask: 255
|
||||
WriteMask: 255
|
||||
- key: Disturbance
|
||||
Values:
|
||||
DefaultQueue: 3000
|
||||
Ref: 0
|
||||
Comp: 8
|
||||
Pass: 0
|
||||
Fail: 0
|
||||
ZFail: 0
|
||||
ReadMask: 255
|
||||
WriteMask: 255
|
||||
- key: ParticalBasePortal
|
||||
Values:
|
||||
DefaultQueue: 3100
|
||||
Ref: 200
|
||||
Comp: 3
|
||||
Pass: 0
|
||||
Fail: 0
|
||||
ZFail: 0
|
||||
ReadMask: 255
|
||||
WriteMask: 255
|
||||
- key: ParticalBasePortalMask
|
||||
Values:
|
||||
DefaultQueue: 2000
|
||||
Ref: 200
|
||||
Comp: 8
|
||||
Pass: 2
|
||||
Fail: 0
|
||||
ZFail: 0
|
||||
ReadMask: 255
|
||||
WriteMask: 255
|
||||
- key: ParticleBaseDecal
|
||||
Values:
|
||||
DefaultQueue: 3100
|
||||
Ref: 2
|
||||
Comp: 7
|
||||
Pass: 0
|
||||
Fail: 0
|
||||
ZFail: 0
|
||||
ReadMask: 255
|
||||
WriteMask: 255
|
||||
- key: ParticleWithoutPlayer
|
||||
Values:
|
||||
DefaultQueue: 3100
|
||||
Ref: 5
|
||||
Comp: 5
|
||||
Pass: 0
|
||||
Fail: 0
|
||||
ZFail: 0
|
||||
ReadMask: 255
|
||||
WriteMask: 255
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7093501998f1b24483fa6c8eddcf8fb
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user