Added HairBlendingSetting in UTSRenderPassSetting; Added MaterialType to UTS; Added MaterialFeature scope to UTS material editor; Merged HairBlendingPass and HairShadowPass into UTSPass; Fixed the bug that character box light can not update rotation correctly according to bound light source;
127 lines
4.4 KiB
HLSL
127 lines
4.4 KiB
HLSL
#undef unity_ObjectToWorld
|
|
#undef unity_WorldToObject
|
|
|
|
#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/MotionVectorVertexShaderCommon.hlsl"
|
|
|
|
// PackedVaryingsType
|
|
// https://github.com/Unity-Technologies/Graphics/blob/e4117c07b479adafed38237f3407a363eefb4590/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl#L120
|
|
|
|
PackedVaryingsType Vert(AttributesMesh inputMesh, AttributesPass inputPass)
|
|
{
|
|
// VaryingsType
|
|
// https://github.com/Unity-Technologies/Graphics/blob/e4117c07b479adafed38237f3407a363eefb4590/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl#L118
|
|
|
|
VaryingsType varyingsType;
|
|
varyingsType.vmesh = VertMesh(inputMesh);
|
|
|
|
return MotionVectorVS(varyingsType, inputMesh, inputPass);
|
|
}
|
|
|
|
#else // _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl"
|
|
|
|
PackedVaryingsType Vert(AttributesMesh inputMesh)
|
|
{
|
|
VaryingsType varyingsType;
|
|
varyingsType.vmesh = VertMesh(inputMesh);
|
|
|
|
return PackVaryingsType(varyingsType);
|
|
}
|
|
|
|
#endif // _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
|
|
|
|
|
|
#ifdef UNITY_VIRTUAL_TEXTURING
|
|
#define VT_BUFFER_TARGET SV_Target1
|
|
#define EXTRA_BUFFER_TARGET SV_Target2
|
|
#else
|
|
#define EXTRA_BUFFER_TARGET SV_Target1
|
|
#endif
|
|
|
|
|
|
|
|
void Frag(PackedVaryingsToPS packedInput,
|
|
#ifdef OUTPUT_SPLIT_LIGHTING
|
|
out float4 outColor : SV_Target0, // outSpecularLighting
|
|
#ifdef UNITY_VIRTUAL_TEXTURING
|
|
out float4 outVTFeedback : VT_BUFFER_TARGET,
|
|
#endif
|
|
out float4 outDiffuseLighting : EXTRA_BUFFER_TARGET,
|
|
OUTPUT_SSSBUFFER(outSSSBuffer)
|
|
#else
|
|
out float4 outColor : SV_Target0
|
|
#ifdef UNITY_VIRTUAL_TEXTURING
|
|
, out float4 outVTFeedback : VT_BUFFER_TARGET
|
|
#endif
|
|
#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
, out float4 outMotionVec : EXTRA_BUFFER_TARGET
|
|
#endif // _WRITE_TRANSPARENT_MOTION_VECTOR
|
|
#endif // OUTPUT_SPLIT_LIGHTING
|
|
#ifdef _DEPTHOFFSET_ON
|
|
, out float outputDepth : SV_Depth
|
|
#endif
|
|
)
|
|
{
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(packedInput);
|
|
FragInputs input = UnpackVaryingsMeshToFragInputs(packedInput.vmesh);
|
|
#ifdef _IS_CLIPPING_MASK
|
|
if (_ClippingMaskMode != 0)
|
|
{
|
|
discard;
|
|
}
|
|
#endif
|
|
#ifdef _IS_CLIPPING_MATTE
|
|
if (_ClippingMatteMode != 0)
|
|
{
|
|
discard;
|
|
}
|
|
#endif // _IS_CLIPPING_MATTE
|
|
#if defined(UTS_DEBUG_SHADOWMAP_NO_OUTLINE)
|
|
discard;
|
|
#endif
|
|
|
|
|
|
|
|
//v.2.0.5
|
|
if (_ZOverDrawMode > 0.99f)
|
|
{
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = posInput.deviceDepth;
|
|
#endif
|
|
#ifdef UNITY_VIRTUAL_TEXTURING
|
|
|
|
outVTFeedback = builtinData.vtPackedFeedback;
|
|
#endif
|
|
outColor = float4(1.0f, 1.0f, 1.0f, 1.0f); // but nothing should be drawn except Z value as colormask is set to 0
|
|
return;
|
|
}
|
|
_Color = _BaseColor;
|
|
float4 objPos = mul(unity_ObjectToWorld, float4(0, 0, 0, 1));
|
|
float4 Set_UV0 = input.texCoord0;
|
|
|
|
// The following temporary definition of unity_AmbientEquator is for HDRP only.
|
|
//float4 unity_AmbientEquator = float4(0.05, 0.05, 0.05, 1.0); //Todo.
|
|
//v.2.0.9
|
|
//float3 envLightSource_GradientEquator = unity_AmbientEquator.rgb > 0.05 ? unity_AmbientEquator.rgb : half3(0.05, 0.05, 0.05);
|
|
float3 envLightSource_GradientEquator = ShadeSH9(float4(0, 1, 0, 0));
|
|
float3 envLightSource_SkyboxIntensity = max(
|
|
SampleBakedGI_UTS_OutLine(objPos.xyz, float3(0.0, 0.0, 0.0), input.texCoord1.xy, input.texCoord2.xy),
|
|
SampleBakedGI_UTS_OutLine(objPos.xyz, float3(0.0, -1.0, 0.0), input.texCoord1.xy, input.texCoord2.xy)
|
|
).rgb;
|
|
float3 ambientSkyColor = envLightSource_SkyboxIntensity.rgb > 0.0 ? envLightSource_SkyboxIntensity : envLightSource_GradientEquator;
|
|
ambientSkyColor *= GetCurrentExposureMultiplier();
|
|
|
|
float4 _BlendingTex_var = SAMPLE_TEXTURE2D(_HairBlendingMap, sampler_HairBlendingMap, TRANSFORM_TEX(Set_UV0, _MainTex));
|
|
outColor = float4(_BlendingTex_var.rgb * ambientSkyColor, _BlendingTex_var.a);
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = posInput.deviceDepth;
|
|
#endif
|
|
#ifdef UNITY_VIRTUAL_TEXTURING
|
|
outVTFeedback = builtinData.vtPackedFeedback;
|
|
#endif
|
|
}
|
|
// End of File |