sebastienlagarde
8 年前
当前提交
ff5e75b4
共有 29 个文件被更改,包括 666 次插入 和 178 次删除
-
31Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
-
32Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.shader
-
10Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitData.hlsl
-
1Assets/ScriptableRenderLoop/ShaderLibrary/Tesselation.hlsl
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitSharePass.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl.meta
-
1Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTesselation.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTesselation.hlsl.meta
-
378Assets/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
-
165Assets/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 |
|
|||
fileFormatVersion: 2 |
|||
guid: e190fae546bdd354e94a04e81eeb67e3 |
|||
timeCreated: 1483954253 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
|
|
|||
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" {} |
|||
_HeightScale("Height Scale", Float) = 0.01 |
|||
_HeightBias("Height Bias", Float) = 0 |
|||
|
|||
_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 |
|||
[Enum(Parallax, 0, Displacement, 1)] _HeightMapMode("Heightmap usage", Float) = 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 |
|||
} |
|||
|
|||
HLSLINCLUDE |
|||
|
|||
#pragma target 5.0 |
|||
#pragma only_renderers d3d11 // TEMP: unitl 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 _HEIGHTMAP_AS_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 |
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// Include |
|||
//------------------------------------------------------------------------------------- |
|||
|
|||
#include "common.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 vertex Vert |
|||
#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 hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_GBUFFER |
|||
#include "../../Material/Material.hlsl" |
|||
#include "LitData.hlsl" |
|||
#include "ShaderPass/LitSharePass.hlsl" |
|||
#include "LitTesselation.hlsl" |
|||
#include "../Tesselation/TesselationShare.hlsl" |
|||
|
|||
#include "../../ShaderPass/ShaderPassGBuffer.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Name "Debug" |
|||
Tags { "LightMode" = "DebugViewMaterial" } |
|||
|
|||
Cull[_CullMode] |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_DEBUG_VIEW_MATERIAL |
|||
#include "../../Material/Material.hlsl" |
|||
#include "LitData.hlsl" |
|||
#include "ShaderPass/LitSharePass.hlsl" |
|||
#include "LitTesselation.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 hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_LIGHT_TRANSPORT |
|||
#include "../../Material/Material.hlsl" |
|||
#include "LitData.hlsl" |
|||
#include "ShaderPass/LitMetaPass.hlsl" |
|||
|
|||
#include "../../ShaderPass/ShaderPassLightTransport.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Name "ShadowCaster" |
|||
Tags{ "LightMode" = "ShadowCaster" } |
|||
|
|||
Cull[_CullMode] |
|||
|
|||
ZWrite On |
|||
ZTest LEqual |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_DEPTH_ONLY |
|||
#include "../../Material/Material.hlsl" |
|||
#include "LitData.hlsl" |
|||
#include "ShaderPass/LitDepthPass.hlsl" |
|||
#include "LitTesselation.hlsl" |
|||
#include "../Tesselation/TesselationShare.hlsl" |
|||
|
|||
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Name "DepthOnly" |
|||
Tags{ "LightMode" = "DepthOnly" } |
|||
|
|||
Cull[_CullMode] |
|||
|
|||
ZWrite On |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_DEPTH_ONLY |
|||
#include "../../Material/Material.hlsl" |
|||
#include "LitData.hlsl" |
|||
#include "ShaderPass/LitDepthPass.hlsl" |
|||
#include "LitTesselation.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 hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_VELOCITY |
|||
#include "../../Material/Material.hlsl" |
|||
#include "LitData.hlsl" |
|||
#include "ShaderPass/LitVelocityPass.hlsl" |
|||
#include "LitTesselation.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 hull Hull |
|||
#pragma domain Domain |
|||
|
|||
#define SHADERPASS SHADERPASS_DISTORTION |
|||
#include "../../Material/Material.hlsl" |
|||
#include "LitData.hlsl" |
|||
#include "ShaderPass/LitDistortionPass.hlsl" |
|||
#include "LitTesselation.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 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 "LitData.hlsl" |
|||
#include "ShaderPass/LitSharePass.hlsl" |
|||
#include "LitTesselation.hlsl" |
|||
#include "../Tesselation/TesselationShare.hlsl" |
|||
|
|||
#include "../../ShaderPass/ShaderPassForward.hlsl" |
|||
|
|||
ENDHLSL |
|||
} |
|||
} |
|||
|
|||
CustomEditor "Experimental.ScriptableRenderLoop.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; |
|||
}; |
|||
|
|||
UnityTessellationFactors 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 = tessEdge(vi[0], vi[1], vi[2]); |
|||
|
|||
TessellationFactors ouput; |
|||
ouput.edge[0] = tf.x; |
|||
ouput.edge[1] = tf.y; |
|||
ouput.edge[2] = tf.z; |
|||
ouput.inside = tf.w; |
|||
|
|||
return ouput; |
|||
} |
|||
|
|||
// add [maxtessfactor(15)] ? |
|||
[UNITY_domain("tri")] |
|||
[UNITY_partitioning("fractional_odd")] |
|||
[UNITY_outputtopology("triangle_cw")] |
|||
[UNITY_patchconstantfunc("HullConstant")] |
|||
[UNITY_outputcontrolpoints(3)] |
|||
AttributesTesselation Hull(InputPatch<AttributesTesselation, 3> input, uint id : SV_OutputControlPointID) |
|||
{ |
|||
return input[id]; |
|||
} |
|||
|
|||
[UNITY_domain("tri")] |
|||
PackedVaryings Domain(UnityTessellationFactors 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(v); |
|||
|
|||
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 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 |
|||
}; |
|||
|
|||
#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 |
|||
} |
|||
|
|||
Attributes AttributesTesselationToAttributes(AttributesTesselation 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 |
|||
} |
|||
|
|||
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