Skip to content

Commit

Permalink
Fixed missing refleciton probes. Removed more stuff from shader to k…
Browse files Browse the repository at this point in the history
…eep simpler.
  • Loading branch information
phi-lira committed Aug 7, 2018
1 parent e726d64 commit c78aa22
Show file tree
Hide file tree
Showing 7 changed files with 242 additions and 80 deletions.
13 changes: 1 addition & 12 deletions Assets/_Completed/CustomDeferredRenderer/DeferredLighting.shader
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@ Shader "SIGGRAPH Studio/DeferredLighting"

HLSLPROGRAM
#pragma exclude_renderers gles d3d11_9x
#pragma enable_d3d11_debug_symbols

// -------------------------------------
// Lightweight Pipeline keywords
#pragma multi_compile _ _ADDITIONAL_LIGHTS
#pragma multi_compile _ _VERTEX_LIGHTS
#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
#pragma multi_compile _ _SHADOWS_ENABLED
#pragma multi_compile _ _LOCAL_SHADOWS_ENABLED
#pragma multi_compile _ _SHADOWS_SOFT
#pragma multi_compile _ _SHADOWS_CASCADE

#pragma vertex Vertex
#pragma fragment Fragment
Expand All @@ -50,8 +39,8 @@ Shader "SIGGRAPH Studio/DeferredLighting"
float depth = UNITY_READ_FRAMEBUFFER_INPUT(3, pos).r;

float2 positionNDC = pos.xy * _ScreenSize.zw;

float3 positionWS = ComputeWorldSpacePosition(positionNDC, depth, UNITY_MATRIX_I_VP);

half3 viewDirection = half3(normalize(GetCameraPositionWS() - positionWS));

Light mainLight = GetMainLight();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public GBufferAndLightingPass()
m_GBufferAlbedo = new RenderPassAttachment(RenderTextureFormat.ARGB32);
m_GBufferSpecRough = new RenderPassAttachment(RenderTextureFormat.ARGB32);
m_GBufferNormal = new RenderPassAttachment(RenderTextureFormat.ARGB2101010);
m_CameraTarget = new RenderPassAttachment(RenderTextureFormat.DefaultHDR);
m_CameraTarget = new RenderPassAttachment(RenderTextureFormat.ARGB32);
m_DepthAttachment = new RenderPassAttachment(RenderTextureFormat.Depth);

m_DeferredShadingMaterial = CoreUtils.CreateEngineMaterial(Shader.Find("SIGGRAPH Studio/DeferredLighting"));
Expand All @@ -34,7 +34,7 @@ public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderCo
Camera camera = renderingData.cameraData.camera;
m_CameraTarget.BindSurface(BuiltinRenderTextureType.CameraTarget, false, true);

context.SetupCameraProperties(renderingData.cameraData.camera, renderingData.cameraData.isStereoEnabled);
context.SetupCameraProperties(renderingData.cameraData.camera, false);

using (RenderPass rp = new RenderPass(context, camera.pixelWidth, camera.pixelHeight, 1,
new[] {m_GBufferAlbedo, m_GBufferSpecRough, m_GBufferNormal, m_CameraTarget}, m_DepthAttachment))
Expand All @@ -60,7 +60,7 @@ void RenderGBuffer(ref ScriptableRenderContext context, ref CullResults cullResu
var drawSettings = new DrawRendererSettings(camera, new ShaderPassName("GBuffer Pass"))
{
sorting = {flags = SortFlags.CommonOpaque},
rendererConfiguration = RendererConfiguration.PerObjectLightmaps | RendererConfiguration.PerObjectLightProbe,
rendererConfiguration = RendererConfiguration.PerObjectReflectionProbes | RendererConfiguration.PerObjectLightmaps | RendererConfiguration.PerObjectLightProbe,
};

var filterSettings = new FilterRenderersSettings(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,10 @@ Shader "SIGGRAPH Studio/Physically Based Deferred"

SubShader
{
// Lightweight Pipeline tag is required. If Lightweight pipeline is not set in the graphics settings
// this Subshader will fail. One can add a subshader below or fallback to Standard built-in to make this
// material work with both Lightweight Pipeline and Builtin Unity Pipeline
Tags{"RenderType" = "Opaque" "RenderPipeline" = "LightweightPipeline" "IgnoreProjector" = "True"}
LOD 300
Tags{"RenderPipeline" = "LightweightPipeline"}

Pass
{
// Lightmode matches the ShaderPassName set in LightweightPipeline.cs. SRPDefaultUnlit and passes with
// no LightMode tag are also rendered by Lightweight Pipeline
Name "Deferred Lit"
Tags{"LightMode" = "GBuffer Pass"}

Blend[_SrcBlend][_DstBlend]
Expand All @@ -82,21 +75,10 @@ Shader "SIGGRAPH Studio/Physically Based Deferred"
#pragma shader_feature _SPECULAR_SETUP
#pragma shader_feature _RECEIVE_SHADOWS_OFF

// -------------------------------------
// Lightweight Pipeline keywords
#pragma multi_compile _ _ADDITIONAL_LIGHTS
#pragma multi_compile _ _VERTEX_LIGHTS
#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
#pragma multi_compile _ _SHADOWS_ENABLED
#pragma multi_compile _ _LOCAL_SHADOWS_ENABLED
#pragma multi_compile _ _SHADOWS_SOFT
#pragma multi_compile _ _SHADOWS_CASCADE

// -------------------------------------
// Unity defined keywords
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile_fog

//--------------------------------------
// GPU Instancing
Expand All @@ -114,8 +96,6 @@ Shader "SIGGRAPH Studio/Physically Based Deferred"
out half4 GBuffer2 : SV_Target2,
out half4 GBuffer3 : SV_Target3)
{
UNITY_SETUP_INSTANCE_ID(IN);

SurfaceData surfaceData;
InitializeStandardLitSurfaceData(IN.uv, surfaceData);

Expand Down
Loading

0 comments on commit c78aa22

Please sign in to comment.