Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change resolve to sample from CameraDepthTexture #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Assets/Resources/Shaders/HiZBuffer.cginc
Original file line number Diff line number Diff line change
@@ -18,6 +18,9 @@ struct Varyings
Texture2D _MainTex;
SamplerState sampler_MainTex;

Texture2D _CameraDepthTexture;
SamplerState sampler_CameraDepthTexture;

Texture2D _Temporary;
SamplerState sampler_Temporary;

@@ -45,7 +48,7 @@ Varyings vertex(in Input input)

float4 resolve(in Varyings input) : SV_Target
{
float depth = _MainTex.Sample(sampler_MainTex, input.uv).r;
float depth = _CameraDepthTexture.Sample(sampler_CameraDepthTexture, input.uv).r;
return 1. / (_ZBufferParams.x * depth + _ZBufferParams.y);
}

6 changes: 2 additions & 4 deletions Assets/Scripts/Debug/Viewer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections;
using System.Collections.Generic;

using UnityEngine;
using UnityEngine;

[RequireComponent(typeof (HiZBuffer))]
public class Viewer : MonoBehaviour
@@ -20,6 +17,7 @@ public Shader shader
return m_Shader;
}
}

private Material m_Material;
public Material material
{