Create my own material definition

Is it possible to create your own material definition (a .j3md file)? I’d like to be able to use a glow map on a translucent object, so it would just be the same as ColoredTextured.j3md but with GlowColor and GlowMap defined, and then the glow technique defined like it is in SolidColor.j3md. I tried just copying ColoredTextured.j3md and renaming it, but when I try using that file to load a material I get a null pointer exception. Is this possible, or no?

Yes this is possible, if you post the stacktrace of your NPE it might be that we can help you, are you sure the file can be found? Where did you place it and how do you try to load it? Are you sure you have all paths inside the file changed as needed? The MaterialEditor in jMP should recognize your file for selection in the dropdown box too.

Ah sorry, the file was just in the wrong place - so no more exception. I can’t get transparency working, though. I think it’s because of the .vert and .frag files, where should those be? I tried just copying them to the same folder where my new .j3md file is and changing the paths in the .j3md file, but still no transparency.

I would like a bit more info on this as-well, i’ve tried in the past copying the terrain .j3md files and the frag / vert shader info to a dir trying to modify the params myself locally but had no success.

These tutorials helped me alot when designing shaders of my own:

wait wait wait.

You want to use glow on a translucent object…why not using the lighting.j3md mat def? it can do that.

Anyway, if you want to use glow in your own j3md file there is a walkthrough in the bloom/glow wiki page at the end in the “Hints and Tricks” section : Making your home brewed material definition support Glow

For the vert and frag file you set the path to them in the j3md file

for example in ColoredTexture

Technique {

VertexShader GLSL100: Common/MatDefs/Misc/ColoredTextured.vert

FragmentShader GLSL100: Common/MatDefs/Misc/ColoredTextured.frag

WorldParameters {




“GLSL100” means that glsl 1.0 is required for this shader to compile properly

“Common/MatDefs/Misc/ColoredTextured.vert” is the path to the shader vert file. if you are using your own vert this path needs to be changed to the actual path of your vert file. Lets say that you put the vert file in your Assets/Shaders folder of your project, then the line will be

VertexShader GLSL100: Shaders/ColoredTextured.vert

for an overview on shaders with JME3 read this :

I know using lighting.j3md can do translucency and glow, but I’ve been avoiding it because I’m so terrible with lighting… I just tried it and it kind of works, but I need to mess around with my lights now.

Alright, I’m having a weird problem - every two rectangles I create has a problem with the material. I can’t tell if it’s not being affected by the light, or if it isn’t applying the alpha map correctly, but something isn’t right.

Right now, the game trails a “wall” (flat box) behind the camera, which moves forward at a constant speed. When the user turns 90 degrees left or right, a “final wall” is created and the current wall’s min Vector3f is updated to be the pivot point… it’s basically like Tron. Here’s a picture of the problem (just a few walls, it should be kind of clear that every other one is not correct): In case it matters, this is my alpha map - and my glow map -

Sorry if this is kind of confusing, if anything needs clarification just ask. My code is here -

Thanks very much, any help is much appreciated!