Skip to content

Commit

Permalink
Final pass on the depth renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierHokke committed Mar 14, 2015
1 parent 4604da7 commit 80f820d
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 13 deletions.
36 changes: 36 additions & 0 deletions Assets/Depth Renderer.mat
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 3
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Depth Renderer
m_Shader: {fileID: 4800000, guid: 2f8a66720f8c7d74eabeab17a9170ebf, type: 3}
m_ShaderKeywords: []
m_CustomRenderQueue: -1
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
data:
first:
name: _MainTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
data:
first:
name: _DepthStart
second: 0
data:
first:
name: _DepthEnd
second: 100
m_Colors:
data:
first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
4 changes: 4 additions & 0 deletions Assets/Depth Renderer.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Assets/Depth.unity
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 28c82ae3b791c4d45bf86c95a48eb9c0, type: 3}
m_Name:
m_EditorClassIdentifier:
depthCalculator: {fileID: 4800000, guid: 2f8a66720f8c7d74eabeab17a9170ebf, type: 3}
start: 6
end: 15
depthRenderer: {fileID: 4800000, guid: 2f8a66720f8c7d74eabeab17a9170ebf, type: 3}
start: 0
end: 25
toggle: 0
--- !u!81 &118528835
AudioListener:
Expand Down
14 changes: 9 additions & 5 deletions Assets/DepthRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
using System.Collections;
using System.Collections.Generic;

[RequireComponent(typeof(Camera))]
[ExecuteInEditMode]
public class DepthRenderer : MonoBehaviour {

public Shader depthCalculator;
public Shader depthRenderer;

public float start;
public float end;
Expand All @@ -16,8 +17,11 @@ public class DepthRenderer : MonoBehaviour {

void LateUpdate()
{
Shader.SetGlobalFloat("_DepthStart", start);
Shader.SetGlobalFloat("_DepthEnd", end);
if (activated)
{
Shader.SetGlobalFloat("_DepthStart", start);
Shader.SetGlobalFloat("_DepthEnd", end);
}
if (toggle)
{
toggle = false;
Expand All @@ -30,12 +34,12 @@ public void SetDepthRenderer(bool active, float start, float end)
if (active && !activated)
{
activated = true;
Camera.main.SetReplacementShader(depthCalculator, "");
camera.SetReplacementShader(depthRenderer, "");
}
else if (!active && activated)
{
activated = false;
Camera.main.ResetReplacementShader();
camera.ResetReplacementShader();
}
}

Expand Down
10 changes: 5 additions & 5 deletions Assets/Iris.unity
Original file line number Diff line number Diff line change
Expand Up @@ -31395,8 +31395,8 @@ Transform:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1229397836}
m_LocalRotation: {x: 0, y: 1, z: 0, w: -1.62920685e-07}
m_LocalPosition: {x: 0, y: -11.2599993, z: -10.2399998}
m_LocalRotation: {x: -.707106829, y: 0, z: 0, w: .707106829}
m_LocalPosition: {x: .5, y: -55.8699989, z: -10.6000004}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
Expand Down Expand Up @@ -37287,7 +37287,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1395794158}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: .5}
m_LocalPosition: {x: -0, y: 0, z: .50999999}
m_LocalScale: {x: 1.06416547, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 876576019}
Expand Down Expand Up @@ -43384,7 +43384,7 @@ Camera:
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_RenderingPath: 2
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_HDR: 0
Expand Down Expand Up @@ -43497,7 +43497,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 28c82ae3b791c4d45bf86c95a48eb9c0, type: 3}
m_Name:
m_EditorClassIdentifier:
blackMaterial: {fileID: 2100000, guid: 03d14de929668fd4e94e279c189f5411, type: 2}
depthRenderer: {fileID: 4800000, guid: 2f8a66720f8c7d74eabeab17a9170ebf, type: 3}
start: 0
end: 100
toggle: 0
Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/Utils/Tiny/Screenshotter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ void Update () {
string path = Path.GetFullPath(folder + filename);
Application.CaptureScreenshot(path, screenshotScale);
SubtitlesManager.ShowSubtitle(3f, "Iris", "Screenshot saved at \n\n" + path);
Debug.Log("Screenshot saved at \n\n" + path);

/* the below script doesnt work... why?
if (File.Exists(path))
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 80f820d

Please sign in to comment.