更新
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
#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_CUSTOMDATA1Z_DISSOLVE_ON (1 << 13)
|
||||
#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)
|
||||
@@ -22,27 +22,27 @@
|
||||
#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_CUSTOMDATA1X_MAINTEXOFFSETX (1 << 21)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA1Y_MAINTEXOFFSETY (1 << 22)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA1W_HUESHIFT (1 << 23)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA2X_MASKMAPOFFSETX (1 << 24)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA2Y_MASKMAPOFFSETY (1 << 25)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA2Z_FRESNELOFFSET (1 << 26)
|
||||
#define FLAG_BIT_PARTICLE_NORMALMAP_MASK_MODE (1 << 21)
|
||||
#define FLAG_BIT_PARTICLE_COLOR_BLEND_FOLLOW_MAINTEX_UV (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_PC_ONLYSPECIALFUNC (1 << 29)
|
||||
#define FLAG_BIT_PARTICLE_EMISSION_FOLLOW_MAINTEX_UV (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_CUSTOMDATA1X_DISSOLVETEXOFFSETX (1 << 2)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA1Y_DISSOLVETEXOFFSETY (1 << 3)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA1Z_NOISE_INTENSITY (1 << 4)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA1W_SATURATE (1 << 5)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA2X_VERTEXOFFSETX (1 << 6)
|
||||
#define FLAG_BIT_PARTICLE_CUSTOMDATA2Y_VERTEXOFFSETY (1 << 7)
|
||||
#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_CUSTOMDATA2W_CHORATICABERRAT_INTENSITY (1 << 8)
|
||||
#define FLAG_BIT_PARTICLE_1_IGNORE_VERTEX_COLOR (1 << 9)
|
||||
#define FLAG_BIT_PARTICLE_1_DISSOVLE_VORONOI (1 << 10)
|
||||
@@ -63,6 +63,9 @@
|
||||
#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位)
|
||||
@@ -80,6 +83,8 @@
|
||||
#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)
|
||||
@@ -128,6 +133,17 @@
|
||||
#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_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)
|
||||
{
|
||||
@@ -224,4 +240,9 @@
|
||||
return baseUVs.cylinderUV;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,90 +1,8 @@
|
||||
#ifndef PARTICLESUNLITFORWARDPASS
|
||||
#define PARTICLESUNLITFORWARDPASS
|
||||
#include "HLSL/ParticlesUnlitInputNew.hlsl"
|
||||
#include "HLSL/SixWaySmokeLit.hlsl"
|
||||
|
||||
struct AttributesParticle//即URP语境下的appdata
|
||||
{
|
||||
float4 vertex: POSITION;
|
||||
float3 normalOS: NORMAL;
|
||||
half4 color: COLOR;
|
||||
#if defined(_FLIPBOOKBLENDING_ON)
|
||||
float4 texcoords: TEXCOORD0; //texcoords.zw就是粒子那边新建的UV2
|
||||
float3 texcoordBlend: TEXCOORD3;//注意,假如需要UI支持,則Canvas要開放相關Channel
|
||||
#else
|
||||
float4 texcoords: TEXCOORD0;
|
||||
#endif
|
||||
|
||||
#ifdef _PARALLAX_MAPPING
|
||||
float4 tangentOS : TANGENT;
|
||||
#endif
|
||||
|
||||
float4 Custom1: TEXCOORD1;
|
||||
float4 Custom2: TEXCOORD2;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct VaryingsParticle//即URP语境下的v2f
|
||||
{
|
||||
float4 clipPos: SV_POSITION;
|
||||
|
||||
half4 color: COLOR;
|
||||
float4 texcoord: TEXCOORD0; // 主帖图 和 mask
|
||||
|
||||
#if defined (_EMISSION) || defined(_COLORMAPBLEND)
|
||||
float4 emissionColorBlendTexcoord: TEXCOORD1; // 流光
|
||||
#endif
|
||||
|
||||
#ifdef _NOISEMAP
|
||||
float4 noisemapTexcoord:TEXCOORD2;//Noise
|
||||
#endif
|
||||
|
||||
#if defined(_DISSOLVE)
|
||||
|
||||
float4 dissolveTexcoord:TEXCOORD15;
|
||||
float4 dissolveNoiseTexcoord: TEXCOORD5;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
float4 positionWS: TEXCOORD3;
|
||||
float4 positionOS: TEXCOORD12;
|
||||
|
||||
float4 texcoord2AndSpecialUV: TEXCOORD6; // UV2和SpecialUV
|
||||
|
||||
float4 positionNDC: TEXCOORD7;
|
||||
|
||||
|
||||
float4 VaryingsP_Custom1: TEXCOORD8;
|
||||
float4 VaryingsP_Custom2: TEXCOORD9;
|
||||
|
||||
|
||||
float4 normalWSAndAnimBlend: TEXCOORD10;
|
||||
|
||||
float3 fresnelViewDir :TEXCOORD11;
|
||||
|
||||
float3 viewDirWS :TEXCOORD13;
|
||||
float4 texcoordMaskMap2 : TEXCOORD14;
|
||||
|
||||
#ifdef _PARALLAX_MAPPING
|
||||
half3 tangentViewDir : TEXCOORD16;
|
||||
#endif
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
bool isProcessUVInFrag()
|
||||
{
|
||||
if(CheckLocalFlags(FLAG_BIT_PARTICLE_POLARCOORDINATES_ON) || CheckLocalFlags(FLAG_BIT_PARTICLE_UTWIRL_ON))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#if defined(_DEPTH_DECAL) || defined(_PARALLAX_MAPPING) || defined(_SCREEN_DISTORT_MODE)
|
||||
return true;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Vertex and Fragment functions //
|
||||
@@ -152,6 +70,33 @@
|
||||
|
||||
output.viewDirWS = GetWorldSpaceNormalizeViewDir(output.positionWS.xyz);
|
||||
output.normalWSAndAnimBlend.xyz = TransformObjectToWorldNormal(input.normalOS.xyz);
|
||||
|
||||
#if defined(_NORMALMAP)||defined(_FX_LIGHT_MODE_SIX_WAY)
|
||||
real sign = input.tangentOS.w * GetOddNegativeScale();
|
||||
half3 tangentWS = TransformObjectToWorldDir(input.tangentOS.xyz);
|
||||
output.tangentWS = half4(tangentWS,sign);
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef _FX_LIGHT_MODE_UNLIT
|
||||
#ifdef _FX_LIGHT_MODE_SIX_WAY
|
||||
float3 bitangent = sign * cross(output.normalWSAndAnimBlend.xyz, output.tangentWS.xyz);
|
||||
// GetSixWayBakeDiffuseLight(output.normalWSAndAnimBlend.xyz,output.tangentWS,bitangent,
|
||||
// output.bakeDiffuseLighting0,output.bakeDiffuseLighting1,output.bakeDiffuseLighting2,
|
||||
// output.backBakeDiffuseLighting0,output.backBakeDiffuseLighting1,output.backBakeDiffuseLighting2);
|
||||
|
||||
GetSixWayBakeDiffuseLight(output.normalWSAndAnimBlend.xyz,output.tangentWS,bitangent,
|
||||
output.bakeDiffuseLighting0,output.bakeDiffuseLighting1,output.bakeDiffuseLighting2,
|
||||
output.backBakeDiffuseLighting0,output.backBakeDiffuseLighting1,output.backBakeDiffuseLighting2);
|
||||
|
||||
#else
|
||||
OUTPUT_SH(output.normalWSAndAnimBlend.xyz, output.vertexSH);
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
output.vertexLight = VertexLighting(output.positionWS.xyz, output.normalWSAndAnimBlend.xyz);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
UNITY_FLATTEN
|
||||
@@ -192,6 +137,12 @@
|
||||
|
||||
output.texcoordMaskMap2.xy = particleUVs.maskMap2UV;
|
||||
output.texcoordMaskMap2.zw = particleUVs.maskMap3UV;
|
||||
#if defined (_NORMALMAP) || defined(_COLOR_RAMP)
|
||||
output.bumpTexAndColorRampMapTexcoord.xy = particleUVs.bumpTexUV;
|
||||
output.bumpTexAndColorRampMapTexcoord.zw = particleUVs.colorRampMapUV;
|
||||
|
||||
#endif
|
||||
|
||||
#if defined (_EMISSION) || defined(_COLORMAPBLEND)
|
||||
output.emissionColorBlendTexcoord.xy = particleUVs.emissionUV;
|
||||
output.emissionColorBlendTexcoord.zw = particleUVs.colorBlendUV;
|
||||
@@ -307,6 +258,8 @@
|
||||
float2 dissolve_uv;
|
||||
float2 dissolve_mask_uv;
|
||||
float4 dissolve_noise_uv;
|
||||
float2 BumpTex_uv;
|
||||
float2 colorRamp_uv;
|
||||
|
||||
//如果同时在粒子系统里开启序列帧融帧和特殊UV通道模式。
|
||||
|
||||
@@ -334,13 +287,20 @@
|
||||
noiseMap_uv = particleUVs.noiseMapUV;
|
||||
noiseMaskMap_uv = particleUVs.noiseMaskMapUV;
|
||||
dissolve_noise_uv = float4(particleUVs.dissolve_noise1_UV,particleUVs.dissolve_noise2_UV);
|
||||
|
||||
BumpTex_uv = particleUVs.bumpTexUV;
|
||||
colorRamp_uv = particleUVs.colorRampMapUV;
|
||||
}
|
||||
else
|
||||
{
|
||||
MaskMapuv = input.texcoord.zw;
|
||||
MaskMapuv2 = input.texcoordMaskMap2.xy;
|
||||
MaskMapuv3 = input.texcoordMaskMap2.zw;
|
||||
|
||||
#if defined (_NORMALMAP)||defined(_COLOR_RAMP)
|
||||
BumpTex_uv = input.bumpTexAndColorRampMapTexcoord.xy;
|
||||
colorRamp_uv = input.bumpTexAndColorRampMapTexcoord.zw;
|
||||
#endif
|
||||
|
||||
#ifdef _NOISEMAP
|
||||
noiseMap_uv = input.noisemapTexcoord.xy;
|
||||
noiseMaskMap_uv = input.noisemapTexcoord.zw;
|
||||
@@ -374,11 +334,12 @@
|
||||
{
|
||||
cum_noise = cum_noise * 2 - 1;
|
||||
}
|
||||
noiseMask *= noiseSample.a;
|
||||
UNITY_BRANCH
|
||||
if(CheckLocalFlags1(FLAG_BIT_PARTICLE_1_NOISE_MASKMAP))
|
||||
{
|
||||
noiseMask= SampleTexture2DWithWrapFlags(_NoiseMaskMap,noiseMaskMap_uv,FLAG_BIT_WRAPMODE_NOISE_MASKMAP).r;
|
||||
noiseMask *= noiseSample.a;
|
||||
half4 noiseMaskSample = SampleTexture2DWithWrapFlags(_NoiseMaskMap,noiseMaskMap_uv,FLAG_BIT_WRAPMODE_NOISE_MASKMAP);
|
||||
noiseMask *= GetColorChannel(noiseMaskSample,FLAG_BIT_COLOR_CHANNEL_POS_0_NOISE_MASK);
|
||||
}
|
||||
_TexDistortion_intensity = GetCustomData(_W9ParticleCustomDataFlag1,FLAGBIT_POS_1_CUSTOMDATA_NOISE_INTENSITY,_TexDistortion_intensity,input.VaryingsP_Custom1,input.VaryingsP_Custom2);
|
||||
|
||||
@@ -392,14 +353,15 @@
|
||||
|
||||
float2 mainTexNoise = cum_noise * noiseMask * _TexDistortion_intensity * _DistortionDirection.xy;
|
||||
uv.xy += mainTexNoise;//主贴图纹理扭曲
|
||||
blendUv.xy += mainTexNoise;
|
||||
blendUv.xy += mainTexNoise;
|
||||
#endif
|
||||
|
||||
|
||||
// SampleAlbedo--------------------
|
||||
half4 albedo = 0;
|
||||
#if defined(_SCREEN_DISTORT_MODE)
|
||||
albedo = half4(cum_noise_xy, 1.0, noiseMask);
|
||||
#else
|
||||
|
||||
UNITY_FLATTEN
|
||||
if(CheckLocalFlags(FLAG_BIT_PARTICLE_BACKCOLOR))
|
||||
{
|
||||
@@ -414,7 +376,6 @@
|
||||
#else
|
||||
baseMap = _BaseMap;
|
||||
#endif
|
||||
|
||||
|
||||
UNITY_BRANCH
|
||||
if (CheckLocalFlags(FLAG_BIT_PARTICLE_UIEFFECT_ON) & !CheckLocalFlags1(FLAG_BIT_PARTICLE_1_UIEFFECT_BASEMAP_MODE))
|
||||
@@ -430,18 +391,25 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
albedo = BlendTexture(baseMap, uv, blendUv,FLAG_BIT_WRAPMODE_BASEMAP);
|
||||
|
||||
}
|
||||
|
||||
albedo.a = GetColorChannel(albedo,FLAG_BIT_COLOR_CHANNEL_POS_0_MAINTEX_ALPHA);
|
||||
|
||||
albedo *= _BaseColor ;
|
||||
albedo.rgb *= _BaseColorIntensityForTimeline;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
half alpha = albedo.a;
|
||||
half3 result = albedo.rgb;
|
||||
|
||||
#ifdef _FX_LIGHT_MODE_SIX_WAY
|
||||
float4 rigRTBkSample = BlendTexture(_RigRTBk, uv, blendUv,FLAG_BIT_WRAPMODE_BASEMAP);
|
||||
float4 rigLBtFSample = BlendTexture(_RigLBtF, uv, blendUv,FLAG_BIT_WRAPMODE_BASEMAP);
|
||||
#endif
|
||||
|
||||
UNITY_BRANCH
|
||||
if(CheckLocalFlags(FLAG_BIT_HUESHIFT_ON))
|
||||
@@ -466,13 +434,132 @@
|
||||
result.rgb = lerp(colorA,colorB,_BaseMapColorRefine.w);
|
||||
}
|
||||
|
||||
half3 normalTS = half3(0, 0, 1);//TODO
|
||||
|
||||
if (CheckLocalFlags1(FLAG_BIT_PARTICLE_1_BUMP_TEX_UV_FOLLOW_MAINTEX))
|
||||
{
|
||||
BumpTex_uv = uv;
|
||||
}
|
||||
|
||||
half metallic = 1;
|
||||
half smoothness = 1;
|
||||
#ifdef _NORMALMAP
|
||||
|
||||
half4 normalMapSample = SampleTexture2DWithWrapFlags(_BumpTex,BumpTex_uv,FLAG_BIT_WRAPMODE_BUMPTEX);
|
||||
if (CheckLocalFlags(FLAG_BIT_PARTICLE_NORMALMAP_MASK_MODE))
|
||||
{
|
||||
normalTS = UnpackNormalRGB(half4(normalMapSample.xy,0,1),_BumpScale);
|
||||
metallic *= normalMapSample.z;
|
||||
smoothness *= normalMapSample.w;
|
||||
}
|
||||
else
|
||||
{
|
||||
normalTS = UnpackNormalScale(half4(normalMapSample),_BumpScale);
|
||||
}
|
||||
|
||||
#endif
|
||||
//光照模式
|
||||
#ifndef _FX_LIGHT_MODE_UNLIT
|
||||
|
||||
InputData inputData;
|
||||
InitializeInputData(input, normalTS, inputData);
|
||||
metallic *= _MaterialInfo.x;
|
||||
half3 specular = 0;
|
||||
smoothness *= _MaterialInfo.y;
|
||||
half occlusion = 1;
|
||||
half3 pbrEmission = 0;
|
||||
// return half4(inputData.bakedGI,1);
|
||||
#if defined (_FX_LIGHT_MODE_BLINN_PHONG) || defined(_FX_LIGHT_MODE_HALF_LAMBERT)
|
||||
half4 specularGloss = _SpecularColor;
|
||||
#ifdef _FX_LIGHT_MODE_BLINN_PHONG
|
||||
half4 blinnPhong = UniversalFragmentBlinnPhong(inputData,result.rgb, specularGloss, smoothness, pbrEmission, alpha,normalTS);
|
||||
#else //_FX_LIGHT_MODE_HALF_LAMBERT
|
||||
half4 blinnPhong = UniversalFragmentHalfLambert(inputData,result.rgb, specularGloss, smoothness, pbrEmission, alpha,normalTS);
|
||||
#endif
|
||||
result = blinnPhong.rgb;
|
||||
alpha = blinnPhong.a;
|
||||
#elif _FX_LIGHT_MODE_PBR
|
||||
half4 pbr = UniversalFragmentPBR(inputData,result.rgb, metallic, specular, smoothness, occlusion, pbrEmission, alpha);
|
||||
result = pbr.rgb;
|
||||
alpha = pbr.a;
|
||||
#elif _FX_LIGHT_MODE_SIX_WAY
|
||||
BSDFData bsdfData = (BSDFData)0;
|
||||
bsdfData.absorptionRange = GetAbsorptionRange(_SixWayInfo.x);
|
||||
bsdfData.diffuseColor = albedo;
|
||||
bsdfData.normalWS = inputData.normalWS;
|
||||
bsdfData.tangentWS = input.tangentWS;//Check this
|
||||
bsdfData.rigRTBk = rigRTBkSample.xyz * INV_PI;//AccordingTo SixWayForwardPass
|
||||
bsdfData.rigLBtF = rigLBtFSample.xyz * INV_PI;//AccordingTo SixWayForwardPass
|
||||
bsdfData.bakeDiffuseLighting0 = input.bakeDiffuseLighting0;
|
||||
bsdfData.bakeDiffuseLighting1 = input.bakeDiffuseLighting1;
|
||||
bsdfData.bakeDiffuseLighting2 = input.bakeDiffuseLighting2;
|
||||
bsdfData.backBakeDiffuseLighting0 = input.backBakeDiffuseLighting0;
|
||||
bsdfData.backBakeDiffuseLighting1 = input.backBakeDiffuseLighting1;
|
||||
bsdfData.backBakeDiffuseLighting2 = input.backBakeDiffuseLighting2;
|
||||
bsdfData.emissionInput = rigLBtFSample.a;
|
||||
GetSixWayEmission(bsdfData,_SixWayEmissionRamp,_SixWayEmissionColor,CheckLocalFlags1(FLAG_BIT_PARTICLE_1_SIXWAY_RAMPMAP));//Init Emission
|
||||
bsdfData.alpha = rigRTBkSample.a * _BaseColor.a;
|
||||
|
||||
ModifyBakedDiffuseLighting(bsdfData,inputData.bakedGI);
|
||||
|
||||
half4 sixWay = UniversalFragmentSixWay(inputData,bsdfData);
|
||||
|
||||
|
||||
// half3 dir = _MainLightPosition.xyz;
|
||||
// dir = TransformToLocalFrame(dir, bsdfData);
|
||||
// return half4(dir,1);
|
||||
|
||||
result = sixWay.rgb;
|
||||
alpha = sixWay.a;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
result.rgb *= input.vertexLight;
|
||||
#endif
|
||||
|
||||
input.normalWSAndAnimBlend.xyz = inputData.normalWS;
|
||||
|
||||
#else
|
||||
#ifdef _NORMALMAP
|
||||
float sgn = input.tangentWS.w; // should be either +1 or -1
|
||||
float3 bitangent = sgn * cross(input.normalWSAndAnimBlend.xyz, input.tangentWS.xyz);
|
||||
half3x3 tangentToWorld = half3x3(input.tangentWS.xyz, bitangent.xyz, input.normalWSAndAnimBlend.xyz);
|
||||
input.normalWSAndAnimBlend.xyz = TransformTangentToWorld(normalTS, tangentToWorld);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _MATCAP
|
||||
// URP
|
||||
half3 normalVS = mul(input.normalWSAndAnimBlend.xyz, (float3x3)UNITY_MATRIX_I_V); // 逆转置矩阵
|
||||
half3 positionVS = TransformWorldToView(input.positionWS);
|
||||
|
||||
|
||||
float3 r = reflect(positionVS, normalVS);
|
||||
r = normalize(r);
|
||||
float m = 2.828427f * sqrt(r.z + 1.0);
|
||||
float2 matCapUV = r.xy / m + 0.5;
|
||||
half3 matCapSample = SAMPLE_TEXTURE2D(_MatCapTex,sampler_linear_clamp,matCapUV);
|
||||
|
||||
matCapSample *= _MatCapColor.rgb;
|
||||
|
||||
half3 matCapMutilResult = result * matCapSample;
|
||||
half3 matAddResult = result + matCapSample;
|
||||
half3 matCapResult = lerp(matAddResult,matCapMutilResult,_MatCapInfo.x);
|
||||
|
||||
result = lerp(result,matCapResult,_MatCapColor.a);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//流光部分
|
||||
half4 emission = half4(0, 0, 0,1);
|
||||
#if defined(_EMISSION)
|
||||
#ifdef _NOISEMAP
|
||||
if (!CheckLocalFlags(FLAG_BIT_PARTICLE_EMISSION_FOLLOW_MAINTEX_UV))
|
||||
{
|
||||
emission_uv += cum_noise * _Emi_Distortion_intensity;
|
||||
}
|
||||
#endif
|
||||
// emission = tex2D_TryLinearizeWithoutAlphaFX(_EmissionMap,emission_uv);
|
||||
emission = SampleTexture2DWithWrapFlags(_EmissionMap,emission_uv,FLAG_BIT_WRAPMODE_EMISSIONMAP);
|
||||
@@ -484,6 +571,55 @@
|
||||
|
||||
result += emission;
|
||||
|
||||
|
||||
#if defined(_COLOR_RAMP)
|
||||
half rampValue = 0;
|
||||
if (CheckLocalFlags(FLAG_BIT_PARTICLE_RAMP_COLOR_MAP_MODE_ON))
|
||||
{
|
||||
half4 RampColorSample = SampleTexture2DWithWrapFlags(_RampColorMap,colorRamp_uv,FLAG_BIT_WRAPMODE_RAMP_COLOR_MAP);
|
||||
rampValue = GetColorChannel(RampColorSample,FLAG_BIT_COLOR_CHANNEL_POS_0_RAMP_COLOR_MAP);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int rampColorWrapMode = CheckLocalWrapFlags(FLAG_BIT_WRAPMODE_RAMP_COLOR_MAP);
|
||||
if (rampColorWrapMode == 0 || rampColorWrapMode == 2)
|
||||
{
|
||||
rampValue = frac(colorRamp_uv.x);
|
||||
}
|
||||
else
|
||||
{
|
||||
rampValue = saturate(colorRamp_uv.x);
|
||||
}
|
||||
}
|
||||
|
||||
half3 colorRampColorArr[] = {_RampColor0.rgb,_RampColor1.rgb,_RampColor2.rgb,_RampColor3.rgb,_RampColor4.rgb,_RampColor5.rgb};
|
||||
half colorRampColorTimeArr[] = {_RampColor0.a,_RampColor1.a,_RampColor2.a,_RampColor3.a,_RampColor4.a,_RampColor5.a};
|
||||
int colorRampColorCount = _RampColorCount & 0xFFFF;
|
||||
|
||||
half colorRampAlphaArr[] = {_RampColorAlpha0.x,_RampColorAlpha0.z,_RampColorAlpha1.x,_RampColorAlpha1.z,_RampColorAlpha2.x,_RampColorAlpha2.z};
|
||||
half colorRampAlphaTimeArr[] = {_RampColorAlpha0.y,_RampColorAlpha0.w,_RampColorAlpha1.y,_RampColorAlpha1.w,_RampColorAlpha2.y,_RampColorAlpha2.w};
|
||||
int colorRampAlphaCount = _RampColorCount >> 16;
|
||||
|
||||
half4 rampColor;
|
||||
rampColor.rgb = GetGradientColorValue(colorRampColorArr,colorRampColorTimeArr,colorRampColorCount,rampValue);
|
||||
rampColor.a = GetGradientAlphaValue(colorRampAlphaArr,colorRampAlphaTimeArr,colorRampAlphaCount,rampValue);
|
||||
|
||||
rampColor *= _RampColorBlendColor;
|
||||
|
||||
if (CheckLocalFlags(FLAG_BIT_PARTICLE_RAMP_COLOR_BLEND_ADD))
|
||||
{
|
||||
result += rampColor;
|
||||
alpha += rampColor.a;
|
||||
}
|
||||
else
|
||||
{
|
||||
result *= rampColor;
|
||||
alpha *= rampColor.a;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//溶解部分
|
||||
#if defined(_DISSOLVE)
|
||||
#ifdef _NOISEMAP
|
||||
@@ -495,9 +631,10 @@
|
||||
dissolve_mask_uv += cum_noise * _DissolveOffsetRotateDistort.w;
|
||||
}
|
||||
#endif
|
||||
half dissolveValue;
|
||||
|
||||
dissolveValue = SampleTexture2DWithWrapFlags(_DissolveMap,dissolve_uv,FLAG_BIT_WRAPMODE_DISSOLVE_MAP);
|
||||
half4 dissolveMapSample = SampleTexture2DWithWrapFlags(_DissolveMap,dissolve_uv,FLAG_BIT_WRAPMODE_DISSOLVE_MAP);
|
||||
|
||||
half dissolveValue = GetColorChannel(dissolveMapSample,FLAG_BIT_COLOR_CHANNEL_POS_0_DISSOLVE_MAP);
|
||||
|
||||
UNITY_BRANCH
|
||||
if(CheckLocalFlags1(FLAG_BIT_PARTICLE_1_DISSOVLE_VORONOI))
|
||||
@@ -518,53 +655,124 @@
|
||||
|
||||
}
|
||||
|
||||
dissolveValue = SimpleSmoothstep(_Dissolve_Vec2.x,_Dissolve_Vec2.y,dissolveValue);
|
||||
// dissolveValue = SimpleSmoothstep(_Dissolve_Vec2.x,_Dissolve_Vec2.y,dissolveValue);
|
||||
dissolveValue = pow(dissolveValue,_Dissolve.y);
|
||||
|
||||
#ifdef _DISSOLVE_EDITOR_TEST //后续Test类的关键字要找机会排除
|
||||
return half4(dissolveValue.rrr,1);
|
||||
#endif
|
||||
|
||||
|
||||
half dissolveMaskValue = 0;
|
||||
|
||||
UNITY_BRANCH
|
||||
if(CheckLocalFlags(FLAG_BIT_PARTICLE_DISSOLVE_MASK))
|
||||
{
|
||||
dissolveMaskValue = SampleTexture2DWithWrapFlags(_DissolveMaskMap,dissolve_mask_uv,FLAG_BIT_WRAPMODE_DISSOLVE_MASKMAP);
|
||||
half dissolveMaskValue = 0;
|
||||
half4 dissolveMaskSample = SampleTexture2DWithWrapFlags(_DissolveMaskMap,dissolve_mask_uv,FLAG_BIT_WRAPMODE_DISSOLVE_MASKMAP);
|
||||
dissolveMaskValue = GetColorChannel(dissolveMaskSample,FLAG_BIT_COLOR_CHANNEL_POS_0_DISSOLVE_MASK_MAP);
|
||||
_Dissolve.z += GetCustomData(_W9ParticleCustomDataFlag1,FLAGBIT_POS_1_CUSTOMDATA_DISSOLVE_MASK_INTENSITY,0,input.VaryingsP_Custom1,input.VaryingsP_Custom2);
|
||||
dissolveMaskValue *= _Dissolve.z;
|
||||
dissolveValue = lerp(dissolveValue,1.01,dissolveMaskValue);
|
||||
dissolveMaskValue += _Dissolve.z;
|
||||
// dissolveValue = dissolveMaskValue*dissolveValue;
|
||||
//
|
||||
// half mixedDisolveValue ;
|
||||
// Blend_HardLight_half(dissolveValue,dissolveMaskValue,mixedDisolveValue);
|
||||
// dissolveValue = mixedDisolveValue;
|
||||
|
||||
dissolveValue = (dissolveValue +dissolveMaskValue)*0.5;//Smart Way By Panda
|
||||
}
|
||||
half originDissolve = dissolveValue;
|
||||
|
||||
_Dissolve.x += GetCustomData(_W9ParticleCustomDataFlag0,FLAGBIT_POS_0_CUSTOMDATA_DISSOLVE_INTENSITY,0,input.VaryingsP_Custom1,input.VaryingsP_Custom2);
|
||||
#ifdef _DISSOLVE_EDITOR_TEST //后续Test类的关键字要找机会排除
|
||||
return half4(dissolveValue.rrr,1);
|
||||
#endif
|
||||
half dissolveStrenth = _Dissolve.x + GetCustomData(_W9ParticleCustomDataFlag0,FLAGBIT_POS_0_CUSTOMDATA_DISSOLVE_INTENSITY,0,input.VaryingsP_Custom1,input.VaryingsP_Custom2);
|
||||
|
||||
dissolveValue = dissolveValue-_Dissolve.x;
|
||||
half dissolveValueBeforeSoftStep = dissolveValue;
|
||||
half softStep = _Dissolve.w;
|
||||
dissolveValue = SimpleSmoothstep(0,softStep,(dissolveValue));
|
||||
half invSoftStep = 1/_Dissolve.w;
|
||||
half dissolveValueBeforeSoftStep = dissolveValue - ((dissolveStrenth)*(invSoftStep + 1)-1)*_Dissolve.w ;
|
||||
dissolveValue = dissolveValue*invSoftStep -(1+invSoftStep)*dissolveStrenth +1;
|
||||
// dissolveValue = smoothstep(dissolveStrenth-_Dissolve.w,dissolveStrenth,dissolveValue);//Smart Way By Panda
|
||||
dissolveValue = saturate(dissolveValue);
|
||||
|
||||
|
||||
|
||||
alpha *= dissolveValue;
|
||||
if(CheckLocalFlags1(FLAG_BIT_PARTICLE_1_DISSOVLE_USE_RAMP))
|
||||
{
|
||||
half rampRange = 1-dissolveValueBeforeSoftStep ;
|
||||
// half rampRange = (dissolveValueBeforeSoftStep - _Dissolve_Vec2.x)*_Dissolve_Vec2.y;
|
||||
half rampRange = dissolveValueBeforeSoftStep;
|
||||
rampRange = rampRange * _DissolveRampMap_ST.x +_DissolveRampMap_ST.z;
|
||||
|
||||
half4 rampSample = SampleTexture2DWithWrapFlags(_DissolveRampMap,half2(rampRange,0.5),FLAG_BIT_WRAPMODE_DISSOLVE_RAMPMAP);
|
||||
result = lerp(result,rampSample.rgb*_DissolveRampColor.rgb,rampSample.a*_DissolveRampColor.a);
|
||||
|
||||
half4 rampSample ;
|
||||
if (CheckLocalFlags(FLAG_BIT_PARTICLE_DISSOLVE_RAMP_MAP))
|
||||
{
|
||||
rampSample = SampleTexture2DWithWrapFlags(_DissolveRampMap,half2(rampRange,0.5),FLAG_BIT_WRAPMODE_DISSOLVE_RAMPMAP);
|
||||
}
|
||||
else
|
||||
{
|
||||
half3 dissolveRampColorArr[] = {_DissolveRampColor0.rgb,_DissolveRampColor1.rgb,_DissolveRampColor2.rgb,_DissolveRampColor3.rgb,_DissolveRampColor4.rgb,_DissolveRampColor5.rgb};
|
||||
half dissolveRampColorTimeArr[] = {_DissolveRampColor0.a,_DissolveRampColor1.a,_DissolveRampColor2.a,_DissolveRampColor3.a,_DissolveRampColor4.a,_DissolveRampColor5.a};
|
||||
int dissolveRampColorCount = _DissolveRampCount & 0xFFFF;
|
||||
|
||||
half dissolveRampAlphaArr[] = {_DissolveRampAlpha0.x,_DissolveRampAlpha0.z,_DissolveRampAlpha1.x,_DissolveRampAlpha1.z,_DissolveRampAlpha2.x,_DissolveRampAlpha2.z};
|
||||
half dissolveRampAlphaTimeArr[] = {_DissolveRampAlpha0.y,_DissolveRampAlpha0.w,_DissolveRampAlpha1.y,_DissolveRampAlpha1.w,_DissolveRampAlpha2.y,_DissolveRampAlpha2.w};
|
||||
int dissolveRampAlphaCount = _DissolveRampCount >> 16;
|
||||
|
||||
const int rampWrapMode = CheckLocalWrapFlags(FLAG_BIT_WRAPMODE_DISSOLVE_RAMPMAP);
|
||||
if (rampWrapMode == 0 || rampWrapMode == 2)
|
||||
{
|
||||
rampRange = frac(rampRange);
|
||||
}
|
||||
else
|
||||
{
|
||||
rampRange = saturate(rampRange);
|
||||
}
|
||||
|
||||
|
||||
rampSample.rgb = GetGradientColorValue(dissolveRampColorArr,dissolveRampColorTimeArr,dissolveRampColorCount,rampRange);
|
||||
rampSample.a = GetGradientAlphaValue(dissolveRampAlphaArr,dissolveRampAlphaTimeArr,dissolveRampAlphaCount,rampRange);
|
||||
}
|
||||
|
||||
if (CheckLocalFlags1(FLAG_BIT_PARTICLE_1_DISSOLVE_RAMP_MULITPLY))
|
||||
{
|
||||
result = result * lerp(1,rampSample.rgb*_DissolveRampColor.rgb,rampSample.a*_DissolveRampColor.a);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = lerp(result,rampSample.rgb*_DissolveRampColor.rgb,rampSample.a*_DissolveRampColor.a);
|
||||
}
|
||||
}
|
||||
|
||||
half lineMask = 1 - smoothstep(0,softStep,alpha * (dissolveValueBeforeSoftStep - _Dissolve.y));
|
||||
result = lerp(result,_DissolveLineColor.rgb,lineMask*_DissolveLineColor.a);
|
||||
|
||||
|
||||
|
||||
if (CheckLocalFlags1(FLAG_BIT_PARTICLE_1_DISSOLVE_LINE_MASK))
|
||||
{
|
||||
half lineMask = dissolveValueBeforeSoftStep;//SmoothStep要优化
|
||||
lineMask = saturate(NB_Remap01(lineMask,_Dissolve_Vec2.x-_Dissolve_Vec2.y,_Dissolve_Vec2 + _Dissolve_Vec2.y));
|
||||
lineMask = 1- lineMask;
|
||||
|
||||
result = lerp(result,_DissolveLineColor.rgb,lineMask*_DissolveLineColor.a);
|
||||
}
|
||||
//
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
//颜色渐变
|
||||
#ifdef _COLORMAPBLEND
|
||||
#if defined(_NOISEMAP)
|
||||
if (!CheckLocalFlags(FLAG_BIT_PARTICLE_COLOR_BLEND_FOLLOW_MAINTEX_UV))
|
||||
{
|
||||
colorBlendMap_uv += cum_noise * _ColorBlendVec.x; //加入扭曲效果
|
||||
}
|
||||
#endif
|
||||
half4 colorBlend = SampleTexture2DWithWrapFlags(_ColorBlendMap,colorBlendMap_uv,FLAG_BIT_WRAPMODE_COLORBLENDMAP);
|
||||
colorBlend.rgb = colorBlend.rgb * _ColorBlendColor.rgb;
|
||||
result.rgb = lerp(result.rgb,result.rgb * colorBlend.rgb,_ColorBlendColor.a);
|
||||
colorBlend.a = lerp(1,colorBlend.a*_ColorBlendColor.a,_ColorBlendVec.z);
|
||||
if (CheckLocalFlags(FLAG_BIT_PARTICLE_COLOR_BLEND_ALPHA_MULTIPLY_MODE))
|
||||
{
|
||||
result *= colorBlend.rgb;
|
||||
alpha *= colorBlend.a;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.rgb = lerp(result.rgb,result.rgb * colorBlend.rgb,colorBlend.a);
|
||||
}
|
||||
#endif
|
||||
|
||||
//菲涅
|
||||
@@ -583,7 +791,8 @@
|
||||
|
||||
_FresnelUnit.x += GetCustomData(_W9ParticleCustomDataFlag0,FLAGBIT_POS_0_CUSTOMDATA_FRESNEL_OFFSET,0,input.VaryingsP_Custom1,input.VaryingsP_Custom2);;
|
||||
|
||||
fresnelValue = NB_Remap(fresnelValue,_FresnelUnit.x,1,0,1);
|
||||
// half fresnelHardness = - _FresnelUnit.w*0.5 +0.5;
|
||||
fresnelValue = NB_Remap(fresnelValue,_FresnelUnit.x,_FresnelUnit.x + 1.01 - _FresnelUnit.w,0,1);
|
||||
UNITY_BRANCH
|
||||
if(!CheckLocalFlags(FLAG_BIT_PARTICLE_FRESNEL_INVERT_ON))
|
||||
{
|
||||
@@ -591,9 +800,8 @@
|
||||
}
|
||||
fresnelValue = pow(fresnelValue,_FresnelUnit.y);
|
||||
|
||||
half fresnelHardness = (1 - _FresnelUnit.w)*0.5;
|
||||
|
||||
fresnelValue = smoothstep(0.5-fresnelHardness,0.5+fresnelHardness,fresnelValue);
|
||||
// fresnelValue = smoothstep(0.5-fresnelHardness,0.5+fresnelHardness,fresnelValue);
|
||||
}
|
||||
|
||||
UNITY_BRANCH
|
||||
@@ -602,7 +810,10 @@
|
||||
float fresnelColorIntensity = fresnelValue*_FresnelColor.a*_FresnelUnit.z;
|
||||
|
||||
result = lerp(result,_FresnelColor.rgb,fresnelColorIntensity);
|
||||
alpha = max(alpha,fresnelColorIntensity);//颜色要不要不被主贴图Alpha影响呢?
|
||||
if (!CheckLocalFlags(FLAG_BIT_PARTICLE_FRESNEL_COLOR_AFFETCT_BY_ALPHA))
|
||||
{
|
||||
alpha = max(alpha,fresnelColorIntensity);//颜色要不要不被主贴图Alpha影响呢?
|
||||
}
|
||||
}
|
||||
|
||||
UNITY_BRANCH
|
||||
@@ -635,28 +846,104 @@
|
||||
#if defined(_NOISEMAP)
|
||||
MaskMapuv += cum_noise * _MaskDistortion_intensity; //加入扭曲效果
|
||||
#endif
|
||||
half4 maskmap1 = SampleTexture2DWithWrapFlags(_MaskMap, MaskMapuv,FLAG_BIT_WRAPMODE_MASKMAP);
|
||||
|
||||
half mask1 = 1;
|
||||
if (CheckLocalFlags1(FLAG_BIT_PARTICLE_1_MASKMAP_GRADIENT))
|
||||
{
|
||||
const int maskMapWrapMode = CheckLocalWrapFlags(FLAG_BIT_WRAPMODE_MASKMAP);
|
||||
half maskMapTimeValue;
|
||||
if (maskMapWrapMode == 0 || maskMapWrapMode == 2)
|
||||
{
|
||||
maskMapTimeValue = frac(MaskMapuv.x);
|
||||
}
|
||||
else
|
||||
{
|
||||
maskMapTimeValue = saturate(MaskMapuv.x);
|
||||
}
|
||||
|
||||
half maskMapAlphaArr[] = {_MaskMapGradientFloat0.x,_MaskMapGradientFloat0.z,_MaskMapGradientFloat1.x,_MaskMapGradientFloat1.z,_MaskMapGradientFloat2.x,_MaskMapGradientFloat2.z};
|
||||
half maskMapAlphaTimeArr[] = {_MaskMapGradientFloat0.y,_MaskMapGradientFloat0.w,_MaskMapGradientFloat1.y,_MaskMapGradientFloat1.w,_MaskMapGradientFloat2.y,_MaskMapGradientFloat2.w};
|
||||
int maskMapAlphaCount = _MaskMapGradientCount;
|
||||
mask1 = GetGradientAlphaValue(maskMapAlphaArr,maskMapAlphaTimeArr,maskMapAlphaCount,maskMapTimeValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
half4 maskmap1Sample = SampleTexture2DWithWrapFlags(_MaskMap, MaskMapuv,FLAG_BIT_WRAPMODE_MASKMAP);
|
||||
mask1 = GetColorChannel(maskmap1Sample,FLAG_BIT_COLOR_CHANNEL_POS_0_MASKMAP1);
|
||||
|
||||
}
|
||||
|
||||
UNITY_BRANCH
|
||||
if(CheckLocalFlags1(FLAG_BIT_PARTICLE_1_MASK_MAP2))
|
||||
{
|
||||
half maskMap2 = SampleTexture2DWithWrapFlags(_MaskMap2, MaskMapuv2,FLAG_BIT_WRAPMODE_MASKMAP2).r;
|
||||
maskmap1 *= maskMap2;
|
||||
half mask2 = 1;
|
||||
if (CheckLocalFlags1(FLAG_BIT_PARTICLE_1_MASKMAP_2_GRADIENT))
|
||||
{
|
||||
const int maskMap2WrapMode = CheckLocalWrapFlags(FLAG_BIT_WRAPMODE_MASKMAP2);
|
||||
half maskMap2TimeValue;
|
||||
if (maskMap2WrapMode == 0 || maskMap2WrapMode == 3)
|
||||
{
|
||||
maskMap2TimeValue = frac(MaskMapuv2.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
maskMap2TimeValue = saturate(MaskMapuv2.y);
|
||||
}
|
||||
|
||||
half maskMap2AlphaArr[] = {_MaskMap2GradientFloat0.x,_MaskMap2GradientFloat0.z,_MaskMap2GradientFloat1.x,_MaskMap2GradientFloat1.z,_MaskMap2GradientFloat2.x,_MaskMap2GradientFloat2.z};
|
||||
half maskMap2AlphaTimeArr[] = {_MaskMap2GradientFloat0.y,_MaskMap2GradientFloat0.w,_MaskMap2GradientFloat1.y,_MaskMap2GradientFloat1.w,_MaskMap2GradientFloat2.y,_MaskMap2GradientFloat2.w};
|
||||
int maskMap2AlphaCount = _MaskMap2GradientCount;
|
||||
mask2 = GetGradientAlphaValue(maskMap2AlphaArr,maskMap2AlphaTimeArr,maskMap2AlphaCount,maskMap2TimeValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
half4 maskMap2Sample = SampleTexture2DWithWrapFlags(_MaskMap2, MaskMapuv2,FLAG_BIT_WRAPMODE_MASKMAP2);
|
||||
mask2 = GetColorChannel(maskMap2Sample,FLAG_BIT_COLOR_CHANNEL_POS_0_MASKMAP2);
|
||||
}
|
||||
mask1 *= mask2;
|
||||
}
|
||||
|
||||
UNITY_BRANCH
|
||||
if(CheckLocalFlags1(FLAG_BIT_PARTICLE_1_MASK_MAP3))
|
||||
{
|
||||
half maskMap3 = SampleTexture2DWithWrapFlags(_MaskMap3, MaskMapuv3,FLAG_BIT_WRAPMODE_MASKMAP3).r;
|
||||
maskmap1 *= maskMap3;
|
||||
half mask3 = 1;
|
||||
if (CheckLocalFlags1(FLAG_BIT_PARTICLE_1_MASKMAP_3_GRADIENT))
|
||||
{
|
||||
const int maskMap3WrapMode = CheckLocalWrapFlags(FLAG_BIT_WRAPMODE_MASKMAP3);
|
||||
half maskMap3TimeValue;
|
||||
if (maskMap3WrapMode == 0 || maskMap3WrapMode == 2)
|
||||
{
|
||||
maskMap3TimeValue = frac(MaskMapuv3.x);
|
||||
}
|
||||
else
|
||||
{
|
||||
maskMap3TimeValue = saturate(MaskMapuv3.x);
|
||||
}
|
||||
|
||||
half maskMap3AlphaArr[] = {_MaskMap3GradientFloat0.x,_MaskMap3GradientFloat0.z,_MaskMap3GradientFloat1.x,_MaskMap3GradientFloat1.z,_MaskMap3GradientFloat2.x,_MaskMap3GradientFloat2.z};
|
||||
half maskMap3AlphaTimeArr[] = {_MaskMap3GradientFloat0.y,_MaskMap3GradientFloat0.w,_MaskMap3GradientFloat1.y,_MaskMap3GradientFloat1.w,_MaskMap3GradientFloat2.y,_MaskMap3GradientFloat2.w};
|
||||
int maskMap3AlphaCount = _MaskMap3GradientCount;
|
||||
mask3 = GetGradientAlphaValue(maskMap3AlphaArr,maskMap3AlphaTimeArr,maskMap3AlphaCount,maskMap3TimeValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
half4 maskMap3Sample = SampleTexture2DWithWrapFlags(_MaskMap3, MaskMapuv3,FLAG_BIT_WRAPMODE_MASKMAP3);
|
||||
mask3 = GetColorChannel(maskMap3Sample,FLAG_BIT_COLOR_CHANNEL_POS_0_MASKMAP3);
|
||||
}
|
||||
mask1 *= mask3;
|
||||
}
|
||||
|
||||
maskmap1.rgb = lerp(1,maskmap1.rgb,_MaskMapVec.x);
|
||||
maskmap1.rgb = saturate(maskmap1.rgb);
|
||||
if (CheckLocalFlags1(FLAG_BIT_PARTICLE_1_MASK_REFINE))
|
||||
{
|
||||
mask1 = pow(mask1,_MaskRefineVec.x);
|
||||
mask1 = mask1 * _MaskRefineVec.y;
|
||||
mask1 += _MaskRefineVec.z;
|
||||
}
|
||||
|
||||
mask1 = lerp(1,mask1,_MaskMapVec.x);
|
||||
mask1 = saturate(mask1);
|
||||
|
||||
maskmap1.rgb *= maskmap1.a;//预乘
|
||||
|
||||
alpha *= maskmap1.r; //mask边缘
|
||||
alpha *= mask1; //mask边缘
|
||||
#endif
|
||||
|
||||
|
||||
@@ -714,28 +1001,36 @@
|
||||
half3 beforeFogResult = result;
|
||||
result = MixFog(result,input.positionWS.w);
|
||||
result = lerp(beforeFogResult, result, _fogintensity);
|
||||
|
||||
|
||||
|
||||
#ifndef _SCREEN_DISTORT_MODE
|
||||
result.rgb = result.rgb * alpha;
|
||||
#endif
|
||||
// #ifndef _SCREEN_DISTORT_MODE
|
||||
// result.rgb = result.rgb * alpha;
|
||||
// #endif
|
||||
|
||||
UNITY_FLATTEN
|
||||
if(CheckLocalFlags(FLAG_BIT_PARTICLE_LINEARTOGAMMA_ON))
|
||||
{
|
||||
result.rgb = LinearToGammaSpace(result.rgb);
|
||||
}
|
||||
UNITY_FLATTEN
|
||||
if(CheckLocalFlags(FLAG_BIT_PARTICLE_LINEARTOGAMMA_ON))
|
||||
{
|
||||
result.rgb = LinearToGammaSpace(result.rgb);
|
||||
}
|
||||
|
||||
|
||||
alpha *= _AlphaAll;
|
||||
|
||||
#if defined (_ALPHAPREMULTIPLY_ON) || defined(_ALPHAMODULATE_ON)
|
||||
result *= alpha;
|
||||
#ifdef _ALPHAPREMULTIPLY_ON
|
||||
alpha *= _AdditiveToPreMultiplyAlphaLerp;
|
||||
#endif
|
||||
#endif
|
||||
half4 color = half4(result, alpha);
|
||||
|
||||
|
||||
|
||||
#ifdef _ALPHATEST_ON
|
||||
clip(color.a - _Cutoff);
|
||||
|
||||
#endif
|
||||
|
||||
color = min(color,1000);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#ifndef PARTICLESUNLITINPUT
|
||||
#define PARTICLESUNLITINPUT
|
||||
|
||||
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
|
||||
|
||||
@@ -14,6 +12,7 @@
|
||||
float _IntersectRadius;
|
||||
half4 _IntersectColor;
|
||||
// #endif
|
||||
half _AdditiveToPreMultiplyAlphaLerp;
|
||||
half _Saturability;
|
||||
half _HueShift;
|
||||
half _Contrast;
|
||||
@@ -35,12 +34,25 @@
|
||||
half _fogintensity;
|
||||
half _Emi_Distortion_intensity;
|
||||
half _BaseMapUVRotation;
|
||||
half _BaseMapUVRotationSpeed;
|
||||
float _MaskMapUVRotation;
|
||||
float _NoiseMapUVRotation;
|
||||
half _uvRapSoft;
|
||||
half4 _EmissionMapColor;
|
||||
half _EmissionMapColorIntensity;
|
||||
|
||||
//--------------光照部分-------------
|
||||
float4 _BumpTex_ST;
|
||||
half _BumpScale;
|
||||
half4 _MaterialInfo;
|
||||
half4 _SpecularColor;
|
||||
//-----------SixWayLight----------
|
||||
half4 _SixWayInfo;
|
||||
half4 _SixWayEmissionColor;
|
||||
|
||||
half4 _MatCapColor;
|
||||
half4 _MatCapInfo;
|
||||
|
||||
half _EdgeFade;
|
||||
half4 _NoiseOffset;
|
||||
half4 _EmissionMapUVOffset;
|
||||
@@ -56,6 +68,21 @@
|
||||
half4 _MaskMapOffsetAnition;
|
||||
half4 _MaskMap3OffsetAnition;
|
||||
half4 _MaskMapVec;
|
||||
half4 _MaskRefineVec;
|
||||
|
||||
int _MaskMapGradientCount;
|
||||
half4 _MaskMapGradientFloat0;
|
||||
half4 _MaskMapGradientFloat1;
|
||||
half4 _MaskMapGradientFloat2;
|
||||
int _MaskMap2GradientCount;
|
||||
half4 _MaskMap2GradientFloat0;
|
||||
half4 _MaskMap2GradientFloat1;
|
||||
half4 _MaskMap2GradientFloat2;
|
||||
int _MaskMap3GradientCount;
|
||||
half4 _MaskMap3GradientFloat0;
|
||||
half4 _MaskMap3GradientFloat1;
|
||||
half4 _MaskMap3GradientFloat2;
|
||||
|
||||
float4 _PCCenter;
|
||||
float4 _TWParameter;
|
||||
float _TWStrength;
|
||||
@@ -109,8 +136,35 @@
|
||||
half4 _Dissolve_Vec2;
|
||||
|
||||
half4 _ColorBlendMap_ST;
|
||||
half2 _ColorBlendMapOffset;
|
||||
float4 _ColorBlendMapOffset;
|
||||
half4 _ColorBlendColor;
|
||||
half4 _ColorBlendVec;
|
||||
|
||||
half4 _RampColor0;
|
||||
half4 _RampColor1;
|
||||
half4 _RampColor2;
|
||||
half4 _RampColor3;
|
||||
half4 _RampColor4;
|
||||
half4 _RampColor5;
|
||||
half4 _RampColorAlpha0;
|
||||
half4 _RampColorAlpha1;
|
||||
half4 _RampColorAlpha2;
|
||||
uint _RampColorCount;
|
||||
half4 _RampColorBlendColor;
|
||||
float4 _RampColorMapOffset;
|
||||
half4 _RampColorMap_ST;
|
||||
|
||||
half4 _DissolveRampColor0;
|
||||
half4 _DissolveRampColor1;
|
||||
half4 _DissolveRampColor2;
|
||||
half4 _DissolveRampColor3;
|
||||
half4 _DissolveRampColor4;
|
||||
half4 _DissolveRampColor5;
|
||||
half4 _DissolveRampAlpha0;
|
||||
half4 _DissolveRampAlpha1;
|
||||
half4 _DissolveRampAlpha2;
|
||||
uint _DissolveRampCount;
|
||||
|
||||
|
||||
half3 _VertexOffset_Vec;
|
||||
half3 _VertexOffset_CustomDir;
|
||||
@@ -136,6 +190,8 @@
|
||||
|
||||
uint _UVModeFlag0;
|
||||
|
||||
uint _W9ParticleShaderColorChannelFlag;
|
||||
|
||||
CBUFFER_END
|
||||
|
||||
|
||||
@@ -173,6 +229,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SamplerState sampler_linear_repeat;
|
||||
SamplerState sampler_linear_clamp;
|
||||
SamplerState sampler_linear_RepeatU_ClampV;
|
||||
@@ -241,6 +298,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
half GetColorChannel(half4 color, int bitPos)
|
||||
{
|
||||
uint bits = _W9ParticleShaderColorChannelFlag >> bitPos;
|
||||
bits = bits & 3;
|
||||
if (bits == 0) return color.x;
|
||||
if (bits == 1) return color.y;
|
||||
if (bits == 2) return color.z;
|
||||
return color.w;
|
||||
}
|
||||
|
||||
|
||||
#include "../HLSL/EffectFlags.hlsl"
|
||||
@@ -264,11 +330,25 @@
|
||||
Texture2D _MaskMap;
|
||||
Texture2D _MaskMap2;
|
||||
Texture2D _MaskMap3;
|
||||
#ifdef _NORMALMAP
|
||||
Texture2D _BumpTex;
|
||||
#endif
|
||||
|
||||
#ifdef _FX_LIGHT_MODE_SIX_WAY
|
||||
Texture2D _RigRTBk;
|
||||
Texture2D _RigLBtF;
|
||||
Texture2D _SixWayEmissionRamp;
|
||||
#endif
|
||||
|
||||
#ifdef _SCREEN_DISTORT_MODE
|
||||
Texture2D _ScreenColorCopy1;
|
||||
#endif
|
||||
|
||||
#ifdef _MATCAP
|
||||
|
||||
#endif
|
||||
Texture2D _MatCapTex;
|
||||
|
||||
// Pre-multiplied alpha helper
|
||||
#if defined(_ALPHAPREMULTIPLY_ON) //if( blend: One OneMinusSrcAlpha)
|
||||
#define ALBEDO_MUL albedo
|
||||
@@ -292,6 +372,10 @@
|
||||
Texture2D _ColorBlendMap;
|
||||
#endif
|
||||
|
||||
#ifdef _COLOR_RAMP
|
||||
Texture2D _RampColorMap;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
half4 tex2D_TryLinearizeWithoutAlphaFX(sampler2D tex, float2 uv)
|
||||
@@ -568,6 +652,8 @@
|
||||
float2 colorBlendUV;
|
||||
float2 noiseMapUV;
|
||||
float2 noiseMaskMapUV;
|
||||
float2 bumpTexUV;
|
||||
float2 colorRampMapUV;
|
||||
};
|
||||
|
||||
BaseUVs ProcessBaseUVs(float4 meshTexcoord0, float2 specialUVInTexcoord3,float4 VaryingsP_Custom1,float4 VaryingsP_Custom2,float3 postionOS)
|
||||
@@ -657,6 +743,7 @@
|
||||
#ifdef _SCREEN_DISTORT_MODE
|
||||
particleUVs.mainTexUV = screenUV;
|
||||
#else
|
||||
_BaseMapUVRotation += time * _BaseMapUVRotationSpeed;
|
||||
baseMapUV = Rotate_Radians_float(baseMapUV, half2(0.5, 0.5), _BaseMapUVRotation); //主贴图旋转
|
||||
UNITY_BRANCH
|
||||
if(CheckLocalFlags(FLAG_BIT_PARTICLE_UIEFFECT_ON) & !CheckLocalFlags1(FLAG_BIT_PARTICLE_1_UIEFFECT_BASEMAP_MODE))
|
||||
@@ -680,6 +767,20 @@
|
||||
particleUVs.mainTexUV = UVOffsetAnimaiton(particleUVs.mainTexUV,_BaseMapMaskMapOffset.xy);
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(_NORMALMAP)
|
||||
if (CheckLocalFlags1(FLAG_BIT_PARTICLE_1_BUMP_TEX_UV_FOLLOW_MAINTEX))
|
||||
{
|
||||
particleUVs.bumpTexUV = particleUVs.mainTexUV;
|
||||
}
|
||||
else
|
||||
{
|
||||
float2 bumpTexUV = GetUVByUVMode(_UVModeFlag0,FLAG_BIT_UVMODE_POS_0_BUMPTEX,baseUVs);
|
||||
bumpTexUV = TRANSFORM_TEX(bumpTexUV, _BumpTex);
|
||||
particleUVs.bumpTexUV = bumpTexUV;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined(_MASKMAP_ON)
|
||||
@@ -706,6 +807,7 @@
|
||||
if(CheckLocalFlags1(FLAG_BIT_PARTICLE_1_MASK_MAP2))
|
||||
{
|
||||
float2 maskMap2UV = GetUVByUVMode(_UVModeFlag0,FLAG_BIT_UVMODE_POS_0_MASKMAP_2,baseUVs);
|
||||
maskMap2UV = Rotate_Radians_float(maskMap2UV,half2(0.5,0.5),_MaskMapVec.y);
|
||||
maskMap2UV = maskMap2UV * _MaskMap2_ST.xy + _MaskMap2_ST.zw;
|
||||
|
||||
maskMap2UV = UVOffsetAnimaiton(maskMap2UV,_MaskMapOffsetAnition.zw);
|
||||
@@ -716,6 +818,8 @@
|
||||
if(CheckLocalFlags1(FLAG_BIT_PARTICLE_1_MASK_MAP3))
|
||||
{
|
||||
float2 maskMap3UV = GetUVByUVMode(_UVModeFlag0,FLAG_BIT_UVMODE_POS_0_MASKMAP_3,baseUVs);
|
||||
maskMap3UV = Rotate_Radians_float(maskMap3UV,half2(0.5,0.5),_MaskMapVec.z);
|
||||
|
||||
maskMap3UV = maskMap3UV* _MaskMap3_ST.xy + _MaskMap3_ST.zw;
|
||||
|
||||
maskMap3UV = UVOffsetAnimaiton(maskMap3UV,_MaskMap3OffsetAnition.xy);
|
||||
@@ -724,9 +828,17 @@
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_EMISSION)
|
||||
if (CheckLocalFlags(FLAG_BIT_PARTICLE_EMISSION_FOLLOW_MAINTEX_UV))
|
||||
{
|
||||
particleUVs.emissionUV = particleUVs.mainTexUV;
|
||||
}
|
||||
else
|
||||
{
|
||||
float2 emissionUV = GetUVByUVMode(_UVModeFlag0,FLAG_BIT_UVMODE_POS_0_EMISSION_MAP,baseUVs);
|
||||
particleUVs.emissionUV = ParticleUVCommonProcess(emissionUV,_EmissionMap_ST,_EmissionMapUVOffset.xy,_EmissionMapUVRotation);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_DISSOLVE)
|
||||
@@ -762,10 +874,21 @@
|
||||
#endif
|
||||
|
||||
#ifdef _COLORMAPBLEND
|
||||
if (CheckLocalFlags(FLAG_BIT_PARTICLE_COLOR_BLEND_FOLLOW_MAINTEX_UV))
|
||||
{
|
||||
particleUVs.colorBlendUV = particleUVs.mainTexUV;
|
||||
}
|
||||
else
|
||||
{
|
||||
float2 colorBlendUV = GetUVByUVMode(_UVModeFlag0,FLAG_BIT_UVMODE_POS_0_COLOR_BLEND_MAP,baseUVs);
|
||||
particleUVs.colorBlendUV = ParticleUVCommonProcess(colorBlendUV,_ColorBlendMap_ST,_ColorBlendMapOffset.xy);
|
||||
|
||||
particleUVs.colorBlendUV = ParticleUVCommonProcess(colorBlendUV,_ColorBlendMap_ST,_ColorBlendMapOffset.xy,_ColorBlendVec.w);
|
||||
}
|
||||
#endif
|
||||
#ifdef _COLOR_RAMP
|
||||
float2 colorRampMapUV = GetUVByUVMode(_UVModeFlag0,FLAG_BIT_UVMODE_POS_0_RAMP_COLOR_MAP,baseUVs);
|
||||
particleUVs.colorRampMapUV = ParticleUVCommonProcess(colorRampMapUV,_RampColorMap_ST,_RampColorMapOffset.xy,_RampColorMapOffset.w);
|
||||
#endif
|
||||
|
||||
half cum_noise = 0;
|
||||
|
||||
//TODO
|
||||
@@ -784,6 +907,9 @@
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Texture2D _VertexOffset_Map;
|
||||
@@ -985,4 +1111,236 @@
|
||||
|
||||
return finalTexCoords;
|
||||
}
|
||||
|
||||
//--------------MatCap------------------
|
||||
|
||||
//-
|
||||
|
||||
struct AttributesParticle//即URP语境下的appdata
|
||||
{
|
||||
float4 vertex: POSITION;
|
||||
float3 normalOS: NORMAL;
|
||||
half4 color: COLOR;
|
||||
#if defined(_FLIPBOOKBLENDING_ON)
|
||||
float4 texcoords: TEXCOORD0; //texcoords.zw就是粒子那边新建的UV2
|
||||
float3 texcoordBlend: TEXCOORD3;//注意,假如需要UI支持,則Canvas要開放相關Channel
|
||||
#else
|
||||
float4 texcoords: TEXCOORD0;
|
||||
#endif
|
||||
|
||||
#if defined(_PARALLAX_MAPPING) || defined(_NORMALMAP) || defined(_FX_LIGHT_MODE_SIX_WAY)
|
||||
float4 tangentOS : TANGENT;
|
||||
#endif
|
||||
|
||||
float4 Custom1: TEXCOORD1;
|
||||
float4 Custom2: TEXCOORD2;
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct VaryingsParticle//即URP语境下的v2f
|
||||
{
|
||||
float4 clipPos: SV_POSITION;
|
||||
|
||||
half4 color: COLOR;
|
||||
float4 texcoord: TEXCOORD0; // 主帖图 和 mask
|
||||
|
||||
#if defined (_EMISSION) || defined(_COLORMAPBLEND)
|
||||
float4 emissionColorBlendTexcoord: TEXCOORD1; // 流光
|
||||
#endif
|
||||
|
||||
#ifdef _NOISEMAP
|
||||
float4 noisemapTexcoord:TEXCOORD2;//Noise
|
||||
#endif
|
||||
|
||||
#if defined(_DISSOLVE)
|
||||
|
||||
float4 dissolveTexcoord:TEXCOORD15;
|
||||
float4 dissolveNoiseTexcoord: TEXCOORD5;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
float4 positionWS: TEXCOORD3;
|
||||
float4 positionOS: TEXCOORD12;
|
||||
|
||||
float4 texcoord2AndSpecialUV: TEXCOORD6; // UV2和SpecialUV
|
||||
|
||||
float4 positionNDC: TEXCOORD7;
|
||||
|
||||
|
||||
float4 VaryingsP_Custom1: TEXCOORD8;
|
||||
float4 VaryingsP_Custom2: TEXCOORD9;
|
||||
|
||||
|
||||
float4 normalWSAndAnimBlend: TEXCOORD10;
|
||||
|
||||
float3 fresnelViewDir :TEXCOORD11;
|
||||
|
||||
float3 viewDirWS :TEXCOORD13;
|
||||
float4 texcoordMaskMap2 : TEXCOORD14;
|
||||
|
||||
#ifdef _PARALLAX_MAPPING
|
||||
half3 tangentViewDir : TEXCOORD16;
|
||||
#endif
|
||||
|
||||
#ifndef _FX_LIGHT_MODE_UNLIT
|
||||
half3 vertexSH :TEXCOORD17;
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
half3 vertexLight :TEXCOORD18;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_NORMALMAP) || defined(_FX_LIGHT_MODE_SIX_WAY)
|
||||
half4 tangentWS : TEXCOOR19;
|
||||
#endif
|
||||
#if defined (_NORMALMAP) || defined(_COLOR_RAMP)
|
||||
float4 bumpTexAndColorRampMapTexcoord : TEXCOOR20;
|
||||
#endif
|
||||
|
||||
#ifdef _FX_LIGHT_MODE_SIX_WAY
|
||||
half3 bakeDiffuseLighting0 :TEXCOOR21;
|
||||
half3 bakeDiffuseLighting1 :TEXCOOR22;
|
||||
half3 bakeDiffuseLighting2 :TEXCOOR23;
|
||||
half3 backBakeDiffuseLighting0 :TEXCOOR24;
|
||||
half3 backBakeDiffuseLighting1 :TEXCOOR25;
|
||||
half3 backBakeDiffuseLighting2 :TEXCOOR26;
|
||||
#endif
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
bool isProcessUVInFrag()
|
||||
{
|
||||
if(CheckLocalFlags(FLAG_BIT_PARTICLE_POLARCOORDINATES_ON) || CheckLocalFlags(FLAG_BIT_PARTICLE_UTWIRL_ON))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#if defined(_DEPTH_DECAL) || defined(_PARALLAX_MAPPING) || defined(_SCREEN_DISTORT_MODE)
|
||||
return true;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifndef _FX_LIGHT_MODE_UNLIT
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
|
||||
|
||||
void InitializeInputData(VaryingsParticle input, half3 normalTS, out InputData inputData)
|
||||
{
|
||||
inputData = (InputData)0;
|
||||
|
||||
#if defined(REQUIRES_WORLD_SPACE_POS_INTERPOLATOR)
|
||||
inputData.positionWS = input.positionWS;
|
||||
#endif
|
||||
|
||||
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(input.positionWS);
|
||||
#if defined(_NORMALMAP) || defined(_DETAIL)
|
||||
float sgn = input.tangentWS.w; // should be either +1 or -1
|
||||
float3 bitangent = sgn * cross(input.normalWSAndAnimBlend.xyz, input.tangentWS.xyz);
|
||||
half3x3 tangentToWorld = half3x3(input.tangentWS.xyz, bitangent.xyz, input.normalWSAndAnimBlend.xyz);
|
||||
|
||||
#if defined(_NORMALMAP)
|
||||
inputData.tangentToWorld = tangentToWorld;
|
||||
#endif
|
||||
inputData.normalWS = TransformTangentToWorld(normalTS, tangentToWorld);
|
||||
#else
|
||||
inputData.normalWS = input.normalWSAndAnimBlend.xyz;
|
||||
#endif
|
||||
|
||||
inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
|
||||
inputData.viewDirectionWS = viewDirWS;
|
||||
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
inputData.shadowCoord = input.shadowCoord;
|
||||
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
|
||||
inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS);
|
||||
#else
|
||||
inputData.shadowCoord = float4(0, 0, 0, 0);
|
||||
#endif
|
||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||
inputData.fogCoord = InitializeInputDataFog(float4(input.positionWS, 1.0), input.fogFactorAndVertexLight.x);
|
||||
inputData.vertexLighting = input.fogFactorAndVertexLight.yzw;
|
||||
#else
|
||||
inputData.fogCoord = InitializeInputDataFog(float4(input.positionWS.xyz, 1.0), input.positionWS.w);
|
||||
#endif
|
||||
|
||||
// #if defined(DYNAMICLIGHTMAP_ON)
|
||||
// inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.dynamicLightmapUV, input.vertexSH, inputData.normalWS);
|
||||
// #else
|
||||
// inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.vertexSH, inputData.normalWS);
|
||||
// #endif
|
||||
|
||||
inputData.bakedGI = SampleSHPixel(input.vertexSH, inputData.normalWS);
|
||||
|
||||
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.clipPos);
|
||||
inputData.shadowMask = SAMPLE_SHADOWMASK(input.staticLightmapUV);
|
||||
|
||||
#if defined(DEBUG_DISPLAY)
|
||||
#if defined(DYNAMICLIGHTMAP_ON)
|
||||
inputData.dynamicLightmapUV = input.dynamicLightmapUV;
|
||||
#endif
|
||||
#if defined(LIGHTMAP_ON)
|
||||
inputData.staticLightmapUV = input.staticLightmapUV;
|
||||
#else
|
||||
inputData.vertexSH = input.vertexSH;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int2 GetGradientIndex(half timeArr[6], int arrCount, half gradientTime)
|
||||
{
|
||||
|
||||
// 边界情况处理
|
||||
if (gradientTime < timeArr[0]) {
|
||||
return int2(-1, 0); // 小于最小值
|
||||
}
|
||||
if (gradientTime >= timeArr[arrCount - 1]) {
|
||||
return int2(arrCount - 1, arrCount); // 大于等于最大值
|
||||
}
|
||||
|
||||
// 顺序查找第一个大于X的元素索引
|
||||
[unroll]
|
||||
for (int i = 0; i < arrCount; i++) {
|
||||
if (timeArr[i] > gradientTime) {
|
||||
return int2(i - 1, i); // 返回区间索引
|
||||
}
|
||||
}
|
||||
return int2(-1, 0); // 理论上不会执行此处
|
||||
}
|
||||
half GetGradientIndexInterval(half timeArr[6],int arrCount,int2 indexes,half gradientTime)
|
||||
{
|
||||
//超出范围的直接在外面就判断好。
|
||||
// half smallVal = indexes.x < 0 ? 0:timeArr[indexes.x];
|
||||
half smallVal = timeArr[indexes.x];
|
||||
// half bigVal = indexes.y >= arrCount ? 1 : timeArr[indexes.y];
|
||||
half bigVal = timeArr[indexes.y];
|
||||
return (gradientTime - smallVal) / (bigVal - smallVal);
|
||||
}
|
||||
|
||||
half3 GetGradientColorValue(half3 colorArr[6],half timeArr[6], int arrCount,half gradientTime)
|
||||
{
|
||||
int2 indexes = GetGradientIndex(timeArr, arrCount, gradientTime);
|
||||
if (indexes.x < 0) return colorArr[0];
|
||||
if (indexes.y >= arrCount ) return colorArr[arrCount - 1];
|
||||
half interval = GetGradientIndexInterval(timeArr, arrCount, indexes, gradientTime);
|
||||
interval = SmoothStep01(interval);
|
||||
return lerp(colorArr[indexes.x], colorArr[indexes.y], interval);
|
||||
}
|
||||
|
||||
half GetGradientAlphaValue(half alphaArr[6],half timeArr[6], int arrCount,half gradientTime)
|
||||
{
|
||||
int2 indexes = GetGradientIndex(timeArr, arrCount, gradientTime);
|
||||
if (indexes.x < 0) return alphaArr[0];
|
||||
if (indexes.y >= arrCount ) return alphaArr[arrCount - 1];
|
||||
half interval = GetGradientIndexInterval(timeArr, arrCount, indexes, gradientTime);
|
||||
interval = SmoothStep01(interval);//TODO:消耗很大,如何避免?
|
||||
half alpha = lerp(alphaArr[indexes.x], alphaArr[indexes.y], interval);
|
||||
alpha *= alpha;//Make Alpha Smoother
|
||||
return alpha ;
|
||||
}
|
||||
#endif
|
||||
357
Packages/NBShaders/Shader/HLSL/SixWaySmokeLit.hlsl
Normal file
357
Packages/NBShaders/Shader/HLSL/SixWaySmokeLit.hlsl
Normal file
@@ -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
|
||||
3
Packages/NBShaders/Shader/HLSL/SixWaySmokeLit.hlsl.meta
Normal file
3
Packages/NBShaders/Shader/HLSL/SixWaySmokeLit.hlsl.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70e94bdedafe40bfb7f8e77cdc4bef0f
|
||||
timeCreated: 1751704445
|
||||
@@ -23,12 +23,12 @@
|
||||
_Dissolve_Test_Toggle("__Dissolve_Test_Toggle",Float) = 0
|
||||
|
||||
|
||||
_ColorBlendMap_Toggle("__ColorBlendMap_Toggle",Float) = 0
|
||||
|
||||
_FresnelMode("__FresnelMode",Float) = 0
|
||||
_InvertFresnel_Toggle("__InvertFresnel_Toggle",Float) = 0
|
||||
_HueShift_Toggle("__HueShift_Toggle",Float) = 0
|
||||
_BackFaceColor_Toggle("_BackFaceColor_Toggle",Float) = 0
|
||||
_BackFristPassToggle("_BackFirstPassToggle",Float) = 0
|
||||
_BackFirstPassToggle("_BackFirstPassToggle",Float) = 0
|
||||
|
||||
_PolarCordinateOnlySpecialFunciton_Toggle("极坐标仅对特殊功能生效_Toggle",Float) = 0
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
_BaseMapMaskMapOffset ("xy主贴图偏移速度", vector) = (0, 0, 0, 0)
|
||||
|
||||
_BaseMapUVRotation ("主贴图旋转", Range(0, 360)) = 0
|
||||
_BaseMapUVRotationSpeed ("主贴图旋转速度",Float) = 0
|
||||
[HDR]_BaseColor ("主贴图颜色_hdr", Color) = (1, 1, 1, 1)//HDR颜色不需要做Gamma Linear转换,Unity默认用Linear颜色
|
||||
// _BaseColor ("Base Color", Color) = (1, 1, 1, 1)//HDR颜色不需要做Gamma Linear转换,Unity默认用Linear颜色
|
||||
[HDR]_BaseBackColor ("背面颜色_hdr", Color) = (1, 1, 1, 1)//HDR颜色不需要做Gamma Linear转换,Unity默认用Linear颜色
|
||||
@@ -75,12 +76,44 @@
|
||||
_CylinderMatrix3("圆柱偏移矩阵3",Vector) = (0,0,0,0)
|
||||
|
||||
_Cutoff ("裁剪位置", float) = 0
|
||||
|
||||
//--------------光照部分-------------
|
||||
_FxLightMode("灯光模式",Float) = 0
|
||||
_BumpMapToggle("法线贴图开关",Float) = 0
|
||||
_BumpMapMaskMode("法线贴图多通道模式",Float) = 0
|
||||
_BumpScale("Scale", Float) = 1.0
|
||||
_BumpTex("Normal Map", 2D) = "bump" {}
|
||||
_BumpTexFollowMainTexUVToggle("法线跟随主贴图UV",Float) = 0
|
||||
_MaterialInfo("x:金属度,y:光滑度",Vector) = (1,1,0,0)
|
||||
_BlinnPhongSpecularToggle("BlinnPhong高光开关",Float) = 0
|
||||
[HDR]_SpecularColor("BlinnPhong高光颜色",Color) = (1,1,1,1)
|
||||
//-----------SixWayLight----------
|
||||
_RigRTBk("六路正方向图(P)",2D) = "white"{}
|
||||
_RigLBtF("六路反方向图(N)",2D) = "white"{}
|
||||
_SixWayColorAbsorptionToggle("六路光颜色吸收开关",Float) = 0
|
||||
_SixWayInfo("x:六路吸收强度",Vector) = (0.5,0,0,0)
|
||||
_SixWayEmissionRamp("六路自发光Ramp",2D) = "white"{}
|
||||
[HDR]_SixWayEmissionColor("六路自发光颜色",Color) = (1,0.5,0,1)
|
||||
|
||||
//-----MatCap------
|
||||
_MatCapToggle("MatCap开关",Float) = 0
|
||||
_MatCapTex("MatCap图",2D) = "white"{}
|
||||
[HDR]_MatCapColor("MatCap颜色",Color) = (1,1,1,1)
|
||||
_MatCapInfo("x:MatCap叠加和相乘过渡",Vector) = (1,0,0,0)
|
||||
// _MatCapBlendMode("MatCap叠加模式",Float) = 0
|
||||
|
||||
//时间缩放影响开关----------
|
||||
[HideInInspector] _TimeMode("__TimeMode",float) = 0.0
|
||||
|
||||
_StencilWithoutPlayerToggle("剔除主角色开关",Float) = 0.0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// MaskMap------------
|
||||
// MaskMap-----------
|
||||
_MaskRefineToggle("遮罩整体调整开关",Float) = 0
|
||||
_MaskRefineVec("遮罩整体调整:x:Pow,y:相乘,z:相加",Vector) = (1,1,0,0)
|
||||
_MaskMap ("遮罩贴图 xy:UV缩放 zw:UV偏移", 2D) = "white" { }
|
||||
_MaskMap2 ("遮罩2贴图 xy:UV缩放 zw:UV偏移", 2D) = "white"{}
|
||||
_MaskMap3 ("遮罩3贴图 xy:UV缩放 zw:UV偏移", 2D) = "white"{}
|
||||
@@ -89,7 +122,23 @@
|
||||
_MaskMapUVRotation ("遮罩旋转", Range(0, 360)) = 0.0
|
||||
_MaskDistortion_intensity ("遮罩扭曲强度", float) = 0.0
|
||||
_MaskMapRotationSpeed("遮罩旋转速度", float) = 0.0
|
||||
_MaskMapVec("x整体遮罩强度",Vector) = (1,0,0,0)
|
||||
_MaskMapVec("x整体遮罩强度,y遮罩2旋转,z遮罩3旋转",Vector) = (1,0,0,0)
|
||||
|
||||
_MaskMapGradientToggle("遮罩渐变模式",Float) = 0
|
||||
_MaskMapGradientCount("颜色映射数量",Integer) = 2
|
||||
_MaskMapGradientFloat0("x:MaskAlpha0,y:Pos0,z:MaskAlpha1,w:Pos1",Vector) = (0,0,1,1)
|
||||
_MaskMapGradientFloat1("x:MaskAlpha2,y:Pos2,z:MaskAlpha3,w:Pos3",Vector) = (1,0,1,1)
|
||||
_MaskMapGradientFloat2("x:MaskAlpha4,y:Pos4,z:MaskAlpha5,w:Pos5",Vector) = (1,0,1,1)
|
||||
_MaskMap2GradientToggle("遮罩2渐变模式",Float) = 0
|
||||
_MaskMap2GradientCount("颜色映射数量",Integer) = 2
|
||||
_MaskMap2GradientFloat0("x:Mask2Alpha0,y:Pos0,z:Mask2Alpha1,w:Pos1",Vector) = (0,0,1,1)
|
||||
_MaskMap2GradientFloat1("x:Mask2Alpha2,y:Pos2,z:Mask2Alpha3,w:Pos3",Vector) = (1,0,1,1)
|
||||
_MaskMap2GradientFloat2("x:Mask2Alpha4,y:Pos4,z:Mask2Alpha5,w:Pos5",Vector) = (1,0,1,1)
|
||||
_MaskMap3GradientToggle("遮罩3渐变模式",Float) = 0
|
||||
_MaskMap3GradientCount("颜色映射数量",Integer) = 2
|
||||
_MaskMap3GradientFloat0("x:Mask3Alpha0,y:Pos0,z:Mask3Alpha1,w:Pos1",Vector) = (0,0,1,1)
|
||||
_MaskMap3GradientFloat1("x:Mask3Alpha2,y:Pos2,z:Mask3Alpha3,w:Pos3",Vector) = (1,0,1,1)
|
||||
_MaskMap3GradientFloat2("x:Mask3Alpha4,y:Pos4,z:Mask3Alpha5,w:Pos5",Vector) = (1,0,1,1)
|
||||
|
||||
// 擦除----------------
|
||||
//[Header(ChaChu(Anima For CustomData.z).......)]
|
||||
@@ -124,9 +173,7 @@
|
||||
_DistortionDirection ("扭曲方向xy, 色散强度z", vector) = (1,1,0,0)
|
||||
_Distortion_Choraticaberrat_Toggle("扭曲色散开关_Toggle",Float) = 0
|
||||
_Distortion_Choraticaberrat_WithNoise_Toggle("色散受扭曲影响_Toggle",Float) = 1
|
||||
|
||||
|
||||
|
||||
|
||||
// 流光 ----------
|
||||
//[Header(LiuGuang(Anima For CustomData.w).......)]
|
||||
//[Toggle(_EMISSION)]_N1 ("EMISSION?", float) = 0
|
||||
@@ -139,27 +186,66 @@
|
||||
_uvRapSoft ("LiuuvRapSoft-ignore", Range(0, 1)) = 0
|
||||
[HDR]_EmissionMapColor ("流光贴图颜色_hdr", Color) = (1, 1, 1, 1)
|
||||
_EmissionMapColorIntensity("流光颜色强度", float) = 1
|
||||
_EmissionFollowMainTexUV("流光跟随主贴图",Float) = 0
|
||||
|
||||
//颜色渐变贴图--------
|
||||
_ColorBlendMap_Toggle("__ColorBlendMap_Toggle",Float) = 0
|
||||
_ColorBlendMap("颜色渐变贴图 xy:UV缩放 zw:UV偏移",2D) = "white"{}
|
||||
[HDR]_ColorBlendColor("颜色渐变叠加_hdr",Color) = (1,1,1,1)
|
||||
_ColorBlendMapOffset("xy:颜色渐变贴图偏移动画",Vector) = (0,0,0,0)
|
||||
_ColorBlendAlphaMultiplyMode("颜色渐变Alpha相乘开关",Float) = 0
|
||||
_ColorBlendFollowMainTexUV("颜色渐变UV跟随主贴图UV",Float) = 0
|
||||
_ColorBlendVec("x:颜色渐变扰动强度z:Alpha强度w:旋转",Vector) = (0,0,1,0)
|
||||
|
||||
//颜色映射Ramp
|
||||
_RampColorToggle("颜色映射开关",Float) = 0
|
||||
_RampColorSourceMode("Ramp来源模式",Float) = 0
|
||||
_RampColorBlendMode("Ramp颜色混合模式",Float) = 0
|
||||
_RampColorMap("颜色映射黑白图",2D) = "white"{}
|
||||
_RampColor0("rgb:RampColor0,a:pos",Color) = (0,0,0,0)
|
||||
_RampColor1("rgb:RampColor1,a:pos",Color) = (1,0,0,1)
|
||||
_RampColor2("rgb:RampColor2,a:pos",Color) = (1,1,1,1)
|
||||
_RampColor3("rgb:RampColor3,a:pos",Color) = (1,1,1,1)
|
||||
_RampColor4("rgb:RampColor4,a:pos",Color) = (1,1,1,1)
|
||||
_RampColor5("rgb:RampColor5,a:pos",Color) = (1,1,1,1)
|
||||
_RampColorAlpha0("x:RampColorAlpha0,y:Pos0,z:RampColorAlpha1,w:Pos1",Vector) = (1,0,1,1)
|
||||
_RampColorAlpha1("x:RampColorAlpha2,y:Pos2,z:RampColorAlpha3,w:Pos3",Vector) = (1,0,1,1)
|
||||
_RampColorAlpha2("x:RampColorAlpha4,y:Pos4,z:RampColorAlpha5,w:Pos5",Vector) = (1,0,1,1)
|
||||
_RampColorCount("颜色映射数量",Integer) = 2
|
||||
[HDR]_RampColorBlendColor("颜色映射叠加颜色_hdr",Color) = (1,1,1,1)
|
||||
_RampColorMapOffset("xy:颜色映射贴图偏移动画,w:旋转",Vector) = (0,0,0,0)
|
||||
|
||||
|
||||
// Rongjie ------------------
|
||||
// [Header(RongJie(Anima For CustomData.y).......)]
|
||||
// [Toggle(_DISSOLVE)]_RJ ("RONGJIE?", float) = 0
|
||||
_Dissolve ("x:溶解强度 y:溶解描边范围 z:局部控制强度 w:溶解硬度, _DissolveWidth", vector) = (0.5, 0.1, 1, 0.1)
|
||||
_DissolveMap("溶解贴图 xy:UV缩放 zw:UV偏移",2D) = "grey"{}
|
||||
_Dissolve ("x:溶解强度 y:溶解值Pow z:过程溶解强度 w:溶解硬软度", vector) = (0.5, 1, 0, 0.1)
|
||||
_DissolveMap("溶解贴图 xy:UV缩放 zw:UV偏移",2D) = "grey"{}
|
||||
_DissolveMaskMap("局部溶解蒙版 xy:UV缩放 zw:UV偏移",2D) = "white"{}
|
||||
_DissolveOffsetRotateDistort("xy:溶解贴图偏移速度 z:溶解贴图旋转",Vector) = (0,0,0,0)
|
||||
[HDR]_DissolveLineColor("溶解描边颜色_hdr",Color) = (0,0,0,1)
|
||||
[HDR]_DissolveLineColor("溶解描边颜色_hdr",Color) = (1,0,0,1)
|
||||
_DissolveVoronoi_Vec("xy:噪波1缩放,zw:噪波2缩放",Vector) = (1,1,2,2)
|
||||
_DissolveVoronoi_Vec2("x:噪波1和噪波2混合系数(圆尖),y:噪波整体和溶解贴图混合系数,z:噪波1速度,w:噪波2速度",Vector) = (1,1,2,2)
|
||||
_DissolveVoronoi_Vec3("xy:噪波1偏移速度,zw:噪波2偏移速度",Vector) = (0,0,0,0)
|
||||
_DissolveVoronoi_Vec4("xy:噪波1偏移,zw:噪波2偏移",Vector) = (0,0,0,0)
|
||||
_Dissolve_Vec2("溶解丝滑度(溶解值黑白调整)黑色X,白色Y",Vector) = (0,1,0,0)
|
||||
_Dissolve_Vec2("x:Ramp位置偏移,y:Ramp范围",Vector) = (0.2,0.1,0,0)
|
||||
_DissolveRampMap("溶解Ramp图",2D) = "white"{}
|
||||
_DissolveRampColorBlendMode("溶解Ramp图混合模式",Float) = 0
|
||||
[HDR]_DissolveRampColor("溶解Ramp颜色_hdr",Color) = (1,1,1,1)
|
||||
|
||||
//颜色渐变贴图--------
|
||||
_ColorBlendMap("颜色渐变贴图 xy:UV缩放 zw:UV偏移",2D) = "white"{}
|
||||
[HDR]_ColorBlendColor("颜色渐变叠加_hdr",Color) = (1,1,1,1)
|
||||
_ColorBlendMapOffset("xy:颜色渐变贴图偏移动画",Vector) = (0,0,0,0)
|
||||
_DissolveLineMaskToggle("溶解描边开关",Float) = 0
|
||||
|
||||
_DissolveRampSourceMode("溶解Ramp来源模式",Float) = 0
|
||||
_DissolveRampColor0("rgb:DissolveRampColor0,a:pos",Color) = (1,0,0,0)
|
||||
_DissolveRampColor1("rgb:DissolveRampColor1,a:pos",Color) = (0,0,0,1)
|
||||
_DissolveRampColor2("rgb:DissolveRampColor2,a:pos",Color) = (1,1,1,1)
|
||||
_DissolveRampColor3("rgb:DissolveRampColor3,a:pos",Color) = (1,1,1,1)
|
||||
_DissolveRampColor4("rgb:DissolveRampColor4,a:pos",Color) = (1,1,1,1)
|
||||
_DissolveRampColor5("rgb:DissolveRampColor5,a:pos",Color) = (1,1,1,1)
|
||||
_DissolveRampAlpha0("x:DissolveRampAlpha0,y:Pos0,z:DissolveRampAlpha1,w:Pos1",Vector) = (1,0,1,1)
|
||||
_DissolveRampAlpha1("x:DissolveRampAlpha2,y:Pos2,z:DissolveRampAlpha3,w:Pos3",Vector) = (1,0,1,1)
|
||||
_DissolveRampAlpha2("x:DissolveRampAlpha4,y:Pos4,z:DissolveRampAlpha5,w:Pos5",Vector) = (1,0,1,1)
|
||||
_DissolveRampCount("溶解Ramp映射数量",Integer) = 2
|
||||
|
||||
|
||||
_CustomData1X ("ignore", float) = 0
|
||||
_CustomData1Y ("ignore", float) = 0
|
||||
@@ -179,6 +265,7 @@
|
||||
_fogintensity ("雾影响强度", Range(0, 1)) = 1
|
||||
// -------------------------------------
|
||||
// Hidden properties - Generic 通用的隐藏属性
|
||||
_AdditiveToPreMultiplyAlphaLerp("相加到预乘混合",Range(0,1)) = 0.0
|
||||
[HideInInspector] _Blend ("__mode-ignore", Float) = 0.0
|
||||
[HideInInspector] _AlphaClip ("__clip-ignore", Float) = 0.0
|
||||
[HideInInspector] _SrcBlend ("__src-ignore", Float) = 1.0
|
||||
@@ -187,10 +274,9 @@
|
||||
[HideInInspector] _ZTest ("__ztest-ignore", Float) = 4.0 //默认值LEqual
|
||||
[HideInInspector] _ZWrite("__ZWrite-ignore", Float) = 0 //默认值LEqual
|
||||
// [HideInInspector] _ZTestt ("__ztestt", Float) = 4.0//雨轩:注释掉了。。。这是个什么鬼。。。
|
||||
|
||||
|
||||
|
||||
|
||||
_CustomStencilTest ("__CustomStencilTest-ignore", Float) = 0
|
||||
_StencilKeyIndex("__StencilKeyIndex-ignore",Float) = 0
|
||||
[Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp ("__StencilComp-ignore", Float) = 8
|
||||
_Stencil("Stencil ID-ignore", Float) = 0
|
||||
[Enum(UnityEngine.Rendering.StencilOp)]_StencilOp("Stencil Operation-ignore", Float) = 0
|
||||
@@ -205,8 +291,9 @@
|
||||
_DepthOutline_Toggle("深度描边",Float) = 0
|
||||
[HDR]_DepthOutline_Color("深度描边颜色_hdr",Color) = (1,1,1,1)
|
||||
_DepthOutline_Vec("菲涅尔深度描边参数",Vector) = (0,0.5,0,0)
|
||||
_FresnelColorAffectByAlpha("菲涅尔颜色受Alpha影响",Float) = 1
|
||||
// _DepthOutline_withoutFresnel_Toggle("深度描边关闭菲涅尔",Float) = 0
|
||||
// _FresnelUnit2("菲涅尔通用2", Vector) = (0,1,0,0)
|
||||
// _FresnelUnit2("菲涅尔通用2", Vector) = (1,1,0,0)
|
||||
|
||||
_DepthDecal_Toggle("深度贴花",Float) = 0
|
||||
|
||||
@@ -224,7 +311,7 @@
|
||||
|
||||
_ParallaxMapping_Toggle("视差",Float) = 0
|
||||
_ParallaxMapping_Map("视差贴图",2D) = "white"{}
|
||||
_ParallaxMapping_Intensity("视差强度",Float) = 1
|
||||
_ParallaxMapping_Intensity("视差强度",Float) = 0.05
|
||||
_ParallaxMapping_Vec("遮蔽视差层数 x:最小值,y:最大值",Vector) = (5,30,0,0)
|
||||
|
||||
|
||||
@@ -233,7 +320,7 @@
|
||||
[HideInInspector] _BaseColorAddSubDiff ("_ColorMode", Vector) = (0, 0, 0, 0)
|
||||
[HideInInspector] _SoftParticlesEnabled ("__softparticlesenabled", Float) = 0.0
|
||||
[HideInInspector] _CameraFadingEnabled ("__camerafadingenabled", Float) = 0.0
|
||||
[HideInInspector] _SoftParticleFadeParams ("xy:软粒子远近裁剪面", Vector) = (0, 0, 0, 0)
|
||||
[HideInInspector] _SoftParticleFadeParams ("xy:软粒子远近裁剪面", Vector) = (0, 0.5, 0, 0)
|
||||
[HideInInspector] _CameraFadeParams ("__camerafadeparams_ignore", Vector) = (0, 0, 0, 0)
|
||||
[HideInInspector] _IntersectEnabled("__IntersectEnabled_ignore",Float) = 0.0
|
||||
[HideInInspector] _IntersectRadius("__IntersectRadius_ignore",Float) = 0.3
|
||||
@@ -241,8 +328,6 @@
|
||||
|
||||
[HideInInspector] _ScreenDistortModeToggle("_ScreenDistortModeToggle",Float) = 0
|
||||
|
||||
|
||||
|
||||
// Editmode props 编辑模式下的PropFlags?
|
||||
[HideInInspector] _QueueBias ("Queue偏移_QueueBias", Float) =0
|
||||
|
||||
@@ -282,14 +367,26 @@
|
||||
[HideInInspector] _W9ParticleCustomDataFlag2("_W9ParticleCustomDataFlag2", Integer) = 0
|
||||
[HideInInspector] _W9ParticleCustomDataFlag3("_W9ParticleCustomDataFlag3", Integer) = 0
|
||||
[HideInInspector] _UVModeFlag0("_UVModeFlag0", Integer) = 0
|
||||
[HideInInspector] _W9ParticleShaderGUIFoldToggle("_W9ParticleShaderGUIFoldToggle", Integer) = 31//前5个开关默认打开
|
||||
[HideInInspector] _W9ParticleShaderGUIFoldToggle("_W9ParticleShaderGUIFoldToggle", Integer) = 3//前2个开关默认打开
|
||||
[HideInInspector] _W9ParticleShaderGUIFoldToggle1("_W9ParticleShaderGUIFoldToggle1", Integer) = 255//这边默认全开
|
||||
|
||||
[HideInInspector] _W9ParticleShaderGUIFoldToggle2("_W9ParticleShaderGUIFoldToggle2", Integer) = 255//这边默认全开
|
||||
[HideInInspector] _W9ParticleShaderColorChannelFlag("_W9ParticleShaderColorChannelFlag", Integer) = 3//默认主贴图开A通道
|
||||
|
||||
|
||||
SaturabilityRangeVec("_Saturability",Vector) = (0,1,0,0)
|
||||
TexDistortionintensityRangeVec("_TexDistortion_intensity",Vector) = (-1,1,0,0)
|
||||
MaskDistortionIntensityRangeVec("_MaskDistortion_intensity",Vector) = (-2,2,0,0)
|
||||
EmiDistortionIntensityRangeVec("_TexDistortion_intensity",Vector) = (-1,1,0,0)
|
||||
BumpScaleRangeVec("_BumpScale",Vector) = (-1,1,0,0)
|
||||
DissolveXRangeVec("_Dissolve.x",Vector) = (-1,2,0,0)
|
||||
Dissolve2XRangeVec("_Dissolve_Vec2.x",Vector) = (0,1,0,0)
|
||||
Dissolve2YRangeVec("_Dissolve_Vec2.y",Vector) = (0,1,0,0)
|
||||
AlphaAllRangeVec("_AlphaAll",Vector) = (0,1,0,0)
|
||||
// _offsetUnits("深度偏移单位距离-ignore", range(-2000,2000)) = 0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" "CanUseSpriteAtlas"="True" }
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Sphere" "CanUseSpriteAtlas"="True" }
|
||||
|
||||
Stencil
|
||||
{
|
||||
@@ -330,6 +427,9 @@
|
||||
#pragma target 4.5
|
||||
#pragma exclude_renderers d3d11_9x
|
||||
#pragma exclude_renderers d3d9
|
||||
|
||||
#pragma enable_d3d11_debug_symbols // 保留D3D11调试符号
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _ _SCREEN_DISTORT_MODE
|
||||
@@ -345,9 +445,13 @@
|
||||
//后续Test类的关键字要找机会排除
|
||||
#pragma shader_feature_local _DISSOLVE_EDITOR_TEST
|
||||
#pragma shader_feature_local _COLORMAPBLEND//颜色渐变
|
||||
#pragma shader_feature_local _COLOR_RAMP//颜色映射
|
||||
|
||||
//将光照和UI混用,达到节省Keywords的目的。
|
||||
#pragma multi_compile _ UNITY_UI_CLIP_RECT _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS//UI 2D遮罩
|
||||
// #pragma multi_compile _ _UIPARTICLE_ON//用于UIParticle组件动态更改参数//暂时注释掉,觉得没什么意义
|
||||
#pragma multi_compile _ SOFT_UI_FRAME EVALUATE_SH_MIXED EVALUATE_SH_VERTEX//用于UI软蒙版
|
||||
|
||||
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT//UI 2D遮罩
|
||||
// #pragma shader_feature_local _ _CH_XIANXING _CH_JINGXIANG _CH_SELF //线性擦除 径向擦除 mask擦除
|
||||
#pragma shader_feature_local _PARCUSTOMDATA_ON
|
||||
|
||||
//用于特效层关键字
|
||||
@@ -356,11 +460,9 @@
|
||||
#pragma shader_feature_local _ FRESNEL_CUBEMAP FRESNEL_REFLECTIONPROBE
|
||||
|
||||
|
||||
// #pragma multi_compile _ _UIPARTICLE_ON//用于UIParticle组件动态更改参数//暂时注释掉,觉得没什么意义
|
||||
#pragma multi_compile _ SOFT_UI_FRAME//用于UI软蒙版
|
||||
// -------------------------------------
|
||||
// Particle Keywords
|
||||
//#pragma shader_feature_local _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON //设置alpah Add 。。组合
|
||||
#pragma shader_feature_local _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON //设置alpah Add 。。组合
|
||||
#pragma shader_feature_local _ALPHATEST_ON
|
||||
//#pragma shader_feature_local _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON //粒子颜色和材质颜色的混合运算 暂时先不要了
|
||||
#pragma shader_feature_local _FLIPBOOKBLENDING_ON
|
||||
@@ -379,6 +481,14 @@
|
||||
#pragma shader_feature_local _PARALLAX_MAPPING
|
||||
|
||||
#pragma shader_feature_local _STENCIL_WITHOUT_PLAYER
|
||||
|
||||
//LIGHTING
|
||||
#pragma shader_feature_local _FX_LIGHT_MODE_UNLIT _FX_LIGHT_MODE_BLINN_PHONG _FX_LIGHT_MODE_HALF_LAMBERT _FX_LIGHT_MODE_PBR _FX_LIGHT_MODE_SIX_WAY
|
||||
#pragma shader_feature_local _ _NORMALMAP
|
||||
#pragma shader_feature_local _ _MATCAP
|
||||
#pragma shader_feature_local _ _SPECULAR_COLOR
|
||||
#pragma shader_feature_local _ VFX_SIX_WAY_ABSORPTION
|
||||
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
@@ -404,7 +514,6 @@
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
|
||||
#include "Packages/com.xuanxuan.render.utility/Shader/HLSL/XuanXuan_Utility.hlsl"
|
||||
#include "HLSL/ParticlesUnlitInputNew.hlsl"
|
||||
#include "HLSL/ParticlesUnlitForwardPassNew.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
@@ -429,6 +538,9 @@
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
|
||||
#pragma enable_d3d11_debug_symbols // 保留D3D11调试符号
|
||||
|
||||
#pragma shader_feature_local _ _SCREEN_DISTORT_MODE
|
||||
#pragma shader_feature_local _ _MASKMAP_ON
|
||||
// #pragma shader_feature_local _MASKMAP
|
||||
@@ -441,9 +553,12 @@
|
||||
#pragma shader_feature_local _DISSOLVE
|
||||
//后续Test类的关键字要找机会排除
|
||||
#pragma shader_feature_local _DISSOLVE_EDITOR_TEST
|
||||
#pragma shader_feature_local _COLORMAPBLEND//颜色渐变
|
||||
#pragma shader_feature_local _COLORMAPBLEND//颜色渐变
|
||||
#pragma shader_feature_local _COLOR_RAMP//颜色映射
|
||||
|
||||
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT//UI 2D遮罩
|
||||
|
||||
|
||||
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS //UI 2D遮罩
|
||||
// #pragma shader_feature_local _ _CH_XIANXING _CH_JINGXIANG _CH_SELF //线性擦除 径向擦除 mask擦除
|
||||
#pragma shader_feature_local _PARCUSTOMDATA_ON
|
||||
|
||||
@@ -454,10 +569,10 @@
|
||||
|
||||
|
||||
// #pragma multi_compile _ _UIPARTICLE_ON//用于UIParticle组件动态更改参数//暂时注释掉,觉得没什么意义
|
||||
#pragma multi_compile _ SOFT_UI_FRAME//用于UI软蒙版
|
||||
#pragma multi_compile _ SOFT_UI_FRAME EVALUATE_SH_MIXED EVALUATE_SH_VERTEX//用于UI软蒙版
|
||||
// -------------------------------------
|
||||
// Particle Keywords
|
||||
//#pragma shader_feature_local _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON //设置alpah Add 。。组合
|
||||
#pragma shader_feature_local _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON //设置alpah Add 。。组合
|
||||
#pragma shader_feature_local _ALPHATEST_ON
|
||||
//#pragma shader_feature_local _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON //粒子颜色和材质颜色的混合运算 暂时先不要了
|
||||
#pragma shader_feature_local _FLIPBOOKBLENDING_ON
|
||||
@@ -477,7 +592,12 @@
|
||||
|
||||
#pragma shader_feature_local _STENCIL_WITHOUT_PLAYER
|
||||
|
||||
|
||||
//LIGHTING
|
||||
#pragma shader_feature_local _FX_LIGHT_MODE_UNLIT _FX_LIGHT_MODE_BLINN_PHONG _FX_LIGHT_MODE_HALF_LAMBERT _FX_LIGHT_MODE_PBR _FX_LIGHT_MODE_SIX_WAY
|
||||
#pragma shader_feature_local _ _NORMALMAP
|
||||
#pragma shader_feature_local _ _MATCAP
|
||||
#pragma shader_feature_local _ _SPECULAR_COLOR
|
||||
#pragma shader_feature_local _ VFX_SIX_WAY_ABSORPTION
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
@@ -492,14 +612,115 @@
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
// The DeclareDepthTexture.hlsl file contains utilities for sampling the Camera
|
||||
// depth texture.
|
||||
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
|
||||
#include "Packages/com.xuanxuan.render.utility/Shader/HLSL/XuanXuan_Utility.hlsl"
|
||||
#include "HLSL/ParticlesUnlitForwardPassNew.hlsl"
|
||||
|
||||
|
||||
ENDHLSL
|
||||
|
||||
}
|
||||
|
||||
#include "HLSL/ParticlesUnlitInputNew.hlsl"
|
||||
// ------------------------------------------------------------------
|
||||
// Forward pass.
|
||||
Pass
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"LightMode" = "Universal2D"
|
||||
} //Queue设置是希望特效渲染在场景透明物体前面
|
||||
offset [_offsetFactor], [_offsetUnits]
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#define PARTICLE
|
||||
//20240228 target3.0 顶点着色器限制16个输出。提高版本
|
||||
#pragma target 4.5
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
|
||||
#pragma enable_d3d11_debug_symbols // 保留D3D11调试符号
|
||||
|
||||
#pragma shader_feature_local _ _SCREEN_DISTORT_MODE
|
||||
#pragma shader_feature_local _ _MASKMAP_ON
|
||||
// #pragma shader_feature_local _MASKMAP
|
||||
// #pragma shader_feature_local _MASKMAP2
|
||||
//#pragma shader_feature_local _NOISEMAP
|
||||
#pragma shader_feature_local _NOISEMAP
|
||||
//#pragma shader_feature_local _EMISSION //流光
|
||||
#pragma shader_feature_local _EMISSION
|
||||
//#pragma shader_feature_local _ _DISSOLVE //溶解
|
||||
#pragma shader_feature_local _DISSOLVE
|
||||
//后续Test类的关键字要找机会排除
|
||||
#pragma shader_feature_local _DISSOLVE_EDITOR_TEST
|
||||
#pragma shader_feature_local _COLORMAPBLEND//颜色渐变
|
||||
#pragma shader_feature_local _COLOR_RAMP//颜色映射
|
||||
|
||||
|
||||
|
||||
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS //UI 2D遮罩
|
||||
// #pragma shader_feature_local _ _CH_XIANXING _CH_JINGXIANG _CH_SELF //线性擦除 径向擦除 mask擦除
|
||||
#pragma shader_feature_local _PARCUSTOMDATA_ON
|
||||
|
||||
//用于特效层关键字
|
||||
// #pragma shader_feature_local _UIEFFECT_ON
|
||||
|
||||
#pragma shader_feature_local _ FRESNEL_CUBEMAP FRESNEL_REFLECTIONPROBE
|
||||
|
||||
|
||||
// #pragma multi_compile _ _UIPARTICLE_ON//用于UIParticle组件动态更改参数//暂时注释掉,觉得没什么意义
|
||||
#pragma multi_compile _ SOFT_UI_FRAME EVALUATE_SH_MIXED EVALUATE_SH_VERTEX//用于UI软蒙版
|
||||
// -------------------------------------
|
||||
// Particle Keywords
|
||||
#pragma shader_feature_local _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON //设置alpah Add 。。组合
|
||||
#pragma shader_feature_local _ALPHATEST_ON
|
||||
//#pragma shader_feature_local _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON //粒子颜色和材质颜色的混合运算 暂时先不要了
|
||||
#pragma shader_feature_local _FLIPBOOKBLENDING_ON
|
||||
#pragma shader_feature_local _SOFTPARTICLES_ON
|
||||
// #pragma shader_feature_local _OCCLUDEOPACITY_ON
|
||||
// #pragma shader_feature_local _ _SATURABILITY_ON
|
||||
|
||||
//UnscaleTime用于接收项目传的公开不受缩放影响的Time值
|
||||
#pragma shader_feature_local _UNSCALETIME
|
||||
//scriptableTime用于程序每帧传值
|
||||
#pragma shader_feature_local _SCRIPTABLETIME
|
||||
//#pragma shader_feature_local _DISTORTION_ON
|
||||
#pragma shader_feature_local _NOISEMAP_NORMALIZEED
|
||||
|
||||
#pragma shader_feature_local _DEPTH_DECAL
|
||||
#pragma shader_feature_local _PARALLAX_MAPPING
|
||||
|
||||
#pragma shader_feature_local _STENCIL_WITHOUT_PLAYER
|
||||
|
||||
//LIGHTING
|
||||
#pragma shader_feature_local _FX_LIGHT_MODE_UNLIT _FX_LIGHT_MODE_BLINN_PHONG _FX_LIGHT_MODE_HALF_LAMBERT _FX_LIGHT_MODE_PBR _FX_LIGHT_MODE_SIX_WAY
|
||||
#pragma shader_feature_local _ _NORMALMAP
|
||||
#pragma shader_feature_local _ _MATCAP
|
||||
#pragma shader_feature_local _ _SPECULAR_COLOR
|
||||
#pragma shader_feature_local _ VFX_SIX_WAY_ABSORPTION
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
// 之后进行优化时再说。
|
||||
#pragma multi_compile_fog
|
||||
// #define FOG_EXP2 1
|
||||
|
||||
#pragma vertex vertParticleUnlit
|
||||
#pragma fragment fragParticleUnlit
|
||||
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
// The DeclareDepthTexture.hlsl file contains utilities for sampling the Camera
|
||||
// depth texture.
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
|
||||
#include "Packages/com.xuanxuan.render.utility/Shader/HLSL/XuanXuan_Utility.hlsl"
|
||||
#include "HLSL/ParticlesUnlitForwardPassNew.hlsl"
|
||||
|
||||
|
||||
@@ -508,5 +729,5 @@
|
||||
}
|
||||
}
|
||||
|
||||
CustomEditor "ParticleBaseGUI"
|
||||
CustomEditor "NBShaderEditor.ParticleBaseGUI"
|
||||
}
|
||||
@@ -13,6 +13,16 @@ MonoBehaviour:
|
||||
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
|
||||
@@ -53,16 +63,6 @@ MonoBehaviour:
|
||||
ZFail: 0
|
||||
ReadMask: 255
|
||||
WriteMask: 255
|
||||
- key: ParticleBaseDefault
|
||||
Values:
|
||||
DefaultQueue: 3100
|
||||
Ref: 0
|
||||
Comp: 8
|
||||
Pass: 0
|
||||
Fail: 0
|
||||
ZFail: 0
|
||||
ReadMask: 255
|
||||
WriteMask: 255
|
||||
- key: ParticleWithoutPlayer
|
||||
Values:
|
||||
DefaultQueue: 3100
|
||||
|
||||
Reference in New Issue
Block a user