Or maybe check texture extensions, if .png then use it if .jpg then not use it.
thought about it, its nice idea, but what if i use png for even opaque? (even opaque textures would be then in transparent bucket making some issues or unnecessary alpha threshold check")
edit: i think i will just check if texture/object name contains āTransparentā keyWord, then make bucket and threshold for it.
btw. For others to know generating hair texture can be done this awesome particleGenerator way(setting render background to transparent):
then i am able to use this textures in JME too.
wrote fast something like this into my asset manager:
protected void loadAssetToCache(AbstractAssetData value){
if(value.model == null){
Spatial spat = assetManager.loadModel(value.dir + '/' +value.modelName); // should auto-cache
spat.setLocalScale(value.size);
spat.setUserData("dataAssetName", value.assetName);
spat.setUserData("dataSize", value.size);
spat.setUserData("dataModelDir", value.dir);
spat.setUserData("dataModelName", value.modelName);
spat.setUserData("batchNodeName", value.batchNodeName);
spat.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
if(spat instanceof Geometry){
transparencyFixer((Geometry)spat);
value.model = new Node("Geometry");
value.model.attachChild(spat);
} else {
value.model = (Node) spat;
SceneGraphVisitor visitor = (Spatial spatTraversal) -> {
if(spatTraversal instanceof Geometry){
transparencyFixer((Geometry)spatTraversal);
}
};
value.model.depthFirstTraversal(visitor);
}
value.onCreate();
}
}
private void transparencyFixer(Geometry geom){
for (String name : Arrays.asList(new String[] { "ColorMap", "DiffuseMap", "BaseColorMap" })) {
MatParam tex = geom.getMaterial().getParam(name);
String texName = tex != null ? tex.getValueAsString() : "";
if(texName.contains("Transparent")){
geom.getMaterial().setFloat("AlphaDiscardThreshold", 0.1f);
geom.setQueueBucket(RenderQueue.Bucket.Transparent);
}
}
}
also this is how can do this in blender for principled bsdf node:
Note: once you figure out which objects you want to put in the transparent bucket then you can also set alphaDiscardThreshold through a material parameter override on the spatial rather than worrying about traversing down through all of the materials.
Edit: though I guess it is likely you will want to set transparent buckets at the geometry level anyway.
sorry, but i dont get it. how can i override alphaDiscardThreshold on parent Spatial(node i understand)?
its material param right? is there some easier way than i do in code above?
edit: anyway i check texture name, not Spatial name, so it looks like geom material traverse is only way?
But yeah, it doesnāt really help you hereā¦ but maybe itās still good to know that you can set material parameters for a whole scene graph subtree.
@pspeed can i have last one question for u? i think you might know.
What is the best place to put LightProbe generate, to make it generate āfastestā.
I mean in JME tests i seen it was done in update loop some frame, but is there some method where can put this instead of some frame of update render?
I also tried:
public void initLightProbe(Vector3f vector) {
environmentCamera.setPosition(vector);
if(lightProbe != null){
rootNode.removeLight(lightProbe);
}
enqueue(() -> {
enqueue(() -> {
lightProbe = LightProbeFactory.makeProbe(environmentCamera, rootNode, new JobProgressAdapter<LightProbe>() {
@Override
public void done(LightProbe result) {
System.err.println("Done rendering env maps");
Node tex = EnvMapUtils.getCubeMapCrossDebugViewWithMipMaps(result.getPrefilteredEnvMap(), assetManager);
}
});
((BoundingSphere) lightProbe.getBounds()).setRadius(1000);
//lightProbe.setColor(new ColorRGBA(53, 81, 92, 1));
rootNode.addLight(lightProbe);
return "true";
});
return "true";
});
}
but enqueue dont help somehow. at least if i put this into āsimpleInitAppā then there is error that app is not defined (because light probe Environment camera state manager dont initialized app for its state (even if i add it into stateManager before calling this(initLightProbe) method)
Add the environment camera as soon as possible. Then it will exist and be initialised by time you attach a game state.
This will become a non-issue once you have a menu.
yes, you are correct, but i got āTestPreviewā files for multiple things, and there i want to see fast how it looks(without menu).
Its not a problem if cant do this in first frame(or on exact init moment), but would be nice.