Normand Briere
2019-06-09 cd87df088b1850ba0c90beb6c866c443e4eaf3b9
CameraPane.java
....@@ -8022,7 +8022,7 @@
80228022 }
80238023 }
80248024
8025
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8025
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80268026 {
80278027 if (// DrawMode() != 0 || /*tex == null ||*/
80288028 ambientOcclusion ) // || !textureon)
....@@ -8067,7 +8067,7 @@
80678067 return; // true;
80688068 }
80698069
8070
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8070
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
80718071 {
80728072 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80738073
....@@ -8184,7 +8184,9 @@
81848184 texturedata = GetFileTexture(cachename, processbump, resolution);
81858185
81868186
8187
- if (texturedata != null)
8187
+ if (texturedata == null)
8188
+ throw new Exception();
8189
+
81888190 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81898191 //texture = GetTexture(tex, bump);
81908192 }
....@@ -8306,7 +8308,7 @@
83068308 return texture;
83078309 }
83088310
8309
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8311
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
83108312 {
83118313 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83128314
....@@ -8324,14 +8326,14 @@
83248326 return texture!=null?texture.texture:null;
83258327 }
83268328
8327
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8329
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
83288330 {
83298331 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83308332
83318333 return texture!=null?texture.texturedata:null;
83328334 }
83338335
8334
- boolean BindTexture(String tex, boolean bump, int resolution)
8336
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
83358337 {
83368338 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83378339 {
....@@ -10798,7 +10800,16 @@
1079810800 // Bump noise
1079910801 gl.glActiveTexture(GL.GL_TEXTURE6);
1080010802 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10801
- BindTexture(NOISE_TEXTURE, false, 2);
10803
+
10804
+ try
10805
+ {
10806
+ BindTexture(NOISE_TEXTURE, false, 2);
10807
+ }
10808
+ catch (Exception e)
10809
+ {
10810
+ System.err.println("FAILED: " + NOISE_TEXTURE);
10811
+ }
10812
+
1080210813
1080310814 gl.glActiveTexture(GL.GL_TEXTURE0);
1080410815 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -11354,7 +11365,14 @@
1135411365
1135511366 usedtextures.clear();
1135611367
11357
- BindTextures(DEFAULT_TEXTURES, 2);
11368
+ try
11369
+ {
11370
+ BindTextures(DEFAULT_TEXTURES, 2);
11371
+ }
11372
+ catch (Exception e)
11373
+ {
11374
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11375
+ }
1135811376 }
1135911377 //System.out.println("--> " + stackdepth);
1136011378 // GrafreeD.traceon();
....@@ -11445,7 +11463,14 @@
1144511463 if (checker != null && DrawMode() == DEFAULT)
1144611464 {
1144711465 //BindTexture(IMMORTAL_TEXTURE);
11448
- BindTextures(checker.GetTextures(), checker.texres);
11466
+ try
11467
+ {
11468
+ BindTextures(checker.GetTextures(), checker.texres);
11469
+ }
11470
+ catch (Exception e)
11471
+ {
11472
+ System.err.println("FAILED: " + checker.GetTextures());
11473
+ }
1144911474 // NEAREST
1145011475 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1145111476 DrawChecker(gl);
....@@ -12477,8 +12502,8 @@
1247712502
1247812503 // display shadow only (bump == 0)
1247912504 "SUB temp.x, half.x, shadow.x;" +
12480
- "MOV temp.y, -params6.x;" +
12481
- "SLT temp.z, temp.y, zero.x;" +
12505
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12506
+ "SLT temp.z, temp.y, -one2048th.x;" +
1248212507 "SUB temp.y, one.x, temp.z;" +
1248312508 "MUL temp.x, temp.x, temp.y;" +
1248412509 "KIL temp.x;" +
....@@ -12809,7 +12834,7 @@
1280912834 //once = true;
1281012835 }
1281112836
12812
- System.out.print("Program #" + mode + "; length = " + program.length());
12837
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1281312838 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1281412839 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1281512840
....@@ -12942,12 +12967,16 @@
1294212967
1294312968 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1294412969 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
12970
+
12971
+ // Compare fragment depth in light space with shadowmap.
1294512972 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1294612973 "SGE temp.y, temp.x, zero.x;" +
12947
- "SUB " + shadow + ".y, one.x, temp.y;" +
12974
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
12975
+
12976
+ // Reverse comparison
1294812977 "SUB temp.x, one.x, temp.x;" +
1294912978 "MUL " + shadow + ".x, temp.x, temp.y;" +
12950
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
12979
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1295112980 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1295212981
1295312982 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12961,6 +12990,10 @@
1296112990 // No shadow for backface
1296212991 "DP3 temp.x, normal, lightd;" +
1296312992 "SLT temp.x, temp.x, zero.x;" + // shadoweps
12993
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
12994
+
12995
+ // No shadow when out of frustrum
12996
+ "SGE temp.x, " + depth + ".z, one.z;" +
1296412997 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1296512998 "";
1296612999 }
....@@ -14870,7 +14903,7 @@
1487014903 //RESIZETEXTURE ^= true;
1487114904 //break;
1487214905 case 'z':
14873
- RENDERSHADOW ^= true;
14906
+ Globals.RENDERSHADOW ^= true;
1487414907 Globals.lighttouched = true;
1487514908 repaint();
1487614909 break;
....@@ -16592,7 +16625,7 @@
1659216625 gl.glDisable(gl.GL_CULL_FACE);
1659316626 }
1659416627
16595
- if (!RENDERSHADOW)
16628
+ if (!Globals.RENDERSHADOW)
1659616629 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659716630
1659816631 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16602,7 +16635,7 @@
1660216635 //gl.glColorMask(false, false, false, false);
1660316636
1660416637 //render_scene_from_light_view(gl, drawable, 0, 0);
16605
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16638
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1660616639 {
1660716640 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1660816641