Evgenii Golubev
8 年前
当前提交
087242cd
共有 54 个文件被更改,包括 1065 次插入 和 506 次删除
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugViewMaterial.cs
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/DebugViewMaterial.cs.hlsl
-
11Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugViewMaterialGBuffer.shader
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugViewTiles.shader
-
34Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/Resources/Deferred.shader
-
5Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/Resources/lightlistbuild-bigtile.compute
-
7Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Builtin/BuiltinData.hlsl
-
82Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/Editor/LayeredLitUI.cs
-
46Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
-
8Assets/ScriptableRenderLoop/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader
-
16Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs
-
64Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.cs
-
36Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.hlsl
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.shader
-
250Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitData.hlsl
-
142Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl
-
33Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitProperties.hlsl
-
17Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitTessellation.shader
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Resources/PreIntegratedFGD.shader
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDepthPass.hlsl
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitDistortionPass.hlsl
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/ShaderPass/LitVelocityPass.hlsl
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Unlit/Unlit.shader
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/Resources/EyeAdaptation.shader
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/Resources/FinalPass.shader
-
2Assets/ScriptableRenderLoop/HDRenderPipeline/PostProcess/Resources/LutGen.shader
-
14Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/TessellationShare.hlsl
-
34Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/VaryingMesh.hlsl
-
16Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/VertMesh.hlsl
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/HDRISky/Resources/SkyHDRI.shader
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/ProceduralSky/Resources/SkyProcedural.shader
-
4Assets/ScriptableRenderLoop/HDRenderPipeline/Sky/Resources/GGXConvolve.shader
-
4Assets/ScriptableRenderLoop/ShaderLibrary/API/D3D11.hlsl
-
4Assets/ScriptableRenderLoop/ShaderLibrary/API/PSSL.hlsl
-
19Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl
-
2Assets/ScriptableRenderLoop/ShaderLibrary/CommonMaterial.hlsl
-
292Assets/ScriptableRenderLoop/fptl/Internal-DeferredComputeShading.compute
-
2Assets/ScriptableRenderLoop/fptl/Internal-DeferredReflections.shader
-
2Assets/ScriptableRenderLoop/fptl/Internal-DeferredShading.shader
-
2Assets/ScriptableRenderLoop/fptl/LightBoundsDebug.shader
-
6Assets/ScriptableRenderLoop/fptl/StandardTest.shader
-
7Assets/ScriptableRenderLoop/fptl/lightlistbuild-bigtile.compute
-
6Assets/TestScenes/HDTest/GraphicTest/Parallax Occlusion Mapping/Material/POM - Wood.mat
-
4Assets/TestScenes/HDTest/GraphicTest/Tessellation/Material/Tessellation - Wood.mat
-
2ProjectSettings/GraphicsSettings.asset
-
158ProjectSettings/ProjectSettings.asset
-
2ProjectSettings/ProjectVersion.txt
-
70Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LayeredLitNormalSampling.hlsl
-
9Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LayeredLitNormalSampling.hlsl.meta
-
88Assets/ScriptableRenderLoop/ShaderLibrary/API/Metal.hlsl
-
9Assets/ScriptableRenderLoop/ShaderLibrary/API/Metal.hlsl.meta
-
9Assets/TestScenes/HDTest/HDRenderLoopTest.meta
|
|||
#pragma kernel ShadeDeferred_Fptl SHADE_DEFERRED_ENTRY=ShadeDeferred_Fptl USE_FPTL_LIGHTLIST=1 ENABLE_DEBUG=0 |
|||
#pragma kernel ShadeDeferred_Clustered SHADE_DEFERRED_ENTRY=ShadeDeferred_Clustered USE_CLUSTERED_LIGHTLIST=1 ENABLE_DEBUG=0 //TODO: disabled clustered permutations so far as it leads to the error "All kernels must use same constant buffer layouts" |
|||
#pragma kernel ShadeDeferred_Fptl_Debug SHADE_DEFERRED_ENTRY=ShadeDeferred_Fptl_Debug USE_FPTL_LIGHTLIST=1 ENABLE_DEBUG=1 |
|||
#pragma kernel ShadeDeferred_Clustered_Debug SHADE_DEFERRED_ENTRY=ShadeDeferred_Clustered_Debug USE_CLUSTERED_LIGHTLIST=1 ENABLE_DEBUG=1 |
|||
|
|||
#define TILE_SIZE 8 |
|||
|
|||
|
|||
// Hacks to get the header to compile in compute |
|||
#define SHADER_TARGET 50 |
|||
#define UNITY_PBS_USE_BRDF1 |
|||
#define fixed4 float4 |
|||
#include "UnityLightingCommon.cginc" |
|||
#undef fixed4 |
|||
|
|||
float3 EvalMaterial(UnityLight light, UnityIndirect ind); |
|||
float3 EvalIndirectSpecular(UnityLight light, UnityIndirect ind); |
|||
|
|||
// uses the optimized single layered light list for opaques only |
|||
|
|||
#ifdef USE_FPTL_LIGHTLIST |
|||
#define OPAQUES_ONLY |
|||
#endif |
|||
|
|||
#include "TiledLightingTemplate.hlsl" |
|||
#include "TiledReflectionTemplate.hlsl" |
|||
|
|||
Texture2D _CameraDepthTexture; |
|||
Texture2D _CameraGBufferTexture0; |
|||
Texture2D _CameraGBufferTexture1; |
|||
Texture2D _CameraGBufferTexture2; |
|||
Texture2D _CameraGBufferTexture3; |
|||
|
|||
RWTexture2D<float4> uavOutput : register(u0); |
|||
|
|||
struct v2f { |
|||
float4 vertex : SV_POSITION; |
|||
float2 texcoord : TEXCOORD0; |
|||
}; |
|||
|
|||
v2f vert(float4 vertex : POSITION, float2 texcoord : TEXCOORD0) |
|||
{ |
|||
v2f o; |
|||
o.vertex = UnityObjectToClipPos(vertex); |
|||
o.texcoord = texcoord.xy; |
|||
return o; |
|||
} |
|||
|
|||
struct StandardData |
|||
{ |
|||
float3 specularColor; |
|||
float3 diffuseColor; |
|||
float3 normalWorld; |
|||
float smoothness; |
|||
float occlusion; |
|||
float3 emission; |
|||
}; |
|||
|
|||
struct LocalDataBRDF |
|||
{ |
|||
StandardData gbuf; |
|||
|
|||
// extras |
|||
float oneMinusReflectivity; |
|||
float3 Vworld; |
|||
}; |
|||
|
|||
static LocalDataBRDF g_localParams; |
|||
|
|||
StandardData UnityStandardDataFromGbufferAux(float4 gbuffer0, float4 gbuffer1, float4 gbuffer2, float4 gbuffer3) |
|||
{ |
|||
StandardData data; |
|||
|
|||
data.normalWorld = normalize(2 * gbuffer2.xyz - 1); |
|||
data.smoothness = gbuffer1.a; |
|||
data.diffuseColor = gbuffer0.xyz; data.specularColor = gbuffer1.xyz; |
|||
data.occlusion = gbuffer0.a; |
|||
data.emission = gbuffer3.xyz; |
|||
|
|||
return data; |
|||
} |
|||
|
|||
half3 BRDF3_Direct2(half3 diffColor, half3 specColor, half rlPow4, half smoothness) |
|||
{ |
|||
half LUT_RANGE = 16.0; // must match range in NHxRoughness() function in GeneratedTextures.cpp |
|||
// Lookup texture to save instructions |
|||
half specular = tex2Dlod(unity_NHxRoughness, half4(rlPow4, SmoothnessToPerceptualRoughness(smoothness), 0, 0)).UNITY_ATTEN_CHANNEL * LUT_RANGE; |
|||
#if defined(_SPECULARHIGHLIGHTS_OFF) |
|||
specular = 0.0; |
|||
#endif |
|||
|
|||
return diffColor + specular * specColor; |
|||
} |
|||
|
|||
|
|||
float3 EvalMaterial(UnityLight light, UnityIndirect ind) |
|||
{ |
|||
StandardData data = g_localParams.gbuf; |
|||
return UNITY_BRDF_PBS(data.diffuseColor, data.specularColor, g_localParams.oneMinusReflectivity, data.smoothness, data.normalWorld, g_localParams.Vworld, light, ind); |
|||
} |
|||
|
|||
float3 EvalIndirectSpecular(UnityLight light, UnityIndirect ind) |
|||
{ |
|||
StandardData data = g_localParams.gbuf; |
|||
|
|||
return data.occlusion * UNITY_BRDF_PBS(0, data.specularColor, g_localParams.oneMinusReflectivity, data.smoothness, data.normalWorld, g_localParams.Vworld, light, ind).rgb; |
|||
} |
|||
|
|||
[numthreads(TILE_SIZE, TILE_SIZE, 1)] |
|||
void SHADE_DEFERRED_ENTRY(uint2 dispatchThreadId : SV_DispatchThreadID, uint2 groupId : SV_GroupID) |
|||
{ |
|||
uint2 pixCoord = dispatchThreadId; |
|||
|
|||
float zbufDpth = FetchDepth(_CameraDepthTexture, pixCoord.xy).x; |
|||
float linDepth = GetLinearDepth(zbufDpth); |
|||
|
|||
float3 vP = GetViewPosFromLinDepth(pixCoord, linDepth); |
|||
float3 vPw = mul(g_mViewToWorld, float4(vP, 1)).xyz; |
|||
float3 Vworld = normalize(mul((float3x3) g_mViewToWorld, -vP).xyz); //unity_CameraToWorld |
|||
|
|||
float4 gbuffer0 = _CameraGBufferTexture0.Load(uint3(pixCoord.xy, 0)); |
|||
float4 gbuffer1 = _CameraGBufferTexture1.Load(uint3(pixCoord.xy, 0)); |
|||
float4 gbuffer2 = _CameraGBufferTexture2.Load(uint3(pixCoord.xy, 0)); |
|||
float4 gbuffer3 = _CameraGBufferTexture3.Load(uint3(pixCoord.xy, 0)); |
|||
|
|||
StandardData data = UnityStandardDataFromGbufferAux(gbuffer0, gbuffer1, gbuffer2, gbuffer3); |
|||
|
|||
g_localParams.gbuf = data; |
|||
g_localParams.oneMinusReflectivity = 1.0 - SpecularStrength(data.specularColor.rgb); |
|||
g_localParams.Vworld = Vworld; |
|||
|
|||
uint2 tileCoord = groupId >> 1; |
|||
|
|||
uint numLightsProcessed = 0; |
|||
float3 c = data.emission + ExecuteLightList(numLightsProcessed, tileCoord, vP, vPw, Vworld); |
|||
|
|||
uint numReflectionsProcessed = 0; |
|||
c += ExecuteReflectionList(numReflectionsProcessed, tileCoord, vP, data.normalWorld, Vworld, data.smoothness); |
|||
|
|||
#if ENABLE_DEBUG |
|||
c = OverlayHeatMap(pixCoord & 15, numLightsProcessed, c); |
|||
#endif |
|||
|
|||
uavOutput[pixCoord] = float4(c, 1.0); |
|||
} |
|||
|
|||
#pragma kernel ShadeDeferred_Fptl SHADE_DEFERRED_ENTRY=ShadeDeferred_Fptl USE_FPTL_LIGHTLIST=1 ENABLE_DEBUG=0 |
|||
#pragma kernel ShadeDeferred_Clustered SHADE_DEFERRED_ENTRY=ShadeDeferred_Clustered USE_CLUSTERED_LIGHTLIST=1 ENABLE_DEBUG=0 //TODO: disabled clustered permutations so far as it leads to the error "All kernels must use same constant buffer layouts" |
|||
#pragma kernel ShadeDeferred_Fptl_Debug SHADE_DEFERRED_ENTRY=ShadeDeferred_Fptl_Debug USE_FPTL_LIGHTLIST=1 ENABLE_DEBUG=1 |
|||
#pragma kernel ShadeDeferred_Clustered_Debug SHADE_DEFERRED_ENTRY=ShadeDeferred_Clustered_Debug USE_CLUSTERED_LIGHTLIST=1 ENABLE_DEBUG=1 |
|||
|
|||
#define TILE_SIZE 8 |
|||
|
|||
|
|||
// Hacks to get the header to compile in compute |
|||
#define SHADER_TARGET 50 |
|||
#define UNITY_PBS_USE_BRDF1 |
|||
#define fixed4 float4 |
|||
#include "UnityLightingCommon.cginc" |
|||
#undef fixed4 |
|||
|
|||
float3 EvalMaterial(UnityLight light, UnityIndirect ind); |
|||
float3 EvalIndirectSpecular(UnityLight light, UnityIndirect ind); |
|||
|
|||
// uses the optimized single layered light list for opaques only |
|||
|
|||
#ifdef USE_FPTL_LIGHTLIST |
|||
#define OPAQUES_ONLY |
|||
#endif |
|||
|
|||
#include "TiledLightingTemplate.hlsl" |
|||
#include "TiledReflectionTemplate.hlsl" |
|||
|
|||
UNITY_DECLARE_TEX2D_FLOAT(_CameraDepthTexture); |
|||
Texture2D _CameraGBufferTexture0; |
|||
Texture2D _CameraGBufferTexture1; |
|||
Texture2D _CameraGBufferTexture2; |
|||
Texture2D _CameraGBufferTexture3; |
|||
|
|||
RWTexture2D<float4> uavOutput : register(u0); |
|||
|
|||
struct v2f { |
|||
float4 vertex : SV_POSITION; |
|||
float2 texcoord : TEXCOORD0; |
|||
}; |
|||
|
|||
v2f vert(float4 vertex : POSITION, float2 texcoord : TEXCOORD0) |
|||
{ |
|||
v2f o; |
|||
o.vertex = UnityObjectToClipPos(vertex); |
|||
o.texcoord = texcoord.xy; |
|||
return o; |
|||
} |
|||
|
|||
struct StandardData |
|||
{ |
|||
float3 specularColor; |
|||
float3 diffuseColor; |
|||
float3 normalWorld; |
|||
float smoothness; |
|||
float occlusion; |
|||
float3 emission; |
|||
}; |
|||
|
|||
struct LocalDataBRDF |
|||
{ |
|||
StandardData gbuf; |
|||
|
|||
// extras |
|||
float oneMinusReflectivity; |
|||
float3 Vworld; |
|||
}; |
|||
|
|||
static LocalDataBRDF g_localParams; |
|||
|
|||
StandardData UnityStandardDataFromGbufferAux(float4 gbuffer0, float4 gbuffer1, float4 gbuffer2, float4 gbuffer3) |
|||
{ |
|||
StandardData data; |
|||
|
|||
data.normalWorld = normalize(2 * gbuffer2.xyz - 1); |
|||
data.smoothness = gbuffer1.a; |
|||
data.diffuseColor = gbuffer0.xyz; data.specularColor = gbuffer1.xyz; |
|||
data.occlusion = gbuffer0.a; |
|||
data.emission = gbuffer3.xyz; |
|||
|
|||
return data; |
|||
} |
|||
|
|||
half3 BRDF3_Direct2(half3 diffColor, half3 specColor, half rlPow4, half smoothness) |
|||
{ |
|||
half LUT_RANGE = 16.0; // must match range in NHxRoughness() function in GeneratedTextures.cpp |
|||
// Lookup texture to save instructions |
|||
half specular = tex2Dlod(unity_NHxRoughness, half4(rlPow4, SmoothnessToPerceptualRoughness(smoothness), 0, 0)).UNITY_ATTEN_CHANNEL * LUT_RANGE; |
|||
#if defined(_SPECULARHIGHLIGHTS_OFF) |
|||
specular = 0.0; |
|||
#endif |
|||
|
|||
return diffColor + specular * specColor; |
|||
} |
|||
|
|||
|
|||
float3 EvalMaterial(UnityLight light, UnityIndirect ind) |
|||
{ |
|||
StandardData data = g_localParams.gbuf; |
|||
return UNITY_BRDF_PBS(data.diffuseColor, data.specularColor, g_localParams.oneMinusReflectivity, data.smoothness, data.normalWorld, g_localParams.Vworld, light, ind); |
|||
} |
|||
|
|||
float3 EvalIndirectSpecular(UnityLight light, UnityIndirect ind) |
|||
{ |
|||
StandardData data = g_localParams.gbuf; |
|||
|
|||
return data.occlusion * UNITY_BRDF_PBS(0, data.specularColor, g_localParams.oneMinusReflectivity, data.smoothness, data.normalWorld, g_localParams.Vworld, light, ind).rgb; |
|||
} |
|||
|
|||
[numthreads(TILE_SIZE, TILE_SIZE, 1)] |
|||
void SHADE_DEFERRED_ENTRY(uint2 dispatchThreadId : SV_DispatchThreadID, uint2 groupId : SV_GroupID) |
|||
{ |
|||
uint2 pixCoord = dispatchThreadId; |
|||
|
|||
float zbufDpth = FetchDepth(_CameraDepthTexture, pixCoord.xy).x; |
|||
float linDepth = GetLinearDepth(zbufDpth); |
|||
|
|||
float3 vP = GetViewPosFromLinDepth(pixCoord, linDepth); |
|||
float3 vPw = mul(g_mViewToWorld, float4(vP, 1)).xyz; |
|||
float3 Vworld = normalize(mul((float3x3) g_mViewToWorld, -vP).xyz); //unity_CameraToWorld |
|||
|
|||
float4 gbuffer0 = _CameraGBufferTexture0.Load(uint3(pixCoord.xy, 0)); |
|||
float4 gbuffer1 = _CameraGBufferTexture1.Load(uint3(pixCoord.xy, 0)); |
|||
float4 gbuffer2 = _CameraGBufferTexture2.Load(uint3(pixCoord.xy, 0)); |
|||
float4 gbuffer3 = _CameraGBufferTexture3.Load(uint3(pixCoord.xy, 0)); |
|||
|
|||
StandardData data = UnityStandardDataFromGbufferAux(gbuffer0, gbuffer1, gbuffer2, gbuffer3); |
|||
|
|||
g_localParams.gbuf = data; |
|||
g_localParams.oneMinusReflectivity = 1.0 - SpecularStrength(data.specularColor.rgb); |
|||
g_localParams.Vworld = Vworld; |
|||
|
|||
uint2 tileCoord = groupId >> 1; |
|||
|
|||
uint numLightsProcessed = 0; |
|||
float3 c = data.emission + ExecuteLightList(numLightsProcessed, tileCoord, vP, vPw, Vworld); |
|||
|
|||
uint numReflectionsProcessed = 0; |
|||
c += ExecuteReflectionList(numReflectionsProcessed, tileCoord, vP, data.normalWorld, Vworld, data.smoothness); |
|||
|
|||
#if ENABLE_DEBUG |
|||
c = OverlayHeatMap(pixCoord & 15, numLightsProcessed, c); |
|||
#endif |
|||
|
|||
uavOutput[pixCoord] = float4(c, 1.0); |
|||
} |
|||
|
|
|||
m_EditorVersion: 5.6.0b5 |
|||
m_EditorVersion: 5.6.0b6 |
|
|||
|
|||
|
|||
|
|||
// TODO: Handle BC5 format, currently this code is for DXT5nm |
|||
// THis function below must call UnpackNormalmapRGorAG |
|||
float3 ADD_FUNC_SUFFIX(SampleLayerNormal)(TEXTURE2D_ARGS(layerTex, layerSampler), LayerUV layerUV, float3 weights, float scale, float bias) |
|||
{ |
|||
if (layerUV.isTriplanar) |
|||
{ |
|||
float3 val = float3(0.0, 0.0, 0.0); |
|||
|
|||
if (weights.x > 0.0) |
|||
val += weights.x * UnpackNormalAG(NORMAL_SAMPLE_FUNC(layerTex, layerSampler, layerUV.uvYZ, bias), scale); |
|||
if (weights.y > 0.0) |
|||
val += weights.y * UnpackNormalAG(NORMAL_SAMPLE_FUNC(layerTex, layerSampler, layerUV.uvZX, bias), scale); |
|||
if (weights.z > 0.0) |
|||
val += weights.z * UnpackNormalAG(NORMAL_SAMPLE_FUNC(layerTex, layerSampler, layerUV.uvXY, bias), scale); |
|||
|
|||
return normalize(val); |
|||
} |
|||
else |
|||
{ |
|||
return UnpackNormalAG(NORMAL_SAMPLE_FUNC(layerTex, layerSampler, layerUV.uv, bias), scale); |
|||
} |
|||
} |
|||
|
|||
// This version is for normalmap with AG encoding only (use with details map) |
|||
float3 ADD_FUNC_SUFFIX(SampleLayerNormalAG)(TEXTURE2D_ARGS(layerTex, layerSampler), LayerUV layerUV, float3 weights, float scale, float bias) |
|||
{ |
|||
if (layerUV.isTriplanar) |
|||
{ |
|||
float3 val = float3(0.0, 0.0, 0.0); |
|||
|
|||
if (weights.x > 0.0) |
|||
val += weights.x * UnpackNormalAG(NORMAL_SAMPLE_FUNC(layerTex, layerSampler, layerUV.uvYZ, bias), scale); |
|||
if (weights.y > 0.0) |
|||
val += weights.y * UnpackNormalAG(NORMAL_SAMPLE_FUNC(layerTex, layerSampler, layerUV.uvZX, bias), scale); |
|||
if (weights.z > 0.0) |
|||
val += weights.z * UnpackNormalAG(NORMAL_SAMPLE_FUNC(layerTex, layerSampler, layerUV.uvXY, bias), scale); |
|||
|
|||
return normalize(val); |
|||
} |
|||
else |
|||
{ |
|||
return UnpackNormalAG(NORMAL_SAMPLE_FUNC(layerTex, layerSampler, layerUV.uv, bias), scale); |
|||
} |
|||
} |
|||
|
|||
// This version is for normalmap with RGB encoding only, i.e non encoding. It is necessary to use this abstraction to handle correctly triplanar |
|||
// plus consistent with the normal scale parameter |
|||
float3 ADD_FUNC_SUFFIX(SampleLayerNormalRGB)(TEXTURE2D_ARGS(layerTex, layerSampler), LayerUV layerUV, float3 weights, float scale, float bias) |
|||
{ |
|||
if (layerUV.isTriplanar) |
|||
{ |
|||
float3 val = float3(0.0, 0.0, 0.0); |
|||
|
|||
if (weights.x > 0.0) |
|||
val += weights.x * UnpackNormalRGB(NORMAL_SAMPLE_FUNC(layerTex, layerSampler, layerUV.uvYZ, bias), scale); |
|||
if (weights.y > 0.0) |
|||
val += weights.y * UnpackNormalRGB(NORMAL_SAMPLE_FUNC(layerTex, layerSampler, layerUV.uvZX, bias), scale); |
|||
if (weights.z > 0.0) |
|||
val += weights.z * UnpackNormalRGB(NORMAL_SAMPLE_FUNC(layerTex, layerSampler, layerUV.uvXY, bias), scale); |
|||
|
|||
return normalize(val); |
|||
} |
|||
else |
|||
{ |
|||
return UnpackNormalRGB(NORMAL_SAMPLE_FUNC(layerTex, layerSampler, layerUV.uv, bias), scale); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 541d9773d4d9b4c4f92e026284359f50 |
|||
timeCreated: 1485010820 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
// This file assumes SHADER_API_METAL is defined |
|||
// TODO: This is a straight copy from D3D11.hlsl. Go through all this stuff and adjust where needed. |
|||
|
|||
#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 util abstraction |
|||
|
|||
#define CALCULATE_TEXTURE2D_LOD(textureName, samplerName, coord2) textureName.CalculateLevelOfDetail(samplerName, coord2) |
|||
|
|||
// 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_BIAS(textureName, samplerName, coord2, bias) textureName.SampleBias(samplerName, coord2, bias) |
|||
#define SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, ddx, ddy) textureName.SampleGrad(samplerName, coord2, ddx, ddy) |
|||
#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_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) textureName.SampleBias(samplerName, float3(coord2, index), bias) |
|||
#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_BIAS(textureName, samplerName, coord3, bias) textureName.SampleBias(samplerName, coord3, bias) |
|||
#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_TEXTURECUBE_ARRAY_BIAS(textureName, samplerName, coord3, index, bias) textureName.SampleBias(samplerName, float4(coord3, index), bias) |
|||
#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: f4d51e77f119d4dc8899ff02b46bb621 |
|||
timeCreated: 1484817807 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: bb067c1f82e9d8648b8909e905f6607b |
|||
folderAsset: yes |
|||
timeCreated: 1484331444 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue