浏览代码
Merge branch 'master' into lowendmobile
Merge branch 'master' into lowendmobile
# Conflicts: # Assets/ScriptableRenderPipeline/RenderPasses/ShadowRenderPass.cs # ProjectSettings/QualitySettings.asset/vr_sandbox
Felipe Lira
8 年前
当前提交
0905d0bc
共有 432 个文件被更改,包括 3341 次插入 和 1917 次删除
-
2Assets/Editor/Tests/RenderloopTests/RenderPipelineTestFixture.cs
-
31Assets/TestScenes/HDTest/GraphicTest/LayeredTessellation/Layer-2-woord-rock.mat
-
22Assets/TestScenes/HDTest/GraphicTest/Tessellation/Material/Tessellation - Rock.mat
-
30Assets/TestScenes/HDTest/GraphicTest/Two Sided/Material/GroundLeaf_DoubleSided.mat
-
22Assets/TestScenes/HDTest/GraphicTest/Two Sided/Material/GroundLeaf_DoubleSidedFlip.mat
-
477Assets/TestScenes/HDTest/HDRenderLoopTest.unity
-
914Assets/TestScenes/HDTest/LayeredLitTest.unity
-
44Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_BlendColor.mat
-
75Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_BlendMask.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_BlendMask.mat.meta
-
75Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_HeightBased.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_HeightBased.mat.meta
-
69Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Planar.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Planar.mat.meta
-
70Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Triplanar.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_Triplanar.mat.meta
-
67Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV0.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV0.mat.meta
-
53Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV1.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV1.mat.meta
-
51Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV2.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV2.mat.meta
-
55Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV3.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer0_UV3.mat.meta
-
85Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_Planar.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_Planar.mat.meta
-
81Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_Triplanar.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_Triplanar.mat.meta
-
80Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV0.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV0.mat.meta
-
80Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV1.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV1.mat.meta
-
80Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV2.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV2.mat.meta
-
80Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV3.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer1_UV3.mat.meta
-
88Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_Planar.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_Planar.mat.meta
-
83Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_Triplanar.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_Triplanar.mat.meta
-
86Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_UV0.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_UV0.mat.meta
-
86Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_UV1.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_UV1.mat.meta
-
83Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_UV2.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_UV2.mat.meta
-
83Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_UV3.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer2_UV3.mat.meta
-
90Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_Planar.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_Planar.mat.meta
-
85Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_Triplanar.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_Triplanar.mat.meta
-
88Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_UV0.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_UV0.mat.meta
-
88Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_UV1.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_UV1.mat.meta
-
85Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_UV2.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_UV2.mat.meta
-
85Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_UV3.mat
-
1Assets/TestScenes/HDTest/LayeredLitTest/Material/Layered_Layer3_UV3.mat.meta
-
19Assets/TestScenes/HDTest/LayeredLitTest/Material/Lit_Sand01_2x2.mat
-
353Assets/TestScenes/HDTest/Material/HDRenderLoopMaterials/test.mat
-
8Assets/ScriptableRenderPipeline/fptl/FPTLRenderPipeline.asset
-
6Assets/ScriptableRenderPipeline/fptl/lightlistbuild.compute
-
12Assets/ScriptableRenderPipeline/fptl/lightlistbuild-clustered.compute
-
4Assets/ScriptableRenderPipeline/fptl/lightlistbuild-bigtile.compute
-
6Assets/ScriptableRenderPipeline/fptl/TiledLightingUtils.hlsl
-
2Assets/ScriptableRenderPipeline/fptl/LightingConvexHullUtils.hlsl
-
2Assets/ScriptableRenderPipeline/fptl/LightDefinitions.cs.hlsl
-
126Assets/ScriptableRenderPipeline/fptl/LightBoundsDebug.shader
-
280Assets/ScriptableRenderPipeline/fptl/Internal-DeferredShading.shader
-
2Assets/ScriptableRenderPipeline/fptl/Internal-DeferredReflections.shader
-
13Assets/ScriptableRenderPipeline/fptl/FptlLighting.cs
-
4Assets/ScriptableRenderPipeline/core/RenderPipeline.cs
-
83Assets/ScriptableRenderPipeline/ShaderLibrary/Sampling.hlsl
-
72Assets/ScriptableRenderPipeline/ShaderLibrary/ImageBasedLighting.hlsl
-
6Assets/ScriptableRenderPipeline/ShaderLibrary/Hammersley.hlsl
-
14Assets/ScriptableRenderPipeline/ShaderLibrary/CommonMaterial.hlsl
-
13Assets/ScriptableRenderPipeline/ShaderLibrary/CommonLighting.hlsl
-
41Assets/ScriptableRenderPipeline/ShaderLibrary/Common.hlsl
-
2Assets/ScriptableRenderPipeline/ShaderLibrary/API/PSSL.hlsl
-
2Assets/ScriptableRenderPipeline/ShaderLibrary/API/Metal.hlsl
-
2Assets/ScriptableRenderPipeline/ShaderLibrary/API/D3D11.hlsl
-
88Assets/ScriptableRenderPipeline/RenderPasses/ShadowRenderPass.cs
-
129Assets/ScriptableRenderPipeline/HDRenderPipeline/Utilities.cs
-
35Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyRenderer.cs
-
35Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyParameters.cs
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs.hlsl
-
162Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs
-
6Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/Resources/GGXConvolve.shader
-
4Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/Resources/ComputeGgxIblSampleData.compute
-
4Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/Resources/BuildProbabilityTables.compute
-
8Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/Resources/SkyProcedural.shader
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/Resources/AtmosphericScattering.hlsl
-
35Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkyRenderer.cs
-
9Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/ProceduralSky/ProceduralSkyParameters.cs
-
8Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/Resources/SkyHDRI.shader
-
37Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/HDRISkyRenderer.cs
-
10Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/HDRISky/HDRISkyParameters.cs
-
13Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderVariables.hlsl
914
Assets/TestScenes/HDTest/LayeredLitTest.unity
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
// Final compositing pass, just does gamma conversion for now. |
|||
|
|||
Shader "Hidden/LightBoundsDebug" |
|||
{ |
|||
Properties { } |
|||
SubShader { |
|||
Pass { |
|||
ZTest Always |
|||
Cull Off |
|||
ZWrite Off |
|||
Blend SrcAlpha One |
|||
|
|||
CGPROGRAM |
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
#pragma target 4.5 |
|||
|
|||
#include "UnityCG.cginc" |
|||
#include "LightDefinitions.cs.hlsl" |
|||
|
|||
StructuredBuffer<SFiniteLightBound> g_data : register(t0); |
|||
|
|||
float4 vert(uint globalIndex : SV_VertexID) : SV_POSITION |
|||
{ |
|||
uint lightIndex = globalIndex / 36; |
|||
uint localIndex = globalIndex - lightIndex * 36; |
|||
uint faceIndex = localIndex / 6; |
|||
uint vertexIndex = localIndex - faceIndex * 6; |
|||
int remapTrisToQuad[6] = { 0,1,2,2,3,0 }; // Remap tri indices to quad indices: 012345->012230 |
|||
vertexIndex = remapTrisToQuad[vertexIndex]; |
|||
|
|||
uint faces[6][4] = { |
|||
{0, 2, 6, 4}, //-x |
|||
{1, 5, 7, 3}, //+x |
|||
{0, 4, 5, 1}, //-y |
|||
{2, 3, 7, 6}, //+y |
|||
{0, 1, 3, 2}, //-z |
|||
{4, 6, 7, 5}, //+z |
|||
}; |
|||
|
|||
SFiniteLightBound lightData = g_data[lightIndex]; |
|||
uint coordIndex = faces[faceIndex][vertexIndex]; |
|||
float3 coord = float3((coordIndex & 1) ? 1.0f : -1.0f, (coordIndex & 2) ? 1.0f : -1.0f, (coordIndex & 4) ? 1.0f : -1.0f); |
|||
coord.xy *= (coordIndex >= 4) ? lightData.scaleXY : float2(1, 1); |
|||
|
|||
float3 viewPos = lightData.center + coord.x * lightData.boxAxisX.xyz + coord.y * lightData.boxAxisY.xyz + coord.z * -lightData.boxAxisZ.xyz; |
|||
#if USE_LEFTHAND_CAMERASPACE |
|||
// not completely sure why this is necessary since the old stuff pretends camera coordinate system is also left-hand. |
|||
// see: Camera::CalculateMatrixShaderProps() |
|||
viewPos.z = -viewPos.z; |
|||
#endif |
|||
return UnityViewToClipPos(viewPos); |
|||
} |
|||
|
|||
fixed4 frag() : SV_Target |
|||
{ |
|||
return float4(1.0f, 0.5f, 0.3f, 0.1f); |
|||
} |
|||
ENDCG |
|||
} |
|||
} |
|||
Fallback Off |
|||
} |
|||
// Final compositing pass, just does gamma conversion for now. |
|||
|
|||
Shader "Hidden/LightBoundsDebug" |
|||
{ |
|||
Properties { } |
|||
SubShader { |
|||
Pass { |
|||
ZTest Always |
|||
Cull Off |
|||
ZWrite Off |
|||
Blend SrcAlpha One |
|||
|
|||
CGPROGRAM |
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
#pragma target 4.5 |
|||
|
|||
#include "UnityCG.cginc" |
|||
#include "LightDefinitions.cs.hlsl" |
|||
|
|||
StructuredBuffer<SFiniteLightBound> g_data : register(t0); |
|||
|
|||
float4 vert(uint globalIndex : SV_VertexID) : SV_POSITION |
|||
{ |
|||
uint lightIndex = globalIndex / 36; |
|||
uint localIndex = globalIndex - lightIndex * 36; |
|||
uint faceIndex = localIndex / 6; |
|||
uint vertexIndex = localIndex - faceIndex * 6; |
|||
int remapTrisToQuad[6] = { 0,1,2,2,3,0 }; // Remap tri indices to quad indices: 012345->012230 |
|||
vertexIndex = remapTrisToQuad[vertexIndex]; |
|||
|
|||
uint faces[6][4] = { |
|||
{0, 2, 6, 4}, //-x |
|||
{1, 5, 7, 3}, //+x |
|||
{0, 4, 5, 1}, //-y |
|||
{2, 3, 7, 6}, //+y |
|||
{0, 1, 3, 2}, //-z |
|||
{4, 6, 7, 5}, //+z |
|||
}; |
|||
|
|||
SFiniteLightBound lightData = g_data[lightIndex]; |
|||
uint coordIndex = faces[faceIndex][vertexIndex]; |
|||
float3 coord = float3((coordIndex & 1) ? 1.0f : -1.0f, (coordIndex & 2) ? 1.0f : -1.0f, (coordIndex & 4) ? 1.0f : -1.0f); |
|||
coord.xy *= (coordIndex >= 4) ? lightData.scaleXY : float2(1, 1); |
|||
|
|||
float3 viewPos = lightData.center + coord.x * lightData.boxAxisX.xyz + coord.y * lightData.boxAxisY.xyz + coord.z * -lightData.boxAxisZ.xyz; |
|||
#if USE_LEFTHAND_CAMERASPACE |
|||
// not completely sure why this is necessary since the old stuff pretends camera coordinate system is also left-hand. |
|||
// see: Camera::CalculateMatrixShaderProps() |
|||
viewPos.z = -viewPos.z; |
|||
#endif |
|||
return UnityViewToClipPos(viewPos); |
|||
} |
|||
|
|||
fixed4 frag() : SV_Target |
|||
{ |
|||
return float4(1.0f, 0.5f, 0.3f, 0.1f); |
|||
} |
|||
ENDCG |
|||
} |
|||
} |
|||
Fallback Off |
|||
} |
|
|||
Shader "Hidden/Internal-Obscurity" { |
|||
Properties { |
|||
_LightTexture0 ("", any) = "" {} |
|||
_ShadowMapTexture ("", any) = "" {} |
|||
_SrcBlend ("", Float) = 1 |
|||
_DstBlend ("", Float) = 1 |
|||
} |
|||
SubShader { |
|||
|
|||
|
|||
|
|||
|
|||
Pass |
|||
{ |
|||
ZWrite Off |
|||
ZTest Always |
|||
Cull Off |
|||
Blend Off |
|||
//Blend [_SrcBlend] [_DstBlend] |
|||
|
|||
|
|||
CGPROGRAM |
|||
#pragma target 4.5 |
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
|
|||
#pragma multi_compile USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST |
|||
#pragma multi_compile __ ENABLE_DEBUG |
|||
|
|||
#include "UnityLightingCommon.cginc" |
|||
|
|||
float3 EvalMaterial(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" |
|||
|
|||
|
|||
Texture2D_float _CameraDepthTexture; |
|||
Texture2D _CameraGBufferTexture0; |
|||
Texture2D _CameraGBufferTexture1; |
|||
Texture2D _CameraGBufferTexture2; |
|||
Texture2D _CameraGBufferTexture3; |
|||
|
|||
|
|||
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; |
|||
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; |
|||
float ao = gbuffer0.a; |
|||
data.emission = gbuffer3.xyz; |
|||
|
|||
return data; |
|||
} |
|||
|
|||
|
|||
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); |
|||
} |
|||
|
|||
|
|||
half4 frag (v2f i) : SV_Target |
|||
{ |
|||
uint2 pixCoord = ((uint2) i.vertex.xy); |
|||
|
|||
float zbufDpth = FetchDepth(_CameraDepthTexture, pixCoord.xy).x; |
|||
float linDepth = GetLinearDepth(zbufDpth); |
|||
|
|||
float3 vP = GetViewPosFromLinDepth(i.vertex.xy, 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; |
|||
|
|||
uint numLightsProcessed = 0; |
|||
float3 c = data.emission + ExecuteLightList(numLightsProcessed, pixCoord, vP, vPw, Vworld); |
|||
|
|||
#if ENABLE_DEBUG |
|||
c = OverlayHeatMap(pixCoord & 15, numLightsProcessed, c); |
|||
#endif |
|||
return float4(c,1.0); |
|||
} |
|||
|
|||
ENDCG |
|||
} |
|||
|
|||
} |
|||
Fallback Off |
|||
} |
|||
Shader "Hidden/Internal-Obscurity" { |
|||
Properties { |
|||
_LightTexture0 ("", any) = "" {} |
|||
_ShadowMapTexture ("", any) = "" {} |
|||
_SrcBlend ("", Float) = 1 |
|||
_DstBlend ("", Float) = 1 |
|||
} |
|||
SubShader { |
|||
|
|||
|
|||
|
|||
|
|||
Pass |
|||
{ |
|||
ZWrite Off |
|||
ZTest Always |
|||
Cull Off |
|||
Blend Off |
|||
//Blend [_SrcBlend] [_DstBlend] |
|||
|
|||
|
|||
CGPROGRAM |
|||
#pragma target 4.5 |
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
|
|||
#pragma multi_compile USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST |
|||
#pragma multi_compile __ ENABLE_DEBUG |
|||
|
|||
#include "UnityLightingCommon.cginc" |
|||
|
|||
float3 EvalMaterial(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" |
|||
|
|||
|
|||
UNITY_DECLARE_TEX2D_FLOAT(_CameraDepthTexture); |
|||
Texture2D _CameraGBufferTexture0; |
|||
Texture2D _CameraGBufferTexture1; |
|||
Texture2D _CameraGBufferTexture2; |
|||
Texture2D _CameraGBufferTexture3; |
|||
|
|||
|
|||
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; |
|||
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; |
|||
float ao = gbuffer0.a; |
|||
data.emission = gbuffer3.xyz; |
|||
|
|||
return data; |
|||
} |
|||
|
|||
|
|||
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); |
|||
} |
|||
|
|||
|
|||
half4 frag (v2f i) : SV_Target |
|||
{ |
|||
uint2 pixCoord = ((uint2) i.vertex.xy); |
|||
|
|||
float zbufDpth = FetchDepth(_CameraDepthTexture, pixCoord.xy).x; |
|||
float linDepth = GetLinearDepth(zbufDpth); |
|||
|
|||
float3 vP = GetViewPosFromLinDepth(i.vertex.xy, 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; |
|||
|
|||
uint numLightsProcessed = 0; |
|||
float3 c = data.emission + ExecuteLightList(numLightsProcessed, pixCoord, vP, vPw, Vworld); |
|||
|
|||
#if ENABLE_DEBUG |
|||
c = OverlayHeatMap(pixCoord & 15, numLightsProcessed, c); |
|||
#endif |
|||
return float4(c,1.0); |
|||
} |
|||
|
|||
ENDCG |
|||
} |
|||
|
|||
} |
|||
Fallback Off |
|||
} |
部分文件因为文件数量过多而无法显示
撰写
预览
正在加载...
取消
保存
Reference in new issue