更新
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
|
||||
Reference in New Issue
Block a user