From cd87df088b1850ba0c90beb6c866c443e4eaf3b9 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Sat, 08 Jun 2019 23:56:42 -0400
Subject: [PATCH] Fix shadow and bump issue.
---
CameraPane.java | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/CameraPane.java b/CameraPane.java
index 7039da8..0d3d46b 100644
--- a/CameraPane.java
+++ b/CameraPane.java
@@ -12502,8 +12502,8 @@
// display shadow only (bump == 0)
"SUB temp.x, half.x, shadow.x;" +
- "MOV temp.y, -params6.x;" +
- "SLT temp.z, temp.y, zero.x;" +
+ "MOV temp.y, -params5.z;" + // params6.x;" +
+ "SLT temp.z, temp.y, -one2048th.x;" +
"SUB temp.y, one.x, temp.z;" +
"MUL temp.x, temp.x, temp.y;" +
"KIL temp.x;" +
@@ -12834,7 +12834,7 @@
//once = true;
}
- System.out.print("Program #" + mode + "; length = " + program.length());
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
@@ -12967,12 +12967,16 @@
"ADD " + depth + ".z, " + depth + ".z, temp.x;" +
//"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
+
+ // Compare fragment depth in light space with shadowmap.
"SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
"SGE temp.y, temp.x, zero.x;" +
- "SUB " + shadow + ".y, one.x, temp.y;" +
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
+
+ // Reverse comparison
"SUB temp.x, one.x, temp.x;" +
"MUL " + shadow + ".x, temp.x, temp.y;" +
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
"POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
"SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
@@ -12987,6 +12991,10 @@
"DP3 temp.x, normal, lightd;" +
"SLT temp.x, temp.x, zero.x;" + // shadoweps
"LRP " + shadow + ", temp.x, one, " + shadow + ";" +
+
+ // No shadow when out of frustrum
+ "SGE temp.x, " + depth + ".z, one.z;" +
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
"";
}
--
Gitblit v1.6.2