Introduced a new Enum ColorSpace.
One can now mark a texture param in a material definition as linear by using -Linear at the end of the parameter declaration (case insensitive). An Image bound to a material texture param in a linear color space will have its ColorSpace set to linear when bound to the material by mat.setTexture("name", texture); Added the -LINEAR flag to all texture param that needed it in stock materials (lighting.j3md, terrainLighting.j3md, different Filter materials).
This commit is contained in:
parent
e4ba4e9e9e
commit
8ff6f8df24
@ -38,12 +38,14 @@ import com.jme3.export.OutputCapsule;
|
|||||||
import com.jme3.renderer.Renderer;
|
import com.jme3.renderer.Renderer;
|
||||||
import com.jme3.shader.VarType;
|
import com.jme3.shader.VarType;
|
||||||
import com.jme3.texture.Texture;
|
import com.jme3.texture.Texture;
|
||||||
|
import com.jme3.texture.image.ColorSpace;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class MatParamTexture extends MatParam {
|
public class MatParamTexture extends MatParam {
|
||||||
|
|
||||||
private Texture texture;
|
private Texture texture;
|
||||||
private int unit;
|
private int unit;
|
||||||
|
private ColorSpace colorSpace;
|
||||||
|
|
||||||
public MatParamTexture(VarType type, String name, Texture texture, int unit) {
|
public MatParamTexture(VarType type, String name, Texture texture, int unit) {
|
||||||
super(type, name, texture, null);
|
super(type, name, texture, null);
|
||||||
@ -51,6 +53,13 @@ public class MatParamTexture extends MatParam {
|
|||||||
this.unit = unit;
|
this.unit = unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MatParamTexture(VarType type, String name, Texture texture, int unit, ColorSpace colorSpace) {
|
||||||
|
super(type, name, texture, null);
|
||||||
|
this.texture = texture;
|
||||||
|
this.unit = unit;
|
||||||
|
this.colorSpace = colorSpace;
|
||||||
|
}
|
||||||
|
|
||||||
public MatParamTexture() {
|
public MatParamTexture() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +81,23 @@ public class MatParamTexture extends MatParam {
|
|||||||
this.texture = (Texture) value;
|
this.texture = (Texture) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return the color space required by this texture param
|
||||||
|
*/
|
||||||
|
public ColorSpace getColorSpace() {
|
||||||
|
return colorSpace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to {@link ColorSpace#Linear} if the texture color space has to be forced to linear
|
||||||
|
* instead of sRGB
|
||||||
|
* @param colorSpace @see ColorSpace
|
||||||
|
*/
|
||||||
|
public void setColorSpace(ColorSpace colorSpace) {
|
||||||
|
this.colorSpace = colorSpace;
|
||||||
|
}
|
||||||
|
|
||||||
public void setUnit(int unit) {
|
public void setUnit(int unit) {
|
||||||
this.unit = unit;
|
this.unit = unit;
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,7 @@ import com.jme3.shader.Uniform;
|
|||||||
import com.jme3.shader.UniformBindingManager;
|
import com.jme3.shader.UniformBindingManager;
|
||||||
import com.jme3.shader.VarType;
|
import com.jme3.shader.VarType;
|
||||||
import com.jme3.texture.Texture;
|
import com.jme3.texture.Texture;
|
||||||
|
import com.jme3.texture.image.ColorSpace;
|
||||||
import com.jme3.util.ListMap;
|
import com.jme3.util.ListMap;
|
||||||
import com.jme3.util.TempVars;
|
import com.jme3.util.TempVars;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -536,6 +537,13 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
|
|||||||
checkSetParam(type, name);
|
checkSetParam(type, name);
|
||||||
MatParamTexture val = getTextureParam(name);
|
MatParamTexture val = getTextureParam(name);
|
||||||
if (val == null) {
|
if (val == null) {
|
||||||
|
MatParamTexture paramDef = (MatParamTexture)def.getMaterialParam(name);
|
||||||
|
if(paramDef.getColorSpace() != null && paramDef.getColorSpace() != value.getImage().getColorSpace()){
|
||||||
|
value.getImage().setColorSpace(paramDef.getColorSpace());
|
||||||
|
logger.log(Level.FINE, "Material parameter {0} needs a {1} texture, texture {2} was switched to {3} color space.", new Object[]{name, paramDef.getColorSpace().toString(), value.getName(), value.getImage().getColorSpace().name()});
|
||||||
|
}else if(paramDef.getColorSpace() == null && value.getName() != null && value.getImage().getColorSpace() == ColorSpace.Linear){
|
||||||
|
logger.log(Level.WARNING, "texture {0} has a {1} color space, but material parameter {2} has no color space requirement, this may lead to unexpected behavior.\n Cheack wether the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().", new Object[]{value.getName(), value.getImage().getColorSpace().name(),name});
|
||||||
|
}
|
||||||
paramValues.put(name, new MatParamTexture(type, name, value, nextTexUnit++));
|
paramValues.put(name, new MatParamTexture(type, name, value, nextTexUnit++));
|
||||||
} else {
|
} else {
|
||||||
val.setTextureValue(value);
|
val.setTextureValue(value);
|
||||||
|
@ -33,6 +33,7 @@ package com.jme3.material;
|
|||||||
|
|
||||||
import com.jme3.asset.AssetManager;
|
import com.jme3.asset.AssetManager;
|
||||||
import com.jme3.shader.VarType;
|
import com.jme3.shader.VarType;
|
||||||
|
import com.jme3.texture.image.ColorSpace;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -124,6 +125,20 @@ public class MaterialDef {
|
|||||||
matParams.put(name, new MatParam(type, name, value, ffBinding));
|
matParams.put(name, new MatParam(type, name, value, ffBinding));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a new material parameter.
|
||||||
|
*
|
||||||
|
* @param type Type of the parameter
|
||||||
|
* @param name Name of the parameter
|
||||||
|
* @param value Default value of the parameter
|
||||||
|
* @param ffBinding Fixed function binding for the parameter
|
||||||
|
* @param colorSpace the color space of the texture required by thiis texture param
|
||||||
|
* @see ColorSpace
|
||||||
|
*/
|
||||||
|
public void addMaterialParamTexture(VarType type, String name, ColorSpace colorSpace) {
|
||||||
|
matParams.put(name, new MatParamTexture(type, name, null , 0, colorSpace));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the material parameter with the given name.
|
* Returns the material parameter with the given name.
|
||||||
*
|
*
|
||||||
|
@ -34,6 +34,7 @@ package com.jme3.texture;
|
|||||||
import com.jme3.export.*;
|
import com.jme3.export.*;
|
||||||
import com.jme3.renderer.Caps;
|
import com.jme3.renderer.Caps;
|
||||||
import com.jme3.renderer.Renderer;
|
import com.jme3.renderer.Renderer;
|
||||||
|
import com.jme3.texture.image.ColorSpace;
|
||||||
import com.jme3.util.BufferUtils;
|
import com.jme3.util.BufferUtils;
|
||||||
import com.jme3.util.NativeObject;
|
import com.jme3.util.NativeObject;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -334,7 +335,7 @@ public class Image extends NativeObject implements Savable /*, Cloneable*/ {
|
|||||||
protected ArrayList<ByteBuffer> data;
|
protected ArrayList<ByteBuffer> data;
|
||||||
protected transient Object efficientData;
|
protected transient Object efficientData;
|
||||||
protected int multiSamples = 1;
|
protected int multiSamples = 1;
|
||||||
protected boolean srgb;
|
protected ColorSpace colorSpace = null;
|
||||||
// protected int mipOffset = 0;
|
// protected int mipOffset = 0;
|
||||||
|
|
||||||
// attributes relating to GL object
|
// attributes relating to GL object
|
||||||
@ -448,12 +449,11 @@ public class Image extends NativeObject implements Savable /*, Cloneable*/ {
|
|||||||
* the image data.
|
* the image data.
|
||||||
* @param mipMapSizes
|
* @param mipMapSizes
|
||||||
* the array of mipmap sizes, or null for no mipmaps.
|
* the array of mipmap sizes, or null for no mipmaps.
|
||||||
* @param isSrgb
|
* @param colorSpace
|
||||||
* true if the image in is sRGB color space false for linear
|
* @see ColorSpace the colorSpace of the image
|
||||||
*color space
|
|
||||||
*/
|
*/
|
||||||
public Image(Format format, int width, int height, int depth, ArrayList<ByteBuffer> data,
|
public Image(Format format, int width, int height, int depth, ArrayList<ByteBuffer> data,
|
||||||
int[] mipMapSizes, boolean isSrgb) {
|
int[] mipMapSizes, ColorSpace colorSpace) {
|
||||||
|
|
||||||
this();
|
this();
|
||||||
|
|
||||||
@ -470,7 +470,7 @@ public class Image extends NativeObject implements Savable /*, Cloneable*/ {
|
|||||||
this.data = data;
|
this.data = data;
|
||||||
this.depth = depth;
|
this.depth = depth;
|
||||||
this.mipMapSizes = mipMapSizes;
|
this.mipMapSizes = mipMapSizes;
|
||||||
this.srgb = isSrgb;
|
this.colorSpace = colorSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -486,7 +486,7 @@ public class Image extends NativeObject implements Savable /*, Cloneable*/ {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public Image(Format format, int width, int height, int depth, ArrayList<ByteBuffer> data,
|
public Image(Format format, int width, int height, int depth, ArrayList<ByteBuffer> data,
|
||||||
int[] mipMapSizes) {
|
int[] mipMapSizes) {
|
||||||
this(format, width, height, depth, data, mipMapSizes, false);
|
this(format, width, height, depth, data, mipMapSizes, ColorSpace.Linear);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -503,12 +503,11 @@ public class Image extends NativeObject implements Savable /*, Cloneable*/ {
|
|||||||
* the image data.
|
* the image data.
|
||||||
* @param mipMapSizes
|
* @param mipMapSizes
|
||||||
* the array of mipmap sizes, or null for no mipmaps.
|
* the array of mipmap sizes, or null for no mipmaps.
|
||||||
* @param isSrgb
|
* @param colorSpace
|
||||||
* true if the image in is sRGB color space false for linear
|
* @see ColorSpace the colorSpace of the image
|
||||||
* color space
|
|
||||||
*/
|
*/
|
||||||
public Image(Format format, int width, int height, ByteBuffer data,
|
public Image(Format format, int width, int height, ByteBuffer data,
|
||||||
int[] mipMapSizes, boolean isSrgb) {
|
int[] mipMapSizes, ColorSpace colorSpace) {
|
||||||
|
|
||||||
this();
|
this();
|
||||||
|
|
||||||
@ -527,7 +526,7 @@ public class Image extends NativeObject implements Savable /*, Cloneable*/ {
|
|||||||
this.data.add(data);
|
this.data.add(data);
|
||||||
}
|
}
|
||||||
this.mipMapSizes = mipMapSizes;
|
this.mipMapSizes = mipMapSizes;
|
||||||
this.srgb = isSrgb;
|
this.colorSpace = colorSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -542,7 +541,7 @@ public class Image extends NativeObject implements Savable /*, Cloneable*/ {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public Image(Format format, int width, int height, ByteBuffer data,
|
public Image(Format format, int width, int height, ByteBuffer data,
|
||||||
int[] mipMapSizes) {
|
int[] mipMapSizes) {
|
||||||
this(format, width, height, data, mipMapSizes, false);
|
this(format, width, height, data, mipMapSizes, ColorSpace.Linear);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -557,12 +556,11 @@ public class Image extends NativeObject implements Savable /*, Cloneable*/ {
|
|||||||
* the height of the image.
|
* the height of the image.
|
||||||
* @param data
|
* @param data
|
||||||
* the image data.
|
* the image data.
|
||||||
* @param isSrgb
|
* @param colorSpace
|
||||||
* true if the image in is sRGB color space false for linear
|
* @see ColorSpace the colorSpace of the image
|
||||||
* color space
|
|
||||||
*/
|
*/
|
||||||
public Image(Format format, int width, int height, int depth, ArrayList<ByteBuffer> data, boolean isSrgb) {
|
public Image(Format format, int width, int height, int depth, ArrayList<ByteBuffer> data, ColorSpace colorSpace) {
|
||||||
this(format, width, height, depth, data, null, isSrgb);
|
this(format, width, height, depth, data, null, colorSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -576,7 +574,7 @@ public class Image extends NativeObject implements Savable /*, Cloneable*/ {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Image(Format format, int width, int height, int depth, ArrayList<ByteBuffer> data) {
|
public Image(Format format, int width, int height, int depth, ArrayList<ByteBuffer> data) {
|
||||||
this(format, width, height, depth, data, false);
|
this(format, width, height, depth, data, ColorSpace.Linear);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -591,12 +589,11 @@ public class Image extends NativeObject implements Savable /*, Cloneable*/ {
|
|||||||
* the height of the image.
|
* the height of the image.
|
||||||
* @param data
|
* @param data
|
||||||
* the image data.
|
* the image data.
|
||||||
* @param isSrgb
|
* @param colorSpace
|
||||||
* true if the image in is sRGB color space false for linear
|
* @see ColorSpace the colorSpace of the image
|
||||||
* color space
|
|
||||||
*/
|
*/
|
||||||
public Image(Format format, int width, int height, ByteBuffer data, boolean isSrgb) {
|
public Image(Format format, int width, int height, ByteBuffer data, ColorSpace colorSpace) {
|
||||||
this(format, width, height, data, null, isSrgb);
|
this(format, width, height, data, null, colorSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -610,7 +607,7 @@ public class Image extends NativeObject implements Savable /*, Cloneable*/ {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Image(Format format, int width, int height, ByteBuffer data) {
|
public Image(Format format, int width, int height, ByteBuffer data) {
|
||||||
this(format, width, height, data, null, false);
|
this(format, width, height, data, null, ColorSpace.Linear);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -865,24 +862,24 @@ public class Image extends NativeObject implements Savable /*, Cloneable*/ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* image loader is responsible for setting this flag based on the color
|
* image loader is responsible for setting this attribute based on the color
|
||||||
* space in which the image has been encoded with. In the majority of cases,
|
* space in which the image has been encoded with. In the majority of cases,
|
||||||
* this flag will be on by default since many image formats do not contain
|
* this flag will be set to sRGB by default since many image formats do not
|
||||||
* any color space information.
|
* contain any color space information and the most frequently used colors
|
||||||
|
* space is sRGB
|
||||||
*
|
*
|
||||||
* The material loader may override this flag to false if it determines that
|
* The material loader may override this attribute to Lineat if it determines that
|
||||||
* such conversion must not be performed, for example, when loading normal
|
* such conversion must not be performed, for example, when loading normal
|
||||||
* maps.
|
* maps.
|
||||||
*
|
*
|
||||||
* @param srgb True to enable SRGB -> linear conversion, false otherwise.
|
* @param colorSpace @see ColorSpace. Set to sRGB to enable srgb -> linear
|
||||||
|
* conversion, Linear otherwise.
|
||||||
*
|
*
|
||||||
* @seealso Renderer#setLinearizeSrgbImages(boolean)
|
* @seealso Renderer#setLinearizeSrgbImages(boolean)
|
||||||
*
|
*
|
||||||
* @throws InvalidStateException If the image format does not support SRGB
|
|
||||||
* -> linear conversion.
|
|
||||||
*/
|
*/
|
||||||
public void setSrgb(boolean srgb) {
|
public void setColorSpace(ColorSpace colorSpace) {
|
||||||
this.srgb = srgb;
|
this.colorSpace = colorSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -898,8 +895,8 @@ public class Image extends NativeObject implements Savable /*, Cloneable*/ {
|
|||||||
*
|
*
|
||||||
* @seealso Renderer#setLinearizeSrgbImages(boolean)
|
* @seealso Renderer#setLinearizeSrgbImages(boolean)
|
||||||
*/
|
*/
|
||||||
public boolean isSrgb() {
|
public ColorSpace getColorSpace() {
|
||||||
return srgb;
|
return colorSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,6 +35,7 @@ import com.jme3.export.InputCapsule;
|
|||||||
import com.jme3.export.JmeExporter;
|
import com.jme3.export.JmeExporter;
|
||||||
import com.jme3.export.JmeImporter;
|
import com.jme3.export.JmeImporter;
|
||||||
import com.jme3.export.OutputCapsule;
|
import com.jme3.export.OutputCapsule;
|
||||||
|
import com.jme3.texture.image.ColorSpace;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,7 +77,7 @@ public class Texture2D extends Texture {
|
|||||||
* @param format
|
* @param format
|
||||||
*/
|
*/
|
||||||
public Texture2D(int width, int height, Image.Format format){
|
public Texture2D(int width, int height, Image.Format format){
|
||||||
this(new Image(format, width, height, null, false));
|
this(new Image(format, width, height, null, ColorSpace.Linear));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,7 +92,7 @@ public class Texture2D extends Texture {
|
|||||||
* @param numSamples
|
* @param numSamples
|
||||||
*/
|
*/
|
||||||
public Texture2D(int width, int height, int numSamples, Image.Format format){
|
public Texture2D(int width, int height, int numSamples, Image.Format format){
|
||||||
this(new Image(format, width, height, null, false));
|
this(new Image(format, width, height, null, ColorSpace.Linear));
|
||||||
getImage().setMultiSamples(numSamples);
|
getImage().setMultiSamples(numSamples);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ import com.jme3.export.InputCapsule;
|
|||||||
import com.jme3.export.JmeExporter;
|
import com.jme3.export.JmeExporter;
|
||||||
import com.jme3.export.JmeImporter;
|
import com.jme3.export.JmeImporter;
|
||||||
import com.jme3.export.OutputCapsule;
|
import com.jme3.export.OutputCapsule;
|
||||||
|
import com.jme3.texture.image.ColorSpace;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,7 +79,7 @@ public class Texture3D extends Texture {
|
|||||||
* @param format
|
* @param format
|
||||||
*/
|
*/
|
||||||
public Texture3D(int width, int height, int depth, Image.Format format) {
|
public Texture3D(int width, int height, int depth, Image.Format format) {
|
||||||
this(new Image(format, width, height, depth, null, false));
|
this(new Image(format, width, height, depth, null, ColorSpace.Linear));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -93,7 +94,7 @@ public class Texture3D extends Texture {
|
|||||||
* @param numSamples
|
* @param numSamples
|
||||||
*/
|
*/
|
||||||
public Texture3D(int width, int height, int depth, int numSamples, Image.Format format) {
|
public Texture3D(int width, int height, int depth, int numSamples, Image.Format format) {
|
||||||
this(new Image(format, width, height, depth, null, false));
|
this(new Image(format, width, height, depth, null, ColorSpace.Linear));
|
||||||
getImage().setMultiSamples(numSamples);
|
getImage().setMultiSamples(numSamples);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
package com.jme3.texture;
|
package com.jme3.texture;
|
||||||
|
|
||||||
import com.jme3.texture.Image.Format;
|
import com.jme3.texture.Image.Format;
|
||||||
|
import com.jme3.texture.image.ColorSpace;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -70,8 +71,8 @@ public class TextureArray extends Texture {
|
|||||||
int width = images.get(0).getWidth();
|
int width = images.get(0).getWidth();
|
||||||
int height = images.get(0).getHeight();
|
int height = images.get(0).getHeight();
|
||||||
Format format = images.get(0).getFormat();
|
Format format = images.get(0).getFormat();
|
||||||
boolean isSRGB = images.get(0).isSrgb();
|
ColorSpace colorSpace = images.get(0).getColorSpace();
|
||||||
Image arrayImage = new Image(format, width, height, null, isSRGB);
|
Image arrayImage = new Image(format, width, height, null, colorSpace);
|
||||||
|
|
||||||
for (Image img : images) {
|
for (Image img : images) {
|
||||||
if (img.getHeight() != height || img.getWidth() != width) {
|
if (img.getHeight() != height || img.getWidth() != width) {
|
||||||
|
@ -35,6 +35,7 @@ import com.jme3.export.InputCapsule;
|
|||||||
import com.jme3.export.JmeExporter;
|
import com.jme3.export.JmeExporter;
|
||||||
import com.jme3.export.JmeImporter;
|
import com.jme3.export.JmeImporter;
|
||||||
import com.jme3.export.OutputCapsule;
|
import com.jme3.export.OutputCapsule;
|
||||||
|
import com.jme3.texture.image.ColorSpace;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -88,7 +89,7 @@ public class TextureCubeMap extends Texture {
|
|||||||
for(int i = 0; i < layerCount; i++) {
|
for(int i = 0; i < layerCount; i++) {
|
||||||
layers.add(null);
|
layers.add(null);
|
||||||
}
|
}
|
||||||
Image image = new Image(format, width, height, 0, layers, false);
|
Image image = new Image(format, width, height, 0, layers, ColorSpace.Linear);
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009-2012 jMonkeyEngine
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are
|
||||||
|
* met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package com.jme3.texture.image;
|
||||||
|
|
||||||
|
|
||||||
|
public enum ColorSpace{
|
||||||
|
|
||||||
|
sRGB,
|
||||||
|
Linear
|
||||||
|
|
||||||
|
}
|
@ -41,6 +41,7 @@ import com.jme3.scene.Spatial;
|
|||||||
import com.jme3.scene.shape.Box;
|
import com.jme3.scene.shape.Box;
|
||||||
import com.jme3.texture.Image;
|
import com.jme3.texture.Image;
|
||||||
import com.jme3.texture.Image.Format;
|
import com.jme3.texture.Image.Format;
|
||||||
|
import com.jme3.texture.image.ColorSpace;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
public class PlaceholderAssets {
|
public class PlaceholderAssets {
|
||||||
@ -73,7 +74,7 @@ public class PlaceholderAssets {
|
|||||||
public static Image getPlaceholderImage(){
|
public static Image getPlaceholderImage(){
|
||||||
ByteBuffer tempData = BufferUtils.createByteBuffer(3 * 4 * 4);
|
ByteBuffer tempData = BufferUtils.createByteBuffer(3 * 4 * 4);
|
||||||
tempData.put(imageData).flip();
|
tempData.put(imageData).flip();
|
||||||
return new Image(Format.RGB8, 4, 4, tempData, null, false);
|
return new Image(Format.RGB8, 4, 4, tempData, null, ColorSpace.Linear);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Material getPlaceholderMaterial(AssetManager assetManager){
|
public static Material getPlaceholderMaterial(AssetManager assetManager){
|
||||||
|
@ -243,7 +243,7 @@ public class SkyFactory {
|
|||||||
|
|
||||||
checkImagesForCubeMap(westImg, eastImg, northImg, southImg, upImg, downImg);
|
checkImagesForCubeMap(westImg, eastImg, northImg, southImg, upImg, downImg);
|
||||||
|
|
||||||
Image cubeImage = new Image(westImg.getFormat(), westImg.getWidth(), westImg.getHeight(), null, westImg.isSrgb());
|
Image cubeImage = new Image(westImg.getFormat(), westImg.getWidth(), westImg.getHeight(), null, westImg.getColorSpace());
|
||||||
|
|
||||||
cubeImage.addData(westImg.getData(0));
|
cubeImage.addData(westImg.getData(0));
|
||||||
cubeImage.addData(eastImg.getData(0));
|
cubeImage.addData(eastImg.getData(0));
|
||||||
|
@ -53,13 +53,13 @@ MaterialDef Phong Lighting {
|
|||||||
Texture2D DiffuseMap
|
Texture2D DiffuseMap
|
||||||
|
|
||||||
// Normal map
|
// Normal map
|
||||||
Texture2D NormalMap
|
Texture2D NormalMap -LINEAR
|
||||||
|
|
||||||
// Specular/gloss map
|
// Specular/gloss map
|
||||||
Texture2D SpecularMap
|
Texture2D SpecularMap
|
||||||
|
|
||||||
// Parallax/height map
|
// Parallax/height map
|
||||||
Texture2D ParallaxMap
|
Texture2D ParallaxMap -LINEAR
|
||||||
|
|
||||||
//Set to true is parallax map is stored in the alpha channel of the normal map
|
//Set to true is parallax map is stored in the alpha channel of the normal map
|
||||||
Boolean PackedNormalParallax
|
Boolean PackedNormalParallax
|
||||||
@ -71,7 +71,7 @@ MaterialDef Phong Lighting {
|
|||||||
Boolean SteepParallax
|
Boolean SteepParallax
|
||||||
|
|
||||||
// Texture that specifies alpha values
|
// Texture that specifies alpha values
|
||||||
Texture2D AlphaMap
|
Texture2D AlphaMap -LINEAR
|
||||||
|
|
||||||
// Color ramp, will map diffuse and specular values through it.
|
// Color ramp, will map diffuse and specular values through it.
|
||||||
Texture2D ColorRamp
|
Texture2D ColorRamp
|
||||||
|
@ -44,6 +44,7 @@ import com.jme3.shader.VarType;
|
|||||||
import com.jme3.texture.Texture;
|
import com.jme3.texture.Texture;
|
||||||
import com.jme3.texture.Texture.WrapMode;
|
import com.jme3.texture.Texture.WrapMode;
|
||||||
import com.jme3.texture.Texture2D;
|
import com.jme3.texture.Texture2D;
|
||||||
|
import com.jme3.texture.image.ColorSpace;
|
||||||
import com.jme3.util.PlaceholderAssets;
|
import com.jme3.util.PlaceholderAssets;
|
||||||
import com.jme3.util.blockparser.BlockLanguageParser;
|
import com.jme3.util.blockparser.BlockLanguageParser;
|
||||||
import com.jme3.util.blockparser.Statement;
|
import com.jme3.util.blockparser.Statement;
|
||||||
@ -206,13 +207,22 @@ public class J3MLoader implements AssetLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// <TYPE> <NAME> [ "(" <FFBINDING> ")" ] [ ":" <DEFAULTVAL> ]
|
// <TYPE> <NAME> [ "(" <FFBINDING> ")" ] [ ":" <DEFAULTVAL> ] [-LINEAR]
|
||||||
private void readParam(String statement) throws IOException{
|
private void readParam(String statement) throws IOException{
|
||||||
String name;
|
String name;
|
||||||
String defaultVal = null;
|
String defaultVal = null;
|
||||||
FixedFuncBinding ffBinding = null;
|
FixedFuncBinding ffBinding = null;
|
||||||
|
ColorSpace colorSpace = null;
|
||||||
|
|
||||||
String[] split = statement.split(":");
|
String[] split = statement.split("-");
|
||||||
|
if(split.length>1){
|
||||||
|
if(split[1].equalsIgnoreCase("LINEAR")){
|
||||||
|
colorSpace = ColorSpace.Linear;
|
||||||
|
}
|
||||||
|
statement = split[0].trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
split = statement.split(":");
|
||||||
|
|
||||||
// Parse default val
|
// Parse default val
|
||||||
if (split.length == 1){
|
if (split.length == 1){
|
||||||
@ -259,8 +269,12 @@ public class J3MLoader implements AssetLoader {
|
|||||||
if (defaultVal != null){
|
if (defaultVal != null){
|
||||||
defaultValObj = readValue(type, defaultVal);
|
defaultValObj = readValue(type, defaultVal);
|
||||||
}
|
}
|
||||||
|
if(type.isTextureType()){
|
||||||
|
materialDef.addMaterialParamTexture(type, name, colorSpace);
|
||||||
|
}else{
|
||||||
|
materialDef.addMaterialParam(type, name, defaultValObj, ffBinding);
|
||||||
|
}
|
||||||
|
|
||||||
materialDef.addMaterialParam(type, name, defaultValObj, ffBinding);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readValueParam(String statement) throws IOException{
|
private void readValueParam(String statement) throws IOException{
|
||||||
|
@ -37,6 +37,7 @@ import com.jme3.asset.TextureKey;
|
|||||||
import com.jme3.texture.Image;
|
import com.jme3.texture.Image;
|
||||||
import com.jme3.texture.Image.Format;
|
import com.jme3.texture.Image.Format;
|
||||||
import com.jme3.texture.Texture.Type;
|
import com.jme3.texture.Texture.Type;
|
||||||
|
import com.jme3.texture.image.ColorSpace;
|
||||||
import com.jme3.util.BufferUtils;
|
import com.jme3.util.BufferUtils;
|
||||||
import com.jme3.util.LittleEndien;
|
import com.jme3.util.LittleEndien;
|
||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
@ -132,7 +133,7 @@ public class DDSLoader implements AssetLoader {
|
|||||||
((TextureKey) info.getKey()).setTextureTypeHint(Type.CubeMap);
|
((TextureKey) info.getKey()).setTextureTypeHint(Type.CubeMap);
|
||||||
}
|
}
|
||||||
ArrayList<ByteBuffer> data = readData(((TextureKey) info.getKey()).isFlipY());
|
ArrayList<ByteBuffer> data = readData(((TextureKey) info.getKey()).isFlipY());
|
||||||
return new Image(pixelFormat, width, height, depth, data, sizes, true);
|
return new Image(pixelFormat, width, height, depth, data, sizes, ColorSpace.sRGB);
|
||||||
} finally {
|
} finally {
|
||||||
if (stream != null){
|
if (stream != null){
|
||||||
stream.close();
|
stream.close();
|
||||||
@ -144,7 +145,7 @@ public class DDSLoader implements AssetLoader {
|
|||||||
in = new LittleEndien(stream);
|
in = new LittleEndien(stream);
|
||||||
loadHeader();
|
loadHeader();
|
||||||
ArrayList<ByteBuffer> data = readData(false);
|
ArrayList<ByteBuffer> data = readData(false);
|
||||||
return new Image(pixelFormat, width, height, depth, data, sizes, true);
|
return new Image(pixelFormat, width, height, depth, data, sizes, ColorSpace.sRGB);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadDX10Header() throws IOException {
|
private void loadDX10Header() throws IOException {
|
||||||
|
@ -37,6 +37,7 @@ import com.jme3.asset.TextureKey;
|
|||||||
import com.jme3.math.FastMath;
|
import com.jme3.math.FastMath;
|
||||||
import com.jme3.texture.Image;
|
import com.jme3.texture.Image;
|
||||||
import com.jme3.texture.Image.Format;
|
import com.jme3.texture.Image.Format;
|
||||||
|
import com.jme3.texture.image.ColorSpace;
|
||||||
import com.jme3.util.BufferUtils;
|
import com.jme3.util.BufferUtils;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -309,7 +310,7 @@ public class HDRLoader implements AssetLoader {
|
|||||||
|
|
||||||
dataStore.rewind();
|
dataStore.rewind();
|
||||||
//TODO, HDR color space? considered linear here
|
//TODO, HDR color space? considered linear here
|
||||||
return new Image(pixelFormat, width, height, dataStore, false);
|
return new Image(pixelFormat, width, height, dataStore, ColorSpace.Linear);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object load(AssetInfo info) throws IOException {
|
public Object load(AssetInfo info) throws IOException {
|
||||||
|
@ -36,6 +36,7 @@ import com.jme3.asset.AssetLoader;
|
|||||||
import com.jme3.asset.TextureKey;
|
import com.jme3.asset.TextureKey;
|
||||||
import com.jme3.texture.Image;
|
import com.jme3.texture.Image;
|
||||||
import com.jme3.texture.Image.Format;
|
import com.jme3.texture.Image.Format;
|
||||||
|
import com.jme3.texture.image.ColorSpace;
|
||||||
import com.jme3.util.BufferUtils;
|
import com.jme3.util.BufferUtils;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -129,7 +130,7 @@ public class PFMLoader implements AssetLoader {
|
|||||||
}
|
}
|
||||||
imageData.rewind();
|
imageData.rewind();
|
||||||
|
|
||||||
return new Image(format, width, height, imageData, null, false);
|
return new Image(format, width, height, imageData, null, ColorSpace.Linear);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object load(AssetInfo info) throws IOException {
|
public Object load(AssetInfo info) throws IOException {
|
||||||
|
@ -45,6 +45,7 @@ import com.jme3.texture.Image;
|
|||||||
import com.jme3.texture.Image.Format;
|
import com.jme3.texture.Image.Format;
|
||||||
import com.jme3.texture.Texture;
|
import com.jme3.texture.Texture;
|
||||||
import com.jme3.texture.Texture2D;
|
import com.jme3.texture.Texture2D;
|
||||||
|
import com.jme3.texture.image.ColorSpace;
|
||||||
import com.jme3.util.BufferUtils;
|
import com.jme3.util.BufferUtils;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
@ -354,7 +355,7 @@ public class TextureAtlas {
|
|||||||
if (clazz == null) {
|
if (clazz == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Image newImage = new Image(format, source.getWidth(), source.getHeight(), BufferUtils.createByteBuffer(source.getWidth() * source.getHeight() * 4), null, false);
|
Image newImage = new Image(format, source.getWidth(), source.getHeight(), BufferUtils.createByteBuffer(source.getWidth() * source.getHeight() * 4), null, ColorSpace.Linear);
|
||||||
clazz.getMethod("convert", Image.class, Image.class).invoke(clazz.newInstance(), source, newImage);
|
clazz.getMethod("convert", Image.class, Image.class).invoke(clazz.newInstance(), source, newImage);
|
||||||
return newImage;
|
return newImage;
|
||||||
} catch (InstantiationException ex) {
|
} catch (InstantiationException ex) {
|
||||||
@ -401,7 +402,8 @@ public class TextureAtlas {
|
|||||||
}
|
}
|
||||||
byte[] image = images.get(mapName);
|
byte[] image = images.get(mapName);
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
Texture2D tex = new Texture2D(new Image(format, atlasWidth, atlasHeight, BufferUtils.createByteBuffer(image), null, true));
|
//TODO check if color space shouldn't be sRGB
|
||||||
|
Texture2D tex = new Texture2D(new Image(format, atlasWidth, atlasHeight, BufferUtils.createByteBuffer(image), null, ColorSpace.Linear));
|
||||||
tex.setMagFilter(Texture.MagFilter.Bilinear);
|
tex.setMagFilter(Texture.MagFilter.Bilinear);
|
||||||
tex.setMinFilter(Texture.MinFilter.BilinearNearestMipMap);
|
tex.setMinFilter(Texture.MinFilter.BilinearNearestMipMap);
|
||||||
tex.setWrap(Texture.WrapMode.Clamp);
|
tex.setWrap(Texture.WrapMode.Clamp);
|
||||||
|
@ -112,7 +112,7 @@ public class AWTLoader implements AssetLoader {
|
|||||||
|
|
||||||
ByteBuffer data1 = BufferUtils.createByteBuffer(img.getWidth()*img.getHeight()*4);
|
ByteBuffer data1 = BufferUtils.createByteBuffer(img.getWidth()*img.getHeight()*4);
|
||||||
data1.put(dataBuf1);
|
data1.put(dataBuf1);
|
||||||
return new Image(Format.ABGR8, width, height, data1, null, true);
|
return new Image(Format.ABGR8, width, height, data1, null, com.jme3.texture.image.ColorSpace.sRGB);
|
||||||
case BufferedImage.TYPE_3BYTE_BGR: // most common in JPEG images
|
case BufferedImage.TYPE_3BYTE_BGR: // most common in JPEG images
|
||||||
byte[] dataBuf2 = (byte[]) extractImageData(img);
|
byte[] dataBuf2 = (byte[]) extractImageData(img);
|
||||||
if (flipY)
|
if (flipY)
|
||||||
@ -120,14 +120,14 @@ public class AWTLoader implements AssetLoader {
|
|||||||
|
|
||||||
ByteBuffer data2 = BufferUtils.createByteBuffer(img.getWidth()*img.getHeight()*3);
|
ByteBuffer data2 = BufferUtils.createByteBuffer(img.getWidth()*img.getHeight()*3);
|
||||||
data2.put(dataBuf2);
|
data2.put(dataBuf2);
|
||||||
return new Image(Format.BGR8, width, height, data2, null, true);
|
return new Image(Format.BGR8, width, height, data2, null, com.jme3.texture.image.ColorSpace.sRGB);
|
||||||
case BufferedImage.TYPE_BYTE_GRAY: // grayscale fonts
|
case BufferedImage.TYPE_BYTE_GRAY: // grayscale fonts
|
||||||
byte[] dataBuf3 = (byte[]) extractImageData(img);
|
byte[] dataBuf3 = (byte[]) extractImageData(img);
|
||||||
if (flipY)
|
if (flipY)
|
||||||
flipImage(dataBuf3, width, height, 8);
|
flipImage(dataBuf3, width, height, 8);
|
||||||
ByteBuffer data3 = BufferUtils.createByteBuffer(img.getWidth()*img.getHeight());
|
ByteBuffer data3 = BufferUtils.createByteBuffer(img.getWidth()*img.getHeight());
|
||||||
data3.put(dataBuf3);
|
data3.put(dataBuf3);
|
||||||
return new Image(Format.Luminance8, width, height, data3, null, true);
|
return new Image(Format.Luminance8, width, height, data3, null, com.jme3.texture.image.ColorSpace.sRGB);
|
||||||
case BufferedImage.TYPE_USHORT_GRAY: // grayscale heightmap
|
case BufferedImage.TYPE_USHORT_GRAY: // grayscale heightmap
|
||||||
short[] dataBuf4 = (short[]) extractImageData(img);
|
short[] dataBuf4 = (short[]) extractImageData(img);
|
||||||
if (flipY)
|
if (flipY)
|
||||||
@ -135,7 +135,7 @@ public class AWTLoader implements AssetLoader {
|
|||||||
|
|
||||||
ByteBuffer data4 = BufferUtils.createByteBuffer(img.getWidth()*img.getHeight()*2);
|
ByteBuffer data4 = BufferUtils.createByteBuffer(img.getWidth()*img.getHeight()*2);
|
||||||
data4.asShortBuffer().put(dataBuf4);
|
data4.asShortBuffer().put(dataBuf4);
|
||||||
return new Image(Format.Luminance16, width, height, data4, null, true);
|
return new Image(Format.Luminance16, width, height, data4, null, com.jme3.texture.image.ColorSpace.sRGB);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -158,7 +158,7 @@ public class AWTLoader implements AssetLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
data.flip();
|
data.flip();
|
||||||
return new Image(Format.RGB8, width, height, data, null, true);
|
return new Image(Format.RGB8, width, height, data, null, com.jme3.texture.image.ColorSpace.sRGB);
|
||||||
}else{
|
}else{
|
||||||
ByteBuffer data = BufferUtils.createByteBuffer(img.getWidth()*img.getHeight()*4);
|
ByteBuffer data = BufferUtils.createByteBuffer(img.getWidth()*img.getHeight()*4);
|
||||||
// alpha
|
// alpha
|
||||||
@ -178,7 +178,7 @@ public class AWTLoader implements AssetLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
data.flip();
|
data.flip();
|
||||||
return new Image(Format.RGBA8, width, height, data, null, true);
|
return new Image(Format.RGBA8, width, height, data, null, com.jme3.texture.image.ColorSpace.sRGB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ MaterialDef SSAO {
|
|||||||
Int NumSamples
|
Int NumSamples
|
||||||
Int NumSamplesDepth
|
Int NumSamplesDepth
|
||||||
Texture2D Texture
|
Texture2D Texture
|
||||||
Texture2D RandomMap
|
Texture2D RandomMap -LINEAR
|
||||||
Texture2D Normals
|
Texture2D Normals
|
||||||
Texture2D DepthTexture
|
Texture2D DepthTexture
|
||||||
Vector3 FrustumCorner
|
Vector3 FrustumCorner
|
||||||
|
@ -4,8 +4,8 @@ MaterialDef Simple Water {
|
|||||||
Texture2D water_reflection
|
Texture2D water_reflection
|
||||||
Texture2D water_refraction
|
Texture2D water_refraction
|
||||||
Texture2D water_depthmap
|
Texture2D water_depthmap
|
||||||
Texture2D water_normalmap
|
Texture2D water_normalmap -LINEAR
|
||||||
Texture2D water_dudvmap
|
Texture2D water_dudvmap -LINEAR
|
||||||
Vector4 waterColor
|
Vector4 waterColor
|
||||||
Vector3 lightPos
|
Vector3 lightPos
|
||||||
Float time
|
Float time
|
||||||
|
@ -5,9 +5,9 @@ MaterialDef Advanced Water {
|
|||||||
Int NumSamplesDepth
|
Int NumSamplesDepth
|
||||||
Texture2D FoamMap
|
Texture2D FoamMap
|
||||||
Texture2D CausticsMap
|
Texture2D CausticsMap
|
||||||
Texture2D NormalMap
|
Texture2D NormalMap -LINEAR
|
||||||
Texture2D ReflectionMap
|
Texture2D ReflectionMap
|
||||||
Texture2D HeightMap
|
Texture2D HeightMap -LINEAR
|
||||||
Texture2D Texture
|
Texture2D Texture
|
||||||
Texture2D DepthTexture
|
Texture2D DepthTexture
|
||||||
Vector3 CameraPosition
|
Vector3 CameraPosition
|
||||||
|
@ -17,6 +17,7 @@ import com.jme3.texture.Texture;
|
|||||||
import com.jme3.texture.Texture.MagFilter;
|
import com.jme3.texture.Texture.MagFilter;
|
||||||
import com.jme3.texture.Texture.MinFilter;
|
import com.jme3.texture.Texture.MinFilter;
|
||||||
import com.jme3.texture.Texture2D;
|
import com.jme3.texture.Texture2D;
|
||||||
|
import com.jme3.texture.image.ColorSpace;
|
||||||
import com.jme3.texture.image.ImageRaster;
|
import com.jme3.texture.image.ImageRaster;
|
||||||
import com.jme3.util.BufferUtils;
|
import com.jme3.util.BufferUtils;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
@ -27,7 +28,7 @@ public class TestImageRaster extends SimpleApplication {
|
|||||||
int width = image.getWidth();
|
int width = image.getWidth();
|
||||||
int height = image.getHeight();
|
int height = image.getHeight();
|
||||||
ByteBuffer data = BufferUtils.createByteBuffer( (int)Math.ceil(newFormat.getBitsPerPixel() / 8.0) * width * height);
|
ByteBuffer data = BufferUtils.createByteBuffer( (int)Math.ceil(newFormat.getBitsPerPixel() / 8.0) * width * height);
|
||||||
Image convertedImage = new Image(newFormat, width, height, data,null, image.isSrgb());
|
Image convertedImage = new Image(newFormat, width, height, data,null, image.getColorSpace());
|
||||||
|
|
||||||
ImageRaster sourceReader = ImageRaster.create(image);
|
ImageRaster sourceReader = ImageRaster.create(image);
|
||||||
ImageRaster targetWriter = ImageRaster.create(convertedImage);
|
ImageRaster targetWriter = ImageRaster.create(convertedImage);
|
||||||
@ -66,7 +67,7 @@ public class TestImageRaster extends SimpleApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Image createTestImage() {
|
private Image createTestImage() {
|
||||||
Image testImage = new Image(Format.BGR8, 4, 3, BufferUtils.createByteBuffer(4 * 4 * 3), null, false);
|
Image testImage = new Image(Format.BGR8, 4, 3, BufferUtils.createByteBuffer(4 * 4 * 3), null, ColorSpace.Linear);
|
||||||
|
|
||||||
ImageRaster io = ImageRaster.create(testImage);
|
ImageRaster io = ImageRaster.create(testImage);
|
||||||
io.setPixel(0, 0, ColorRGBA.Black);
|
io.setPixel(0, 0, ColorRGBA.Black);
|
||||||
|
@ -46,6 +46,7 @@ import com.jme3.texture.Image;
|
|||||||
import com.jme3.texture.Image.Format;
|
import com.jme3.texture.Image.Format;
|
||||||
import com.jme3.texture.Texture;
|
import com.jme3.texture.Texture;
|
||||||
import com.jme3.texture.Texture3D;
|
import com.jme3.texture.Texture3D;
|
||||||
|
import com.jme3.texture.image.ColorSpace;
|
||||||
import com.jme3.util.BufferUtils;
|
import com.jme3.util.BufferUtils;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
@ -125,6 +126,6 @@ public class TestTexture3D extends SimpleApplication {
|
|||||||
}
|
}
|
||||||
bb.rewind();
|
bb.rewind();
|
||||||
data.add(bb);
|
data.add(bb);
|
||||||
return new Texture3D(new Image(Format.RGB8, 10, 10, 10, data, null, false));
|
return new Texture3D(new Image(Format.RGB8, 10, 10, 10, data, null, ColorSpace.Linear));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -82,11 +82,14 @@ public class TestPostWater extends SimpleApplication {
|
|||||||
|
|
||||||
//cam.setLocation(new Vector3f(-700, 100, 300));
|
//cam.setLocation(new Vector3f(-700, 100, 300));
|
||||||
//cam.setRotation(new Quaternion().fromAngleAxis(0.5f, Vector3f.UNIT_Z));
|
//cam.setRotation(new Quaternion().fromAngleAxis(0.5f, Vector3f.UNIT_Z));
|
||||||
cam.setLocation(new Vector3f(-327.21957f, 61.6459f, 126.884346f));
|
// cam.setLocation(new Vector3f(-327.21957f, 61.6459f, 126.884346f));
|
||||||
cam.setRotation(new Quaternion(0.052168474f, 0.9443102f, -0.18395276f, 0.2678024f));
|
// cam.setRotation(new Quaternion(0.052168474f, 0.9443102f, -0.18395276f, 0.2678024f));
|
||||||
|
|
||||||
|
|
||||||
|
cam.setLocation(new Vector3f(-370.31592f, 182.04016f, 196.81192f));
|
||||||
|
cam.setRotation(new Quaternion(0.015302252f, 0.9304095f, -0.039101653f, 0.3641086f));
|
||||||
|
|
||||||
|
|
||||||
cam.setRotation(new Quaternion().fromAngles(new float[]{FastMath.PI * 0.06f, FastMath.PI * 0.65f, 0}));
|
|
||||||
|
|
||||||
|
|
||||||
Spatial sky = SkyFactory.createSky(assetManager, "Scenes/Beach/FullskiesSunset0068.dds", false);
|
Spatial sky = SkyFactory.createSky(assetManager, "Scenes/Beach/FullskiesSunset0068.dds", false);
|
||||||
@ -293,21 +296,21 @@ public class TestPostWater extends SimpleApplication {
|
|||||||
@Override
|
@Override
|
||||||
public void simpleUpdate(float tpf) {
|
public void simpleUpdate(float tpf) {
|
||||||
super.simpleUpdate(tpf);
|
super.simpleUpdate(tpf);
|
||||||
// box.updateGeometricState();
|
// // box.updateGeometricState();
|
||||||
time += tpf;
|
// time += tpf;
|
||||||
waterHeight = (float) Math.cos(((time * 0.6f) % FastMath.TWO_PI)) * 1.5f;
|
// waterHeight = (float) Math.cos(((time * 0.6f) % FastMath.TWO_PI)) * 1.5f;
|
||||||
water.setWaterHeight(initialWaterHeight + waterHeight);
|
// water.setWaterHeight(initialWaterHeight + waterHeight);
|
||||||
if (water.isUnderWater() && !uw) {
|
// if (water.isUnderWater() && !uw) {
|
||||||
|
//
|
||||||
waves.setDryFilter(new LowPassFilter(0.5f, 0.1f));
|
// waves.setDryFilter(new LowPassFilter(0.5f, 0.1f));
|
||||||
uw = true;
|
// uw = true;
|
||||||
}
|
// }
|
||||||
if (!water.isUnderWater() && uw) {
|
// if (!water.isUnderWater() && uw) {
|
||||||
uw = false;
|
// uw = false;
|
||||||
//waves.setReverbEnabled(false);
|
// //waves.setReverbEnabled(false);
|
||||||
waves.setDryFilter(new LowPassFilter(1, 1f));
|
// waves.setDryFilter(new LowPassFilter(1, 1f));
|
||||||
//waves.setDryFilter(new LowPassFilter(1,1f));
|
// //waves.setDryFilter(new LowPassFilter(1,1f));
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ package com.jme3.renderer.jogl;
|
|||||||
import com.jme3.renderer.RendererException;
|
import com.jme3.renderer.RendererException;
|
||||||
import com.jme3.texture.Image;
|
import com.jme3.texture.Image;
|
||||||
import com.jme3.texture.Image.Format;
|
import com.jme3.texture.Image.Format;
|
||||||
|
import com.jme3.texture.image.ColorSpace;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -291,7 +292,7 @@ public class TextureUtil {
|
|||||||
boolean linearizeSrgb){
|
boolean linearizeSrgb){
|
||||||
GL gl = GLContext.getCurrentGL();
|
GL gl = GLContext.getCurrentGL();
|
||||||
Image.Format fmt = image.getFormat();
|
Image.Format fmt = image.getFormat();
|
||||||
GLImageFormat glFmt = getImageFormatWithError(fmt, image.isSrgb() && linearizeSrgb);
|
GLImageFormat glFmt = getImageFormatWithError(fmt, image.getColorSpace() == ColorSpace.sRGB && linearizeSrgb);
|
||||||
|
|
||||||
ByteBuffer data;
|
ByteBuffer data;
|
||||||
if (index >= 0 && image.getData() != null && image.getData().size() > 0){
|
if (index >= 0 && image.getData() != null && image.getData().size() > 0){
|
||||||
@ -474,7 +475,7 @@ public class TextureUtil {
|
|||||||
boolean linearizeSrgb) {
|
boolean linearizeSrgb) {
|
||||||
GL gl = GLContext.getCurrentGL();
|
GL gl = GLContext.getCurrentGL();
|
||||||
Image.Format fmt = image.getFormat();
|
Image.Format fmt = image.getFormat();
|
||||||
GLImageFormat glFmt = getImageFormatWithError(fmt, image.isSrgb() && linearizeSrgb);
|
GLImageFormat glFmt = getImageFormatWithError(fmt, image.getColorSpace() == ColorSpace.sRGB && linearizeSrgb);
|
||||||
|
|
||||||
ByteBuffer data = null;
|
ByteBuffer data = null;
|
||||||
if (index >= 0 && image.getData() != null && image.getData().size() > 0) {
|
if (index >= 0 && image.getData() != null && image.getData().size() > 0) {
|
||||||
|
@ -56,6 +56,7 @@ import com.jme3.renderer.RendererException;
|
|||||||
import com.jme3.texture.Image;
|
import com.jme3.texture.Image;
|
||||||
import com.jme3.texture.Image.Format;
|
import com.jme3.texture.Image.Format;
|
||||||
import static com.jme3.texture.Image.Format.RGB8;
|
import static com.jme3.texture.Image.Format.RGB8;
|
||||||
|
import com.jme3.texture.image.ColorSpace;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.lwjgl.opengl.EXTTextureSRGB;
|
import org.lwjgl.opengl.EXTTextureSRGB;
|
||||||
@ -268,7 +269,7 @@ class TextureUtil {
|
|||||||
boolean linearizeSrgb){
|
boolean linearizeSrgb){
|
||||||
|
|
||||||
Image.Format fmt = image.getFormat();
|
Image.Format fmt = image.getFormat();
|
||||||
GLImageFormat glFmt = getImageFormatWithError(fmt, image.isSrgb() && linearizeSrgb);
|
GLImageFormat glFmt = getImageFormatWithError(fmt, image.getColorSpace() == ColorSpace.sRGB && linearizeSrgb);
|
||||||
|
|
||||||
ByteBuffer data;
|
ByteBuffer data;
|
||||||
if (index >= 0 && image.getData() != null && image.getData().size() > 0){
|
if (index >= 0 && image.getData() != null && image.getData().size() > 0){
|
||||||
@ -425,7 +426,7 @@ class TextureUtil {
|
|||||||
int y,
|
int y,
|
||||||
boolean linearizeSrgb) {
|
boolean linearizeSrgb) {
|
||||||
Image.Format fmt = image.getFormat();
|
Image.Format fmt = image.getFormat();
|
||||||
GLImageFormat glFmt = getImageFormatWithError(fmt, image.isSrgb() && linearizeSrgb);
|
GLImageFormat glFmt = getImageFormatWithError(fmt, image.getColorSpace() == ColorSpace.sRGB && linearizeSrgb);
|
||||||
|
|
||||||
ByteBuffer data = null;
|
ByteBuffer data = null;
|
||||||
if (index >= 0 && image.getData() != null && image.getData().size() > 0) {
|
if (index >= 0 && image.getData() != null && image.getData().size() > 0) {
|
||||||
|
@ -5,7 +5,7 @@ MaterialDef Terrain {
|
|||||||
// use tri-planar mapping
|
// use tri-planar mapping
|
||||||
Boolean useTriPlanarMapping
|
Boolean useTriPlanarMapping
|
||||||
|
|
||||||
Texture2D Alpha
|
Texture2D Alpha -LINEAR
|
||||||
Texture2D Tex1
|
Texture2D Tex1
|
||||||
Texture2D Tex2
|
Texture2D Tex2
|
||||||
Texture2D Tex3
|
Texture2D Tex3
|
||||||
|
@ -27,62 +27,62 @@ MaterialDef Terrain Lighting {
|
|||||||
// Texture map #0
|
// Texture map #0
|
||||||
Texture2D DiffuseMap
|
Texture2D DiffuseMap
|
||||||
Float DiffuseMap_0_scale
|
Float DiffuseMap_0_scale
|
||||||
Texture2D NormalMap
|
Texture2D NormalMap -LINEAR
|
||||||
|
|
||||||
// Texture map #1
|
// Texture map #1
|
||||||
Texture2D DiffuseMap_1
|
Texture2D DiffuseMap_1
|
||||||
Float DiffuseMap_1_scale
|
Float DiffuseMap_1_scale
|
||||||
Texture2D NormalMap_1
|
Texture2D NormalMap_1 -LINEAR
|
||||||
|
|
||||||
// Texture map #2
|
// Texture map #2
|
||||||
Texture2D DiffuseMap_2
|
Texture2D DiffuseMap_2
|
||||||
Float DiffuseMap_2_scale
|
Float DiffuseMap_2_scale
|
||||||
Texture2D NormalMap_2
|
Texture2D NormalMap_2 -LINEAR
|
||||||
|
|
||||||
// Texture map #3
|
// Texture map #3
|
||||||
Texture2D DiffuseMap_3
|
Texture2D DiffuseMap_3
|
||||||
Float DiffuseMap_3_scale
|
Float DiffuseMap_3_scale
|
||||||
Texture2D NormalMap_3
|
Texture2D NormalMap_3 -LINEAR
|
||||||
|
|
||||||
// Texture map #4
|
// Texture map #4
|
||||||
Texture2D DiffuseMap_4
|
Texture2D DiffuseMap_4
|
||||||
Float DiffuseMap_4_scale
|
Float DiffuseMap_4_scale
|
||||||
Texture2D NormalMap_4
|
Texture2D NormalMap_4 -LINEAR
|
||||||
|
|
||||||
// Texture map #5
|
// Texture map #5
|
||||||
Texture2D DiffuseMap_5
|
Texture2D DiffuseMap_5
|
||||||
Float DiffuseMap_5_scale
|
Float DiffuseMap_5_scale
|
||||||
Texture2D NormalMap_5
|
Texture2D NormalMap_5 -LINEAR
|
||||||
|
|
||||||
// Texture map #6
|
// Texture map #6
|
||||||
Texture2D DiffuseMap_6
|
Texture2D DiffuseMap_6
|
||||||
Float DiffuseMap_6_scale
|
Float DiffuseMap_6_scale
|
||||||
Texture2D NormalMap_6
|
Texture2D NormalMap_6 -LINEAR
|
||||||
|
|
||||||
// Texture map #7
|
// Texture map #7
|
||||||
Texture2D DiffuseMap_7
|
Texture2D DiffuseMap_7
|
||||||
Float DiffuseMap_7_scale
|
Float DiffuseMap_7_scale
|
||||||
Texture2D NormalMap_7
|
Texture2D NormalMap_7 -LINEAR
|
||||||
|
|
||||||
// Texture map #8
|
// Texture map #8
|
||||||
Texture2D DiffuseMap_8
|
Texture2D DiffuseMap_8
|
||||||
Float DiffuseMap_8_scale
|
Float DiffuseMap_8_scale
|
||||||
Texture2D NormalMap_8
|
Texture2D NormalMap_8 -LINEAR
|
||||||
|
|
||||||
// Texture map #9
|
// Texture map #9
|
||||||
Texture2D DiffuseMap_9
|
Texture2D DiffuseMap_9
|
||||||
Float DiffuseMap_9_scale
|
Float DiffuseMap_9_scale
|
||||||
Texture2D NormalMap_9
|
Texture2D NormalMap_9 -LINEAR
|
||||||
|
|
||||||
// Texture map #10
|
// Texture map #10
|
||||||
Texture2D DiffuseMap_10
|
Texture2D DiffuseMap_10
|
||||||
Float DiffuseMap_10_scale
|
Float DiffuseMap_10_scale
|
||||||
Texture2D NormalMap_10
|
Texture2D NormalMap_10 -LINEAR
|
||||||
|
|
||||||
// Texture map #11
|
// Texture map #11
|
||||||
Texture2D DiffuseMap_11
|
Texture2D DiffuseMap_11
|
||||||
Float DiffuseMap_11_scale
|
Float DiffuseMap_11_scale
|
||||||
Texture2D NormalMap_11
|
Texture2D NormalMap_11 -LINEAR
|
||||||
|
|
||||||
|
|
||||||
// Specular/gloss map
|
// Specular/gloss map
|
||||||
@ -90,9 +90,9 @@ MaterialDef Terrain Lighting {
|
|||||||
|
|
||||||
|
|
||||||
// Texture that specifies alpha values
|
// Texture that specifies alpha values
|
||||||
Texture2D AlphaMap
|
Texture2D AlphaMap -LINEAR
|
||||||
Texture2D AlphaMap_1
|
Texture2D AlphaMap_1 -LINEAR
|
||||||
Texture2D AlphaMap_2
|
Texture2D AlphaMap_2 -LINEAR
|
||||||
|
|
||||||
// Texture of the glowing parts of the material
|
// Texture of the glowing parts of the material
|
||||||
Texture2D GlowMap
|
Texture2D GlowMap
|
||||||
|
Loading…
x
Reference in New Issue
Block a user