Normand Briere
2018-10-27 d34fd9341c61d13677e029cb187d4dacff5e44ea
CameraPane.java
....@@ -7693,7 +7693,7 @@
76937693
76947694 if (renderCamera != lightCamera)
76957695 for (int count = parentcam.GetTransformCount(); --count>=0;)
7696
- LA.matConcat(parentcam.toParent, matrix, matrix);
7696
+ LA.matConcat(matrix, parentcam.toParent, matrix);
76977697
76987698 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
76997699
....@@ -7709,7 +7709,7 @@
77097709
77107710 if (renderCamera != lightCamera)
77117711 for (int count = parentcam.GetTransformCount(); --count>=0;)
7712
- LA.matConcat(matrix, parentcam.fromParent, matrix);
7712
+ LA.matConcat(parentcam.fromParent, matrix, matrix);
77137713
77147714 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
77157715
....@@ -8915,7 +8915,7 @@
89158915 // if (parentcam != renderCamera) // not a light
89168916 if (cam != lightCamera)
89178917 for (int count = parentcam.GetTransformCount(); --count>=0;)
8918
- LA.matConcat(parentcam.toParent, matrix, matrix);
8918
+ LA.matConcat(matrix, parentcam.toParent, matrix);
89198919
89208920 for (int j = 0; j < 4; j++)
89218921 {
....@@ -8930,7 +8930,7 @@
89308930 // if (parentcam != renderCamera) // not a light
89318931 if (cam != lightCamera)
89328932 for (int count = parentcam.GetTransformCount(); --count>=0;)
8933
- LA.matConcat(matrix, parentcam.fromParent, matrix);
8933
+ LA.matConcat(parentcam.fromParent, matrix, matrix);
89348934
89358935 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
89368936
....@@ -9754,7 +9754,7 @@
97549754 selectedpoint.radius = radius;
97559755 selectedpoint.recalculate();
97569756 selectedpoint.material = new cMaterial();
9757
- selectedpoint.material.color = 0.25f;
9757
+ selectedpoint.material.color = 0.15f;
97589758 selectedpoint.material.modulation = 0.75f;
97599759
97609760 debugpoint.radius = radius;
....@@ -15115,13 +15115,19 @@
1511515115 gl.glFlush();
1511615116
1511715117 /**/
15118
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer);
15118
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
1511915119
15120
- int[] pixels = occlusionsizebuffer.array();
15120
+ float[] pixels = occlusionsizebuffer.array();
1512115121
1512215122 double r = 0, g = 0, b = 0;
1512315123
1512415124 double count = 0;
15125
+
15126
+ gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0);
15127
+
15128
+ float mindepth = 1;
15129
+
15130
+ double FACTOR = 1;
1512515131
1512615132 for (int i = 0; i < pixels.length; i++)
1512715133 {
....@@ -15206,7 +15212,7 @@
1520615212
1520715213 double scale = ray.z; // 1; // cos
1520815214
15209
- int p = pixels[newindex];
15215
+ float depth = pixels[newindex];
1521015216
1521115217 /*
1521215218 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -15230,10 +15236,23 @@
1523015236 scale = (1 - modu) * modv;
1523115237 */
1523215238
15233
- r += ((p >> 16) & 0xFF) * scale / 255;
15234
- g += ((p >> 8) & 0xFF) * scale / 255;
15235
- b += (p & 0xFF) * scale / 255;
15239
+ //r += ((p >> 16) & 0xFF) * scale / 255;
15240
+ //g += ((p >> 8) & 0xFF) * scale / 255;
15241
+ //b += (p & 0xFF) * scale / 255;
15242
+
15243
+ if (mindepth > depth)
15244
+ {
15245
+ mindepth = depth;
15246
+ }
1523615247
15248
+ double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]);
15249
+
15250
+ double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR);
15251
+
15252
+ r += factor * scale;
15253
+ g += factor * scale;
15254
+ b += factor * scale;
15255
+
1523715256 count += scale;
1523815257 }
1523915258
....@@ -15407,7 +15426,8 @@
1540715426 static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1540815427 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1540915428 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
15410
- static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
15429
+ //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
15430
+ static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
1541115431 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1541215432 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1541315433 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();