From 6ed65dcb597fb2153cef75bf1845978f1115658c Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Fri, 14 Dec 2018 22:53:55 -0500 Subject: [PATCH] Repair shadow, normal push + attractor mesh. --- CameraPane.java | 126 ++++++++++++++++++++++++++++-------------- 1 files changed, 84 insertions(+), 42 deletions(-) diff --git a/CameraPane.java b/CameraPane.java index a1b29d7..a5a5ed5 100644 --- a/CameraPane.java +++ b/CameraPane.java @@ -7444,6 +7444,8 @@ //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); double scale = lightCamera.SCALE / lightCamera.Distance(); +// PATCH FILLE AUX JEANS + //scale *= lightCamera.shaper_fovy / 25; gl.glScaled(2 * scale, 2 * scale, -scale); gl.glTranslated(0, 0, lightCamera.DECAL); @@ -9092,6 +9094,8 @@ //gl.glFrustum(-0.5*scale, 0.5*scale, -0.5*scale, 0.5*scale, 1, 100); //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); double scale = lightCamera.SCALE / lightCamera.Distance(); +// PATCH FILLE AUX JEANS + //scale *= lightCamera.shaper_fovy / 25; gl.glScaled(2 * scale, 2 * scale, -scale); gl.glTranslated(0, 0, lightCamera.DECAL); @@ -9231,6 +9235,8 @@ { //glu.gluPerspective(lightshaper_fovy, 1, lightshaper_zNear, lightshaper_zFar); double scale = lightCamera.SCALE / lightCamera.Distance(); +// PATCH FILLE AUX JEANS + //scale *= lightCamera.shaper_fovy / 25; gl.glScaled(2 * scale, 2 * scale, -scale); gl.glTranslated(0, 0, lightCamera.DECAL); //System.out.println("DECAL = " + LIGHTDECAL + "; SCALE = " + LIGHTSCALE); @@ -9754,40 +9760,40 @@ selectedpoint.radius = radius; selectedpoint.recalculate(); selectedpoint.material = new cMaterial(); - selectedpoint.material.color = 0.15f; + selectedpoint.material.color = 0.15f; // Yellow selectedpoint.material.modulation = 0.75f; - debugpoint.radius = radius; - debugpoint.recalculate(); - debugpoint.material = new cMaterial(); - debugpoint.material.color = 0.25f; - debugpoint.material.modulation = 0.75f; + debugpointG.radius = radius; + debugpointG.recalculate(); + debugpointG.material = new cMaterial(); + debugpointG.material.color = 0.25f; // Green + debugpointG.material.modulation = 0.75f; - debugpoint2.radius = radius; - debugpoint2.recalculate(); - debugpoint2.material = new cMaterial(); - debugpoint2.material.color = 0.75f; - debugpoint2.material.modulation = 0.75f; + debugpointP.radius = radius; + debugpointP.recalculate(); + debugpointP.material = new cMaterial(); + debugpointP.material.color = 0.75f; // Purple + debugpointP.material.modulation = 0.75f; - debugpoint3.radius = radius; - debugpoint3.recalculate(); - debugpoint3.material = new cMaterial(); - debugpoint3.material.color = 0.5f; - debugpoint3.material.modulation = 0.75f; + debugpointC.radius = radius; + debugpointC.recalculate(); + debugpointC.material = new cMaterial(); + debugpointC.material.color = 0.5f; // Cyan + debugpointC.material.modulation = 0.75f; - debugpoint4.radius = radius; - debugpoint4.recalculate(); - debugpoint4.material = new cMaterial(); - debugpoint4.material.color = 0f; - debugpoint4.material.modulation = 0.75f; + debugpointR.radius = radius; + debugpointR.recalculate(); + debugpointR.material = new cMaterial(); + debugpointR.material.color = 0f; // Red + debugpointR.material.modulation = 0.75f; InitPoints(radius); } selectedpoint.draw(this, /*(Composite)*/ null, false, false); - debugpoint.draw(this, /*(Composite)*/ null, false,false); - debugpoint2.draw(this, /*(Composite)*/ null, false,false); - debugpoint3.draw(this, /*(Composite)*/ null, false,false); - debugpoint4.draw(this, /*(Composite)*/ null, false,false); + debugpointG.draw(this, /*(Composite)*/ null, false,false); + debugpointP.draw(this, /*(Composite)*/ null, false,false); + debugpointC.draw(this, /*(Composite)*/ null, false,false); + debugpointR.draw(this, /*(Composite)*/ null, false,false); // DrawPoints(this); } @@ -9825,12 +9831,14 @@ if (checker != null && drawMode == DEFAULT) { - // BindTexture(IMMORTAL_TEXTURE); + //BindTexture(IMMORTAL_TEXTURE); + BindTextures(checker.GetTextures(), checker.texres); // NEAREST GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); DrawChecker(gl); //checker.Draw(this, null, false); // ReleaseTexture(IMMORTAL_TEXTURE); + ReleaseTextures(checker.GetTextures()); } if (object.parent != null) @@ -10388,6 +10396,7 @@ "PARAM lodbias = { 10,10,10,10 };" + // 20, -2, -20, 1.0 };" + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + "PARAM one2048th = { 0.00048828125, 0.00048828125, 0.00048828125, 1.0 };" + + "PARAM ninetenth = { 0.9, 0.9, 0.9, 1.0 };" + "PARAM almostone = { 0.999, 0.999, 0.999, 1.0 };" + "PARAM c256 = { 256, 256, 256, 1.0 };" + "PARAM c256i = { 0.00390625, 0.00390625, 0.00390625, 1.0 };" + @@ -11302,6 +11311,7 @@ String Shadow(String depth, String shadow) { return "MAX temp.x, ndotl.x, one64th.x;" + + "MIN temp.x, temp.x, ninetenth.x;" + /**/ // Sine "MUL temp.y, temp.x, temp.x;" + @@ -14438,7 +14448,7 @@ gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS); gl.glPushMatrix(); gl.glLoadIdentity(); - PushMatrix(checker.toParent); + //PushMatrix(checker.toParent); gl.glMatrixMode(GL.GL_TEXTURE); gl.glPushMatrix(); @@ -14461,8 +14471,8 @@ gl.glNormal3f(0.0f, 0.0f, 1.0f); - float step = 0.1666f; //0.25f; - float stepv = step * 1652 / 998; + float step = 2; // 0.1666f; //0.25f; + float stepv = 2; // step * 1652 / 998; int i0 = 0; /* @@ -14532,15 +14542,27 @@ //float u = (i+1)/2; //float v = (j+1)/2; - gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2); + if (checker.flipV) + gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1) / 2); + else + gl.glTexCoord2f((i + 1) / 2, (j + 1) / 2); // (1,0) // (i+1+step)/2,(j+1)/2); gl.glVertex3f(i, j, -0.5f); + if (checker.flipV) + gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); + else gl.glTexCoord2f((i + 1 + step) / 2, (j + 1) / 2); // (1,1) // (i+1+step)/2,(j+1+step)/2); gl.glVertex3f(i + step, j, -0.5f); + if (checker.flipV) + gl.glTexCoord2f((i + 1 + step) / 2, 1 - (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); + else gl.glTexCoord2f((i + 1 + step) / 2, (j + 1 + stepv) / 2); // (0,1) //(i+1)/2,(j+1+step)/2); gl.glVertex3f(i + step, j + stepv, -0.5f); + if (checker.flipV) + gl.glTexCoord2f((i + 1) / 2, 1 - (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); + else gl.glTexCoord2f((i + 1) / 2, (j + 1 + stepv) / 2); // (0,0) //(i+1)/2,(j+1)/2); gl.glVertex3f(i, j + stepv, -0.5f); } @@ -14552,7 +14574,7 @@ gl.glMatrixMode(GL.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GL.GL_MODELVIEW); - PopMatrix(null); // checker.toParent); // null); + //PopMatrix(null); // checker.toParent); // null); gl.glPopMatrix(); PopTextureMatrix(checker.toParent); gl.glMatrixMode(GL.GL_TEXTURE); @@ -15115,13 +15137,19 @@ gl.glFlush(); /**/ - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusionsizebuffer); + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); - int[] pixels = occlusionsizebuffer.array(); + float[] pixels = occlusionsizebuffer.array(); double r = 0, g = 0, b = 0; double count = 0; + + gl.glGetDoublev(gl.GL_PROJECTION_MATRIX, tempmat2, 0); + + float mindepth = 1; + + double FACTOR = 1; for (int i = 0; i < pixels.length; i++) { @@ -15206,7 +15234,7 @@ double scale = ray.z; // 1; // cos - int p = pixels[newindex]; + float depth = pixels[newindex]; /* int newindex2 = (x + 1) * OCCLUSION_SIZE + y; @@ -15230,10 +15258,23 @@ scale = (1 - modu) * modv; */ - r += ((p >> 16) & 0xFF) * scale / 255; - g += ((p >> 8) & 0xFF) * scale / 255; - b += (p & 0xFF) * scale / 255; + //r += ((p >> 16) & 0xFF) * scale / 255; + //g += ((p >> 8) & 0xFF) * scale / 255; + //b += (p & 0xFF) * scale / 255; + + if (mindepth > depth) + { + mindepth = depth; + } + double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]); + + double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR); + + r += factor * scale; + g += factor * scale; + b += factor * scale; + count += scale; } @@ -15351,10 +15392,10 @@ //double[] selectedpoint = new double[3]; static Superellipsoid selectedpoint = new Superellipsoid(); static Sphere previousselectedpoint = null; - static Sphere debugpoint = new Sphere(); - static Sphere debugpoint2 = new Sphere(); - static Sphere debugpoint3 = new Sphere(); - static Sphere debugpoint4 = new Sphere(); + static Sphere debugpointG = new Sphere(); + static Sphere debugpointP = new Sphere(); + static Sphere debugpointC = new Sphere(); + static Sphere debugpointR = new Sphere(); static Sphere debugpoints[] = new Sphere[8]; @@ -15407,7 +15448,8 @@ static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); - static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); + //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); + static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); -- Gitblit v1.6.2