Normand Briere
2017-05-07 314b34423070cf127464da79a53cddf6b1c38587
CameraPane.java
....@@ -228,7 +228,7 @@
228228 void PushMatrix(double[][] matrix, int count)
229229 {
230230 matrixdepth++;
231
- // GraphreeD.tracein(matrix);
231
+ // GrafreeD.tracein(matrix);
232232 if (matrix == null)
233233 return; // Identity
234234
....@@ -253,13 +253,13 @@
253253
254254 void PushMatrix(double[][] matrix)
255255 {
256
- // GraphreeD.tracein(matrix);
256
+ // GrafreeD.tracein(matrix);
257257 PushMatrix(matrix,1);
258258 }
259259
260260 void PushMatrix()
261261 {
262
- // GraphreeD.tracein(null);
262
+ // GrafreeD.tracein(null);
263263 if (matrixdepth++ < MAXSTACK - 1)
264264 {
265265 currentGL.glPushMatrix();
....@@ -274,7 +274,7 @@
274274 {
275275 --matrixdepth;
276276
277
- // GraphreeD.traceout(inverse);
277
+ // GrafreeD.traceout(inverse);
278278 if (inverse == null)
279279 return; // Identity
280280
....@@ -292,7 +292,7 @@
292292
293293 void PopMatrix()
294294 {
295
- // GraphreeD.traceout(null);
295
+ // GrafreeD.traceout(null);
296296 // inverse == null??
297297 if (--matrixdepth < MAXSTACK - 1)
298298 {
....@@ -491,7 +491,7 @@
491491 System.err.println("LIVE = " + isLIVE());
492492
493493 if (!isLIVE()) // save sound
494
- GraphreeD.savesound = true; // wav.save();
494
+ GrafreeD.savesound = true; // wav.save();
495495 // else
496496 repaint(); // start loop // may 2013
497497 }
....@@ -768,6 +768,8 @@
768768 class CacheTexture
769769 {
770770 com.sun.opengl.util.texture.Texture texture;
771
+ com.sun.opengl.util.texture.TextureData texturedata;
772
+
771773 int resolution;
772774
773775 CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
....@@ -1998,10 +2000,12 @@
19982000 */
19992001 TextureData ReduceTexture(TextureData texturedata, int resolution) // String name)
20002002 {
2003
+ int pixelformat = texturedata.getPixelFormat();
2004
+
20012005 int stride = 1;
2002
- if (texturedata.getPixelFormat() == GetGL().GL_RGB || texturedata.getPixelFormat() == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE)
2006
+ if (pixelformat == GetGL().GL_RGB || pixelformat == GetGL().GL_BGR) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE)
20032007 stride = 3;
2004
- if (texturedata.getPixelFormat() == GetGL().GL_RGBA || texturedata.getPixelFormat() == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA)
2008
+ if (pixelformat == GetGL().GL_RGBA || pixelformat == GetGL().GL_BGRA) // || texturedata.getPixelFormat() == GL.GL_LUMINANCE_ALPHA)
20052009 stride = 4;
20062010
20072011 int width = texturedata.getWidth();
....@@ -6331,7 +6335,7 @@
63316335 {
63326336 bumpdepth--;
63336337
6334
- // GraphreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
6338
+ // GrafreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
63356339 if (bumpstack[bumpdepth] != (texture!=null?texture.texture:null))
63366340 {
63376341 // assert (bumpstack[bumpdepth] == texture);
....@@ -6361,7 +6365,7 @@
63616365 {
63626366 pigmentdepth--;
63636367
6364
- // GraphreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
6368
+ // GrafreeD.trace("POP " + tex + "(" + pigmentdepth + ")" + " : " + pigmentstack[pigmentdepth] + " vs " + texture);
63656369 if (pigmentstack[pigmentdepth] != (texture!=null?texture.texture:null))
63666370 {
63676371 // assert (pigmentstack[pigmentdepth] == texture);
....@@ -6451,7 +6455,7 @@
64516455 return; // true;
64526456 }
64536457
6454
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
6458
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
64556459 {
64566460 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
64576461
....@@ -6665,6 +6669,8 @@
66656669 thetex.texture.dispose();
66666670 textures.remove(texname);
66676671 }
6672
+
6673
+ texture.texturedata = texturedata;
66686674 textures.put(texname, texture);
66696675
66706676 // newtex = true;
....@@ -6681,18 +6687,32 @@
66816687 }
66826688 }
66836689
6690
+ return texture;
6691
+ }
6692
+
6693
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
6694
+ {
6695
+ CacheTexture texture = GetCacheTexture(tex, bump, resolution);
6696
+
66846697 if (bump)
66856698 {
6686
- // GraphreeD.trace("PUSH BUMP " + tex + "(" + bumpdepth + ")" + " : " + texture);
6699
+ // GrafreeD.trace("PUSH BUMP " + tex + "(" + bumpdepth + ")" + " : " + texture);
66876700 bumpstack[bumpdepth++] = texture!=null?texture.texture:null;
66886701 }
66896702 else
66906703 {
6691
- // GraphreeD.trace("PUSH PIGMENT " + tex + "(" + pigmentdepth + ")" + " : " + texture);
6704
+ // GrafreeD.trace("PUSH PIGMENT " + tex + "(" + pigmentdepth + ")" + " : " + texture);
66926705 pigmentstack[pigmentdepth++] = texture!=null?texture.texture:null;
66936706 }
66946707
66956708 return texture!=null?texture.texture:null;
6709
+ }
6710
+
6711
+ com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
6712
+ {
6713
+ CacheTexture texture = GetCacheTexture(tex, bump, resolution);
6714
+
6715
+ return texture!=null?texture.texturedata:null;
66966716 }
66976717
66986718 boolean BindTexture(String tex, boolean bump, int resolution)
....@@ -7572,7 +7592,8 @@
75727592
75737593 float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
75747594 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
7575
- float[] options3 = new float[]{1, 1, 1, 1}; // fog color. image intensity
7595
+ float[] options3 = new float[]{1, 1, 1, 0}; // fog color
7596
+ float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
75767597
75777598 static int imagecount = 0; // movie generation
75787599
....@@ -7610,14 +7631,14 @@
76107631
76117632 //System.out.println("start frame");
76127633 gl.glClear(gl.GL_ACCUM_BUFFER_BIT);
7613
- for (jitter = 0; jitter < ACSIZE; jitter++) //, GraphreeD.wav.cursor += LIVE ? 735 : 0)
7634
+ for (jitter = 0; jitter < ACSIZE; jitter++) //, GrafreeD.wav.cursor += LIVE ? 735 : 0)
76147635 {
76157636 framecount++;
76167637
76177638 if (CameraPane.tickcount > 0)
76187639 CameraPane.tickcount--;
76197640
7620
-// GraphreeD.wav.cursor += 735; // 44100 Hz / 120 Hz * 2 (for 16 bits)
7641
+// GrafreeD.wav.cursor += 735; // 44100 Hz / 120 Hz * 2 (for 16 bits)
76217642 // restartframe = true;
76227643 if (options1[2] > 100 && (jitter%2==0))
76237644 {
....@@ -7905,7 +7926,7 @@
79057926
79067927 if (!BOXMODE)
79077928 {
7908
- System.out.println("image: " + fullname + " (" + (GraphreeD.wav.cursor / 735 / 4) + ")");
7929
+ System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
79097930 }
79107931
79117932 if (!BOXMODE)
....@@ -7933,7 +7954,7 @@
79337954 {
79347955 if (ACSIZE > 1)
79357956 {
7936
- // System.err.println("image #" + (GraphreeD.wav.cursor / 735 / 4));
7957
+ // System.err.println("image #" + (GrafreeD.wav.cursor / 735 / 4));
79377958 }
79387959 }
79397960
....@@ -7943,7 +7964,7 @@
79437964 ABORTED = false;
79447965 }
79457966 else
7946
- GraphreeD.wav.cursor += 735 * ACSIZE;
7967
+ GrafreeD.wav.cursor += 735 * ACSIZE;
79477968
79487969 if (false)
79497970 {
....@@ -8613,11 +8634,11 @@
86138634
86148635 public void display(GLAutoDrawable drawable)
86158636 {
8616
- if (GraphreeD.savesound && GraphreeD.hassound)
8637
+ if (GrafreeD.savesound && GrafreeD.hassound)
86178638 {
8618
- GraphreeD.wav.save();
8619
- GraphreeD.savesound = false;
8620
- GraphreeD.hassound = false;
8639
+ GrafreeD.wav.save();
8640
+ GrafreeD.savesound = false;
8641
+ GrafreeD.hassound = false;
86218642 }
86228643 // if (DEBUG_SELECTION)
86238644 // {
....@@ -8747,7 +8768,7 @@
87478768 Object3D theobject = object;
87488769 Object3D theparent = object.parent;
87498770 object.parent = null;
8750
- object = (Object3D)GraphreeD.clone(object);
8771
+ object = (Object3D)GrafreeD.clone(object);
87518772 object.Stripify();
87528773 if (theobject.selection == null || theobject.selection.Size() == 0)
87538774 theobject.PreprocessOcclusion(this);
....@@ -8766,7 +8787,7 @@
87668787 if (!IsFrozen())
87678788 {
87688789 // dec 2012
8769
- if (!(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0))
8790
+ if (!ambientOcclusion && !(!flash && !lightMode && drawMode == DEFAULT && ANTIALIAS > 0))
87708791 {
87718792 framecount++;
87728793 shadowbuffer.display();
....@@ -9361,6 +9382,7 @@
93619382
93629383 gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 63, options2, 0);
93639384 gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 62, options3, 0);
9385
+ gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 61, options4, 0);
93649386
93659387 options2[0] *= renderCamera.Distance();
93669388
....@@ -9642,8 +9664,8 @@
96429664 e.printStackTrace();
96439665 }
96449666
9645
- if (GraphreeD.RENDERME > 0)
9646
- GraphreeD.RENDERME--; // mechante magouille
9667
+ if (GrafreeD.RENDERME > 0)
9668
+ GrafreeD.RENDERME--; // mechante magouille
96479669
96489670 ONESTEP = false;
96499671 }
....@@ -9716,7 +9738,7 @@
97169738 BindTextures(DEFAULT_TEXTURES, 2);
97179739 }
97189740 //System.out.println("--> " + stackdepth);
9719
-// GraphreeD.traceon();
9741
+// GrafreeD.traceon();
97209742
97219743 // DRAW
97229744 object.draw(this, /*(Composite)*/ object, false, false);
....@@ -9747,17 +9769,31 @@
97479769 debugpoint2.material.color = 0.75f;
97489770 debugpoint2.material.modulation = 0.75f;
97499771
9772
+ debugpoint3.radius = radius;
9773
+ debugpoint3.recalculate();
9774
+ debugpoint3.material = new cMaterial();
9775
+ debugpoint3.material.color = 0.5f;
9776
+ debugpoint3.material.modulation = 0.75f;
9777
+
9778
+ debugpoint4.radius = radius;
9779
+ debugpoint4.recalculate();
9780
+ debugpoint4.material = new cMaterial();
9781
+ debugpoint4.material.color = 0f;
9782
+ debugpoint4.material.modulation = 0.75f;
9783
+
97509784 InitPoints(radius);
97519785 }
97529786 selectedpoint.draw(this, /*(Composite)*/ null, false, false);
9753
- //debugpoint.draw(this, /*(Composite)*/ null, false);
9754
- //debugpoint2.draw(this, /*(Composite)*/ null, false);
9755
- DrawPoints(this);
9787
+ debugpoint.draw(this, /*(Composite)*/ null, false,false);
9788
+ debugpoint2.draw(this, /*(Composite)*/ null, false,false);
9789
+ debugpoint3.draw(this, /*(Composite)*/ null, false,false);
9790
+ debugpoint4.draw(this, /*(Composite)*/ null, false,false);
9791
+ // DrawPoints(this);
97569792 }
97579793
97589794 // debugstuff.draw(this, /*(Composite)*/ null, false);
97599795 }
9760
-// GraphreeD.traceoff();
9796
+// GrafreeD.traceoff();
97619797 //System.out.println(stackdepth);
97629798 if (drawMode == 0)
97639799 {
....@@ -10253,7 +10289,7 @@
1025310289 return;
1025410290 }
1025510291
10256
- if (obj instanceof CheckerIG)
10292
+ if (obj instanceof Checker)
1025710293 {
1025810294 checker = obj;
1025910295
....@@ -10325,11 +10361,13 @@
1032510361 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
1032610362 "PARAM params7 = program.env[7];" + // noise power, opacity power
1032710363 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
10328
- "PARAM options1 = program.env[62];" + // fog rgb color, image intensity
10364
+ "PARAM options1 = program.env[62];" + // fog rgb color
10365
+ "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
1032910366 "PARAM pointlight = program.env[127];" + // ...
1033010367 "PARAM zero = { 0.0, 0.0, 0.0, 0.0 };" +
1033110368 "PARAM halfhalf = { 0.25, 0.25, 0.25, 1.0 };" +
1033210369 "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" +
10370
+ "PARAM threequarter = { 0.75, 0.75, 0.75, 1.0 };" +
1033310371 "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" +
1033410372 "PARAM ten = { 10, 10, 10, 1.0 };" +
1033510373 "PARAM one3rd = { 0.5, 0.33333333333, 0.333333333, 1.0 };" +
....@@ -10390,6 +10428,10 @@
1039010428 "TEMP R1;" +
1039110429 "TEMP R2;" +
1039210430 "TEMP R3;" +
10431
+ "TEMP min;" +
10432
+ "TEMP max;" +
10433
+ "TEMP average;" +
10434
+ "TEMP saturation;" +
1039310435 "TEMP keep1;" +
1039410436 "TEMP keep2;" +
1039510437 "TEMP keep3;" +
....@@ -10920,10 +10962,40 @@
1092010962
1092110963 // skin?
1092210964 // Saturation for skin
10923
- /**/ // c'est ici
10924
- (Skinshader? "DP3 temp.x, final,one;" +
10965
+ /**/
10966
+ (Skinshader?
10967
+ "DP3 average.x, final,one;" +
10968
+ "MUL average, one3rd.xxxx,average.xxxx;" +
10969
+
10970
+ "MIN min.x, final.x,final.y;" +
10971
+ "MIN min.x, min.x,final.z;" +
10972
+
10973
+ "MAX max.x, final.x,final.y;" +
10974
+ "MAX max.x, max.x,final.z;" +
10975
+ "MOV max, max.xxxx;" +
10976
+
10977
+ "SUB saturation, max, final;" +
10978
+
10979
+ "ADD temp.x, max.x, one10th.x;" +
10980
+ "RCP temp.x, temp.x;" +
10981
+ "MUL temp.x, temp.x, half.x;" +
10982
+ "MUL saturation, saturation, temp.xxxx;" +
10983
+
10984
+ "DP3 ndotl.x, normald, light;" +
10985
+ "MAX ndotl.x, ndotl.x, -ndotl.x;" +
10986
+
10987
+ "SUB temp.x, one.x, ndotl.x;" +
10988
+ "ADD temp.x, temp.x, options2.z;" + // lightsheen
10989
+ "ADD temp.y, one.y, options2.y;" + // sursurface
10990
+ "MUL temp.x, temp.x, temp.y;" +
10991
+
10992
+ "MUL saturation, saturation, temp.xxxx;" +
10993
+ "SUB_SAT temp, max, saturation;" +
10994
+/**
10995
+ "DP3 temp.x, final,one;" +
1092510996 "MUL R2, one3rd.xxxx,temp.xxxx;" +
10926
- "SUB temp, final,R2;" +
10997
+ "SUB temp, final, R2;" +
10998
+
1092710999 // using light angle
1092811000 "DP3 ndotl.x, normald,light;" +
1092911001 //"SLT ndotl.y, ndotl.x, zero.x;" +
....@@ -10936,7 +11008,6 @@
1093611008 // using light intensity
1093711009 "MOV ndotl.z, R2.x;" +
1093811010 "MUL ndotl.z, ndotl.z, ndotl.z;" + // tuning...
10939
-
1094011011 // june 2014
1094111012 "MAD R1.x, ndotl.z,slope.y,one.x;" +
1094211013 // "SUB ndotl.x, one.x, ndotl.x;" +
....@@ -10948,6 +11019,7 @@
1094811019 //"MUL R2.y, shadow.x,R2.y;" + // avril 2014
1094911020
1095011021 "MAD temp.x, R2.y, ndotl.y, temp.x;" + // red shift (skin)
11022
+/**/
1095111023
1095211024 // "ADD final, R2,temp;" +
1095311025 "MOV final, temp;"
....@@ -11037,7 +11109,7 @@
1103711109 /**/
1103811110 // HDR
1103911111 "MOV temp.z, final.a;" +
11040
- "MUL final, final,options1.w;" +
11112
+ "MUL final, final,options2.x;" +
1104111113 "MOV final.a, temp.z;" +
1104211114 /**/
1104311115
....@@ -11074,10 +11146,17 @@
1107411146 "MOV final.z, zero.x;" +
1107511147 "MOV final.a, one.w;":""
1107611148 ) +
11149
+ /*
1107711150 (NORMALdebug?"MOV final.x, normal.x;" +
1107811151 "MOV final.y, normal.y;" +
1107911152 "MOV final.z, normal.z;" +
1108011153 "MOV final.a, one.w;":""
11154
+ ) +
11155
+ */
11156
+ (NORMALdebug?"SUB final.x, one.x, final.x;" +
11157
+ "SUB final.y, one.x, final.y;" +
11158
+ "SUB final.z, one.x, final.z;" +
11159
+ "MOV final.a, final.a;":""
1108111160 ) +
1108211161 // "MOV final, bumpmap;" +
1108311162 "MOV result.color, final;" +
....@@ -14682,16 +14761,16 @@
1468214761 System.out.println("; fromto " + sel + " " + Trunk(previousselectedpoint.toParent[3][0]) + " " + Trunk(previousselectedpoint.toParent[3][2]) + " " + Trunk(selectedpoint.toParent[3][0]) + " " + Trunk(selectedpoint.toParent[3][2]));
1468314762 }
1468414763
14685
- previousselectedpoint = (Sphere) GraphreeD.clone(selectedpoint);
14764
+ previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
1468614765 }
1468714766 }
1468814767
1468914768 if (!movingcamera && !PAINTMODE)
1469014769 object.editWindow.ScreenFitPoint(); // fev 2014
1469114770
14692
- if (PAINTMODE && GraphreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
14771
+ if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1469314772 {
14694
- Object3D paintobj = GraphreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
14773
+ Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1469514774
1469614775 Object3D group = new Object3D("inst" + paintcount++);
1469714776
....@@ -15265,6 +15344,8 @@
1526515344 static Sphere previousselectedpoint = null;
1526615345 static Sphere debugpoint = new Sphere();
1526715346 static Sphere debugpoint2 = new Sphere();
15347
+ static Sphere debugpoint3 = new Sphere();
15348
+ static Sphere debugpoint4 = new Sphere();
1526815349
1526915350 static Sphere debugpoints[] = new Sphere[8];
1527015351