Normand Briere
2019-07-27 1af7d3700724834e40ad8636bc9a56cdc3b19b15
CameraPane.java
....@@ -206,7 +206,8 @@
206206
207207 SetCamera(cam);
208208
209
- SetLight(new Camera(new cVector(10, 10, -20)));
209
+ // Warning: not used.
210
+ SetLight(new Camera(new cVector(15, 10, -20)));
210211
211212 object = o;
212213
....@@ -12402,44 +12403,66 @@
1240212403 String program =
1240312404 // Min shader
1240412405 "!!ARBfp1.0\n" +
12405
- "PARAM zero123 = { 0.0, 1.0, 2.0, 1.25 };" +
12406
+ "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
1240612407 "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
1240712408 "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
1240812409 "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
1240912410 "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
12411
+ "PARAM light2cam0 = program.env[10];" +
12412
+ "PARAM light2cam1 = program.env[11];" +
12413
+ "PARAM light2cam2 = program.env[12];" +
1241012414 "TEMP temp;" +
1241112415 "TEMP light;" +
1241212416 "TEMP ndotl;" +
1241312417 "TEMP normal;" +
1241412418 "TEMP depth;" +
12419
+ "TEMP eye;" +
12420
+ "TEMP pos;" +
1241512421
1241612422 "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12417
-
12423
+ Normalize("normal") +
1241812424 "MOV light, state.light[0].position;" +
1241912425 "DP3 ndotl.x, light, normal;" +
1242012426
1242112427 // shadow
12422
- "MOV temp, fragment.texcoord[1];" +
12423
- TextureFetch("depth", "temp", "1") +
12428
+ "MOV pos, fragment.texcoord[1];" +
12429
+ "MOV temp, pos;" +
12430
+ ShadowTextureFetch("depth", "temp", "1") +
1242412431 //"TEX depth, fragment.texcoord[1], texture[1], 2D;" +
12425
- "SLT temp.x, fragment.texcoord[1].z, depth.z;" +
12426
-
12432
+ "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" +
1242712433
1242812434 // No shadow when out of frustum
1242912435 //"SGE temp.y, depth.z, zero123.y;" +
1243012436 //"LRP temp.x, temp.y, zero123.y, temp.x;" +
1243112437
12432
- "MUL ndotl.x, ndotl.x, temp.x;" +
12433
- "MAX ndotl.x, ndotl.x, pow2.y;" +
12438
+ "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow
1243412439
12440
+ // Backlit
12441
+ "MOV pos.w, zero123.y;" +
12442
+ "DP4 eye.x, pos, light2cam0;" +
12443
+ "DP4 eye.y, pos, light2cam1;" +
12444
+ "DP4 eye.z, pos, light2cam2;" +
12445
+ Normalize("eye") +
12446
+
12447
+ "DP3 ndotl.y, -eye, normal;" +
12448
+ //"MUL ndotl.y, ndotl.y, pow2.x;" +
12449
+ "POW ndotl.y, ndotl.y, pow2.z;" + // backlit
12450
+ "SUB ndotl.y, zero123.y, ndotl.y;" +
12451
+ //"SUB ndotl.y, zero123.y, ndotl.y;" +
12452
+ //"MUL ndotl.y, ndotl.y, pow2.z;" +
12453
+
12454
+ "MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
12455
+
12456
+ // Pigment
1243512457 "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
1243612458 "LRP temp, zero123.w, temp, one;" + // texture proportion
1243712459 "MUL temp, temp, ndotl.x;" +
1243812460
1243912461 "MUL temp, temp, zero123.z;" +
1244012462
12441
- "MOV temp.w, zero123.y;" + // reset alpha
12463
+ //"MUL temp, temp, ndotl.y;" +
1244212464
12465
+ "MOV temp.w, zero123.y;" + // reset alpha
1244312466 "MOV result.color, temp;" +
1244412467 "END";
1244512468
....@@ -12581,20 +12604,20 @@
1258112604 "MUL temp, floor, mapgrid.x;" +
1258212605 //"TEX depth0, temp, texture[1], 2D;" +
1258312606 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12584
- TextureFetch("depth0", "temp", "1") +
12607
+ ShadowTextureFetch("depth0", "temp", "1") +
1258512608 "") +
1258612609 "ADD temp.x, temp.x, mapgrid.x;" +
1258712610 //"TEX depth1, temp, texture[1], 2D;" +
1258812611 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12589
- TextureFetch("depth1", "temp", "1") +
12612
+ ShadowTextureFetch("depth1", "temp", "1") +
1259012613 "") +
1259112614 "ADD temp.y, temp.y, mapgrid.x;" +
1259212615 //"TEX depth2, temp, texture[1], 2D;" +
12593
- TextureFetch("depth2", "temp", "1") +
12616
+ ShadowTextureFetch("depth2", "temp", "1") +
1259412617 "SUB temp.x, temp.x, mapgrid.x;" +
1259512618 //"TEX depth3, temp, texture[1], 2D;" +
1259612619 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12597
- TextureFetch("depth3", "temp", "1") +
12620
+ ShadowTextureFetch("depth3", "temp", "1") +
1259812621 "") +
1259912622 //"MUL texSamp0, texSamp0, state.material.front.diffuse;" +
1260012623 //"MOV params, material;" +
....@@ -13392,7 +13415,8 @@
1339213415 return out;
1339313416 }
1339413417
13395
- String TextureFetch(String dest, String src, String unit)
13418
+ // Also does frustum culling
13419
+ String ShadowTextureFetch(String dest, String src, String unit)
1339613420 {
1339713421 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1339813422 "SGE " + src + ".w, " + src + ".x, eps.x;" +