Merge pull request #1132 from riccardobl/fixfspace
Fix forced colorspace in matdefs working only once.
This commit is contained in:
commit
7058439e7d
@ -539,6 +539,7 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
|
||||
checkTextureParamColorSpace(name, value);
|
||||
paramValues.put(name, new MatParamTexture(type, name, value, value.getImage() != null ? value.getImage().getColorSpace() : null));
|
||||
} else {
|
||||
checkTextureParamColorSpace(name, value);
|
||||
val.setTextureValue(value);
|
||||
val.setColorSpace(value.getImage() != null ? value.getImage().getColorSpace() : null);
|
||||
}
|
||||
|
@ -36,8 +36,15 @@ import com.jme3.renderer.Caps;
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.shape.Box;
|
||||
import com.jme3.shader.VarType;
|
||||
import com.jme3.system.NullRenderer;
|
||||
import com.jme3.system.TestUtil;
|
||||
import com.jme3.texture.Image;
|
||||
import com.jme3.texture.Texture2D;
|
||||
import com.jme3.texture.Image.Format;
|
||||
import com.jme3.texture.image.ColorSpace;
|
||||
import com.jme3.util.BufferUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import static org.junit.Assert.*;
|
||||
@ -120,6 +127,30 @@ public class MaterialTest {
|
||||
checkRequiredCaps(Caps.GLSL150);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForcedColorSpace(){
|
||||
|
||||
Image img=new Image(Format.RGBA8,2,2,BufferUtils.createByteBuffer(16),null,ColorSpace.sRGB);
|
||||
Image img2=new Image(Format.RGBA8,2,2,BufferUtils.createByteBuffer(16),null,ColorSpace.sRGB);
|
||||
Texture2D tx=new Texture2D(img);
|
||||
Texture2D tx2=new Texture2D(img2);
|
||||
|
||||
assertTrue(tx2.getImage().getColorSpace()==ColorSpace.sRGB);
|
||||
assertTrue(tx2.getImage().getColorSpace()==ColorSpace.sRGB);
|
||||
|
||||
AssetManager assetManager = TestUtil.createAssetManager();
|
||||
MaterialDef def=new MaterialDef(assetManager,"test");
|
||||
def.addMaterialParamTexture(VarType.Texture2D, "ColorMap",ColorSpace.Linear, null);
|
||||
Material mat=new Material(def);
|
||||
|
||||
mat.setTexture("ColorMap",tx);
|
||||
assertTrue(tx.getImage().getColorSpace()==ColorSpace.Linear);
|
||||
|
||||
mat.setTexture("ColorMap",tx2);
|
||||
assertTrue(tx2.getImage().getColorSpace()==ColorSpace.Linear);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelectNamedTechnique_GLSL100Cap() {
|
||||
supportGlsl(100);
|
||||
|
Loading…
x
Reference in New Issue
Block a user