From 7058eef32e524cae08a7373d8bc1061e373b223c Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Wed, 24 Jul 2019 23:51:25 -0400 Subject: [PATCH] Backlit --- BoundaryRep.java | 5 +- CameraPane.java | 54 +++++++++++++++++++------- ClickInfo.java | 2 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/BoundaryRep.java b/BoundaryRep.java index 36f7b5d..30f230a 100644 --- a/BoundaryRep.java +++ b/BoundaryRep.java @@ -1997,8 +1997,9 @@ if (v.vertexlinks == null) continue; - // Warning: faster but dangerous - if (v.weights != null && v.weights[j] == 0) // < 0.001 * v.totalweight) + // Warning: a bit faster but dangerous + if (v.weights != null && v.weights[j] == 0) + // < 0.001 * v.totalweight) { //testweight += v.weights[j-1]; continue; diff --git a/CameraPane.java b/CameraPane.java index 07290d0..fdb5f77 100644 --- a/CameraPane.java +++ b/CameraPane.java @@ -206,7 +206,8 @@ SetCamera(cam); - SetLight(new Camera(new cVector(10, 10, -20))); + // Warning: not used. + SetLight(new Camera(new cVector(15, 10, -20))); object = o; @@ -12402,44 +12403,66 @@ String program = // Min shader "!!ARBfp1.0\n" + - "PARAM zero123 = { 0.0, 1.0, 2.0, 1.25 };" + + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + + "PARAM light2cam0 = program.env[10];" + + "PARAM light2cam1 = program.env[11];" + + "PARAM light2cam2 = program.env[12];" + "TEMP temp;" + "TEMP light;" + "TEMP ndotl;" + "TEMP normal;" + "TEMP depth;" + + "TEMP eye;" + + "TEMP pos;" + "MAD normal, fragment.color, zero123.z, -zero123.y;" + - + Normalize("normal") + "MOV light, state.light[0].position;" + "DP3 ndotl.x, light, normal;" + // shadow - "MOV temp, fragment.texcoord[1];" + - TextureFetch("depth", "temp", "1") + + "MOV pos, fragment.texcoord[1];" + + "MOV temp, pos;" + + ShadowTextureFetch("depth", "temp", "1") + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + - "SLT temp.x, fragment.texcoord[1].z, depth.z;" + - + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + // No shadow when out of frustum //"SGE temp.y, depth.z, zero123.y;" + //"LRP temp.x, temp.y, zero123.y, temp.x;" + - "MUL ndotl.x, ndotl.x, temp.x;" + - "MAX ndotl.x, ndotl.x, pow2.y;" + + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow + // Backlit + "MOV pos.w, zero123.y;" + + "DP4 eye.x, pos, light2cam0;" + + "DP4 eye.y, pos, light2cam1;" + + "DP4 eye.z, pos, light2cam2;" + + Normalize("eye") + + + "DP3 ndotl.y, -eye, normal;" + + //"MUL ndotl.y, ndotl.y, pow2.x;" + + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit + "SUB ndotl.y, zero123.y, ndotl.y;" + + //"SUB ndotl.y, zero123.y, ndotl.y;" + + //"MUL ndotl.y, ndotl.y, pow2.z;" + + + "MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient + + // Pigment "TEX temp, fragment.texcoord[0], texture[0], 2D;" + "LRP temp, zero123.w, temp, one;" + // texture proportion "MUL temp, temp, ndotl.x;" + "MUL temp, temp, zero123.z;" + - "MOV temp.w, zero123.y;" + // reset alpha + //"MUL temp, temp, ndotl.y;" + + "MOV temp.w, zero123.y;" + // reset alpha "MOV result.color, temp;" + "END"; @@ -12581,20 +12604,20 @@ "MUL temp, floor, mapgrid.x;" + //"TEX depth0, temp, texture[1], 2D;" + (((mode & FP_SOFTSHADOW) == 0) ? "" : - TextureFetch("depth0", "temp", "1") + + ShadowTextureFetch("depth0", "temp", "1") + "") + "ADD temp.x, temp.x, mapgrid.x;" + //"TEX depth1, temp, texture[1], 2D;" + (((mode & FP_SOFTSHADOW) == 0) ? "" : - TextureFetch("depth1", "temp", "1") + + ShadowTextureFetch("depth1", "temp", "1") + "") + "ADD temp.y, temp.y, mapgrid.x;" + //"TEX depth2, temp, texture[1], 2D;" + - TextureFetch("depth2", "temp", "1") + + ShadowTextureFetch("depth2", "temp", "1") + "SUB temp.x, temp.x, mapgrid.x;" + //"TEX depth3, temp, texture[1], 2D;" + (((mode & FP_SOFTSHADOW) == 0) ? "" : - TextureFetch("depth3", "temp", "1") + + ShadowTextureFetch("depth3", "temp", "1") + "") + //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + //"MOV params, material;" + @@ -13392,7 +13415,8 @@ return out; } - String TextureFetch(String dest, String src, String unit) + // Also does frustum culling + String ShadowTextureFetch(String dest, String src, String unit) { return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + "SGE " + src + ".w, " + src + ".x, eps.x;" + diff --git a/ClickInfo.java b/ClickInfo.java index f85414c..8966a67 100644 --- a/ClickInfo.java +++ b/ClickInfo.java @@ -12,7 +12,7 @@ ClickInfo() { bounds = new Rectangle(); - System.out.println("CLICKINFO"); + //System.out.println("CLICKINFO"); } static final int kCamera = 1; -- Gitblit v1.6.2