Transparent textures

Hi,



How can I export models with textures with an alpha channel? I am using blender. I exportex an old model with new ogre exporter. Instead of transparent sections jme shows black. If I replace newly exported material file with an old one the transparency works.



Thanks

Check the FAQ or manual. Can you imaine you are not the first to ask about transparency?

2 Likes

It is not that I haven’t taken a look at (JME3) FAQ or manual. I just haven’t found a topic discussing transparency of exported models. So, please give me more precise link to correct documentation location.

:facepalm: http://www.hub.jmonkeyengine.org/wiki/doku.php/jme3:faq#how_do_i_make_materials_transparent

I am not trying to create a material or try to tweak a material (in code).



I am trying to import a model to JME3 with a material like it is specified in blender (textured with a texture having transparency). I can even see references to transparency in exported material file, however I am not sure what they exactly mean (for example, colour_op alpha_blend).



In earlier version of the exporter and JME3, exporting models with transparency worked just fine. Now exporter material file format has changed somehow and it does not work anymore.

yeah… just do whats written there, its best to understand whats happening. you cannot expect anything but the mesh and uv mapping to export to the engine from a model editor.

This sound something that should be mentioned in FAQ. That is: “you cannot expect anything but the mesh and uv mapping to export to the engine from a model editor”.



Still, why exactly that is so?



It would seem that the main source of assets for 3D engines are 3D model editors. It would sound very essential to have good tools to export models properly with most basic features (such as transparency) from 3D editors to JME.

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:intermediate:multi-media_asset_pipeline

The jmonkeyplatform has material editor. Can I use the material editor to add apha blending mode to object’s j3o file? I tried to do this, but pushing “properties->Material->create j3m file” button makes the whole texture invisible. It seems just trying to create material file from j3m file does this strange thing.



Perhaps this approach is also something that is not supported?

Open your model in the sceneComposer, then in the bottom left find the mesh with the alpha texture, do the create j3m, then make sure the j3m you just created is seleted in the dropdown box. Then open the j3m you created, go to additional renderstate and set blend to alpha. Oh yeah and make sure the j3m’s diffusemap is set to the texture you wish to have on that part of the model.

1 Like

I took a video of me trying to set on the alpha to the texture.



http://users.utu.fi/sampie/jme/jme.ogv



However, I have not done any diffusemap related steps. Is that the reason the texture becomes invisible?

It seems that the texture becomes invisible because alpha is set on from blender also.

After taking alpha away from blender the model looks ok on jmonkeyplatform editor.



However, when I use the model in a game, the border of transparent and visible area renders black when terrain is shown on background. When tree trunk is on background there are no black borders. Please see the two images.



http://users.utu.fi/sampie/jme/palmtree.png

http://users.utu.fi/sampie/jme/palmtree-zoom.png



What is happening, why there are background dependent black borders?

Ok, transparent queue bucket took care of those nasty black borders.



I am not sure if an object with alpha in opaque bucket makes sense at all. If not, it would be nice if jmonkeyplatform would warn if such a combination is used.

I think it would really be alot of work to add this feature which saves a marginal amount of time. The developers really have better stuff to do

It seems there is still something funny happening at the border of visible and transparent area. See http://users.utu.fi/sampie/jme/firtree.png

The borders of visible and transparent area are drawn with terrain color even though terrain color should not be shown because there are faces from the model that should block the terrain color from showing.



The model is using transparent render bucket and alpha is set for the texture.



Does anybody know why this is happening and how can I fix the rendering?

Those triangles are being drawn first and filling the Z-buffer. None of the stuff behind them is getting drawn at those pixels.



There are a few ways to fix this but the easiest is probably to set:

http://hub.jmonkeyengine.org/javadoc/com/jme3/material/RenderState.html#setAlphaFallOff(float)

http://hub.jmonkeyengine.org/javadoc/com/jme3/material/RenderState.html#setAlphaTest(boolean)



The hard way in this case would be to make sure the tree mesh is always drawn bottom to top, ie: reorder the triangles (which wouldn’t help you if you were underneath the tree looking up but would fix most views in this specific case). That’s assuming the tree is just one mesh.

Would it make sense to have an alpha threshold below which it does not write to the z buffer but still draws the pixel colour?



In that case situations like this would not resolve completely accurately but the effect should be pretty close as writing the highly transparent higher layer wouldn’t prevent the less transparent lower layer still writing.

@zarch said:
Would it make sense to have an alpha threshold below which it does not write to the z buffer but still draws the pixel colour?

In that case situations like this would not resolve completely accurately but the effect should be pretty close as writing the highly transparent higher layer wouldn't prevent the less transparent lower layer still writing.


Which is exactly what I posted.
@pspeed said:
Which is exactly what I posted.


Sets the alpha fall off value for alpha testing.
If the pixel's alpha value is greater than the alphaFallOff then the pixel will be rendered, otherwise the pixel will be discarded.


This says the pixels are discarded entirely. I'm suggesting to draw them to the screen but not the z buffer, important difference.

Or is the javadoc misleading and that is what it means?