From 09e705dcc42d463c565fbcadde0d31e156448e9d Mon Sep 17 00:00:00 2001 From: Nehon Date: Sun, 25 May 2014 14:59:06 +0200 Subject: [PATCH] Introduced RGB10_A2 Image Format. It offers greater precision for RGB channels at the expense of precision for the alpha channel. This format is convenient for post processing, and especially when gamma correction is turned on. --- jme3-core/src/main/java/com/jme3/post/Filter.java | 5 ++++- jme3-core/src/main/java/com/jme3/texture/Image.java | 13 ++++++++++++- .../java/com/jme3/renderer/jogl/TextureUtil.java | 1 + .../java/com/jme3/renderer/lwjgl/TextureUtil.java | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/post/Filter.java b/jme3-core/src/main/java/com/jme3/post/Filter.java index a15374590..564a1a15f 100644 --- a/jme3-core/src/main/java/com/jme3/post/Filter.java +++ b/jme3-core/src/main/java/com/jme3/post/Filter.java @@ -40,6 +40,7 @@ import com.jme3.renderer.Renderer; import com.jme3.renderer.ViewPort; import com.jme3.renderer.queue.RenderQueue; import com.jme3.texture.FrameBuffer; +import com.jme3.texture.Image; import com.jme3.texture.Image.Format; import com.jme3.texture.Texture; import com.jme3.texture.Texture2D; @@ -201,10 +202,12 @@ public abstract class Filter implements Savable { /** * returns the default pass texture format + * default is {@link Format#RGB10_A2} + * * @return */ protected Format getDefaultPassTextureFormat() { - return Format.RGBA8; + return Format.RGB10_A2; } /** diff --git a/jme3-core/src/main/java/com/jme3/texture/Image.java b/jme3-core/src/main/java/com/jme3/texture/Image.java index 3bbeccca9..6f7682aba 100644 --- a/jme3-core/src/main/java/com/jme3/texture/Image.java +++ b/jme3-core/src/main/java/com/jme3/texture/Image.java @@ -274,7 +274,18 @@ public class Image extends NativeObject implements Savable /*, Cloneable*/ { * 24-bit depth with 8-bit stencil. * Check the cap {@link Caps#PackedDepthStencilBuffer}. */ - Depth24Stencil8(32, true, false, false); + Depth24Stencil8(32, true, false, false), + + /** + * 10 bits each for RGB, 2 for Alpha. This can be a useful format for + * framebuffers, if you do not need a high-precision destination alpha + * value. It carries more color depth, thus preserving subtle + * gradations. They can also be used for normals, though there is no + * signed-normalized version, so you have to do the conversion manually. + * It is also a required format, so you can count on it + * being present. + */ + RGB10_A2(32, false); private int bpp; private boolean isDepth; diff --git a/jme3-jogl/src/main/java/com/jme3/renderer/jogl/TextureUtil.java b/jme3-jogl/src/main/java/com/jme3/renderer/jogl/TextureUtil.java index df248d956..0027a64ad 100644 --- a/jme3-jogl/src/main/java/com/jme3/renderer/jogl/TextureUtil.java +++ b/jme3-jogl/src/main/java/com/jme3/renderer/jogl/TextureUtil.java @@ -139,6 +139,7 @@ public class TextureUtil { setFormat(Format.RGB9E5, GL2GL3.GL_RGB9_E5, GL.GL_RGB, GL2GL3.GL_UNSIGNED_INT_5_9_9_9_REV, false); setFormat(Format.RGB16F_to_RGB111110F, GL.GL_R11F_G11F_B10F, GL.GL_RGB, GL.GL_HALF_FLOAT, false); setFormat(Format.RGB16F_to_RGB9E5, GL2.GL_RGB9_E5, GL.GL_RGB, GL.GL_HALF_FLOAT, false); + setFormat(Format.RGB10_A2, GL.GL_RGB10_A2, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, false); // RGBA formats setFormat(Format.ABGR8, GL.GL_RGBA8, GL2.GL_ABGR_EXT, GL.GL_UNSIGNED_BYTE, false); diff --git a/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/TextureUtil.java b/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/TextureUtil.java index 0563a7f75..72e4fea68 100644 --- a/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/TextureUtil.java +++ b/jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/TextureUtil.java @@ -125,6 +125,7 @@ class TextureUtil { setFormat(Format.RGB9E5, EXTTextureSharedExponent.GL_RGB9_E5_EXT, GL11.GL_RGB, EXTTextureSharedExponent.GL_UNSIGNED_INT_5_9_9_9_REV_EXT, false); setFormat(Format.RGB16F_to_RGB111110F, EXTPackedFloat.GL_R11F_G11F_B10F_EXT, GL11.GL_RGB, ARBHalfFloatPixel.GL_HALF_FLOAT_ARB, false); setFormat(Format.RGB16F_to_RGB9E5, EXTTextureSharedExponent.GL_RGB9_E5_EXT, GL11.GL_RGB, ARBHalfFloatPixel.GL_HALF_FLOAT_ARB, false); + setFormat(Format.RGB10_A2, GL11.GL_RGB10_A2, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, false); // RGBA formats setFormat(Format.ABGR8, GL11.GL_RGBA8, EXTAbgr.GL_ABGR_EXT, GL11.GL_UNSIGNED_BYTE, false);