Evgenii Golubev
8 年前
当前提交
74657c39
共有 74 个文件被更改,包括 2246 次插入 和 393 次删除
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugViewMaterialGBuffer.shader
-
10Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugViewTiles.shader
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/Resources/Deferred.shader
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/Resources/lightlistbuild-bigtile.compute
-
58Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs
-
81Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
-
136Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs
-
38Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/LitUI.cs
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.hlsl
-
59Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.shader
-
42Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitData.hlsl
-
19Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitProperties.hlsl
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Resources/PreIntegratedFGD.shader
-
47Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl
-
8Assets/ScriptableRenderLoop/HDRenderPipeline/Material/MaterialUtilities.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
-
6Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl
-
8Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/Resources/SkyProcedural.shader
-
4Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl
-
1Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl
-
62Assets/ScriptableRenderLoop/ShaderLibrary/EntityLighting.hlsl
-
40Assets/ScriptableRenderLoop/ShaderLibrary/Packing.hlsl
-
136Assets/ScriptableRenderLoop/ShaderLibrary/Tessellation.hlsl
-
2Assets/ScriptableRenderLoop/common/TextureCache.cs
-
18Assets/TestScenes/HDTest/LayeredLitTest.unity
-
30Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_HeightBased.mat
-
24Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Planar.mat
-
19Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Triplanar.mat
-
20Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV0.mat
-
23Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV1.mat
-
21Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV2.mat
-
21Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV3.mat
-
7Assets/TestScenes/HDTest/LayeredLitTest/Material/Lit_Ground_01_2x2.mat
-
3Assets/TestScenes/HDTest/LayeredLitTest/Material/Lit_Moss_02_2x2.mat
-
3Assets/TestScenes/HDTest/LayeredLitTest/Material/Lit_Sand01_2x2.mat
-
3Assets/TestScenes/HDTest/LayeredLitTest/Material/Lit_Spheres.mat
-
2Assets/TestScenes/HDTest/LayeredLitTest/Textures/VolumeTest_01_H.tga.meta
-
68Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitVelocityPass.hlsl
-
78Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitSharePass.hlsl
-
56Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDistortionPass.hlsl
-
513Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader.meta
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl.meta
-
41Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.hlsl.meta
-
391Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.shader
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.shader.meta
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass.meta
-
87Assets/ScriptableRenderLoop/ShaderLibrary/API/PSSL.hlsl
-
9Assets/ScriptableRenderLoop/ShaderLibrary/API/PSSL.hlsl.meta
-
170Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDepthPass.hlsl
-
77Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Tessellation/TessellationShare.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Tessellation/TessellationShare.hlsl.meta
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitSurfaceData.hlsl.meta
-
108Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDepthPass.hlsl
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl
-
0/Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Tessellation.meta
-
0/Assets/ScriptableRenderLoop/ShaderLibrary/Tessellation.hlsl.meta
-
0/Assets/ScriptableRenderLoop/ShaderLibrary/Tessellation.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 TESSELLATION_INTERPOLATE_BARY(name, bary) ouput.name = input0.name * bary.x + input1.name * bary.y + input2.name * bary.z |
|||
|
|||
float3 ProjectPointOnPlane(float3 position, float3 planePosition, float3 planeNormal) |
|||
{ |
|||
return position - (dot(position - planePosition, planeNormal) * planeNormal); |
|||
} |
|||
|
|||
// p0, p1, p2 triangle world position |
|||
// p0, p1, p2 triangle world vertex normal |
|||
float3 PhongTessellation(float3 positionWS, float3 p0, float3 p1, float3 p2, float3 n0, float3 n1, float3 n2, float3 baryCoords, float shape) |
|||
{ |
|||
float3 c0 = ProjectPointOnPlane(positionWS, p0, n0); |
|||
float3 c1 = ProjectPointOnPlane(positionWS, p1, n1); |
|||
float3 c2 = ProjectPointOnPlane(positionWS, p2, n2); |
|||
|
|||
float3 phongPositionWS = baryCoords.x * c0 + baryCoords.y * c1 + baryCoords.z * c2; |
|||
|
|||
return lerp(positionWS, phongPositionWS, shape); |
|||
} |
|||
|
|||
// ---- utility functions |
|||
float CalcDistanceTessFactor(float3 positionWS, float minDist, float maxDist, float4x4 objectToWorld, float3 cameraPosWS) |
|||
{ |
|||
float dist = distance(positionWS, cameraPosWS); |
|||
float f = clamp(1.0 - (dist - minDist) / (maxDist - minDist), 0.01, 1.0); |
|||
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 DistanceBasedTess(float3 p0, float3 p1, float3 p2, float minDist, float maxDist, float4x4 objectToWorld, float3 cameraPosWS) |
|||
{ |
|||
float3 f; |
|||
f.x = CalcDistanceTessFactor(p0, minDist, maxDist, objectToWorld, cameraPosWS); |
|||
f.y = CalcDistanceTessFactor(p1, minDist, maxDist, objectToWorld, cameraPosWS); |
|||
f.z = CalcDistanceTessFactor(p2, minDist, maxDist, 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 |
|||
[Enum(Phong, 0, Displacement, 1, DisplacementPhong, 2)] _TessellationMode("Tessellation mode", Float) = 1 |
|||
_TessellationFactorFixed("Tessellation Factor", Float) = 4.0 // if != -1.0 force fixed factor |
|||
_TessellationFactorMaxDistance("Tessellation max distance factor", Float) = 12.0 |
|||
_TessellationFactorTriangleSize("Tessellation triangle size", Float) = 20.0 |
|||
_TessellationShapeFactor("Tessellation shape factor", Range(0.0, 1.0)) = 0.75 // Only use with Phong |
|||
_TessellationBackFaceCullEpsilon("Tessellation back face epsilon", Range(-1.0, 1.0)) = 0.25 |
|||
[ToggleOff] _TessellationObjectScale("Tessellation object scale", Float) = 0.0 |
|||
// TODO: Handle culling mode for backface culling |
|||
} |
|||
|
|||
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 |
|||
// Default is _TESSELATION_PHONG |
|||
#pragma shader_feature _ _TESSELATION_DISPLACEMENT _TESSELATION_DISPLACEMENT_PHONG |
|||
|
|||
#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 TessellationEdge(float3 p0, float3 p1, float3 p2, float3 n0, float3 n1, float3 n2) |
|||
{ |
|||
// if (_TessellationFactorFixed >= 0.0f) |
|||
{ |
|||
// return _TessellationFactorFixed.xxxx; |
|||
} |
|||
|
|||
return DistanceBasedTess(p0, p1, p2, 0.0, _TessellationFactorMaxDistance, unity_ObjectToWorld, _WorldSpaceCameraPos) * _TessellationFactorFixed.xxxx; |
|||
} |
|||
|
|||
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/LitTessellation" |
|||
{ |
|||
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 |
|||
|
|||
// Tessellation specific |
|||
[Enum(Phong, 0, Displacement, 1, DisplacementPhong, 2)] _TessellationMode("Tessellation mode", Float) = 0 |
|||
_TessellationFactorFixed("Tessellation Factor", Float) = 4.0 // if != -1.0 force fixed factor |
|||
_TessellationFactorMaxDistance("Tessellation max distance factor", Float) = 12.0 |
|||
_TessellationFactorTriangleSize("Tessellation triangle size", Float) = 20.0 |
|||
_TessellationShapeFactor("Tessellation shape factor", Range(0.0, 1.0)) = 0.75 // Only use with Phong |
|||
_TessellationBackFaceCullEpsilon("Tessellation back face epsilon", Range(-1.0, 1.0)) = 0.25 |
|||
[ToggleOff] _TessellationObjectScale("Tessellation object scale", Float) = 0.0 |
|||
// TODO: Handle culling mode for backface culling |
|||
} |
|||
|
|||
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 |
|||
// Default is _TESSELLATION_PHONG |
|||
#pragma shader_feature _ _TESSELLATION_DISPLACEMENT _TESSELLATION_DISPLACEMENT_PHONG |
|||
|
|||
#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 TESSELLATION_ON |
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// Include |
|||
//------------------------------------------------------------------------------------- |
|||
|
|||
#include "common.hlsl" |
|||
#include "tessellation.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 VertTessellation |
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_GBUFFER |
|||
#include "../../Material/Material.hlsl" |
|||
#include "ShaderPass/LitSharePass.hlsl" |
|||
#include "LitData.hlsl" |
|||
#include "../Tessellation/TessellationShare.hlsl" |
|||
|
|||
#include "../../ShaderPass/ShaderPassGBuffer.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Name "Debug" |
|||
Tags { "LightMode" = "DebugViewMaterial" } |
|||
|
|||
Cull[_CullMode] |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertTessellation |
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_DEBUG_VIEW_MATERIAL |
|||
#include "../../Material/Material.hlsl" |
|||
#include "ShaderPass/LitSharePass.hlsl" |
|||
#include "LitData.hlsl" |
|||
#include "../Tessellation/TessellationShare.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 tessellation 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 VertTessellation |
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_DEPTH_ONLY |
|||
#include "../../Material/Material.hlsl" |
|||
#include "ShaderPass/LitDepthPass.hlsl" |
|||
#include "LitData.hlsl" |
|||
#include "../Tessellation/TessellationShare.hlsl" |
|||
|
|||
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Name "DepthOnly" |
|||
Tags{ "LightMode" = "DepthOnly" } |
|||
|
|||
Cull[_CullMode] |
|||
|
|||
ZWrite On |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex VertTessellation |
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_DEPTH_ONLY |
|||
#include "../../Material/Material.hlsl" |
|||
#include "ShaderPass/LitDepthPass.hlsl" |
|||
#include "LitData.hlsl" |
|||
#include "../Tessellation/TessellationShare.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 VertTessellation |
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_VELOCITY |
|||
#include "../../Material/Material.hlsl" |
|||
#include "ShaderPass/LitVelocityPass.hlsl" |
|||
#include "LitData.hlsl" |
|||
#include "../Tessellation/TessellationShare.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 VertTessellation |
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_DISTORTION |
|||
#include "../../Material/Material.hlsl" |
|||
#include "ShaderPass/LitDistortionPass.hlsl" |
|||
#include "LitData.hlsl" |
|||
#include "../Tessellation/TessellationShare.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 VertTessellation |
|||
#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 "../Tessellation/TessellationShare.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: |
|
|||
// This file assume SHADER_API_D3D11 is defined |
|||
|
|||
#define INTRINSIC_BITFIELD_EXTRACT |
|||
#define INTRINSIC_MAD24 |
|||
#define Mad24 mad24 |
|||
#define INTRINSIC_MED3 |
|||
#define INTRINSIC_MINMAX3 |
|||
#define Min3 min3 |
|||
#define Max3 max3 |
|||
//#define INTRINSIC_CUBEMAP_FACE_ID // Must investigate why AMD reference implementation is different than ours |
|||
|
|||
#define UNITY_UV_STARTS_AT_TOP 1 |
|||
#define UNITY_REVERSED_Z 1 |
|||
#define UNITY_NEAR_CLIP_VALUE (1.0) |
|||
// This value will not go through any matrix projection convertion |
|||
#define UNITY_RAW_FAR_CLIP_VALUE (0.0) |
|||
#define FRONT_FACE_SEMATIC SV_IsFrontFace |
|||
#define FRONT_FACE_TYPE bool |
|||
#define IS_FRONT_VFACE(VAL, FRONT, BACK) ((VAL) ? (FRONT) : (BACK)) |
|||
|
|||
#define CBUFFER_START(name) cbuffer name { |
|||
#define CBUFFER_END }; |
|||
|
|||
// Initialize arbitrary structure with zero values. |
|||
// Do not exist on some platform, in this case we need to have a standard name that call a function that will initialize all parameters to 0 |
|||
#define ZERO_INITIALIZE(type, name) name = (type)0; |
|||
|
|||
// Texture abstraction |
|||
|
|||
#define TEXTURE2D(textureName) Texture2D textureName |
|||
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName |
|||
#define TEXTURECUBE(textureName) TextureCube textureName |
|||
#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName |
|||
#define TEXTURE3D(textureName) Texture3D textureName |
|||
|
|||
#define SAMPLER2D(samplerName) SamplerState samplerName |
|||
#define SAMPLERCUBE(samplerName) SamplerState samplerName |
|||
#define SAMPLER3D(samplerName) SamplerState samplerName |
|||
#define SAMPLER2D_SHADOW(samplerName) SamplerComparisonState samplerName |
|||
#define SAMPLERCUBE_SHADOW(samplerName) SamplerComparisonState samplerName |
|||
|
|||
#define TEXTURE2D_ARGS(textureName, samplerName) Texture2D textureName, SamplerState samplerName |
|||
#define TEXTURE2D_ARRAY_ARGS(textureName, samplerName) Texture2DArray textureName, SamplerState samplerName |
|||
#define TEXTURECUBE_ARGS(textureName, samplerName) TextureCube textureName, SamplerState samplerName |
|||
#define TEXTURECUBE_ARRAY_ARGS(textureName, samplerName) TextureCubeArray textureName, SamplerState samplerName |
|||
#define TEXTURE3D_ARGS(textureName, samplerName) Texture3D textureName, SamplerState samplerName |
|||
#define TEXTURE2D_SHADOW_ARGS(textureName, samplerName) Texture2D textureName, SamplerComparisonState samplerName |
|||
#define TEXTURE2D_ARRAY_SHADOW_ARGS(textureName, samplerName) Texture2DArray textureName, SamplerComparisonState samplerName |
|||
#define TEXTURECUBE_SHADOW_ARGS(textureName, samplerName) TextureCube textureName, SamplerComparisonState samplerName |
|||
|
|||
#define TEXTURE2D_PARAM(textureName, samplerName) textureName, samplerName |
|||
#define TEXTURE2D_ARRAY_PARAM(textureName, samplerName) textureName, samplerName |
|||
#define TEXTURECUBE_PARAM(textureName, samplerName) textureName, samplerName |
|||
#define TEXTURECUBE_ARRAY_PARAM(textureName, samplerName) textureName, samplerName |
|||
#define TEXTURE3D_PARAM(textureName, samplerName) textureName, samplerName |
|||
#define TEXTURE2D_SHADOW_PARAM(textureName, samplerName) textureName, samplerName |
|||
#define TEXTURE2D_ARRAY_SHADOW_PARAM(textureName, samplerName) textureName, samplerName |
|||
#define TEXTURECUBE_SHADOW_PARAM(textureName, samplerName) textureName, samplerName |
|||
|
|||
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2) |
|||
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod) |
|||
#define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Sample(samplerName, float3(coord2, index)) |
|||
#define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) textureName.SampleLevel(samplerName, float3(coord2, index), lod) |
|||
#define SAMPLE_TEXTURECUBE(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3) |
|||
#define SAMPLE_TEXTURECUBE_LOD(textureName, samplerName, coord3, lod) textureName.SampleLevel(samplerName, coord3, lod) |
|||
#define SAMPLE_TEXTURECUBE_ARRAY(textureName, samplerName, coord3, index) textureName.Sample(samplerName, float4(coord3, index)) |
|||
#define SAMPLE_TEXTURECUBE_ARRAY_LOD(textureName, samplerName, coord3, index, lod) textureName.SampleLevel(samplerName, float4(coord3, index), lod) |
|||
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3) |
|||
#define SAMPLE_TEXTURE2D_SHADOW(textureName, samplerName, coord3) textureName.SampleCmpLevelZero(samplerName, (coord3).xy, (coord3).z) |
|||
#define SAMPLE_TEXTURE2D_ARRAY_SHADOW(textureName, samplerName, coord3, index) textureName.SampleCmpLevelZero(samplerName, float3((coord3).xy, index), (coord3).z) |
|||
#define SAMPLE_TEXTURECUBE_SHADOW(textureName, samplerName, coord4) textureName.SampleCmpLevelZero(samplerName, (coord3).xyz, (coord3).w) |
|||
|
|||
#define TEXTURE2D_HALF TEXTURE2D |
|||
#define TEXTURE2D_FLOAT TEXTURE2D |
|||
#define SAMPLER2D_HALF SAMPLER2D |
|||
#define SAMPLER2D_FLOAT SAMPLER2D |
|||
|
|||
#define LOAD_TEXTURE2D(textureName, unCoord2) textureName.Load(int3(unCoord2, 0)) |
|||
#define LOAD_TEXTURE2D_LOD(textureName, unCoord2, lod) textureName.Load(int3(unCoord2, lod)) |
|||
#define LOAD_TEXTURE2D_MSAA(textureName, unCoord2, sampleIndex) textureName.Load(unCoord2, sampleIndex) |
|||
#define LOAD_TEXTURE2D_ARRAY(textureName, unCoord2, index) textureName.Load(int4(unCoord2, index, 0)) |
|||
#define LOAD_TEXTURE2D_ARRAY_LOD(textureName, unCoord2, index, lod) textureName.Load(int4(unCoord2, index, lod)) |
|||
|
|||
#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2) |
|||
#define GATHER_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Gather(samplerName, float3(coord2, index)) |
|||
#define GATHER_TEXTURECUBE(textureName, samplerName, coord3) textureName.Gather(samplerName, coord3) |
|||
#define GATHER_TEXTURECUBE_ARRAY(textureName, samplerName, coord3, index) textureName.Gather(samplerName, float4(coord3, index)) |
|
|||
fileFormatVersion: 2 |
|||
guid: 0437569999393274f8baf4c00cc0100a |
|||
timeCreated: 1483982129 |
|||
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 tessellation so it can access normalOS |
|||
|
|||
// When modifying this structure, update the tessellation 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 TESSELLATION_ON |
|||
// Copy paste of above struct with POSITION rename to INTERNALTESSPOS (internal of unity shader compiler) |
|||
struct AttributesTessellation |
|||
{ |
|||
float3 positionOS : INTERNALTESSPOS; |
|||
#if NEED_TEXCOORD0 |
|||
float2 uv0 : TEXCOORD0; |
|||
#endif |
|||
#if NEED_TANGENT_TO_WORLD |
|||
float3 normalOS : NORMAL; |
|||
float4 tangentOS : TANGENT; |
|||
#endif |
|||
}; |
|||
|
|||
AttributesTessellation AttributesToAttributesTessellation(Attributes input) |
|||
{ |
|||
AttributesTessellation 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 AttributesTessellationToAttributes(AttributesTessellation 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; |
|||
} |
|||
|
|||
AttributesTessellation InterpolateWithBaryCoords(AttributesTessellation input0, AttributesTessellation input1, AttributesTessellation input2, float3 baryCoords) |
|||
{ |
|||
AttributesTessellation ouput; |
|||
|
|||
TESSELLATION_INTERPOLATE_BARY(positionOS, baryCoords); |
|||
#if NEED_TEXCOORD0 |
|||
TESSELLATION_INTERPOLATE_BARY(uv0, baryCoords); |
|||
#endif |
|||
#if NEED_TANGENT_TO_WORLD |
|||
TESSELLATION_INTERPOLATE_BARY(normalOS, baryCoords); |
|||
TESSELLATION_INTERPOLATE_BARY(tangentOS, baryCoords); |
|||
#endif |
|||
|
|||
return ouput; |
|||
} |
|||
#endif // TESSELLATION_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); |
|||
} |
|
|||
AttributesTessellation VertTessellation(Attributes input) |
|||
{ |
|||
return AttributesToAttributesTessellation(input); |
|||
} |
|||
|
|||
struct TessellationFactors |
|||
{ |
|||
float edge[3] : SV_TessFactor; |
|||
float inside : SV_InsideTessFactor; |
|||
}; |
|||
|
|||
TessellationFactors HullConstant(InputPatch<AttributesTessellation, 3> input) |
|||
{ |
|||
Attributes params[3]; |
|||
params[0] = AttributesTessellationToAttributes(input[0]); |
|||
params[1] = AttributesTessellationToAttributes(input[1]); |
|||
params[2] = AttributesTessellationToAttributes(input[2]); |
|||
|
|||
#if (SHADERPASS != SHADERPASS_VELOCITY) && (SHADERPASS != SHADERPASS_DISTORTION) |
|||
|
|||
// TEMP: We will provide world position but for now convert to world position here |
|||
float3 p0 = TransformObjectToWorld(input[0].positionOS); |
|||
float3 n0 = TransformObjectToWorldNormal(input[0].normalOS); |
|||
|
|||
float3 p1 = TransformObjectToWorld(input[1].positionOS); |
|||
float3 n1 = TransformObjectToWorldNormal(input[1].normalOS); |
|||
|
|||
float3 p2 = TransformObjectToWorld(input[2].positionOS); |
|||
float3 n2 = TransformObjectToWorldNormal(input[2].normalOS); |
|||
|
|||
float4 tf = TessellationEdge(p0, p1, p2, n0, n1, n2); |
|||
#else |
|||
float4 tf = float4(0.0, 0.0, 0.0, 0.0); |
|||
#endif |
|||
|
|||
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)] |
|||
AttributesTessellation Hull(InputPatch<AttributesTessellation, 3> input, uint id : SV_OutputControlPointID) |
|||
{ |
|||
return input[id]; |
|||
} |
|||
|
|||
[domain("tri")] |
|||
PackedVaryings Domain(TessellationFactors tessFactors, const OutputPatch<AttributesTessellation, 3> input, float3 baryCoords : SV_DomainLocation) |
|||
{ |
|||
Attributes params = InterpolateWithBaryCoords(input[0], input[1], input[2], baryCoords); |
|||
|
|||
#ifndef _TESSELLATION_DISPLACEMENT // We have Phong tessellation in all case where we don't have only displacement |
|||
#if (SHADERPASS != SHADERPASS_VELOCITY) && (SHADERPASS != SHADERPASS_DISTORTION) |
|||
params.positionOS = PhongTessellation( params.positionOS, |
|||
input[0].positionOS, input[1].positionOS, input[2].positionOS, |
|||
input[0].normalOS, input[1].normalOS, input[2].normalOS, |
|||
baryCoords, _TessellationShapeFactor); |
|||
#endif |
|||
#endif |
|||
|
|||
// 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: |
|
|||
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); |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue