Normand Briere
2019-08-20 564f4d12d93813b5d680fc24d4f118c3886d96ed
Parallax mapping!
4 files modified
78 ■■■■ changed files
CameraPane.java 48 ●●●● patch | view | raw | blame | history
GroupEditor.java 5 ●●●●● patch | view | raw | blame | history
ObjEditor.java 12 ●●●●● patch | view | raw | blame | history
cMaterial.java 13 ●●●●● patch | view | raw | blame | history
CameraPane.java
....@@ -1819,7 +1819,7 @@
18191819
18201820 display.modelParams7[0] = 0;
18211821 display.modelParams7[1] = 1000;
1822
- display.modelParams7[2] = 0;
1822
+ display.modelParams7[2] = material.parallax;
18231823 display.modelParams7[3] = 0;
18241824
18251825 //display.modelParams6[0] = 100; // criss de bug de bump
....@@ -12593,7 +12593,7 @@
1259312593 "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow
1259412594 "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias
1259512595 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
12596
- "PARAM params7 = program.env[7];" + // noise power, opacity power
12596
+ "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax
1259712597 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
1259812598 "PARAM options1 = program.env[62];" + // fog rgb color
1259912599 "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
....@@ -12838,7 +12838,7 @@
1283812838 "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut
1283912839 // mar 2013 ??? "KIL alpha.a;" +
1284012840 "MOV alpha, texSamp.aaaa;" + // y;" +
12841
- "KIL alpha.a;" +
12841
+ "KIL alpha.a;" + // not sure with parallax mapping
1284212842 /*
1284312843 "MUL temp.xy, temp, two;" +
1284412844 "TXB bump, temp, texture[0], 2D;" +
....@@ -12924,11 +12924,6 @@
1292412924 "SUB bump0, bump0, half;" +
1292512925 "ADD bump, bump, bump0;" +
1292612926
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
-
1293212927 // double-sided
1293312928 /**/
1293412929 (doublesided?"DP3 temp.z, normal, eye;" +
....@@ -12958,6 +12953,41 @@
1295812953 Normalize("U") +
1295912954
1296012955 // parallax mapping
12956
+
12957
+ "DP3 temp2.x, V, eye;" +
12958
+ "DP3 temp2.y, U, eye;" +
12959
+ "DP3 temp2.z, normal, eye;" +
12960
+ "RCP temp2.z, temp2.z;" +
12961
+
12962
+ "DP3 temp2.w, texSamp, texSamp;" + // Height
12963
+ "RSQ temp2.w, temp2.w;" +
12964
+ "RCP temp2.w, temp2.w;" +
12965
+
12966
+ "SUB temp2.w, temp2.w, half;" +
12967
+// "SGE temp.x, temp2.w, eps.x;" +
12968
+// "MUL temp2.w, temp2.w, temp.x;" +
12969
+
12970
+ //"MOV texSamp, U;" +
12971
+
12972
+ "MUL temp2.z, temp2.z, temp2.w;" +
12973
+ "MUL temp2.z, temp2.z, params7.z;" + // parallax
12974
+
12975
+ "MUL temp2, temp2, temp2.z;" +
12976
+
12977
+ "MOV temp, fragment.texcoord[0];" +
12978
+
12979
+ "SUB temp, temp, temp2;" +
12980
+
12981
+ "TEX texSamp, temp, texture[0], 2D;" +
12982
+ "POW texSamp.a, texSamp.a, params6.w;" + // punch through
12983
+ "MOV alpha, texSamp.aaaa;" +
12984
+
12985
+// parallax mapping
12986
+
12987
+ "MOV temp.x, texSamp.a;" +
12988
+ "LRP texSamp, params5.x, texSamp, one;" + // texture proportion
12989
+ //"LRP texSamp0, params5.x, texSamp0, one;" +
12990
+ "MOV texSamp.a, temp.x;" +
1296112991
1296212992 //"MOV temp, fragment.texcoord[0];" +
1296312993 //
....@@ -13739,7 +13769,7 @@
1373913769 /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow
1374013770 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1374113771 /*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
13772
+ /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax
1374313773
1374413774 //Object3D.cVector2[] vector2buffer;
1374513775
GroupEditor.java
....@@ -936,6 +936,8 @@
936936 cGridBag currenttab;
937937 //boolean added; // patch for jar
938938
939
+ int totalcount = 0;
940
+
939941 int tabcount = 0;
940942 int colcount = 0;
941943 int rowcount = 0;
....@@ -974,6 +976,7 @@
974976 }
975977
976978 AddTextureButton(path[0], path[1], path[2], ++texturecount, currenttab);
979
+ totalcount++;
977980
978981 if (++colcount >= columns)
979982 {
....@@ -999,6 +1002,8 @@
9991002 container.add(resourcecontainer);
10001003
10011004 Grafreed.ParseResources("textures", this);
1005
+
1006
+ // 935. System.out.println("Total = " + totalcount);
10021007 }
10031008
10041009 void SetupUI2(ObjEditor oe)
ObjEditor.java
....@@ -2682,6 +2682,12 @@
26822682 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
26832683 colorSection.add(backlit);
26842684
2685
+ cGridBag parallax = new cGridBag();
2686
+ parallax.add(parallaxLabel = new JLabel("Parallax")); // , aConstraints);
2687
+ parallaxLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2688
+ parallax.add(parallaxField = new cNumberSlider(this, 0.001, 0.5, -0.25)); // , aConstraints);
2689
+ colorSection.add(parallax);
2690
+
26852691 //panel.add(new JSeparator());
26862692
26872693 //panel.add(globalSection);
....@@ -3733,6 +3739,7 @@
37333739 shadowField.setFloat(mat.shadow);
37343740 textureField.setFloat(mat.texture);
37353741 opacityField.setFloat(mat.opacity);
3742
+ parallaxField.setFloat(mat.parallax + 0.25f);
37363743 fakedepthField.setFloat(mat.fakedepth);
37373744 shadowbiasField.setFloat(mat.shadowbias);
37383745 bumpField.setInteger(1); // dec 2013
....@@ -4957,6 +4964,7 @@
49574964 current.shadow = (float) shadowField.getFloat();
49584965 current.texture = (float) textureField.getFloat();
49594966 current.opacity = (float) opacityField.getFloat();
4967
+ current.parallax = (float) parallaxField.getFloat() - 0.25f;
49604968 current.fakedepth = (float) fakedepthField.getFloat();
49614969 current.shadowbias = (float) shadowbiasField.getFloat();
49624970
....@@ -5011,6 +5019,8 @@
50115019 textureField.SetToolTipValue((mat.texture));
50125020 if (!Equal(opacityField.getFloat(), mat.opacity))
50135021 opacityField.SetToolTipValue((mat.opacity));
5022
+ //if (!Equal(parallaxField.getFloat(), mat.parallax))
5023
+ parallaxField.SetToolTipValue((mat.parallax));
50145024 if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
50155025 fakedepthField.SetToolTipValue((mat.fakedepth));
50165026 if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
....@@ -6267,6 +6277,8 @@
62676277 cNumberSlider textureField;
62686278 JLabel opacityLabel;
62696279 cNumberSlider opacityField;
6280
+ JLabel parallaxLabel;
6281
+ cNumberSlider parallaxField;
62706282 JLabel fakedepthLabel;
62716283 cNumberSlider fakedepthField;
62726284 JLabel shadowbiasLabel;
cMaterial.java
....@@ -34,6 +34,7 @@
3434 shadow = val;
3535 texture = val;
3636 opacity = val;
37
+ parallax = val;
3738 fakedepth = val;
3839 shadowbias = val;
3940 }
....@@ -71,6 +72,7 @@
7172 shadow = mat.shadow;
7273 texture = mat.texture;
7374 opacity = mat.opacity;
75
+ parallax = mat.parallax;
7476 fakedepth = mat.fakedepth;
7577 shadowbias = mat.shadowbias;
7678
....@@ -105,16 +107,17 @@
105107 shadow *= Factor(anchor.shadow, current.shadow);
106108 texture *= Factor(anchor.texture, current.texture);
107109 opacity *= Factor(anchor.opacity, current.opacity);
110
+// if (anchor.parallax == 0)
111
+// anchor.parallax = 0.001f;
112
+ //parallax *= Factor(anchor.parallax, current.parallax);
113
+ parallax = current.parallax;
108114 fakedepth *= Factor(anchor.fakedepth, current.fakedepth);
109115 shadowbias *= Factor(anchor.shadowbias, current.shadowbias);
110116 }
111117
112118 float Factor(float anchor, float current)
113119 {
114
- if (anchor <= 0)
115
- {
116
- assert anchor > 0;
117
- }
120
+ Grafreed.Assert(anchor > 0);
118121
119122 return current / anchor;
120123 }
....@@ -364,6 +367,8 @@
364367 float sheen = 1f, subsurface = 0.001f, bump = 0.75f, aniso = 0.001f, anisoV = 0.001f;
365368 float cameralight = 0.3f, diffuseness = 0.001f, shadow = 5f, texture = 1f, opacity = 1;
366369 float fakedepth = 0.5f, shadowbias = 0.01f; // 0.001f;
370
+
371
+ float parallax = 0;
367372
368373 boolean multiply;
369374