General & simple Question about optimization

GIMP is free and while not quite as good as photoshop allows decent image editing.

I understand the concept but having some issues implementing. I did look in the javaDoc and through the forum and I couldn’t figure it out. Here are my steps:



(What I am trying to do is change colors of objects inside my BatchNode.)



1- I used an open-source software called Atlas Maker to create a .png composed of two colors blue and red.



2- I create a TextureAtlas instance: static TextureAtlas atlas= new TextureAtlas(512, 512);



3- I add the texture to it: atlas.addTexture(assetManager.loadTexture("/Materials/colorsAtlas.png"), “colorsTextureAtlas”);



4- when creating the object:

[java]

else if (type.equals(rabbit)) {

Material mateo = new Material(myApp.getAssetManager(),“Common/MatDefs/Misc/Unshaded.j3md”);

mateo.setTexture(“ColorMap”, AnimatorVisualizer.atlas.getAtlasTexture(“colorsTextureAtlas”));

//mateo.getAdditionalRenderState().setAlphaTest(true);



Geometry boxGeom = (Geometry) mySpatial;

boxGeom.setMaterial(mateo);

batch.attachChild(boxGeom);

}

[/java]



this will cause an illegal argument that ColorMap is null.



[java]



Mar 22, 2012 12:44:15 PM com.jme3.app.Application handleError

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.IllegalArgumentException: The given texture for parameter “ColorMap” is null.

at com.jme3.material.Material.clearTextureParam(Material.java:454)

at com.jme3.material.Material.setTexture(Material.java:512)

[/java]

You basically mix everything up ^^ “Texture atlas” is just a name for a texture that contains imagery for multiple meshes or mesh parts. They solve the problem that multiple textures mean multiple geometry objects with multiple materials each referencing one texture. You can create them e.g. using your 3d editor to combine all used textures to one large texture and then export the models so that they use this texture or you can make the texture atlas before and while you edit your models you map their uv coords so that they match the correct parts of the atlas or you load models with separate textures and use the TextureAtlas class in-code to combine them to improve rendering performance.

I thought that’s what I was doing in my example :s


using your 3d editor to combine all used textures to one large texture and then export the models so that they use this texture


any way you could give a code example so I can clearly understand that?'

I really appreciate the help
1 Like
@nightwolf911 said:
@normen does the material type influence the performance? any reason why the material chosen is slowing my fps?


if you mean material definition, its obvious.

each material definitions are using different shaders = different performance. also texture sizes / etc ;)

maybe this is why someone gived you -1, but i will be nice and i will give you +1, becouse you always try to be nice

edit: ahh now i see that normen gived you :P
1 Like
becouse you always try to be nice


I am nice :)

each material definitions are using different shaders = different performance. also texture sizes / et

but I am using the same material definition and also same j3m for all these objects.

Thanks a lot really.
@oxplay2 said:
if you mean material definition, its obvious.
each material definitions are using different shaders = different performance. also texture sizes / etc ;)
maybe this is why someone gived you -1, but i will be nice and i will give you +1, becouse you always try to be nice
edit: ahh now i see that normen gived you :P

dafuq stop editing your post with the @mention, I get a mail each time -.-

normen



i forgot that this is so really annoying, sorry. You should fix this on webpage :stuck_out_tongue:



nightwolf911



first i seen this:

[java]Material mateo = new Material(myApp.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");[/java]

then this:

[java]Material shiny bumpy rock : Common/MatDefs/Light/Lighting.j3md {[/java]



so i thinkegthinking you changed Unshaded to Lighting.



PS: now understand normen? ;p





edit:



now i see what you done bad too:

[java]Material shiny bumpy rock : Common/MatDefs/Light/Lighting.j3md {

MaterialParameters {

Shininess: 8.0

NormalMap: Textures/bump_rock_normal.png

UseMaterialColors : true

Ambient : 0.0 0.0 0.0 1.0

Diffuse : 0.0 0.117 0.8 1.0

Specular : 0.0 0.0 0.0 1.0

}

}

[/java]

you use NormalMap. and you propably wanted use DiffuseMap… NormalMap is not what you think.

no worries, I think what’s happening is that for some reason when they are batch the BatchNode is considering them not the same and therefore counting them as separate objects (not truly batching).



I think the solution as recommended by normen and homsi and you is to go with TextureAtlas. I already created sompething simple (atlas.png) to test it out but not sure how easy it is to do mapping and use it. Can anyone provide some code? I looked all over the place and there’s nothing about it.

ok so like u said @oxplay2 it works fine now… but I guess since I change the colors of the batched node I need to use what you recommended, the TextureAtlas. I read about it but seems there’s not much about it. can anyone post a working code or a pseudo code of how it works?



I created one atlas file (a png that has all the materials i want separted - and my materials are simply different colors) andI have no idea how to attach it to my code and map the textures to these specific sub-images. Anyone can help with that? maybe a link/ref about TextureAtlas and jmE?



thanks