.. | .. |
---|
110 | 110 | //private Mat4f spotlightTransform = new Mat4f(); |
---|
111 | 111 | //private Mat4f spotlightInverseTransform = new Mat4f(); |
---|
112 | 112 | static GLContext glcontext = null; |
---|
113 | | - /*static*/ com.sun.opengl.util.texture.Texture cubemap; |
---|
| 113 | + /*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb |
---|
| 114 | + /*static*/ com.sun.opengl.util.texture.Texture cubemapcustom; |
---|
| 115 | + /*static*/ com.sun.opengl.util.texture.Texture cubemaprgb; |
---|
| 116 | + boolean transformMode; |
---|
| 117 | + |
---|
114 | 118 | boolean reverseUP = false; |
---|
115 | 119 | static boolean frozen = false; |
---|
116 | 120 | boolean enablebackspace = false; // patch for back buffer refresh |
---|
.. | .. |
---|
164 | 168 | |
---|
165 | 169 | |
---|
166 | 170 | // OPTIONS |
---|
167 | | - boolean Skinshader = true; |
---|
| 171 | + boolean Skinshader = false; // true; |
---|
168 | 172 | boolean cameraLight = false; |
---|
169 | 173 | boolean UVdebug = false; |
---|
170 | 174 | boolean Udebug = false; |
---|
.. | .. |
---|
173 | 177 | static boolean doublesided = false; // true; // reversed normals are awful for conformance |
---|
174 | 178 | boolean anisotropy = true; |
---|
175 | 179 | boolean softshadow = true; // slower but better false; |
---|
176 | | - boolean opacityhalo = false; |
---|
| 180 | + boolean opacityhalo = false; // reverse the halo effect (e.g. glass) |
---|
177 | 181 | |
---|
178 | 182 | boolean macromode = false; |
---|
179 | 183 | |
---|
.. | .. |
---|
188 | 192 | |
---|
189 | 193 | private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
190 | 194 | |
---|
191 | | - public void LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
| 195 | + public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
192 | 196 | { |
---|
193 | 197 | try |
---|
194 | 198 | { |
---|
195 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
| 199 | + return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
196 | 200 | } catch (IOException e) |
---|
197 | 201 | { |
---|
198 | 202 | System.out.println("NAME = " + name); |
---|
199 | 203 | e.printStackTrace(); // throw new RuntimeException(e); |
---|
| 204 | + return null; |
---|
200 | 205 | } |
---|
201 | 206 | } |
---|
202 | 207 | |
---|
.. | .. |
---|
537 | 542 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
538 | 543 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
539 | 544 | LA.vecNormalize(obj.v2); |
---|
540 | | - gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
| 545 | + |
---|
| 546 | + SetGLNormal(gl, (float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
541 | 547 | } |
---|
542 | 548 | |
---|
543 | 549 | // P |
---|
.. | .. |
---|
559 | 565 | y += ny * obj.NORMALPUSH; |
---|
560 | 566 | z += nz * obj.NORMALPUSH; |
---|
561 | 567 | |
---|
562 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 568 | + SetGLNormal(gl, nx, ny, nz); |
---|
563 | 569 | } |
---|
564 | 570 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
565 | 571 | SetColor(obj, pv); |
---|
.. | .. |
---|
591 | 597 | y += ny * obj.NORMALPUSH; |
---|
592 | 598 | z += nz * obj.NORMALPUSH; |
---|
593 | 599 | |
---|
594 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 600 | + SetGLNormal(gl, nx, ny, nz); |
---|
595 | 601 | } |
---|
596 | 602 | //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
597 | 603 | // boolean locked = false; |
---|
.. | .. |
---|
639 | 645 | y += ny * obj.NORMALPUSH; |
---|
640 | 646 | z += nz * obj.NORMALPUSH; |
---|
641 | 647 | |
---|
642 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 648 | + SetGLNormal(gl, nx, ny, nz); |
---|
643 | 649 | } |
---|
644 | 650 | |
---|
645 | 651 | // if ((dot&4) == 0) |
---|
.. | .. |
---|
875 | 881 | //// tris.postdraw(this); |
---|
876 | 882 | } |
---|
877 | 883 | |
---|
878 | | - static Camera localcamera = new Camera(); |
---|
| 884 | + static Camera localAOcamera = new Camera(); |
---|
879 | 885 | static cVector from = new cVector(); |
---|
880 | 886 | static cVector to = new cVector(); |
---|
881 | 887 | |
---|
.. | .. |
---|
884 | 890 | CameraPane cp = this; |
---|
885 | 891 | |
---|
886 | 892 | Camera keep = cp.RenderCamera(); |
---|
887 | | - cp.renderCamera = localcamera; |
---|
| 893 | + cp.renderCamera = localAOcamera; |
---|
888 | 894 | |
---|
889 | 895 | if (br.trimmed) |
---|
890 | 896 | { |
---|
.. | .. |
---|
902 | 908 | br.positions[i3 + 2] + br.normals[i3 + 2]); |
---|
903 | 909 | LA.xformPos(from, transform, from); |
---|
904 | 910 | LA.xformPos(to, transform, to); // RIGID ONLY |
---|
905 | | - localcamera.setAim(from, to); |
---|
| 911 | + localAOcamera.setAim(from, to); |
---|
906 | 912 | |
---|
907 | 913 | CameraPane.occlusionbuffer.display(); |
---|
908 | 914 | |
---|
.. | .. |
---|
936 | 942 | to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
937 | 943 | LA.xformPos(from, transform, from); |
---|
938 | 944 | LA.xformPos(to, transform, to); // RIGID ONLY |
---|
939 | | - localcamera.setAim(from, to); |
---|
| 945 | + localAOcamera.setAim(from, to); |
---|
940 | 946 | |
---|
941 | 947 | CameraPane.occlusionbuffer.display(); |
---|
942 | 948 | |
---|
.. | .. |
---|
1245 | 1251 | { |
---|
1246 | 1252 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1247 | 1253 | { |
---|
1248 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1254 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1249 | 1255 | } else |
---|
1250 | 1256 | { |
---|
1251 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1257 | + SetGLNormal(gl, 0, 0, 1); |
---|
1252 | 1258 | } |
---|
1253 | 1259 | |
---|
1254 | 1260 | if (c != null) |
---|
.. | .. |
---|
1272 | 1278 | { |
---|
1273 | 1279 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1274 | 1280 | { |
---|
1275 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1281 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1276 | 1282 | } else |
---|
1277 | 1283 | { |
---|
1278 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1284 | + SetGLNormal(gl, 0, 0, 1); |
---|
1279 | 1285 | } |
---|
1280 | 1286 | if (c != null) |
---|
1281 | 1287 | { |
---|
.. | .. |
---|
1300 | 1306 | { |
---|
1301 | 1307 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1302 | 1308 | { |
---|
1303 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1309 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1304 | 1310 | } else |
---|
1305 | 1311 | { |
---|
1306 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1312 | + SetGLNormal(gl, 0, 0, 1); |
---|
1307 | 1313 | } |
---|
1308 | 1314 | if (c != null) |
---|
1309 | 1315 | { |
---|
.. | .. |
---|
1485 | 1491 | { |
---|
1486 | 1492 | if (!selectmode) |
---|
1487 | 1493 | { |
---|
1488 | | - gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
| 1494 | + SetGLNormal(gl, (float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
1489 | 1495 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
1490 | 1496 | |
---|
1491 | 1497 | if (flipV) |
---|
.. | .. |
---|
1814 | 1820 | |
---|
1815 | 1821 | display.modelParams7[0] = 0; |
---|
1816 | 1822 | display.modelParams7[1] = 1000; |
---|
1817 | | - display.modelParams7[2] = 0; |
---|
| 1823 | + display.modelParams7[2] = material.parallax; |
---|
1818 | 1824 | display.modelParams7[3] = 0; |
---|
1819 | 1825 | |
---|
1820 | 1826 | //display.modelParams6[0] = 100; // criss de bug de bump |
---|
.. | .. |
---|
2047 | 2053 | switch(viewcode) |
---|
2048 | 2054 | { |
---|
2049 | 2055 | case 0: return "main"; |
---|
2050 | | - case 1: return "one"; |
---|
2051 | | - case 2: return "two"; |
---|
2052 | | - case 3: return "three"; |
---|
| 2056 | + case 1: return "Red"; |
---|
| 2057 | + case 2: return "Green"; |
---|
| 2058 | + case 3: return "Blue"; |
---|
2053 | 2059 | case 4: return "light"; |
---|
2054 | 2060 | } |
---|
2055 | 2061 | |
---|
.. | .. |
---|
2470 | 2476 | return CreateBim(bytes, width, height); |
---|
2471 | 2477 | } |
---|
2472 | 2478 | |
---|
| 2479 | + private void SetGLNormal(javax.media.opengl.GL gl, float nx, float ny, float nz) |
---|
| 2480 | + { |
---|
| 2481 | + gl.glNormal3f(nx, ny, nz); |
---|
| 2482 | + |
---|
| 2483 | + if (ny > 0.9 || ny < -0.9) |
---|
| 2484 | + // Ground or ceiling |
---|
| 2485 | + gl.glVertexAttrib3f(4, 1, 0, 0); |
---|
| 2486 | + else |
---|
| 2487 | + // Walls |
---|
| 2488 | + gl.glVertexAttrib3f(4, 0, 1, 0); |
---|
| 2489 | + } |
---|
| 2490 | + |
---|
2473 | 2491 | /**/ |
---|
2474 | 2492 | class CacheTexture |
---|
2475 | 2493 | { |
---|
.. | .. |
---|
2512 | 2530 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
2513 | 2531 | getClass().getClassLoader().getResourceAsStream(name), |
---|
2514 | 2532 | true, |
---|
2515 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2533 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2516 | 2534 | } catch (java.io.IOException e) |
---|
2517 | 2535 | { |
---|
2518 | 2536 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
8358 | 8376 | // else |
---|
8359 | 8377 | // if (!texname.startsWith("/")) |
---|
8360 | 8378 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8361 | | - if (!FileExists(texname)) |
---|
| 8379 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
8362 | 8380 | { |
---|
8363 | 8381 | texname = fallbackTextureName; |
---|
8364 | 8382 | } |
---|
.. | .. |
---|
8441 | 8459 | new Exception().printStackTrace(); |
---|
8442 | 8460 | } else |
---|
8443 | 8461 | { |
---|
| 8462 | + if (texname.startsWith("@")) |
---|
| 8463 | + { |
---|
| 8464 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8465 | + if (texturecache == null) |
---|
| 8466 | + texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution); |
---|
| 8467 | + else |
---|
| 8468 | + new Exception().printStackTrace(); |
---|
| 8469 | + } else |
---|
| 8470 | + { |
---|
8444 | 8471 | if (textureon) |
---|
8445 | 8472 | { |
---|
8446 | 8473 | String cachename = texname; |
---|
.. | .. |
---|
8500 | 8527 | texturecache = new CacheTexture(texturedata,resolution); |
---|
8501 | 8528 | //texture = GetTexture(tex, bump); |
---|
8502 | 8529 | } |
---|
| 8530 | + } |
---|
8503 | 8531 | } |
---|
8504 | 8532 | //} |
---|
8505 | 8533 | } |
---|
.. | .. |
---|
8768 | 8796 | |
---|
8769 | 8797 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8770 | 8798 | MAXSTACK = temp[0]; |
---|
8771 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8799 | + if (Globals.DEBUG) |
---|
| 8800 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8772 | 8801 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8773 | 8802 | MAXSTACK = temp[0]; |
---|
8774 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8803 | + if (Globals.DEBUG) |
---|
| 8804 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8775 | 8805 | |
---|
8776 | 8806 | // Use debug pipeline |
---|
8777 | 8807 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8779 | 8809 | gl = drawable.getGL(); // |
---|
8780 | 8810 | |
---|
8781 | 8811 | GL gl3 = getGL(); |
---|
8782 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8812 | + if (Globals.DEBUG) |
---|
| 8813 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8783 | 8814 | |
---|
8784 | 8815 | |
---|
8785 | 8816 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
9220 | 9251 | |
---|
9221 | 9252 | void LoadEnvy(int which) |
---|
9222 | 9253 | { |
---|
| 9254 | + assert(false); |
---|
| 9255 | + |
---|
9223 | 9256 | String name; |
---|
9224 | 9257 | String ext; |
---|
9225 | 9258 | |
---|
.. | .. |
---|
9316 | 9349 | double[] light2camera = new double[16]; |
---|
9317 | 9350 | |
---|
9318 | 9351 | //int newenvy = -1; |
---|
9319 | | - boolean envyoff = true; // false; |
---|
9320 | | - String skyboxname = ""; |
---|
9321 | | - String skyboxext; |
---|
9322 | | - String loadedskyboxname = ""; |
---|
| 9352 | + //boolean envyoff = false; |
---|
| 9353 | + |
---|
| 9354 | + String loadedskyboxname; |
---|
9323 | 9355 | |
---|
9324 | 9356 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9325 | 9357 | //float[] light0 = { 0,0,0 }; |
---|
.. | .. |
---|
10671 | 10703 | static boolean init = false; |
---|
10672 | 10704 | |
---|
10673 | 10705 | double[][] matrix = LA.newMatrix(); |
---|
| 10706 | + |
---|
| 10707 | + // This is to refresh the UI of the material panel. |
---|
| 10708 | + ObjEditor patchMaterial; |
---|
10674 | 10709 | |
---|
10675 | 10710 | public void display(GLAutoDrawable drawable) |
---|
10676 | 10711 | { |
---|
| 10712 | + if (patchMaterial.patchMaterial) |
---|
| 10713 | + { |
---|
| 10714 | + patchMaterial.patchMaterial = false; |
---|
| 10715 | + patchMaterial.objectPanel.setSelectedIndex(1); |
---|
| 10716 | + } |
---|
| 10717 | + |
---|
10677 | 10718 | if (Grafreed.savesound && Grafreed.hassound) |
---|
10678 | 10719 | { |
---|
10679 | 10720 | Grafreed.wav.save(); |
---|
.. | .. |
---|
10842 | 10883 | |
---|
10843 | 10884 | if (wait) |
---|
10844 | 10885 | { |
---|
10845 | | - Sleep(500); |
---|
| 10886 | + Sleep(200); // blocks everything |
---|
10846 | 10887 | |
---|
10847 | 10888 | wait = false; |
---|
10848 | 10889 | } |
---|
.. | .. |
---|
11065 | 11106 | // |
---|
11066 | 11107 | // newenvy = -1; |
---|
11067 | 11108 | |
---|
11068 | | - if (!skyboxname.equals(this.loadedskyboxname)) |
---|
| 11109 | + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
11069 | 11110 | { |
---|
11070 | | - LoadSkybox(skyboxname + "/", skyboxext, false); |
---|
11071 | | - loadedskyboxname = skyboxname; |
---|
| 11111 | + if (cubemaprgb == null) |
---|
| 11112 | + { |
---|
| 11113 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
| 11114 | + } |
---|
| 11115 | + |
---|
| 11116 | + cubemap = cubemaprgb; |
---|
| 11117 | + } |
---|
| 11118 | + else |
---|
| 11119 | + { |
---|
| 11120 | + if (object.skyboxname != null) |
---|
| 11121 | + { |
---|
| 11122 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11123 | + { |
---|
| 11124 | + if (cubemap != null && cubemap != cubemaprgb) |
---|
| 11125 | + cubemap.dispose(); |
---|
| 11126 | + cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11127 | + loadedskyboxname = object.skyboxname; |
---|
| 11128 | + } |
---|
| 11129 | + } |
---|
| 11130 | + else |
---|
| 11131 | + { |
---|
| 11132 | + cubemapcustom = null; |
---|
| 11133 | + loadedskyboxname = null; |
---|
| 11134 | + } |
---|
| 11135 | + |
---|
| 11136 | + cubemap = cubemapcustom; |
---|
11072 | 11137 | } |
---|
11073 | 11138 | |
---|
11074 | 11139 | ratio = ((double) getWidth()) / getHeight(); |
---|
.. | .. |
---|
11372 | 11437 | |
---|
11373 | 11438 | // if (cam != lightCamera) |
---|
11374 | 11439 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11375 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11440 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11376 | 11441 | } |
---|
11377 | 11442 | |
---|
11378 | 11443 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
12446 | 12511 | |
---|
12447 | 12512 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12448 | 12513 | |
---|
12449 | | - String program0 = |
---|
| 12514 | + String programmin = |
---|
12450 | 12515 | // Min shader |
---|
12451 | 12516 | "!!ARBfp1.0\n" + |
---|
12452 | | - "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
12453 | | - "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12517 | + "PARAM zero12t = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12518 | + "PARAM pow_2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12519 | + "PARAM pow2 = { 2, 4, 8, 0.0 };" + |
---|
12454 | 12520 | "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
12455 | 12521 | "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
12456 | 12522 | "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
.. | .. |
---|
12465 | 12531 | "TEMP eye;" + |
---|
12466 | 12532 | "TEMP pos;" + |
---|
12467 | 12533 | |
---|
12468 | | - "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12534 | + "MAD normal, fragment.color, zero12t.z, -zero12t.y;" + |
---|
12469 | 12535 | Normalize("normal") + |
---|
12470 | 12536 | "MOV light, state.light[0].position;" + |
---|
12471 | 12537 | "DP3 ndotl.x, light, normal;" + |
---|
| 12538 | + "MAX ndotl.x, ndotl.x, zero12t.x;" + |
---|
12472 | 12539 | |
---|
12473 | 12540 | // shadow |
---|
12474 | 12541 | "MOV pos, fragment.texcoord[1];" + |
---|
.. | .. |
---|
12484 | 12551 | "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
12485 | 12552 | |
---|
12486 | 12553 | // Backlit |
---|
12487 | | - "MOV pos.w, zero123.y;" + |
---|
| 12554 | + "MOV pos.w, zero12t.y;" + // one |
---|
12488 | 12555 | "DP4 eye.x, pos, light2cam0;" + |
---|
12489 | 12556 | "DP4 eye.y, pos, light2cam1;" + |
---|
12490 | 12557 | "DP4 eye.z, pos, light2cam2;" + |
---|
.. | .. |
---|
12492 | 12559 | |
---|
12493 | 12560 | "DP3 ndotl.y, -eye, normal;" + |
---|
12494 | 12561 | //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
12495 | | - "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
12496 | | - "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12562 | + "POW ndotl.y, ndotl.y, pow2.x;" + // backlit |
---|
| 12563 | + "SUB ndotl.y, zero12t.y, ndotl.y;" + // 1 - y |
---|
| 12564 | + //"POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
12497 | 12565 | //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
12498 | 12566 | //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12567 | + "ADD ndotl.y, ndotl.y, one.x;" + |
---|
| 12568 | + "MUL ndotl.y, ndotl.y, pow_2.x;" + |
---|
12499 | 12569 | |
---|
12500 | 12570 | //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
12501 | 12571 | //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
12502 | 12572 | |
---|
12503 | 12573 | // Pigment |
---|
12504 | 12574 | "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12505 | | - "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
12506 | | - "MUL temp, temp, ndotl.x;" + |
---|
12507 | | - |
---|
12508 | | - "MUL temp, temp, zero123.z;" + |
---|
| 12575 | + "LRP temp, zero12t.w, temp, one;" + // texture proportion |
---|
| 12576 | + "MUL temp, temp, zero12t.w;" + // Times x |
---|
12509 | 12577 | |
---|
12510 | 12578 | //"MUL temp, temp, ndotl.y;" + |
---|
| 12579 | + "MAD ndotl.x, pow_2.xxxx, ndotl.yyyy, ndotl.x;" + |
---|
12511 | 12580 | |
---|
12512 | | - "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12581 | + "MUL temp, temp, ndotl.x;" + // lambert |
---|
| 12582 | + |
---|
| 12583 | + "MOV temp.w, zero12t.y;" + // reset alpha |
---|
12513 | 12584 | "MOV result.color, temp;" + |
---|
12514 | 12585 | "END"; |
---|
12515 | 12586 | |
---|
12516 | | - String program = |
---|
| 12587 | + String programmax = |
---|
12517 | 12588 | "!!ARBfp1.0\n" + |
---|
12518 | 12589 | |
---|
12519 | 12590 | //"OPTION ARB_fragment_program_shadow;" + |
---|
.. | .. |
---|
12541 | 12612 | "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow |
---|
12542 | 12613 | "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias |
---|
12543 | 12614 | "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough |
---|
12544 | | - "PARAM params7 = program.env[7];" + // noise power, opacity power |
---|
| 12615 | + "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax |
---|
12545 | 12616 | "PARAM options0 = program.env[63];" + // fog density, intensity, elevation |
---|
12546 | 12617 | "PARAM options1 = program.env[62];" + // fog rgb color |
---|
12547 | 12618 | "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen |
---|
.. | .. |
---|
12786 | 12857 | "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut |
---|
12787 | 12858 | // mar 2013 ??? "KIL alpha.a;" + |
---|
12788 | 12859 | "MOV alpha, texSamp.aaaa;" + // y;" + |
---|
12789 | | - "KIL alpha.a;" + |
---|
| 12860 | + "KIL alpha.a;" + // not sure with parallax mapping |
---|
12790 | 12861 | /* |
---|
12791 | 12862 | "MUL temp.xy, temp, two;" + |
---|
12792 | 12863 | "TXB bump, temp, texture[0], 2D;" + |
---|
.. | .. |
---|
12872 | 12943 | "SUB bump0, bump0, half;" + |
---|
12873 | 12944 | "ADD bump, bump, bump0;" + |
---|
12874 | 12945 | |
---|
12875 | | - "MOV temp.x, texSamp.a;" + |
---|
12876 | | - "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
12877 | | - //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
12878 | | - "MOV texSamp.a, temp.x;" + |
---|
12879 | | - |
---|
12880 | 12946 | // double-sided |
---|
12881 | 12947 | /**/ |
---|
12882 | 12948 | (doublesided?"DP3 temp.z, normal, eye;" + |
---|
.. | .. |
---|
12893 | 12959 | "MOV normald, normal;" + |
---|
12894 | 12960 | "MOV normals, normal;" + |
---|
12895 | 12961 | |
---|
| 12962 | + "MOV temp, fragment.texcoord[4];" + |
---|
| 12963 | + |
---|
12896 | 12964 | // UV base |
---|
12897 | 12965 | //"DP3 UP.x,state.matrix.modelview.row[0],Y;" + |
---|
12898 | 12966 | //"DP3 UP.y,state.matrix.modelview.row[1],Y;" + |
---|
12899 | 12967 | //"DP3 UP.z,state.matrix.modelview.row[2],Y;" + |
---|
12900 | | - "DP3 UP.x,state.matrix.texture[7].row[0],Y;" + |
---|
12901 | | - "DP3 UP.y,state.matrix.texture[7].row[1],Y;" + |
---|
12902 | | - "DP3 UP.z,state.matrix.texture[7].row[2],Y;" + |
---|
| 12968 | + "DP3 UP.x,state.matrix.texture[7].row[0],temp;" + |
---|
| 12969 | + "DP3 UP.y,state.matrix.texture[7].row[1],temp;" + |
---|
| 12970 | + "DP3 UP.z,state.matrix.texture[7].row[2],temp;" + |
---|
| 12971 | + Normalize("UP") + |
---|
| 12972 | + |
---|
12903 | 12973 | "XPD V, normal, UP;" + |
---|
12904 | 12974 | Normalize("V") + |
---|
12905 | 12975 | "XPD U, V, normal;" + |
---|
12906 | 12976 | Normalize("U") + |
---|
12907 | 12977 | |
---|
12908 | 12978 | // parallax mapping |
---|
| 12979 | + |
---|
| 12980 | + "DP3 temp2.x, V, eye;" + |
---|
| 12981 | + "DP3 temp2.y, U, eye;" + |
---|
| 12982 | + "DP3 temp2.z, normal, eye;" + |
---|
| 12983 | + "RCP temp2.z, temp2.z;" + |
---|
| 12984 | + |
---|
| 12985 | + "DP3 temp2.w, texSamp, texSamp;" + // Height |
---|
| 12986 | + "RSQ temp2.w, temp2.w;" + |
---|
| 12987 | + "RCP temp2.w, temp2.w;" + |
---|
| 12988 | + |
---|
| 12989 | + "SUB temp2.w, temp2.w, half;" + |
---|
| 12990 | +// "SGE temp.x, temp2.w, eps.x;" + |
---|
| 12991 | +// "MUL temp2.w, temp2.w, temp.x;" + |
---|
| 12992 | + |
---|
| 12993 | + //"MOV texSamp, U;" + |
---|
| 12994 | + |
---|
| 12995 | + "MUL temp2.z, temp2.z, temp2.w;" + |
---|
| 12996 | + "MUL temp2.z, temp2.z, params7.z;" + // parallax |
---|
| 12997 | + |
---|
| 12998 | + "MUL temp2, temp2, temp2.z;" + |
---|
| 12999 | + |
---|
| 13000 | + "MOV temp, fragment.texcoord[0];" + |
---|
| 13001 | + |
---|
| 13002 | + "SUB temp, temp, temp2;" + |
---|
| 13003 | + |
---|
| 13004 | + "TEX temp, temp, texture[0], 2D;" + |
---|
| 13005 | + "POW temp.a, temp.a, params6.w;" + // punch through |
---|
| 13006 | + |
---|
| 13007 | + "ADD texSamp, temp, texSamp;" + |
---|
| 13008 | + "MUL texSamp.xyz, half, texSamp;" + |
---|
| 13009 | + |
---|
| 13010 | + "MOV alpha, texSamp.aaaa;" + |
---|
| 13011 | + |
---|
| 13012 | +// parallax mapping |
---|
| 13013 | + |
---|
| 13014 | + "MOV temp.x, texSamp.a;" + |
---|
| 13015 | + "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
| 13016 | + //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
| 13017 | + "MOV texSamp.a, temp.x;" + |
---|
12909 | 13018 | |
---|
12910 | 13019 | //"MOV temp, fragment.texcoord[0];" + |
---|
12911 | 13020 | // |
---|
.. | .. |
---|
13369 | 13478 | //once = true; |
---|
13370 | 13479 | } |
---|
13371 | 13480 | |
---|
13372 | | - System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13373 | | - System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13481 | + String program = programmax; |
---|
| 13482 | + |
---|
| 13483 | + if (Globals.MINSHADER) |
---|
| 13484 | + { |
---|
| 13485 | + program = programmin; |
---|
| 13486 | + } |
---|
| 13487 | + |
---|
| 13488 | + if (Globals.DEBUG) |
---|
| 13489 | + { |
---|
| 13490 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
| 13491 | + System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13492 | + } |
---|
| 13493 | + |
---|
13374 | 13494 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13375 | 13495 | |
---|
13376 | 13496 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13417 | 13537 | "\n" + |
---|
13418 | 13538 | "END\n"; |
---|
13419 | 13539 | |
---|
13420 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13540 | + if (Globals.DEBUG) |
---|
| 13541 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
13421 | 13542 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13422 | 13543 | |
---|
13423 | 13544 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13675 | 13796 | /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow |
---|
13676 | 13797 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13677 | 13798 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13678 | | - /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
| 13799 | + /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax |
---|
13679 | 13800 | |
---|
13680 | 13801 | //Object3D.cVector2[] vector2buffer; |
---|
13681 | 13802 | |
---|
.. | .. |
---|
13842 | 13963 | "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" + |
---|
13843 | 13964 | "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" + |
---|
13844 | 13965 | "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" + |
---|
13845 | | - "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" + |
---|
| 13966 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
13846 | 13967 | "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" + |
---|
13847 | 13968 | "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" + |
---|
13848 | 13969 | //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" + |
---|
.. | .. |
---|
13903 | 14024 | "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" + |
---|
13904 | 14025 | "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" + |
---|
13905 | 14026 | "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" + |
---|
13906 | | - //"MOV result.texcoord, vertex.texcoord;" + |
---|
| 14027 | + //"MOV result.texcoord, vertex.fogcoord;" + |
---|
13907 | 14028 | "MOV result.texcoord, temp;" + |
---|
13908 | 14029 | // border fade |
---|
13909 | 14030 | "MOV result.texcoord[3], vertex.texcoord;" + |
---|
.. | .. |
---|
13950 | 14071 | |
---|
13951 | 14072 | //"ADD temp.z, temp.z, one;" + |
---|
13952 | 14073 | |
---|
13953 | | - "MOV result.color, temp;" |
---|
| 14074 | + "MOV result.texcoord[4], vertex.attrib[4];" + // U dir |
---|
| 14075 | + |
---|
| 14076 | + "MOV result.color, temp;" // Normal |
---|
13954 | 14077 | : "MOV result.color, vertex.color;") + |
---|
13955 | 14078 | ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;" |
---|
13956 | 14079 | : "") + |
---|
.. | .. |
---|
14616 | 14739 | void GoDown(int mod) |
---|
14617 | 14740 | { |
---|
14618 | 14741 | MODIFIERS |= COMMAND; |
---|
| 14742 | + boolean isVR = (mouseMode&VR)!=0; |
---|
14619 | 14743 | /**/ |
---|
14620 | 14744 | if((mod&SHIFT) == SHIFT) |
---|
14621 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14745 | + { |
---|
| 14746 | + if (isVR) |
---|
| 14747 | + manipCamera.RotateInterest(0, -speed); |
---|
| 14748 | + else |
---|
| 14749 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14750 | + } |
---|
14622 | 14751 | else |
---|
14623 | | - manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14752 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
14624 | 14753 | /**/ |
---|
14625 | 14754 | if ((mod & SHIFT) == SHIFT) |
---|
14626 | 14755 | { |
---|
.. | .. |
---|
14630 | 14759 | mouseMode |= BACKFORTH; |
---|
14631 | 14760 | } |
---|
14632 | 14761 | |
---|
| 14762 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14763 | + |
---|
14633 | 14764 | //prevX = X = anchorX; |
---|
14634 | 14765 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
14635 | 14766 | } |
---|
.. | .. |
---|
14638 | 14769 | { |
---|
14639 | 14770 | MODIFIERS |= COMMAND; |
---|
14640 | 14771 | /**/ |
---|
| 14772 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14773 | + |
---|
14641 | 14774 | if((mod&SHIFT) == SHIFT) |
---|
14642 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14775 | + { |
---|
| 14776 | + if (isVR) |
---|
| 14777 | + manipCamera.RotateInterest(0, speed); |
---|
| 14778 | + else |
---|
| 14779 | + manipCamera.RotatePosition(0, speed); |
---|
| 14780 | + } |
---|
14643 | 14781 | else |
---|
14644 | | - manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14782 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
14645 | 14783 | /**/ |
---|
14646 | 14784 | if ((mod & SHIFT) == SHIFT) |
---|
14647 | 14785 | { |
---|
.. | .. |
---|
14651 | 14789 | mouseMode |= BACKFORTH; |
---|
14652 | 14790 | } |
---|
14653 | 14791 | |
---|
| 14792 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14793 | + |
---|
14654 | 14794 | //prevX = X = anchorX; |
---|
14655 | 14795 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
14656 | 14796 | } |
---|
.. | .. |
---|
14660 | 14800 | MODIFIERS |= COMMAND; |
---|
14661 | 14801 | /**/ |
---|
14662 | 14802 | if((mod&SHIFT) == SHIFT) |
---|
14663 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
| 14803 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14664 | 14804 | else |
---|
14665 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 14805 | + { |
---|
| 14806 | + if ((mouseMode&VR)!=0) |
---|
| 14807 | + manipCamera.RotateInterest(-speed, 0); |
---|
| 14808 | + else |
---|
| 14809 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14810 | + } |
---|
14666 | 14811 | /**/ |
---|
14667 | 14812 | if ((mod & SHIFT) == SHIFT) |
---|
14668 | 14813 | { |
---|
.. | .. |
---|
14672 | 14817 | mouseMode |= ROTATE; |
---|
14673 | 14818 | } // TRANSLATE; |
---|
14674 | 14819 | |
---|
| 14820 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14821 | + |
---|
14675 | 14822 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
14676 | 14823 | prevY = Y = anchorY; |
---|
14677 | 14824 | } |
---|
.. | .. |
---|
14681 | 14828 | MODIFIERS |= COMMAND; |
---|
14682 | 14829 | /**/ |
---|
14683 | 14830 | if((mod&SHIFT) == SHIFT) |
---|
14684 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
| 14831 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14685 | 14832 | else |
---|
14686 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 14833 | + { |
---|
| 14834 | + if ((mouseMode&VR)!=0) |
---|
| 14835 | + manipCamera.RotateInterest(speed, 0); |
---|
| 14836 | + else |
---|
| 14837 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14838 | + } |
---|
| 14839 | + |
---|
14687 | 14840 | /**/ |
---|
14688 | 14841 | if ((mod & SHIFT) == SHIFT) |
---|
14689 | 14842 | { |
---|
.. | .. |
---|
14693 | 14846 | mouseMode |= ROTATE; |
---|
14694 | 14847 | } // TRANSLATE; |
---|
14695 | 14848 | |
---|
| 14849 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14850 | + |
---|
14696 | 14851 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
14697 | 14852 | prevY = Y = anchorY; |
---|
14698 | 14853 | } |
---|
.. | .. |
---|
15195 | 15350 | case 'K': |
---|
15196 | 15351 | KOMPACTTEXTURE ^= true; |
---|
15197 | 15352 | //textures.clear(); |
---|
15198 | | - break; |
---|
15199 | | - case 'P': // Texture Projection macros |
---|
| 15353 | + // break; |
---|
| 15354 | + //case 'P': // Texture Projection macros |
---|
15200 | 15355 | // SAVETEXTURE ^= true; |
---|
15201 | 15356 | macromode = true; |
---|
15202 | 15357 | Udebug = Vdebug = NORMALdebug = false; programInitialized = false; |
---|
.. | .. |
---|
15317 | 15472 | targetLookAt.set(manipCamera.lookAt); |
---|
15318 | 15473 | repaint(); |
---|
15319 | 15474 | break; |
---|
15320 | | - case 'p': |
---|
| 15475 | + case 'P': // p': |
---|
15321 | 15476 | // c'est quoi ca au juste? spherical ^= true; |
---|
15322 | 15477 | Skinshader ^= true; programInitialized = false; |
---|
15323 | 15478 | repaint(); |
---|
.. | .. |
---|
15355 | 15510 | repaint(); |
---|
15356 | 15511 | break; |
---|
15357 | 15512 | case 'O': |
---|
15358 | | - Globals.drawMode = OCCLUSION; // WARNING |
---|
| 15513 | + // Too dangerous. Use menu. Globals.drawMode = OCCLUSION; // WARNING |
---|
15359 | 15514 | repaint(); |
---|
15360 | 15515 | break; |
---|
15361 | 15516 | case 'o': |
---|
15362 | 15517 | OCCLUSION_CULLING ^= true; |
---|
15363 | 15518 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15364 | 15519 | break; |
---|
15365 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15520 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15366 | 15521 | case '1': |
---|
15367 | 15522 | case '2': |
---|
15368 | 15523 | case '3': |
---|
.. | .. |
---|
15372 | 15527 | case '7': |
---|
15373 | 15528 | case '8': |
---|
15374 | 15529 | case '9': |
---|
15375 | | - if (envyoff) |
---|
| 15530 | + if (true) // envyoff) |
---|
15376 | 15531 | { |
---|
15377 | 15532 | BGcolor = (key - '1')/8.f; |
---|
15378 | 15533 | } |
---|
.. | .. |
---|
16077 | 16232 | { |
---|
16078 | 16233 | switch (hitSomething) |
---|
16079 | 16234 | { |
---|
16080 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16235 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
16081 | 16236 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16082 | 16237 | break; |
---|
16083 | 16238 | case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
16084 | 16239 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16085 | 16240 | break; |
---|
16086 | 16241 | case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
16087 | | - gr.drawLine(X, Y, 0, 0); |
---|
| 16242 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16088 | 16243 | break; |
---|
16089 | 16244 | } |
---|
16090 | 16245 | |
---|
.. | .. |
---|
16103 | 16258 | if (hasMarquee) |
---|
16104 | 16259 | { |
---|
16105 | 16260 | gr.setXORMode(Color.white); |
---|
16106 | | - gr.setColor(Color.red); |
---|
| 16261 | + gr.setColor(Color.white); |
---|
16107 | 16262 | if (!firstime) |
---|
16108 | 16263 | { |
---|
16109 | 16264 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
16633 | 16788 | |
---|
16634 | 16789 | return cubemap; |
---|
16635 | 16790 | } |
---|
| 16791 | + |
---|
16636 | 16792 | int bigsphere = -1; |
---|
16637 | 16793 | |
---|
16638 | 16794 | float BGcolor = 0.5f; |
---|
.. | .. |
---|
16641 | 16797 | |
---|
16642 | 16798 | private void DrawSkyBox(GL gl, float ratio) |
---|
16643 | 16799 | { |
---|
16644 | | - if (envyoff || cubemap == null) |
---|
| 16800 | + if (//envyoff || |
---|
| 16801 | + WIREFRAME || |
---|
| 16802 | + cubemap == null) |
---|
16645 | 16803 | { |
---|
16646 | 16804 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16647 | 16805 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16658 | 16816 | gl.glLoadIdentity(); |
---|
16659 | 16817 | gl.glScalef(1,ratio,1); |
---|
16660 | 16818 | |
---|
16661 | | - colorV[0] = 2; |
---|
16662 | | - colorV[1] = 2; |
---|
16663 | | - colorV[2] = 2; |
---|
16664 | | - colorV[3] = 1; |
---|
16665 | | - gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
16666 | | - gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
16667 | | - |
---|
16668 | | - gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16819 | +// colorV[0] = 2; |
---|
| 16820 | +// colorV[1] = 2; |
---|
| 16821 | +// colorV[2] = 2; |
---|
| 16822 | +// colorV[3] = 1; |
---|
| 16823 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16824 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16825 | +// |
---|
| 16826 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
16669 | 16827 | |
---|
16670 | 16828 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16671 | 16829 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
.. | .. |
---|
16679 | 16837 | // GL_NORMAL_MAP texgen mode. Temporarily enabling lighting |
---|
16680 | 16838 | // causes the normals to be sent down. Thanks to Ken Dyke. |
---|
16681 | 16839 | //gl.glEnable(GL.GL_LIGHTING); |
---|
16682 | | - gl.glEnable(GL.GL_LIGHTING); |
---|
| 16840 | + gl.glDisable(GL.GL_LIGHTING); |
---|
16683 | 16841 | |
---|
16684 | 16842 | gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP); |
---|
16685 | 16843 | gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP); |
---|
.. | .. |
---|
16739 | 16897 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16740 | 16898 | |
---|
16741 | 16899 | cubemap.disable(); |
---|
16742 | | - ////cubemap.unbind(); |
---|
| 16900 | + //cubemap.dispose(); |
---|
| 16901 | + |
---|
16743 | 16902 | if (CULLFACE) |
---|
16744 | 16903 | { |
---|
16745 | 16904 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
16795 | 16954 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16796 | 16955 | } |
---|
16797 | 16956 | |
---|
16798 | | - gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
| 16957 | + SetGLNormal(gl, 0.0f, 0.0f, 1.0f); |
---|
16799 | 16958 | |
---|
16800 | 16959 | float step = 2; // 0.1666f; //0.25f; |
---|
16801 | 16960 | float stepv = 2; // step * 1652 / 998; |
---|
.. | .. |
---|
17275 | 17434 | |
---|
17276 | 17435 | public void init(GLAutoDrawable drawable) |
---|
17277 | 17436 | { |
---|
| 17437 | + if (Globals.DEBUG) |
---|
17278 | 17438 | System.out.println("shadow buffer init"); |
---|
17279 | 17439 | |
---|
17280 | 17440 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
17503 | 17663 | gl.glFlush(); |
---|
17504 | 17664 | |
---|
17505 | 17665 | /**/ |
---|
17506 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 17666 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
17507 | 17667 | |
---|
17508 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17668 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17509 | 17669 | |
---|
| 17670 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17671 | + |
---|
| 17672 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17673 | + |
---|
17510 | 17674 | double r = 0, g = 0, b = 0; |
---|
17511 | 17675 | |
---|
17512 | 17676 | double count = 0; |
---|
.. | .. |
---|
17517 | 17681 | |
---|
17518 | 17682 | double FACTOR = 1; |
---|
17519 | 17683 | |
---|
17520 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17684 | + for (int i = 0; i < depths.length; i++) |
---|
17521 | 17685 | { |
---|
17522 | 17686 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17523 | 17687 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17600 | 17764 | |
---|
17601 | 17765 | double scale = ray.z; // 1; // cos |
---|
17602 | 17766 | |
---|
17603 | | - float depth = pixels[newindex]; |
---|
| 17767 | + float depth = depths[newindex]; |
---|
17604 | 17768 | |
---|
17605 | 17769 | /* |
---|
17606 | 17770 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17797 | 17961 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17798 | 17962 | static IntBuffer bigAAbuffer; |
---|
17799 | 17963 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17800 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17964 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17801 | 17965 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17802 | 17966 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17803 | 17967 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17804 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17968 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17969 | + |
---|
| 17970 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17971 | + |
---|
17805 | 17972 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17806 | 17973 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17807 | 17974 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|