.. | .. |
---|
542 | 542 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
543 | 543 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
544 | 544 | 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); |
---|
546 | 547 | } |
---|
547 | 548 | |
---|
548 | 549 | // P |
---|
.. | .. |
---|
564 | 565 | y += ny * obj.NORMALPUSH; |
---|
565 | 566 | z += nz * obj.NORMALPUSH; |
---|
566 | 567 | |
---|
567 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 568 | + SetGLNormal(gl, nx, ny, nz); |
---|
568 | 569 | } |
---|
569 | 570 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
570 | 571 | SetColor(obj, pv); |
---|
.. | .. |
---|
596 | 597 | y += ny * obj.NORMALPUSH; |
---|
597 | 598 | z += nz * obj.NORMALPUSH; |
---|
598 | 599 | |
---|
599 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 600 | + SetGLNormal(gl, nx, ny, nz); |
---|
600 | 601 | } |
---|
601 | 602 | //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
602 | 603 | // boolean locked = false; |
---|
.. | .. |
---|
644 | 645 | y += ny * obj.NORMALPUSH; |
---|
645 | 646 | z += nz * obj.NORMALPUSH; |
---|
646 | 647 | |
---|
647 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 648 | + SetGLNormal(gl, nx, ny, nz); |
---|
648 | 649 | } |
---|
649 | 650 | |
---|
650 | 651 | // if ((dot&4) == 0) |
---|
.. | .. |
---|
1250 | 1251 | { |
---|
1251 | 1252 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1252 | 1253 | { |
---|
1253 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1254 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1254 | 1255 | } else |
---|
1255 | 1256 | { |
---|
1256 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1257 | + SetGLNormal(gl, 0, 0, 1); |
---|
1257 | 1258 | } |
---|
1258 | 1259 | |
---|
1259 | 1260 | if (c != null) |
---|
.. | .. |
---|
1277 | 1278 | { |
---|
1278 | 1279 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1279 | 1280 | { |
---|
1280 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1281 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1281 | 1282 | } else |
---|
1282 | 1283 | { |
---|
1283 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1284 | + SetGLNormal(gl, 0, 0, 1); |
---|
1284 | 1285 | } |
---|
1285 | 1286 | if (c != null) |
---|
1286 | 1287 | { |
---|
.. | .. |
---|
1305 | 1306 | { |
---|
1306 | 1307 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1307 | 1308 | { |
---|
1308 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1309 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1309 | 1310 | } else |
---|
1310 | 1311 | { |
---|
1311 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1312 | + SetGLNormal(gl, 0, 0, 1); |
---|
1312 | 1313 | } |
---|
1313 | 1314 | if (c != null) |
---|
1314 | 1315 | { |
---|
.. | .. |
---|
1490 | 1491 | { |
---|
1491 | 1492 | if (!selectmode) |
---|
1492 | 1493 | { |
---|
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); |
---|
1494 | 1495 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
1495 | 1496 | |
---|
1496 | 1497 | if (flipV) |
---|
.. | .. |
---|
1819 | 1820 | |
---|
1820 | 1821 | display.modelParams7[0] = 0; |
---|
1821 | 1822 | display.modelParams7[1] = 1000; |
---|
1822 | | - display.modelParams7[2] = 0; |
---|
| 1823 | + display.modelParams7[2] = material.parallax; |
---|
1823 | 1824 | display.modelParams7[3] = 0; |
---|
1824 | 1825 | |
---|
1825 | 1826 | //display.modelParams6[0] = 100; // criss de bug de bump |
---|
.. | .. |
---|
2473 | 2474 | byte[] bytes = bytebuf.array(); |
---|
2474 | 2475 | |
---|
2475 | 2476 | 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); |
---|
2476 | 2489 | } |
---|
2477 | 2490 | |
---|
2478 | 2491 | /**/ |
---|
.. | .. |
---|
12593 | 12606 | "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow |
---|
12594 | 12607 | "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias |
---|
12595 | 12608 | "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough |
---|
12596 | | - "PARAM params7 = program.env[7];" + // noise power, opacity power |
---|
| 12609 | + "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax |
---|
12597 | 12610 | "PARAM options0 = program.env[63];" + // fog density, intensity, elevation |
---|
12598 | 12611 | "PARAM options1 = program.env[62];" + // fog rgb color |
---|
12599 | 12612 | "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen |
---|
.. | .. |
---|
12838 | 12851 | "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut |
---|
12839 | 12852 | // mar 2013 ??? "KIL alpha.a;" + |
---|
12840 | 12853 | "MOV alpha, texSamp.aaaa;" + // y;" + |
---|
12841 | | - "KIL alpha.a;" + |
---|
| 12854 | + "KIL alpha.a;" + // not sure with parallax mapping |
---|
12842 | 12855 | /* |
---|
12843 | 12856 | "MUL temp.xy, temp, two;" + |
---|
12844 | 12857 | "TXB bump, temp, texture[0], 2D;" + |
---|
.. | .. |
---|
12924 | 12937 | "SUB bump0, bump0, half;" + |
---|
12925 | 12938 | "ADD bump, bump, bump0;" + |
---|
12926 | 12939 | |
---|
12927 | | - "MOV temp.x, texSamp.a;" + |
---|
12928 | | - "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
12929 | | - //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
12930 | | - "MOV texSamp.a, temp.x;" + |
---|
12931 | | - |
---|
12932 | 12940 | // double-sided |
---|
12933 | 12941 | /**/ |
---|
12934 | 12942 | (doublesided?"DP3 temp.z, normal, eye;" + |
---|
.. | .. |
---|
12945 | 12953 | "MOV normald, normal;" + |
---|
12946 | 12954 | "MOV normals, normal;" + |
---|
12947 | 12955 | |
---|
| 12956 | + "MOV temp, fragment.texcoord[4];" + |
---|
| 12957 | + |
---|
12948 | 12958 | // UV base |
---|
12949 | 12959 | //"DP3 UP.x,state.matrix.modelview.row[0],Y;" + |
---|
12950 | 12960 | //"DP3 UP.y,state.matrix.modelview.row[1],Y;" + |
---|
12951 | 12961 | //"DP3 UP.z,state.matrix.modelview.row[2],Y;" + |
---|
12952 | | - "DP3 UP.x,state.matrix.texture[7].row[0],Y;" + |
---|
12953 | | - "DP3 UP.y,state.matrix.texture[7].row[1],Y;" + |
---|
12954 | | - "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 | + |
---|
12955 | 12967 | "XPD V, normal, UP;" + |
---|
12956 | 12968 | Normalize("V") + |
---|
12957 | 12969 | "XPD U, V, normal;" + |
---|
12958 | 12970 | Normalize("U") + |
---|
12959 | 12971 | |
---|
12960 | 12972 | // parallax mapping |
---|
| 12973 | + |
---|
| 12974 | + "DP3 temp2.x, V, eye;" + |
---|
| 12975 | + "DP3 temp2.y, U, eye;" + |
---|
| 12976 | + "DP3 temp2.z, normal, eye;" + |
---|
| 12977 | + "RCP temp2.z, temp2.z;" + |
---|
| 12978 | + |
---|
| 12979 | + "DP3 temp2.w, texSamp, texSamp;" + // Height |
---|
| 12980 | + "RSQ temp2.w, temp2.w;" + |
---|
| 12981 | + "RCP temp2.w, temp2.w;" + |
---|
| 12982 | + |
---|
| 12983 | + "SUB temp2.w, temp2.w, half;" + |
---|
| 12984 | +// "SGE temp.x, temp2.w, eps.x;" + |
---|
| 12985 | +// "MUL temp2.w, temp2.w, temp.x;" + |
---|
| 12986 | + |
---|
| 12987 | + //"MOV texSamp, U;" + |
---|
| 12988 | + |
---|
| 12989 | + "MUL temp2.z, temp2.z, temp2.w;" + |
---|
| 12990 | + "MUL temp2.z, temp2.z, params7.z;" + // parallax |
---|
| 12991 | + |
---|
| 12992 | + "MUL temp2, temp2, temp2.z;" + |
---|
| 12993 | + |
---|
| 12994 | + "MOV temp, fragment.texcoord[0];" + |
---|
| 12995 | + |
---|
| 12996 | + "SUB temp, temp, temp2;" + |
---|
| 12997 | + |
---|
| 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 texSamp.xyz, half, texSamp;" + |
---|
| 13003 | + |
---|
| 13004 | + "MOV alpha, texSamp.aaaa;" + |
---|
| 13005 | + |
---|
| 13006 | +// parallax mapping |
---|
| 13007 | + |
---|
| 13008 | + "MOV temp.x, texSamp.a;" + |
---|
| 13009 | + "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
| 13010 | + //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
| 13011 | + "MOV texSamp.a, temp.x;" + |
---|
12961 | 13012 | |
---|
12962 | 13013 | //"MOV temp, fragment.texcoord[0];" + |
---|
12963 | 13014 | // |
---|
.. | .. |
---|
13739 | 13790 | /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow |
---|
13740 | 13791 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13741 | 13792 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13742 | | - /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
| 13793 | + /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax |
---|
13743 | 13794 | |
---|
13744 | 13795 | //Object3D.cVector2[] vector2buffer; |
---|
13745 | 13796 | |
---|
.. | .. |
---|
13906 | 13957 | "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" + |
---|
13907 | 13958 | "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" + |
---|
13908 | 13959 | "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" + |
---|
13909 | | - "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" + |
---|
| 13960 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
13910 | 13961 | "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" + |
---|
13911 | 13962 | "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" + |
---|
13912 | 13963 | //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" + |
---|
.. | .. |
---|
13967 | 14018 | "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" + |
---|
13968 | 14019 | "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" + |
---|
13969 | 14020 | "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" + |
---|
13970 | | - //"MOV result.texcoord, vertex.texcoord;" + |
---|
| 14021 | + //"MOV result.texcoord, vertex.fogcoord;" + |
---|
13971 | 14022 | "MOV result.texcoord, temp;" + |
---|
13972 | 14023 | // border fade |
---|
13973 | 14024 | "MOV result.texcoord[3], vertex.texcoord;" + |
---|
.. | .. |
---|
14014 | 14065 | |
---|
14015 | 14066 | //"ADD temp.z, temp.z, one;" + |
---|
14016 | 14067 | |
---|
14017 | | - "MOV result.color, temp;" |
---|
| 14068 | + "MOV result.texcoord[4], vertex.attrib[4];" + // U dir |
---|
| 14069 | + |
---|
| 14070 | + "MOV result.color, temp;" // Normal |
---|
14018 | 14071 | : "MOV result.color, vertex.color;") + |
---|
14019 | 14072 | ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;" |
---|
14020 | 14073 | : "") + |
---|
.. | .. |
---|
16895 | 16948 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16896 | 16949 | } |
---|
16897 | 16950 | |
---|
16898 | | - gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
| 16951 | + SetGLNormal(gl, 0.0f, 0.0f, 1.0f); |
---|
16899 | 16952 | |
---|
16900 | 16953 | float step = 2; // 0.1666f; //0.25f; |
---|
16901 | 16954 | float stepv = 2; // step * 1652 / 998; |
---|