summaryrefslogtreecommitdiffstats
path: root/3ner.cginc
diff options
context:
space:
mode:
Diffstat (limited to '3ner.cginc')
-rw-r--r--3ner.cginc51
1 files changed, 31 insertions, 20 deletions
diff --git a/3ner.cginc b/3ner.cginc
index 1788116..ab80a8d 100644
--- a/3ner.cginc
+++ b/3ner.cginc
@@ -9,6 +9,7 @@
#include "AutoLight.cginc"
#include "brdf.cginc"
+#include "cnlohr.cginc"
#include "geometry.cginc"
#include "pbr.cginc"
#include "lighting.cginc"
@@ -251,19 +252,14 @@ void geom(triangle v2f tri_in[3],
}
//endex
-struct FragOut {
- float4 color;
+float4 frag(v2f i, uint facing : SV_IsFrontFace
#if defined(_IMPOSTORS)
- float depth : SV_DepthLessEqual;
+ , out float depth : SV_DepthLessEqual
#endif
-};
-
-FragOut frag(v2f i, uint facing : SV_IsFrontFace) : SV_Target {
- FragOut result = (FragOut) 0;
-
+ ) : SV_Target {
UNITY_SETUP_INSTANCE_ID(i);
#if defined(SHADOW_CASTER_PASS)
- return result;
+ return 0;
#endif
#if defined(_RAY_MARCHING)
@@ -285,18 +281,35 @@ FragOut frag(v2f i, uint facing : SV_IsFrontFace) : SV_Target {
i.normal = pbr.normal;
i.objPos = pbr.objPos;
propagateObjPos(i);
- result.depth = i.pos.z;
+ float4 imp_clip_pos = UnityObjectToClipPos(i.objPos);
+ depth = imp_clip_pos.z / imp_clip_pos.w;
+ if (false) {
+ depth *= 100;
+ depth *= depth;
+ depth *= depth;
+ depth *= 100;
+ return float4(depth, depth, depth, 1);
+ }
+ if (false) {
+ return float4(i.objPos, 1);
+ }
#endif
#if defined(_DEBUG_VIEW_UNLIT)
- result.color = pbr.albedo;
- return result;
+ return pbr.albedo;
#elif defined(_DEBUG_VIEW_WORLD_SPACE_NORMALS)
- result.color = float4((pbr.normal + 1.0f) * 0.5f, 1);
- return result;
+ return float4((pbr.normal + 1.0f) * 0.5f, 1);
#elif defined(_DEBUG_VIEW_METALLIC_GLOSS)
- result.color = float4(pbr.metallic, pbr.smoothness, 0, 1);
- return result;
+ return float4(pbr.metallic, pbr.smoothness, 0, 1);
+#elif defined(_DEBUG_VIEW_DEPTH)
+ float2 screen_uv = i.pos.xy / _ScreenParams.xy;
+ float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, screen_uv);
+ depth = 1.0f - depth;
+ depth *= 100;
+ depth *= depth;
+ depth *= depth;
+ depth *= 100;
+ return float4(depth, depth, depth, 1);
#endif
LightData light_data;
@@ -304,11 +317,9 @@ FragOut frag(v2f i, uint facing : SV_IsFrontFace) : SV_Target {
#if 0
float c = light_data.common.NoV;
- result.color = float4(c,c,c,1);
- return result;
+ return float4(c,c,c,1);
#endif
- result.color = brdf(pbr, light_data);
- return result;
+ return brdf(pbr, light_data);
}
#endif // __3NER_INC