GitHub
8 年前
当前提交
789af10a
共有 47 个文件被更改,包括 1702 次插入 和 240 次删除
-
53Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs
-
36Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
-
5Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs
-
30Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/LitUI.cs
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.hlsl
-
36Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.shader
-
33Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitData.hlsl
-
6Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitProperties.hlsl
-
45Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl
-
7Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/Unlit.shader
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl
-
8Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/Resources/SkyProcedural.shader
-
2Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl
-
1Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl
-
17Assets/ScriptableRenderLoop/ShaderLibrary/Packing.hlsl
-
119Assets/ScriptableRenderLoop/ShaderLibrary/Tesselation.hlsl
-
68Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitVelocityPass.hlsl
-
78Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitSharePass.hlsl
-
56Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDistortionPass.hlsl
-
504Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLitTesselation.shader
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLitTesselation.shader.meta
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl.meta
-
41Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTesselation.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTesselation.hlsl.meta
-
382Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.shader
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.shader.meta
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass.meta
-
53Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Tesselation/TesselationShare.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Tesselation/TesselationShare.hlsl.meta
-
170Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDepthPass.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitSurfaceData.hlsl.meta
-
108Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDepthPass.hlsl
-
0Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Tesselation/ShareTesselation.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Tesselation/ShareTesselation.hlsl.meta
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitVelocityPass.hlsl.meta
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitVelocityPass.hlsl
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitSharePass.hlsl.meta
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitSharePass.hlsl
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitMetaPass.hlsl.meta
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitMetaPass.hlsl
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDistortionPass.hlsl.meta
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDistortionPass.hlsl
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDepthPass.hlsl.meta
|
|||
#define TESSELATION_INTERPOLATE_BARY(name, bary) ouput.name = input0.name * bary.x + input1.name * bary.y + input2.name * bary.z |
|||
|
|||
// ---- utility functions |
|||
float UnityCalcDistanceTessFactor(float3 positionOS, float minDist, float maxDist, float tess, float4x4 objectToWorld, float3 cameraPosWS) |
|||
{ |
|||
float3 positionWS = mul(objectToWorld, float4(positionOS, 1.0)).xyz; |
|||
float dist = distance(positionWS, cameraPosWS); |
|||
float f = clamp(1.0 - (dist - minDist) / (maxDist - minDist), 0.01, 1.0) * tess; |
|||
return f; |
|||
} |
|||
|
|||
float4 UnityCalcTriEdgeTessFactors(float3 triVertexFactors) |
|||
{ |
|||
float4 tess; |
|||
tess.x = 0.5 * (triVertexFactors.y + triVertexFactors.z); |
|||
tess.y = 0.5 * (triVertexFactors.x + triVertexFactors.z); |
|||
tess.z = 0.5 * (triVertexFactors.x + triVertexFactors.y); |
|||
tess.w = (triVertexFactors.x + triVertexFactors.y + triVertexFactors.z) / 3.0f; |
|||
return tess; |
|||
} |
|||
|
|||
/* |
|||
float UnityCalcEdgeTessFactor(float3 wpos0, float3 wpos1, float edgeLen) |
|||
{ |
|||
// distance to edge center |
|||
float dist = distance(0.5 * (wpos0 + wpos1), _WorldSpaceCameraPos); |
|||
// length of the edge |
|||
float len = distance(wpos0, wpos1); |
|||
// edgeLen is approximate desired size in pixels |
|||
float f = max(len * _ScreenParams.y / (edgeLen * dist), 1.0); |
|||
return f; |
|||
} |
|||
|
|||
float UnityDistanceFromPlane(float3 pos, float4 plane) |
|||
{ |
|||
float d = dot(float4(pos, 1.0f), plane); |
|||
return d; |
|||
} |
|||
|
|||
// Returns true if triangle with given 3 world positions is outside of camera's view frustum. |
|||
// cullEps is distance outside of frustum that is still considered to be inside (i.e. max displacement) |
|||
bool UnityWorldViewFrustumCull(float3 wpos0, float3 wpos1, float3 wpos2, float cullEps) |
|||
{ |
|||
float4 planeTest; |
|||
|
|||
// left |
|||
planeTest.x = ((UnityDistanceFromPlane(wpos0, unity_CameraWorldClipPlanes[0]) > -cullEps) ? 1.0f : 0.0f) + |
|||
((UnityDistanceFromPlane(wpos1, unity_CameraWorldClipPlanes[0]) > -cullEps) ? 1.0f : 0.0f) + |
|||
((UnityDistanceFromPlane(wpos2, unity_CameraWorldClipPlanes[0]) > -cullEps) ? 1.0f : 0.0f); |
|||
// right |
|||
planeTest.y = ((UnityDistanceFromPlane(wpos0, unity_CameraWorldClipPlanes[1]) > -cullEps) ? 1.0f : 0.0f) + |
|||
((UnityDistanceFromPlane(wpos1, unity_CameraWorldClipPlanes[1]) > -cullEps) ? 1.0f : 0.0f) + |
|||
((UnityDistanceFromPlane(wpos2, unity_CameraWorldClipPlanes[1]) > -cullEps) ? 1.0f : 0.0f); |
|||
// top |
|||
planeTest.z = ((UnityDistanceFromPlane(wpos0, unity_CameraWorldClipPlanes[2]) > -cullEps) ? 1.0f : 0.0f) + |
|||
((UnityDistanceFromPlane(wpos1, unity_CameraWorldClipPlanes[2]) > -cullEps) ? 1.0f : 0.0f) + |
|||
((UnityDistanceFromPlane(wpos2, unity_CameraWorldClipPlanes[2]) > -cullEps) ? 1.0f : 0.0f); |
|||
// bottom |
|||
planeTest.w = ((UnityDistanceFromPlane(wpos0, unity_CameraWorldClipPlanes[3]) > -cullEps) ? 1.0f : 0.0f) + |
|||
((UnityDistanceFromPlane(wpos1, unity_CameraWorldClipPlanes[3]) > -cullEps) ? 1.0f : 0.0f) + |
|||
((UnityDistanceFromPlane(wpos2, unity_CameraWorldClipPlanes[3]) > -cullEps) ? 1.0f : 0.0f); |
|||
|
|||
// has to pass all 4 plane tests to be visible |
|||
return !all(planeTest); |
|||
} |
|||
*/ |
|||
|
|||
// ---- functions that compute tessellation factors |
|||
// Distance based tessellation: |
|||
// Tessellation level is "tess" before "minDist" from camera, and linearly decreases to 1 |
|||
// up to "maxDist" from camera. |
|||
float4 UnityDistanceBasedTess(float3 positionOS0, float3 positionOS1, float3 positionOS2, float minDist, float maxDist, float tess, float4x4 objectToWorld, float3 cameraPosWS) |
|||
{ |
|||
float3 f; |
|||
f.x = UnityCalcDistanceTessFactor(positionOS0, minDist, maxDist, tess, objectToWorld, cameraPosWS); |
|||
f.y = UnityCalcDistanceTessFactor(positionOS1, minDist, maxDist, tess, objectToWorld, cameraPosWS); |
|||
f.z = UnityCalcDistanceTessFactor(positionOS2, minDist, maxDist, tess, objectToWorld, cameraPosWS); |
|||
return UnityCalcTriEdgeTessFactors(f); |
|||
} |
|||
|
|||
/* |
|||
// Desired edge length based tessellation: |
|||
// Approximate resulting edge length in pixels is "edgeLength". |
|||
// Does not take viewing FOV into account, just flat out divides factor by distance. |
|||
float4 UnityEdgeLengthBasedTess(float4 v0, float4 v1, float4 v2, float edgeLength) |
|||
{ |
|||
float3 pos0 = mul(unity_ObjectToWorld, v0).xyz; |
|||
float3 pos1 = mul(unity_ObjectToWorld, v1).xyz; |
|||
float3 pos2 = mul(unity_ObjectToWorld, v2).xyz; |
|||
float4 tess; |
|||
tess.x = UnityCalcEdgeTessFactor(pos1, pos2, edgeLength); |
|||
tess.y = UnityCalcEdgeTessFactor(pos2, pos0, edgeLength); |
|||
tess.z = UnityCalcEdgeTessFactor(pos0, pos1, edgeLength); |
|||
tess.w = (tess.x + tess.y + tess.z) / 3.0f; |
|||
return tess; |
|||
} |
|||
|
|||
// Same as UnityEdgeLengthBasedTess, but also does patch frustum culling: |
|||
// patches outside of camera's view are culled before GPU tessellation. Saves some wasted work. |
|||
float4 UnityEdgeLengthBasedTessCull(float4 v0, float4 v1, float4 v2, float edgeLength, float maxDisplacement) |
|||
{ |
|||
float3 pos0 = mul(unity_ObjectToWorld, v0).xyz; |
|||
float3 pos1 = mul(unity_ObjectToWorld, v1).xyz; |
|||
float3 pos2 = mul(unity_ObjectToWorld, v2).xyz; |
|||
float4 tess; |
|||
if (UnityWorldViewFrustumCull(pos0, pos1, pos2, maxDisplacement)) |
|||
{ |
|||
tess = 0.0f; |
|||
} |
|||
else |
|||
{ |
|||
tess.x = UnityCalcEdgeTessFactor(pos1, pos2, edgeLength); |
|||
tess.y = UnityCalcEdgeTessFactor(pos2, pos0, edgeLength); |
|||
tess.z = UnityCalcEdgeTessFactor(pos0, pos1, edgeLength); |
|||
tess.w = (tess.x + tess.y + tess.z) / 3.0f; |
|||
} |
|||
return tess; |
|||
} |
|||
*/ |
|
|||
Shader "HDRenderPipeline/LayeredLitTesselation" |
|||
{ |
|||
Properties |
|||
{ |
|||
// Following set of parameters represent the parameters node inside the MaterialGraph. |
|||
// They are use to fill a SurfaceData. With a MaterialGraph this should not exist. |
|||
|
|||
// Reminder. Color here are in linear but the UI (color picker) do the conversion sRGB to linear |
|||
_BaseColor0("BaseColor0", Color) = (1, 1, 1, 1) |
|||
_BaseColor1("BaseColor1", Color) = (1, 1, 1, 1) |
|||
_BaseColor2("BaseColor2", Color) = (1, 1, 1, 1) |
|||
_BaseColor3("BaseColor3", Color) = (1, 1, 1, 1) |
|||
|
|||
_BaseColorMap0("BaseColorMap0", 2D) = "white" {} |
|||
_BaseColorMap1("BaseColorMap1", 2D) = "white" {} |
|||
_BaseColorMap2("BaseColorMap2", 2D) = "white" {} |
|||
_BaseColorMap3("BaseColorMap3", 2D) = "white" {} |
|||
|
|||
_Metallic0("Metallic0", Range(0.0, 1.0)) = 0 |
|||
_Metallic1("Metallic1", Range(0.0, 1.0)) = 0 |
|||
_Metallic2("Metallic2", Range(0.0, 1.0)) = 0 |
|||
_Metallic3("Metallic3", Range(0.0, 1.0)) = 0 |
|||
|
|||
_Smoothness0("Smoothness0", Range(0.0, 1.0)) = 0.5 |
|||
_Smoothness1("Smoothness1", Range(0.0, 1.0)) = 0.5 |
|||
_Smoothness2("Smoothness2", Range(0.0, 1.0)) = 0.5 |
|||
_Smoothness3("Smoothness3", Range(0.0, 1.0)) = 0.5 |
|||
|
|||
_MaskMap0("MaskMap0", 2D) = "white" {} |
|||
_MaskMap1("MaskMap1", 2D) = "white" {} |
|||
_MaskMap2("MaskMap2", 2D) = "white" {} |
|||
_MaskMap3("MaskMap3", 2D) = "white" {} |
|||
|
|||
_SpecularOcclusionMap0("SpecularOcclusion0", 2D) = "white" {} |
|||
_SpecularOcclusionMap1("SpecularOcclusion1", 2D) = "white" {} |
|||
_SpecularOcclusionMap2("SpecularOcclusion2", 2D) = "white" {} |
|||
_SpecularOcclusionMap3("SpecularOcclusion3", 2D) = "white" {} |
|||
|
|||
_NormalMap0("NormalMap0", 2D) = "bump" {} |
|||
_NormalMap1("NormalMap1", 2D) = "bump" {} |
|||
_NormalMap2("NormalMap2", 2D) = "bump" {} |
|||
_NormalMap3("NormalMap3", 2D) = "bump" {} |
|||
|
|||
_NormalScale0("_NormalScale0", Range(0.0, 2.0)) = 1 |
|||
_NormalScale1("_NormalScale1", Range(0.0, 2.0)) = 1 |
|||
_NormalScale2("_NormalScale2", Range(0.0, 2.0)) = 1 |
|||
_NormalScale3("_NormalScale3", Range(0.0, 2.0)) = 1 |
|||
|
|||
_HeightMap0("HeightMap0", 2D) = "black" {} |
|||
_HeightMap1("HeightMap1", 2D) = "black" {} |
|||
_HeightMap2("HeightMap2", 2D) = "black" {} |
|||
_HeightMap3("HeightMap3", 2D) = "black" {} |
|||
|
|||
_HeightAmplitude0("Height Scale0", Float) = 1 |
|||
_HeightAmplitude1("Height Scale1", Float) = 1 |
|||
_HeightAmplitude2("Height Scale2", Float) = 1 |
|||
_HeightAmplitude3("Height Scale3", Float) = 1 |
|||
|
|||
_HeightCenter0("Height Bias0", Float) = 0 |
|||
_HeightCenter1("Height Bias1", Float) = 0 |
|||
_HeightCenter2("Height Bias2", Float) = 0 |
|||
_HeightCenter3("Height Bias3", Float) = 0 |
|||
|
|||
_DetailMap0("DetailMap0", 2D) = "black" {} |
|||
_DetailMap1("DetailMap1", 2D) = "black" {} |
|||
_DetailMap2("DetailMap2", 2D) = "black" {} |
|||
_DetailMap3("DetailMap3", 2D) = "black" {} |
|||
|
|||
_DetailMask0("DetailMask0", 2D) = "white" {} |
|||
_DetailMask1("DetailMask1", 2D) = "white" {} |
|||
_DetailMask2("DetailMask2", 2D) = "white" {} |
|||
_DetailMask3("DetailMask3", 2D) = "white" {} |
|||
|
|||
_DetailAlbedoScale0("_DetailAlbedoScale0", Range(-2.0, 2.0)) = 1 |
|||
_DetailAlbedoScale1("_DetailAlbedoScale1", Range(-2.0, 2.0)) = 1 |
|||
_DetailAlbedoScale2("_DetailAlbedoScale2", Range(-2.0, 2.0)) = 1 |
|||
_DetailAlbedoScale3("_DetailAlbedoScale3", Range(-2.0, 2.0)) = 1 |
|||
|
|||
_DetailNormalScale0("_DetailNormalScale0", Range(0.0, 2.0)) = 1 |
|||
_DetailNormalScale1("_DetailNormalScale1", Range(0.0, 2.0)) = 1 |
|||
_DetailNormalScale2("_DetailNormalScale2", Range(0.0, 2.0)) = 1 |
|||
_DetailNormalScale3("_DetailNormalScale3", Range(0.0, 2.0)) = 1 |
|||
|
|||
_DetailSmoothnessScale0("_DetailSmoothnessScale0", Range(-2.0, 2.0)) = 1 |
|||
_DetailSmoothnessScale1("_DetailSmoothnessScale1", Range(-2.0, 2.0)) = 1 |
|||
_DetailSmoothnessScale2("_DetailSmoothnessScale2", Range(-2.0, 2.0)) = 1 |
|||
_DetailSmoothnessScale3("_DetailSmoothnessScale3", Range(-2.0, 2.0)) = 1 |
|||
|
|||
_DetailHeightScale0("_DetailHeightScale0", Range(-2.0, 2.0)) = 1 |
|||
_DetailHeightScale1("_DetailHeightScale1", Range(-2.0, 2.0)) = 1 |
|||
_DetailHeightScale2("_DetailHeightScale2", Range(-2.0, 2.0)) = 1 |
|||
_DetailHeightScale3("_DetailHeightScale3", Range(-2.0, 2.0)) = 1 |
|||
|
|||
_DetailAOScale0("_DetailAOScale0", Range(-2.0, 2.0)) = 1 |
|||
_DetailAOScale1("_DetailAOScale1", Range(-2.0, 2.0)) = 1 |
|||
_DetailAOScale2("_DetailAOScale2", Range(-2.0, 2.0)) = 1 |
|||
_DetailAOScale3("_DetailAOScale3", Range(-2.0, 2.0)) = 1 |
|||
|
|||
// Specific to planar mapping |
|||
_TexWorldScale0("TexWorldScale0", Float) = 1.0 |
|||
_TexWorldScale1("TexWorldScale1", Float) = 1.0 |
|||
_TexWorldScale2("TexWorldScale2", Float) = 1.0 |
|||
_TexWorldScale3("TexWorldScale3", Float) = 1.0 |
|||
|
|||
// Layer blending options |
|||
_LayerMaskMap("LayerMaskMap", 2D) = "white" {} |
|||
[ToggleOff] _LayerMaskVertexColor("Use Vertex Color Mask", Float) = 0.0 |
|||
[ToggleOff] _UseHeightBasedBlend("UseHeightBasedBlend", Float) = 0.0 |
|||
|
|||
_HeightOffset1("_HeightOffset1", Range(-0.3, 0.3)) = 0.0 |
|||
_HeightOffset2("_HeightOffset2", Range(-0.3, 0.3)) = 0.0 |
|||
_HeightOffset3("_HeightOffset3", Range(-0.3, 0.3)) = 0.0 |
|||
|
|||
_HeightFactor1("_HeightFactor1", Range(0, 5)) = 1 |
|||
_HeightFactor2("_HeightFactor2", Range(0, 5)) = 1 |
|||
_HeightFactor3("_HeightFactor3", Range(0, 5)) = 1 |
|||
|
|||
_BlendSize1("_BlendSize1", Range(0, 0.05)) = 0.0 |
|||
_BlendSize2("_BlendSize2", Range(0, 0.05)) = 0.0 |
|||
_BlendSize3("_BlendSize3", Range(0, 0.05)) = 0.0 |
|||
|
|||
_InheritBaseLayer1("_InheritBaseLayer1", Range(0, 1.0)) = 0.0 |
|||
_InheritBaseLayer2("_InheritBaseLayer2", Range(0, 1.0)) = 0.0 |
|||
_InheritBaseLayer3("_InheritBaseLayer3", Range(0, 1.0)) = 0.0 |
|||
|
|||
_VertexColorHeightFactor("_VertexColorHeightFactor", Float) = 0.3 |
|||
|
|||
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {} |
|||
|
|||
_EmissiveColor("EmissiveColor", Color) = (0, 0, 0) |
|||
_EmissiveColorMap("EmissiveColorMap", 2D) = "white" {} |
|||
_EmissiveIntensity("EmissiveIntensity", Float) = 0 |
|||
|
|||
[ToggleOff] _DistortionEnable("Enable Distortion", Float) = 0.0 |
|||
[ToggleOff] _DistortionOnly("Distortion Only", Float) = 0.0 |
|||
[ToggleOff] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 0.0 |
|||
[ToggleOff] _DepthOffsetEnable("Depth Offset View space", Float) = 0.0 |
|||
|
|||
[ToggleOff] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0 |
|||
|
|||
_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 |
|||
|
|||
// Blending state |
|||
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0 |
|||
[HideInInspector] _BlendMode ("__blendmode", Float) = 0.0 |
|||
[HideInInspector] _SrcBlend ("__src", Float) = 1.0 |
|||
[HideInInspector] _DstBlend ("__dst", Float) = 0.0 |
|||
[HideInInspector] _ZWrite ("__zw", Float) = 1.0 |
|||
[HideInInspector] _CullMode("__cullmode", Float) = 2.0 |
|||
[HideInInspector] _ZTestMode("_ZTestMode", Int) = 8 |
|||
|
|||
[Enum(None, 0, DoubleSided, 1, DoubleSidedLigthingFlip, 2, DoubleSidedLigthingMirror, 3)] _DoubleSidedMode("Double sided mode", Float) = 0 |
|||
|
|||
[Enum(Mask Alpha, 0, BaseColor Alpha, 1)] _SmoothnessTextureChannel("Smoothness texture channel", Float) = 1 |
|||
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0 |
|||
[ToggleOff] _EnablePerPixelDisplacement("Enable per pixel displacement", Float) = 0.0 |
|||
[Enum(DetailMapNormal, 0, DetailMapAOHeight, 1)] _DetailMapMode("DetailMap mode", Float) = 0 |
|||
[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1 |
|||
|
|||
[HideInInspector] _LayerCount("_LayerCount", Float) = 2.0 |
|||
|
|||
// WARNING |
|||
// All the following properties that concern the UV mapping are the same as in the Lit shader. |
|||
// This means that they will get overridden when synchronizing the various layers. |
|||
// To avoid this, make sure that all properties here are in the exclusion list in LayeredLitUI.SynchronizeLayerProperties |
|||
_TexWorldScale0("Tiling", Float) = 1.0 |
|||
_TexWorldScale1("Tiling", Float) = 1.0 |
|||
_TexWorldScale2("Tiling", Float) = 1.0 |
|||
_TexWorldScale3("Tiling", Float) = 1.0 |
|||
|
|||
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase0("UV Set for base0", Float) = 0 |
|||
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase1("UV Set for base1", Float) = 0 |
|||
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase2("UV Set for base2", Float) = 0 |
|||
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase3("UV Set for base3", Float) = 0 |
|||
|
|||
[HideInInspector] _UVMappingMask0("_UVMappingMask0", Color) = (1, 0, 0, 0) |
|||
[HideInInspector] _UVMappingMask1("_UVMappingMask1", Color) = (1, 0, 0, 0) |
|||
[HideInInspector] _UVMappingMask2("_UVMappingMask2", Color) = (1, 0, 0, 0) |
|||
[HideInInspector] _UVMappingMask3("_UVMappingMask3", Color) = (1, 0, 0, 0) |
|||
|
|||
[HideInInspector] _UVMappingPlanar0("_UVMappingPlanar0", Float) = 0.0 |
|||
[HideInInspector] _UVMappingPlanar1("_UVMappingPlanar1", Float) = 0.0 |
|||
[HideInInspector] _UVMappingPlanar2("_UVMappingPlanar2", Float) = 0.0 |
|||
[HideInInspector] _UVMappingPlanar3("_UVMappingPlanar3", Float) = 0.0 |
|||
|
|||
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail0("UV Set for detail0", Float) = 0 |
|||
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail1("UV Set for detail1", Float) = 0 |
|||
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail2("UV Set for detail2", Float) = 0 |
|||
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail3("UV Set for detail3", Float) = 0 |
|||
|
|||
[HideInInspector] _UVDetailsMappingMask0("_UVDetailsMappingMask0", Color) = (1, 0, 0, 0) |
|||
[HideInInspector] _UVDetailsMappingMask1("_UVDetailsMappingMask1", Color) = (1, 0, 0, 0) |
|||
[HideInInspector] _UVDetailsMappingMask2("_UVDetailsMappingMask2", Color) = (1, 0, 0, 0) |
|||
[HideInInspector] _UVDetailsMappingMask3("_UVDetailsMappingMask3", Color) = (1, 0, 0, 0) |
|||
|
|||
// Tesselation specific |
|||
_TesselationFactor("Tesselation Factor", Float) = 3.0 |
|||
} |
|||
|
|||
HLSLINCLUDE |
|||
|
|||
#pragma target 5.0 |
|||
#pragma only_renderers d3d11 // TEMP: unitl we go futher in dev |
|||
|
|||
#pragma shader_feature _ALPHATEST_ON |
|||
#pragma shader_feature _DISTORTION_ON |
|||
#pragma shader_feature _DEPTHOFFSET_ON |
|||
#pragma shader_feature _ _DOUBLESIDED_LIGHTING_FLIP _DOUBLESIDED_LIGHTING_MIRROR |
|||
|
|||
#pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A |
|||
#pragma shader_feature _LAYER_MAPPING_TRIPLANAR_0 |
|||
#pragma shader_feature _LAYER_MAPPING_TRIPLANAR_1 |
|||
#pragma shader_feature _LAYER_MAPPING_TRIPLANAR_2 |
|||
#pragma shader_feature _LAYER_MAPPING_TRIPLANAR_3 |
|||
#pragma shader_feature _DETAIL_MAP_WITH_NORMAL |
|||
#pragma shader_feature _NORMALMAP_TANGENT_SPACE |
|||
#pragma shader_feature _PER_PIXEL_DISPLACEMENT |
|||
#pragma shader_feature _REQUIRE_UV2_OR_UV3 |
|||
#pragma shader_feature _EMISSIVE_COLOR |
|||
|
|||
#pragma shader_feature _NORMALMAP |
|||
#pragma shader_feature _MASKMAP |
|||
#pragma shader_feature _SPECULAROCCLUSIONMAP |
|||
#pragma shader_feature _EMISSIVE_COLOR_MAP |
|||
#pragma shader_feature _HEIGHTMAP |
|||
#pragma shader_feature _DETAIL_MAP |
|||
#pragma shader_feature _ _LAYER_MASK_VERTEX_COLOR_MUL _LAYER_MASK_VERTEX_COLOR_ADD |
|||
#pragma shader_feature _HEIGHT_BASED_BLEND |
|||
#pragma shader_feature _ _LAYEREDLIT_3_LAYERS _LAYEREDLIT_4_LAYERS |
|||
|
|||
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON |
|||
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED |
|||
#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON |
|||
// TODO: We should have this keyword only if VelocityInGBuffer is enable, how to do that ? |
|||
//#pragma multi_compile VELOCITYOUTPUT_OFF VELOCITYOUTPUT_ON |
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// Define |
|||
//------------------------------------------------------------------------------------- |
|||
|
|||
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl |
|||
#define TESSELATION_ON |
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// Include |
|||
//------------------------------------------------------------------------------------- |
|||
|
|||
#include "common.hlsl" |
|||
#include "tesselation.hlsl" |
|||
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs.hlsl" |
|||
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl" |
|||
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Attributes.hlsl" |
|||
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPass.cs.hlsl" |
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// variable declaration |
|||
//------------------------------------------------------------------------------------- |
|||
|
|||
#define _MAX_LAYER 4 |
|||
|
|||
#if defined(_LAYEREDLIT_4_LAYERS) |
|||
# define _LAYER_COUNT 4 |
|||
#elif defined(_LAYEREDLIT_3_LAYERS) |
|||
# define _LAYER_COUNT 3 |
|||
#else |
|||
# define _LAYER_COUNT 2 |
|||
#endif |
|||
|
|||
// Explicitely said that we are a layered shader as we share code between lit and layered lit |
|||
#define LAYERED_LIT_SHADER |
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// variable declaration |
|||
//------------------------------------------------------------------------------------- |
|||
|
|||
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitProperties.hlsl" |
|||
|
|||
// All our shaders use same name for entry point |
|||
#pragma fragment Frag |
|||
|
|||
ENDHLSL |
|||
|
|||
SubShader |
|||
{ |
|||
Tags { "RenderType"="Opaque" "PerformanceChecks"="False" } |
|||
LOD 300 |
|||
|
|||
Pass |
|||
{ |
|||
Name "GBuffer" // Name is not used |
|||
Tags { "LightMode" = "GBuffer" } // This will be only for opaque object based on the RenderQueue index |
|||
|
|||
Cull [_CullMode] |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertTesselation |
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_GBUFFER |
|||
|
|||
#include "../../Material/Material.hlsl" |
|||
#include "../Lit/ShaderPass/LitSharePass.hlsl" |
|||
#include "../Lit/LitData.hlsl" |
|||
#include "../Tesselation/TesselationShare.hlsl" |
|||
|
|||
#include "../../ShaderPass/ShaderPassGBuffer.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Name "Debug" |
|||
Tags{ "LightMode" = "DebugViewMaterial" } |
|||
|
|||
Cull[_CullMode] |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertTesselation |
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_DEBUG_VIEW_MATERIAL |
|||
|
|||
#include "../../Material/Material.hlsl" |
|||
#include "../Lit/ShaderPass/LitSharePass.hlsl" |
|||
#include "../Lit/LitData.hlsl" |
|||
#include "../Tesselation/TesselationShare.hlsl" |
|||
|
|||
#include "../../ShaderPass/ShaderPassDebugViewMaterial.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
// Extracts information for lightmapping, GI (emission, albedo, ...) |
|||
// This pass it not used during regular rendering. |
|||
Pass |
|||
{ |
|||
Name "META" |
|||
Tags{ "LightMode" = "Meta" } |
|||
|
|||
Cull Off |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
// Lightmap memo |
|||
// DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light, |
|||
// both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON. |
|||
|
|||
#pragma vertex Vert |
|||
|
|||
#define SHADERPASS SHADERPASS_LIGHT_TRANSPORT |
|||
#include "../../Material/Material.hlsl" |
|||
#include "../Lit/ShaderPass/LitMetaPass.hlsl" |
|||
#include "../Lit/LitData.hlsl" |
|||
|
|||
#include "../../ShaderPass/ShaderPassLightTransport.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Name "Motion Vectors" |
|||
Tags{ "LightMode" = "MotionVectors" } // Caution, this need to be call like this to setup the correct parameters by C++ (legacy Unity) |
|||
|
|||
Cull[_CullMode] |
|||
|
|||
ZWrite Off // TODO: Test Z equal here. |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertTesselation |
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_VELOCITY |
|||
#include "../../Material/Material.hlsl" |
|||
#include "../Lit/ShaderPass/LitVelocityPass.hlsl" |
|||
#include "../Lit/LitData.hlsl" |
|||
#include "../Tesselation/TesselationShare.hlsl" |
|||
|
|||
#include "../../ShaderPass/ShaderPassVelocity.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Name "ShadowCaster" |
|||
Tags{ "LightMode" = "ShadowCaster" } |
|||
|
|||
Cull[_CullMode] |
|||
|
|||
ZWrite On |
|||
ZTest LEqual |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertTesselation |
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_DEPTH_ONLY |
|||
#include "../../Material/Material.hlsl" |
|||
#include "../Lit/ShaderPass/LitDepthPass.hlsl" |
|||
#include "../Lit/LitData.hlsl" |
|||
#include "../Tesselation/TesselationShare.hlsl" |
|||
|
|||
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Name "DepthOnly" |
|||
Tags{ "LightMode" = "DepthOnly" } |
|||
|
|||
Cull[_CullMode] |
|||
|
|||
ZWrite On |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertTesselation |
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_DEPTH_ONLY |
|||
#include "../../Material/Material.hlsl" |
|||
#include "../Lit/ShaderPass/LitDepthPass.hlsl" |
|||
#include "../Lit/LitData.hlsl" |
|||
#include "../Tesselation/TesselationShare.hlsl" |
|||
|
|||
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Name "Distortion" // Name is not used |
|||
Tags { "LightMode" = "DistortionVectors" } // This will be only for transparent object based on the RenderQueue index |
|||
|
|||
Blend One One |
|||
ZTest [_ZTestMode] |
|||
ZWrite off |
|||
Cull [_CullMode] |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertTesselation |
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_DISTORTION |
|||
#include "../../Material/Material.hlsl" |
|||
#include "../Lit/ShaderPass/LitDistortionPass.hlsl" |
|||
#include "../Lit/LitData.hlsl" |
|||
#include "../Tesselation/TesselationShare.hlsl" |
|||
|
|||
#include "../../ShaderPass/ShaderPassDistortion.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Name "Forward" // Name is not used |
|||
Tags{ "LightMode" = "Forward" } // This will be only for transparent object based on the RenderQueue index |
|||
|
|||
Blend[_SrcBlend][_DstBlend] |
|||
ZWrite[_ZWrite] |
|||
Cull[_CullMode] |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertTesselation |
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_FORWARD |
|||
// TEMP until pragma work in include |
|||
// #include "../../Lighting/Forward.hlsl" |
|||
#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS |
|||
//#pragma multi_compile SHADOWFILTERING_FIXED_SIZE_PCF |
|||
|
|||
#include "../../Lighting/Lighting.hlsl" |
|||
#include "../Lit/ShaderPass/LitSharePass.hlsl" |
|||
#include "../Lit/LitData.hlsl" |
|||
#include "../Tesselation/TesselationShare.hlsl" |
|||
|
|||
#include "../../ShaderPass/ShaderPassForward.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
} |
|||
|
|||
CustomEditor "Experimental.Rendering.HDPipeline.LayeredLitGUI" |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: eab0538d9d5746246806a9611c04ac4d |
|||
timeCreated: 1484060873 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: e190fae546bdd354e94a04e81eeb67e3 |
|||
timeCreated: 1483954253 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
/* |
|||
float _Tess; |
|||
float _TessNear; |
|||
float _TessFar; |
|||
float _UseDisplacementfalloff; |
|||
float _DisplacementfalloffNear; |
|||
float _DisplacementfalloffFar; |
|||
*/ |
|||
|
|||
float4 TesselationEdge(Attributes input0, Attributes input1, Attributes input2) |
|||
{ |
|||
// float minDist = 0; // _TessNear; |
|||
// float maxDist = 15; // _TessFar; |
|||
|
|||
// return UnityDistanceBasedTess(input0.positionOS, input1.positionOS, input2.positionOS, minDist, maxDist, 0.5 /* _Tess */, unity_ObjectToWorld, _WorldSpaceCameraPos); |
|||
|
|||
return float4(_TesselationFactor, _TesselationFactor, _TesselationFactor, _TesselationFactor); |
|||
} |
|||
|
|||
void Displacement(inout Attributes v) |
|||
{ |
|||
/* |
|||
float LengthLerp = length(ObjSpaceViewDir(v.vertex)); |
|||
LengthLerp -= _DisplacementfalloffNear; |
|||
LengthLerp /= _DisplacementfalloffFar - _DisplacementfalloffNear; |
|||
LengthLerp = 1 - (saturate(LengthLerp)); |
|||
|
|||
float d = ((tex2Dlod(_DispTex, float4(v.texcoord.xy * _Tiling, 0, 0)).r) - _DisplacementCenter) * (_Displacement * LengthLerp); |
|||
d /= max(0.0001, _Tiling); |
|||
*/ |
|||
|
|||
#ifdef _HEIGHTMAP |
|||
float height = (SAMPLE_TEXTURE2D_LOD(ADD_ZERO_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), v.uv0, 0).r - ADD_ZERO_IDX(_HeightCenter)) * ADD_IDX(_HeightAmplitude); |
|||
#else |
|||
float height = 0.0; |
|||
#endif |
|||
|
|||
#if (SHADERPASS != SHADERPASS_VELOCITY) && (SHADERPASS != SHADERPASS_DISTORTION) |
|||
v.positionOS.xyz += height * v.normalOS; |
|||
#endif |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 29d3b1d8672d46b4291970a2666b230e |
|||
timeCreated: 1483954252 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
Shader "HDRenderPipeline/LitTesselation" |
|||
{ |
|||
Properties |
|||
{ |
|||
// Following set of parameters represent the parameters node inside the MaterialGraph. |
|||
// They are use to fill a SurfaceData. With a MaterialGraph this should not exist. |
|||
|
|||
// Reminder. Color here are in linear but the UI (color picker) do the conversion sRGB to linear |
|||
_BaseColor("BaseColor", Color) = (1,1,1,1) |
|||
_BaseColorMap("BaseColorMap", 2D) = "white" {} |
|||
|
|||
_Metallic("_Metallic", Range(0.0, 1.0)) = 0 |
|||
_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5 |
|||
_MaskMap("MaskMap", 2D) = "white" {} |
|||
|
|||
_SpecularOcclusionMap("SpecularOcclusion", 2D) = "white" {} |
|||
|
|||
_NormalMap("NormalMap", 2D) = "bump" {} |
|||
_NormalScale("_NormalScale", Range(0.0, 2.0)) = 1 |
|||
|
|||
_HeightMap("HeightMap", 2D) = "black" {} |
|||
_HeightAmplitude("Height Amplitude", Float) = 0.01 // In world units |
|||
_HeightCenter("Height Center", Float) = 0.5 // In texture space |
|||
|
|||
_TangentMap("TangentMap", 2D) = "bump" {} |
|||
_Anisotropy("Anisotropy", Range(0.0, 1.0)) = 0 |
|||
_AnisotropyMap("AnisotropyMap", 2D) = "white" {} |
|||
|
|||
_DetailMap("DetailMap", 2D) = "black" {} |
|||
_DetailMask("DetailMask", 2D) = "white" {} |
|||
_DetailAlbedoScale("_DetailAlbedoScale", Range(-2.0, 2.0)) = 1 |
|||
_DetailNormalScale("_DetailNormalScale", Range(0.0, 2.0)) = 1 |
|||
_DetailSmoothnessScale("_DetailSmoothnessScale", Range(-2.0, 2.0)) = 1 |
|||
_DetailHeightScale("_DetailHeightScale", Range(-2.0, 2.0)) = 1 |
|||
_DetailAOScale("_DetailAOScale", Range(-2.0, 2.0)) = 1 |
|||
|
|||
_SubSurfaceRadius("SubSurfaceRadius", Range(0.0, 1.0)) = 0 |
|||
_SubSurfaceRadiusMap("SubSurfaceRadiusMap", 2D) = "white" {} |
|||
//_Thickness("Thickness", Range(0.0, 1.0)) = 0 |
|||
//_ThicknessMap("ThicknessMap", 2D) = "white" {} |
|||
//_SubSurfaceProfile("SubSurfaceProfile", Float) = 0 |
|||
|
|||
//_CoatCoverage("CoatCoverage", Range(0.0, 1.0)) = 0 |
|||
//_CoatCoverageMap("CoatCoverageMapMap", 2D) = "white" {} |
|||
|
|||
//_CoatRoughness("CoatRoughness", Range(0.0, 1.0)) = 0 |
|||
//_CoatRoughnessMap("CoatRoughnessMap", 2D) = "white" {} |
|||
|
|||
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {} |
|||
|
|||
// Following options are for the GUI inspector and different from the input parameters above |
|||
// These option below will cause different compilation flag. |
|||
|
|||
_EmissiveColor("EmissiveColor", Color) = (0, 0, 0) |
|||
_EmissiveColorMap("EmissiveColorMap", 2D) = "white" {} |
|||
_EmissiveIntensity("EmissiveIntensity", Float) = 0 |
|||
|
|||
[ToggleOff] _DistortionEnable("Enable Distortion", Float) = 0.0 |
|||
[ToggleOff] _DistortionOnly("Distortion Only", Float) = 0.0 |
|||
[ToggleOff] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 0.0 |
|||
[ToggleOff] _DepthOffsetEnable("Depth Offset View space", Float) = 0.0 |
|||
|
|||
[ToggleOff] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0 |
|||
_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 |
|||
|
|||
// Blending state |
|||
[HideInInspector] _SurfaceType("__surfacetype", Float) = 0.0 |
|||
[HideInInspector] _BlendMode("__blendmode", Float) = 0.0 |
|||
[HideInInspector] _SrcBlend("__src", Float) = 1.0 |
|||
[HideInInspector] _DstBlend("__dst", Float) = 0.0 |
|||
[HideInInspector] _ZWrite("__zw", Float) = 1.0 |
|||
[HideInInspector] _CullMode("__cullmode", Float) = 2.0 |
|||
[HideInInspector] _ZTestMode("_ZTestMode", Int) = 8 |
|||
|
|||
// Material Id |
|||
[HideInInspector] _MaterialId("_MaterialId", FLoat) = 0 |
|||
|
|||
[Enum(None, 0, DoubleSided, 1, DoubleSidedLigthingFlip, 2, DoubleSidedLigthingMirror, 3)] _DoubleSidedMode("Double sided mode", Float) = 0 |
|||
|
|||
[Enum(Mask Alpha, 0, BaseColor Alpha, 1)] _SmoothnessTextureChannel("Smoothness texture channel", Float) = 1 |
|||
[Enum(UV0, 0, Planar, 1, TriPlanar, 2)] _UVBase("UV Set for base", Float) = 0 |
|||
_TexWorldScale("Scale to apply on world coordinate", Float) = 1.0 |
|||
[HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0) |
|||
[HideInInspector] _UVMappingPlanar("_UVMappingPlanar", Float) = 0 |
|||
[Enum(TangentSpace, 0, ObjectSpace, 1)] _NormalMapSpace("NormalMap space", Float) = 0 |
|||
[ToggleOff] _EnablePerPixelDisplacement("Enable per pixel displacement", Float) = 0.0 |
|||
[Enum(DetailMapNormal, 0, DetailMapAOHeight, 1)] _DetailMapMode("DetailMap mode", Float) = 0 |
|||
[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3)] _UVDetail("UV Set for detail", Float) = 0 |
|||
[HideInInspector] _UVDetailsMappingMask("_UVDetailsMappingMask", Color) = (1, 0, 0, 0) |
|||
[Enum(Use Emissive Color, 0, Use Emissive Mask, 1)] _EmissiveColorMode("Emissive color mode", Float) = 1 |
|||
|
|||
// Tesselation specific |
|||
_TesselationFactor("Tesselation Factor", Float) = 3.0 |
|||
} |
|||
|
|||
HLSLINCLUDE |
|||
|
|||
#pragma target 5.0 |
|||
#pragma only_renderers d3d11 // TEMP: until we go futher in dev |
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// Variant |
|||
//------------------------------------------------------------------------------------- |
|||
|
|||
#pragma shader_feature _ALPHATEST_ON |
|||
#pragma shader_feature _DISTORTION_ON |
|||
#pragma shader_feature _DEPTHOFFSET_ON |
|||
#pragma shader_feature _ _DOUBLESIDED_LIGHTING_FLIP _DOUBLESIDED_LIGHTING_MIRROR |
|||
|
|||
#pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A |
|||
#pragma shader_feature _MAPPING_TRIPLANAR |
|||
#pragma shader_feature _DETAIL_MAP_WITH_NORMAL |
|||
#pragma shader_feature _NORMALMAP_TANGENT_SPACE |
|||
#pragma shader_feature _PER_PIXEL_DISPLACEMENT |
|||
#pragma shader_feature _REQUIRE_UV2_OR_UV3 |
|||
#pragma shader_feature _EMISSIVE_COLOR |
|||
|
|||
#pragma shader_feature _NORMALMAP |
|||
#pragma shader_feature _MASKMAP |
|||
#pragma shader_feature _SPECULAROCCLUSIONMAP |
|||
#pragma shader_feature _EMISSIVE_COLOR_MAP |
|||
#pragma shader_feature _HEIGHTMAP |
|||
#pragma shader_feature _TANGENTMAP |
|||
#pragma shader_feature _ANISOTROPYMAP |
|||
#pragma shader_feature _DETAIL_MAP |
|||
|
|||
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON |
|||
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED |
|||
#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON |
|||
// TODO: We should have this keyword only if VelocityInGBuffer is enable, how to do that ? |
|||
//#pragma multi_compile VELOCITYOUTPUT_OFF VELOCITYOUTPUT_ON |
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// Define |
|||
//------------------------------------------------------------------------------------- |
|||
|
|||
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl |
|||
#define TESSELATION_ON |
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// Include |
|||
//------------------------------------------------------------------------------------- |
|||
|
|||
#include "common.hlsl" |
|||
#include "tesselation.hlsl" |
|||
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderConfig.cs.hlsl" |
|||
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl" |
|||
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Attributes.hlsl" |
|||
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPass.cs.hlsl" |
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// variable declaration |
|||
//------------------------------------------------------------------------------------- |
|||
|
|||
#include "Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitProperties.hlsl" |
|||
|
|||
// All our shaders use same name for entry point |
|||
#pragma fragment Frag |
|||
|
|||
ENDHLSL |
|||
|
|||
SubShader |
|||
{ |
|||
Tags { "RenderType"="Opaque" "PerformanceChecks"="False" } |
|||
LOD 300 |
|||
|
|||
Pass |
|||
{ |
|||
Name "GBuffer" // Name is not used |
|||
Tags { "LightMode" = "GBuffer" } // This will be only for opaque object based on the RenderQueue index |
|||
|
|||
Cull [_CullMode] |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertTesselation |
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_GBUFFER |
|||
#include "../../Material/Material.hlsl" |
|||
#include "ShaderPass/LitSharePass.hlsl" |
|||
#include "LitData.hlsl" |
|||
#include "../Tesselation/TesselationShare.hlsl" |
|||
|
|||
#include "../../ShaderPass/ShaderPassGBuffer.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Name "Debug" |
|||
Tags { "LightMode" = "DebugViewMaterial" } |
|||
|
|||
Cull[_CullMode] |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertTesselation |
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_DEBUG_VIEW_MATERIAL |
|||
#include "../../Material/Material.hlsl" |
|||
#include "ShaderPass/LitSharePass.hlsl" |
|||
#include "LitData.hlsl" |
|||
#include "../Tesselation/TesselationShare.hlsl" |
|||
|
|||
#include "../../ShaderPass/ShaderPassDebugViewMaterial.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
// Extracts information for lightmapping, GI (emission, albedo, ...) |
|||
// This pass it not used during regular rendering. |
|||
Pass |
|||
{ |
|||
Name "META" |
|||
Tags{ "LightMode" = "Meta" } |
|||
|
|||
Cull Off |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
// Lightmap memo |
|||
// DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light, |
|||
// both direct and indirect lighting) will hand up in the "regular" lightmap->LIGHTMAP_ON. |
|||
|
|||
// No tesselation for Meta pass |
|||
#pragma vertex Vert |
|||
|
|||
#define SHADERPASS SHADERPASS_LIGHT_TRANSPORT |
|||
#include "../../Material/Material.hlsl" |
|||
#include "ShaderPass/LitMetaPass.hlsl" |
|||
#include "LitData.hlsl" |
|||
|
|||
#include "../../ShaderPass/ShaderPassLightTransport.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Name "ShadowCaster" |
|||
Tags{ "LightMode" = "ShadowCaster" } |
|||
|
|||
Cull[_CullMode] |
|||
|
|||
ZWrite On |
|||
ZTest LEqual |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertTesselation |
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_DEPTH_ONLY |
|||
#include "../../Material/Material.hlsl" |
|||
#include "ShaderPass/LitDepthPass.hlsl" |
|||
#include "LitData.hlsl" |
|||
#include "../Tesselation/TesselationShare.hlsl" |
|||
|
|||
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Name "DepthOnly" |
|||
Tags{ "LightMode" = "DepthOnly" } |
|||
|
|||
Cull[_CullMode] |
|||
|
|||
ZWrite On |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertTesselation |
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_DEPTH_ONLY |
|||
#include "../../Material/Material.hlsl" |
|||
#include "ShaderPass/LitDepthPass.hlsl" |
|||
#include "LitData.hlsl" |
|||
#include "../Tesselation/TesselationShare.hlsl" |
|||
|
|||
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Name "Motion Vectors" |
|||
Tags{ "LightMode" = "MotionVectors" } // Caution, this need to be call like this to setup the correct parameters by C++ (legacy Unity) |
|||
|
|||
Cull[_CullMode] |
|||
|
|||
ZWrite Off // TODO: Test Z equal here. |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertTesselation |
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_VELOCITY |
|||
#include "../../Material/Material.hlsl" |
|||
#include "ShaderPass/LitVelocityPass.hlsl" |
|||
#include "LitData.hlsl" |
|||
#include "../Tesselation/TesselationShare.hlsl" |
|||
|
|||
#include "../../ShaderPass/ShaderPassVelocity.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Name "Distortion" // Name is not used |
|||
Tags { "LightMode" = "DistortionVectors" } // This will be only for transparent object based on the RenderQueue index |
|||
|
|||
Blend One One |
|||
ZTest [_ZTestMode] |
|||
ZWrite off |
|||
Cull [_CullMode] |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertTesselation |
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_DISTORTION |
|||
#include "../../Material/Material.hlsl" |
|||
#include "ShaderPass/LitDistortionPass.hlsl" |
|||
#include "LitData.hlsl" |
|||
#include "../Tesselation/TesselationShare.hlsl" |
|||
|
|||
#include "../../ShaderPass/ShaderPassDistortion.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Name "Forward" // Name is not used |
|||
Tags { "LightMode" = "Forward" } // This will be only for transparent object based on the RenderQueue index |
|||
|
|||
Blend [_SrcBlend] [_DstBlend] |
|||
ZWrite [_ZWrite] |
|||
Cull [_CullMode] |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertTesselation |
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_FORWARD |
|||
// TEMP until pragma work in include |
|||
// #include "../../Lighting/Forward.hlsl" |
|||
#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS |
|||
//#pragma multi_compile SHADOWFILTERING_FIXED_SIZE_PCF |
|||
|
|||
#include "../../Lighting/Lighting.hlsl" |
|||
#include "ShaderPass/LitSharePass.hlsl" |
|||
#include "LitData.hlsl" |
|||
#include "../Tesselation/TesselationShare.hlsl" |
|||
|
|||
#include "../../ShaderPass/ShaderPassForward.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
} |
|||
|
|||
CustomEditor "Experimental.Rendering.HDPipeline.LitGUI" |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 756bac9090102564582875f4c7e30202 |
|||
timeCreated: 1483720902 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: cf157ff6c6d99d24b87ba5de6be19aec |
|||
folderAsset: yes |
|||
timeCreated: 1483954252 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
AttributesTesselation VertTesselation(Attributes input) |
|||
{ |
|||
return AttributesToAttributesTesselation(input); |
|||
} |
|||
|
|||
struct TessellationFactors |
|||
{ |
|||
float edge[3] : SV_TessFactor; |
|||
float inside : SV_InsideTessFactor; |
|||
}; |
|||
|
|||
TessellationFactors HullConstant(InputPatch<AttributesTesselation, 3> input) |
|||
{ |
|||
Attributes params[3]; |
|||
params[0] = AttributesTesselationToAttributes(input[0]); |
|||
params[1] = AttributesTesselationToAttributes(input[1]); |
|||
params[2] = AttributesTesselationToAttributes(input[2]); |
|||
|
|||
float4 tf = TesselationEdge(params[0], params[1], params[2]); |
|||
|
|||
TessellationFactors ouput; |
|||
ouput.edge[0] = tf.x; |
|||
ouput.edge[1] = tf.y; |
|||
ouput.edge[2] = tf.z; |
|||
ouput.inside = tf.w; |
|||
|
|||
return ouput; |
|||
} |
|||
|
|||
[maxtessfactor(15.0)] // AMD recommand this value for GCN http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2013/05/GCNPerformanceTweets.pdf |
|||
[domain("tri")] |
|||
[partitioning("fractional_odd")] |
|||
[outputtopology("triangle_cw")] |
|||
[patchconstantfunc("HullConstant")] |
|||
[outputcontrolpoints(3)] |
|||
AttributesTesselation Hull(InputPatch<AttributesTesselation, 3> input, uint id : SV_OutputControlPointID) |
|||
{ |
|||
return input[id]; |
|||
} |
|||
|
|||
[domain("tri")] |
|||
PackedVaryings Domain(TessellationFactors tessFactors, const OutputPatch<AttributesTesselation, 3> input, float3 baryWeight : SV_DomainLocation) |
|||
{ |
|||
Attributes params = InterpolateWithBary(input[0], input[1], input[2], baryWeight); |
|||
|
|||
// perform displacement |
|||
Displacement(params); |
|||
|
|||
// Evaluate regular vertex shader |
|||
PackedVaryings outout = Vert(params); |
|||
|
|||
return outout; |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 398b52fe541a9964a85a043bffd670e9 |
|||
timeCreated: 1483954253 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#ifndef SHADERPASS |
|||
#error Undefine_SHADERPASS |
|||
#endif |
|||
|
|||
// Check if Alpha test is enabled. If it is, check if parallax is enabled on this material |
|||
#define NEED_TEXCOORD0 1 // defined(_ALPHATEST_ON) |
|||
#define NEED_TANGENT_TO_WORLD 1 // NEED_TEXCOORD0 && (defined(_HEIGHTMAP) && defined(_PER_PIXEL_DISPLACEMENT)) TEMP!!!: until we fix tesselation so it can access normalOS |
|||
|
|||
// When modifying this structure, update the tesselation code below |
|||
struct Attributes |
|||
{ |
|||
float3 positionOS : POSITION; |
|||
#if NEED_TEXCOORD0 |
|||
float2 uv0 : TEXCOORD0; |
|||
#endif |
|||
#if NEED_TANGENT_TO_WORLD |
|||
float3 normalOS : NORMAL; |
|||
float4 tangentOS : TANGENT; |
|||
#endif |
|||
}; |
|||
|
|||
#ifdef TESSELATION_ON |
|||
// Copy paste of above struct with POSITION rename to INTERNALTESSPOS (internal of unity shader compiler) |
|||
struct AttributesTesselation |
|||
{ |
|||
float3 positionOS : INTERNALTESSPOS; |
|||
#if NEED_TEXCOORD0 |
|||
float2 uv0 : TEXCOORD0; |
|||
#endif |
|||
#if NEED_TANGENT_TO_WORLD |
|||
float3 normalOS : NORMAL; |
|||
float4 tangentOS : TANGENT; |
|||
#endif |
|||
}; |
|||
|
|||
AttributesTesselation AttributesToAttributesTesselation(Attributes input) |
|||
{ |
|||
AttributesTesselation output; |
|||
output.positionOS = input.positionOS; |
|||
#if NEED_TEXCOORD0 |
|||
output.uv0 = input.uv0; |
|||
#endif |
|||
#if NEED_TANGENT_TO_WORLD |
|||
output.normalOS = input.normalOS; |
|||
output.tangentOS = input.tangentOS; |
|||
#endif |
|||
|
|||
return output; |
|||
} |
|||
|
|||
Attributes AttributesTesselationToAttributes(AttributesTesselation input) |
|||
{ |
|||
Attributes output; |
|||
output.positionOS = input.positionOS; |
|||
#if NEED_TEXCOORD0 |
|||
output.uv0 = input.uv0; |
|||
#endif |
|||
#if NEED_TANGENT_TO_WORLD |
|||
output.normalOS = input.normalOS; |
|||
output.tangentOS = input.tangentOS; |
|||
#endif |
|||
|
|||
return output; |
|||
} |
|||
|
|||
AttributesTesselation InterpolateWithBary(AttributesTesselation input0, AttributesTesselation input1, AttributesTesselation input2, float3 baryWeight) |
|||
{ |
|||
AttributesTesselation ouput; |
|||
|
|||
TESSELATION_INTERPOLATE_BARY(positionOS, baryWeight); |
|||
#if NEED_TEXCOORD0 |
|||
TESSELATION_INTERPOLATE_BARY(uv0, baryWeight); |
|||
#endif |
|||
#if NEED_TANGENT_TO_WORLD |
|||
TESSELATION_INTERPOLATE_BARY(normalOS, baryWeight); |
|||
TESSELATION_INTERPOLATE_BARY(tangentOS, baryWeight); |
|||
#endif |
|||
|
|||
return ouput; |
|||
} |
|||
#endif // TESSELATION_ON |
|||
|
|||
struct Varyings |
|||
{ |
|||
float4 positionCS; |
|||
#if NEED_TEXCOORD0 |
|||
float2 texCoord0; |
|||
#endif |
|||
#if NEED_TANGENT_TO_WORLD |
|||
float3 positionWS; |
|||
float3 tangentToWorld[3]; |
|||
#endif |
|||
}; |
|||
|
|||
struct PackedVaryings |
|||
{ |
|||
float4 positionCS : SV_Position; |
|||
#if NEED_TANGENT_TO_WORLD |
|||
float4 interpolators[4] : TEXCOORD0; |
|||
#elif NEED_TEXCOORD0 |
|||
float4 interpolators[1] : TEXCOORD0; |
|||
#endif |
|||
}; |
|||
|
|||
// Function to pack data to use as few interpolator as possible, the ShaderGraph should generate these functions |
|||
PackedVaryings PackVaryings(Varyings input) |
|||
{ |
|||
PackedVaryings output; |
|||
output.positionCS = input.positionCS; |
|||
#if NEED_TANGENT_TO_WORLD |
|||
output.interpolators[0].xyz = input.positionWS.xyz; |
|||
output.interpolators[1].xyz = input.tangentToWorld[0]; |
|||
output.interpolators[2].xyz = input.tangentToWorld[1]; |
|||
output.interpolators[3].xyz = input.tangentToWorld[2]; |
|||
|
|||
output.interpolators[0].w = input.texCoord0.x; |
|||
output.interpolators[1].w = input.texCoord0.y; |
|||
#elif NEED_TEXCOORD0 |
|||
output.interpolators[0] = float4(input.texCoord0, 0.0, 0.0); |
|||
#endif |
|||
|
|||
return output; |
|||
} |
|||
|
|||
FragInputs UnpackVaryings(PackedVaryings input) |
|||
{ |
|||
FragInputs output; |
|||
ZERO_INITIALIZE(FragInputs, output); |
|||
|
|||
output.unPositionSS = input.positionCS; // input.positionCS is SV_Position |
|||
|
|||
#if NEED_TANGENT_TO_WORLD |
|||
output.positionWS.xyz = input.interpolators[0].xyz; |
|||
output.tangentToWorld[0] = input.interpolators[1].xyz; |
|||
output.tangentToWorld[1] = input.interpolators[2].xyz; |
|||
output.tangentToWorld[2] = input.interpolators[3].xyz; |
|||
|
|||
output.texCoord0.xy = float2(input.interpolators[0].w, input.interpolators[1].w); |
|||
#elif NEED_TEXCOORD0 |
|||
output.texCoord0.xy = input.interpolators[0].xy; |
|||
#endif |
|||
|
|||
return output; |
|||
} |
|||
|
|||
PackedVaryings Vert(Attributes input) |
|||
{ |
|||
Varyings output; |
|||
|
|||
float3 positionWS = TransformObjectToWorld(input.positionOS); |
|||
output.positionCS = TransformWorldToHClip(positionWS); |
|||
|
|||
#if NEED_TEXCOORD0 |
|||
output.texCoord0 = input.uv0; |
|||
#endif |
|||
|
|||
#if NEED_TANGENT_TO_WORLD |
|||
output.positionWS = positionWS; |
|||
|
|||
float3 normalWS = TransformObjectToWorldNormal(input.normalOS); |
|||
float4 tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w); |
|||
|
|||
float3x3 tangentToWorld = CreateTangentToWorld(normalWS, tangentWS.xyz, tangentWS.w); |
|||
output.tangentToWorld[0] = tangentToWorld[0]; |
|||
output.tangentToWorld[1] = tangentToWorld[1]; |
|||
output.tangentToWorld[2] = tangentToWorld[2]; |
|||
#endif |
|||
|
|||
return PackVaryings(output); |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b24a503f5b489bb4896bc43d861f7f49 |
|||
timeCreated: 1479984801 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#ifndef SHADERPASS |
|||
#error Undefine_SHADERPASS |
|||
#endif |
|||
|
|||
// Check if Alpha test is enabled. If it is, check if parallax is enabled on this material |
|||
#define NEED_TEXCOORD0 defined(_ALPHATEST_ON) |
|||
#define NEED_TANGENT_TO_WORLD NEED_TEXCOORD0 && (defined(_HEIGHTMAP) && !defined(_HEIGHTMAP_AS_DISPLACEMENT)) |
|||
|
|||
struct Attributes |
|||
{ |
|||
float3 positionOS : POSITION; |
|||
#if NEED_TEXCOORD0 |
|||
float2 uv0 : TEXCOORD0; |
|||
#endif |
|||
#if NEED_TANGENT_TO_WORLD |
|||
float3 normalOS : NORMAL; |
|||
float4 tangentOS : TANGENT; |
|||
#endif |
|||
}; |
|||
|
|||
struct Varyings |
|||
{ |
|||
float4 positionCS; |
|||
#if NEED_TEXCOORD0 |
|||
float2 texCoord0; |
|||
#endif |
|||
#if NEED_TANGENT_TO_WORLD |
|||
float3 positionWS; |
|||
float3 tangentToWorld[3]; |
|||
#endif |
|||
}; |
|||
|
|||
struct PackedVaryings |
|||
{ |
|||
float4 positionCS : SV_Position; |
|||
#if NEED_TANGENT_TO_WORLD |
|||
float4 interpolators[4] : TEXCOORD0; |
|||
#elif NEED_TEXCOORD0 |
|||
float4 interpolators[1] : TEXCOORD0; |
|||
#endif |
|||
}; |
|||
|
|||
// Function to pack data to use as few interpolator as possible, the ShaderGraph should generate these functions |
|||
PackedVaryings PackVaryings(Varyings input) |
|||
{ |
|||
PackedVaryings output; |
|||
output.positionCS = input.positionCS; |
|||
#if NEED_TANGENT_TO_WORLD |
|||
output.interpolators[0].xyz = input.positionWS.xyz; |
|||
output.interpolators[1].xyz = input.tangentToWorld[0]; |
|||
output.interpolators[2].xyz = input.tangentToWorld[1]; |
|||
output.interpolators[3].xyz = input.tangentToWorld[2]; |
|||
|
|||
output.interpolators[0].w = input.texCoord0.x; |
|||
output.interpolators[1].w = input.texCoord0.y; |
|||
#elif NEED_TEXCOORD0 |
|||
output.interpolators[0] = float4(input.texCoord0, 0.0, 0.0); |
|||
#endif |
|||
|
|||
return output; |
|||
} |
|||
|
|||
FragInputs UnpackVaryings(PackedVaryings input) |
|||
{ |
|||
FragInputs output; |
|||
ZERO_INITIALIZE(FragInputs, output); |
|||
|
|||
output.unPositionSS = input.positionCS; // input.positionCS is SV_Position |
|||
|
|||
#if NEED_TANGENT_TO_WORLD |
|||
output.positionWS.xyz = input.interpolators[0].xyz; |
|||
output.tangentToWorld[0] = input.interpolators[1].xyz; |
|||
output.tangentToWorld[1] = input.interpolators[2].xyz; |
|||
output.tangentToWorld[2] = input.interpolators[3].xyz; |
|||
|
|||
output.texCoord0.xy = float2(input.interpolators[0].w, input.interpolators[1].w); |
|||
#elif NEED_TEXCOORD0 |
|||
output.texCoord0.xy = input.interpolators[0].xy; |
|||
#endif |
|||
|
|||
return output; |
|||
} |
|||
|
|||
PackedVaryings Vert(Attributes input) |
|||
{ |
|||
Varyings output; |
|||
|
|||
float3 positionWS = TransformObjectToWorld(input.positionOS); |
|||
output.positionCS = TransformWorldToHClip(positionWS); |
|||
|
|||
#if NEED_TEXCOORD0 |
|||
output.texCoord0 = input.uv0; |
|||
#endif |
|||
|
|||
#if NEED_TANGENT_TO_WORLD |
|||
output.positionWS = positionWS; |
|||
|
|||
float3 normalWS = TransformObjectToWorldNormal(input.normalOS); |
|||
float4 tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w); |
|||
|
|||
float3x3 tangentToWorld = CreateTangentToWorld(normalWS, tangentWS.xyz, tangentWS.w); |
|||
output.tangentToWorld[0] = tangentToWorld[0]; |
|||
output.tangentToWorld[1] = tangentToWorld[1]; |
|||
output.tangentToWorld[2] = tangentToWorld[2]; |
|||
#endif |
|||
|
|||
return PackVaryings(output); |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 70a7ee6a44b86494daad0acd691e1d51 |
|||
timeCreated: 1483692743 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue