Normand Briere
2018-10-27 d34fd9341c61d13677e029cb187d4dacff5e44ea
CameraPane.java
....@@ -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>();