-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix for #1106 #1110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix for #1106 #1110
Conversation
…eave it at the default value. fix for #1106
|
I had hoped for some review by a more senior monkey, but you seem to know what you're doing. |
|
I did a few tests with my own models and some free one’s I found online. I didn’t encounter any errors or strange behaviour, it seems to work. |
|
Ok, sorry i didn't see this (it might be a good idea for the future to use an actual title for PRs, because when you start having several "Fix ISSUE NUMBER" it's easy to miss some). My question is, what will happen if i have a matdef that defines a -LINEAR param, but the image is sRGB? Will this pr break the linearization by forcing the mat param to become sRGB ? |
Hi @riccardobl, I wasn't aware of the -LINEAR option in a material definition file. This is my test case: Same test as above, but without the -LINEAR flag: The first image is clearly gamma corrected (too bright) because of the colorspace, so all should still be working as expected. |
|
Can you share the code? |
|
test: TestMaterialLinearColorspace.java public class TestMaterialLinearColorspace extends SimpleApplication {
public static void main(String[] args) {
new TestMaterialLinearColorspace().start();
}
@Override
public void simpleInitApp() {
AmbientLight ambientLight = new AmbientLight(ColorRGBA.White.mult(0.2f));
DirectionalLight directionalLight = new DirectionalLight(new Vector3f(-0.2f, -1, -0.2f).normalizeLocal(), ColorRGBA.White);
Spatial model = assetManager.loadModel("staff-0.j3o");
Material material = assetManager.loadMaterial("colorspace-test.j3m");
model.depthFirstTraversal(new SceneGraphVisitorAdapter() {
@Override
public void visit(Geometry geom) {
geom.setMaterial(material);
System.out.println("Colorspace: " + material.getTextureParam("DiffuseMap").getColorSpace());
}
});
rootNode.addLight(ambientLight);
rootNode.addLight(directionalLight);
rootNode.attachChild(model);
}
}colorspace-test.j3m: When running the testcase, I adapted this line in to: If you want I can create a proper testcase for it, and put it in the jme3-examples module. |
|
Oh ok, i see. I was mislead by the fact that both Materials and MatDefs keep a list of MatParamTexture. But the material will always look at the matdef list to see if it needs to switch the colorspace. |
Yep, indeed. You can always overwrite it if needed. This should only set the colorspace to the colorspace of the texture instead of defaulting to null. |



when the image object has a ColorSpace value we pass it on, else we leave it at the default value.