Skip to content
Open
Show file tree
Hide file tree
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
Binary file modified Assets/Assets/Industrial building/Garage/Materials/garage.mat
Binary file not shown.
Binary file not shown.
Binary file modified Assets/Assets/Tank/Materials/Tank_mat.mat
Binary file not shown.
Binary file not shown.
Binary file modified Assets/Materials/Blue.mat
Binary file not shown.
Binary file modified Assets/Materials/DarkBlue.mat
Binary file not shown.
Binary file modified Assets/Materials/Skin.mat
Binary file not shown.
Binary file modified Assets/Materials/Soldier.mat
Binary file not shown.
Binary file modified Assets/Scene/ConeOfSight.unity
Binary file not shown.
Binary file modified Assets/Scene/ConeOfSightURP.unity
Binary file not shown.
13 changes: 12 additions & 1 deletion Assets/Shaders/ConeOfSight.shader
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,18 @@

// 3D point reconstruction from depth texture
float depth = SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, i.screenUV);
depth = Linear01Depth(depth);

// Orthographic camera depth texture is already linear
UNITY_BRANCH
if (unity_OrthoParams.w)
{
depth = 1.0 - depth;
}
else
{
depth = Linear01Depth(depth);
}

float4 vpos = float4(i.ray * depth, 1);
float4 wpos = mul(unity_CameraToWorld, vpos);

Expand Down
14 changes: 13 additions & 1 deletion Assets/Shaders/ConeOfSightURP.shader
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,19 @@ Shader "GPUMan/ConeOfSightURP" {
i.ray = i.ray * (_ProjectionParams.z / i.ray.z); // farPlane

// ray impact point reconstruction from depth texture
float depth = Linear01Depth(SampleSceneDepth(i.screenUV.xy / i.screenUV.w), _ZBufferParams); // depth
float depth = SampleSceneDepth(i.screenUV.xy / i.screenUV.w);

UNITY_BRANCH
// Orthographic camera depth texture is already linear
if (unity_OrthoParams.w)
{
depth = 1.0 - depth;
}
else
{
depth = Linear01Depth(depth, _ZBufferParams);
}

float4 vpos = float4(i.ray * depth, 1);
float4 wpos = mul(unity_CameraToWorld, vpos);

Expand Down