Normand Briere
2019-08-21 7ac1b01c591ed65743676b1181d60eb17c5cb69d
U dir and average.
1 files modified
63 ■■■■■ changed files
CameraPane.java 63 ●●●●● patch | view | raw | blame | history
CameraPane.java
....@@ -542,7 +542,8 @@
542542 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
543543 LA.vecCross(obj.v0, obj.v1, obj.v2);
544544 LA.vecNormalize(obj.v2);
545
- 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);
546547 }
547548
548549 // P
....@@ -564,7 +565,7 @@
564565 y += ny * obj.NORMALPUSH;
565566 z += nz * obj.NORMALPUSH;
566567
567
- gl.glNormal3f(nx, ny, nz);
568
+ SetGLNormal(gl, nx, ny, nz);
568569 }
569570 gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
570571 SetColor(obj, pv);
....@@ -596,7 +597,7 @@
596597 y += ny * obj.NORMALPUSH;
597598 z += nz * obj.NORMALPUSH;
598599
599
- gl.glNormal3f(nx, ny, nz);
600
+ SetGLNormal(gl, nx, ny, nz);
600601 }
601602 //System.out.println("vertexq = " + qv.s + ", " + qv.t);
602603 // boolean locked = false;
....@@ -644,7 +645,7 @@
644645 y += ny * obj.NORMALPUSH;
645646 z += nz * obj.NORMALPUSH;
646647
647
- gl.glNormal3f(nx, ny, nz);
648
+ SetGLNormal(gl, nx, ny, nz);
648649 }
649650
650651 // if ((dot&4) == 0)
....@@ -1250,10 +1251,10 @@
12501251 {
12511252 if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
12521253 {
1253
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1254
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
12541255 } else
12551256 {
1256
- gl.glNormal3f(0, 0, 1);
1257
+ SetGLNormal(gl, 0, 0, 1);
12571258 }
12581259
12591260 if (c != null)
....@@ -1277,10 +1278,10 @@
12771278 {
12781279 if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
12791280 {
1280
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1281
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
12811282 } else
12821283 {
1283
- gl.glNormal3f(0, 0, 1);
1284
+ SetGLNormal(gl, 0, 0, 1);
12841285 }
12851286 if (c != null)
12861287 {
....@@ -1305,10 +1306,10 @@
13051306 {
13061307 if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
13071308 {
1308
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1309
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
13091310 } else
13101311 {
1311
- gl.glNormal3f(0, 0, 1);
1312
+ SetGLNormal(gl, 0, 0, 1);
13121313 }
13131314 if (c != null)
13141315 {
....@@ -1490,7 +1491,7 @@
14901491 {
14911492 if (!selectmode)
14921493 {
1493
- 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);
14941495 gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
14951496
14961497 if (flipV)
....@@ -2473,6 +2474,18 @@
24732474 byte[] bytes = bytebuf.array();
24742475
24752476 return CreateBim(bytes, width, height);
2477
+ }
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);
24762489 }
24772490
24782491 /**/
....@@ -12940,13 +12953,17 @@
1294012953 "MOV normald, normal;" +
1294112954 "MOV normals, normal;" +
1294212955
12956
+ "MOV temp, fragment.texcoord[4];" +
12957
+
1294312958 // UV base
1294412959 //"DP3 UP.x,state.matrix.modelview.row[0],Y;" +
1294512960 //"DP3 UP.y,state.matrix.modelview.row[1],Y;" +
1294612961 //"DP3 UP.z,state.matrix.modelview.row[2],Y;" +
12947
- "DP3 UP.x,state.matrix.texture[7].row[0],Y;" +
12948
- "DP3 UP.y,state.matrix.texture[7].row[1],Y;" +
12949
- "DP3 UP.z,state.matrix.texture[7].row[2],Y;" +
12962
+ "DP3 UP.x,state.matrix.texture[7].row[0],temp;" +
12963
+ "DP3 UP.y,state.matrix.texture[7].row[1],temp;" +
12964
+ "DP3 UP.z,state.matrix.texture[7].row[2],temp;" +
12965
+ Normalize("UP") +
12966
+
1295012967 "XPD V, normal, UP;" +
1295112968 Normalize("V") +
1295212969 "XPD U, V, normal;" +
....@@ -12978,8 +12995,12 @@
1297812995
1297912996 "SUB temp, temp, temp2;" +
1298012997
12981
- "TEX texSamp, temp, texture[0], 2D;" +
12982
- "POW texSamp.a, texSamp.a, params6.w;" + // punch through
12998
+ "TEX temp, temp, texture[0], 2D;" +
12999
+ "POW temp.a, temp.a, params6.w;" + // punch through
13000
+
13001
+ "ADD texSamp, temp, texSamp;" +
13002
+ "MUL temp.xyz, half, texSamp;" +
13003
+
1298313004 "MOV alpha, texSamp.aaaa;" +
1298413005
1298513006 // parallax mapping
....@@ -13936,7 +13957,7 @@
1393613957 "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" +
1393713958 "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" +
1393813959 "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" +
13939
- "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" +
13960
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
1394013961 "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" +
1394113962 "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" +
1394213963 //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" +
....@@ -13997,7 +14018,7 @@
1399714018 "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" +
1399814019 "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" +
1399914020 "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" +
14000
- //"MOV result.texcoord, vertex.texcoord;" +
14021
+ //"MOV result.texcoord, vertex.fogcoord;" +
1400114022 "MOV result.texcoord, temp;" +
1400214023 // border fade
1400314024 "MOV result.texcoord[3], vertex.texcoord;" +
....@@ -14044,7 +14065,9 @@
1404414065
1404514066 //"ADD temp.z, temp.z, one;" +
1404614067
14047
- "MOV result.color, temp;"
14068
+ "MOV result.texcoord[4], vertex.attrib[4];" + // U dir
14069
+
14070
+ "MOV result.color, temp;" // Normal
1404814071 : "MOV result.color, vertex.color;") +
1404914072 ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;"
1405014073 : "") +
....@@ -16925,7 +16948,7 @@
1692516948 gl.glScalef(1.0f, -1.0f, 1.0f);
1692616949 }
1692716950
16928
- gl.glNormal3f(0.0f, 0.0f, 1.0f);
16951
+ SetGLNormal(gl, 0.0f, 0.0f, 1.0f);
1692916952
1693016953 float step = 2; // 0.1666f; //0.25f;
1693116954 float stepv = 2; // step * 1652 / 998;