JME3 and Shaders

For those willing to know more about shaders and how to use them in JME3, i made a wiki page that explains the basics.


Cool, I adapted the wiki code a bit so it assigns a TOC. Did you use some web tool to convert a google html export? :slight_smile:

nope…i used copy/paste and my fingers :stuck_out_tongue:

The TOC looks good !

I have bookmarked the page. Many thanks!

I particularly appreciate the explanation about built in variables/parameters and their GLSL counterparts, which was a bit confusing for the beginner (not because JME3 but rather because of all the changes in the language specs and custom naming in the GLSL fauna. Sometimes I was unsure about using one or other variable/parameter name…).

It would be great if you could showcase the shaders. JMonkey really lacks benchmark examples!

You know. Here is an example from ogre3d:

there is a showcase on

You have pictures and a webstart.

Every single material is rendered via shaders in JME3, so I guess every example is a shader showcase.

1 Like

@carlaimmoth: The screenshot you provided was not created by the makers of Ogre3D. It is probably created by one of the users of the engine, probably making a game or demo scene kind of thing.

Also, it doesn’t showcase shaders in particular, but 3D rendering in general.

There isn’t anything special in that screenshot really, its just well designed composition. The trees are low poly, the terrain has low resolution textures, the grass is a bunch of alpha blended quads. The terrain in the background has fog applied, the sky is probably static as well although I am not sure about that since it is quite blurry. The only thing it shows is that good assets can make as good a showcase as powerful shader effects.

1 Like

I do not get it … I have a pb with Shader - I try the example that you did Nehon (expect that I put Simple for j3md,frag,vert file names)… it is working … expected that I have this result:

oooh, yes, it is doing what it should … but look closer … framerate : 13 … wooooo I have 4Giga / 4 cores. We could expect better for a blue box :wink:

more seriously, if someone can tell me what s wrong here …

the incredible code :


public class Main extends SimpleApplication {

public static void main(String[] args) {

Main app = new Main();




public void simpleInitApp() {




public void simpleUpdate(float tpf) {

//TODO: add update code



public void simpleRender(RenderManager rm) {

//TODO: add render code


public void useShader(Node rootNode){

// A cube

Box box= new Box(Vector3f.ZERO, 1f,1f,1f);

Geometry cube = new Geometry(“box”, box);

Material mat = new Material(assetManager,“Materials/Simple.j3md”);

// mat.setColor(“Color”, ColorRGBA.randomColor());//red color





code of the simple.frag:

[java]void main(){

//returning the color of the pixel (here solid blue)

//- gl_FragColor is the standard GLSL variable that holds the pixel

//color. It must be filled in the Fragment Shader.

gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);


the simple.vert now :

[java]//the global uniform World view projection matrix

//(more on global uniforms below)

uniform mat4 g_WorldViewProjectionMatrix;

//The attribute inPosition is the Object space position of the vertex

attribute vec3 inPosition;

void main(){

//Transformation of the object space coordinate to projection space


//- gl_Position is the standard GLSL variable holding projection space

//position. It must be filled in the vertex shader

//- To convert position we multiply the worldViewProjectionMatrix by

//by the position vector.

//The multiplication must be done in this order.

gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1.0);


First time that I use shader :slight_smile:


I forgot this one too: Simple.j3md


MaterialDef Simple Color {

MaterialParameters {

Vector4 Color


Technique {

VertexShader GLSL100: Shaders/simple.vert

FragmentShader GLSL100: Shaders/simple.frag

WorldParameters {




Technique FixedFunc {



mhh…works fine for me

maybe you should try to update your graphic drivers.


unfortunatly I have already the last drivers installed

NVIDIA GeForce 9800 GTX/9800 GTX version installed : 266.58 (this is the last)

That’s not nice, because I want to use shaders … and where I could see if the shaders are properly supported on my machine?

In Jmonkey I have this :

do you have something different ?

f***** :frowning:

PS/ by the way, it is normal that we do not have ne same number of Vertices???

We have different number of vertices because I have 2 more digits on the frame rate label…that’s not the issue

This is the most basic shader that can exist, and btw any other test case use plenty of more complex shaders.

Do you have issues with any other tests?

I did this test right now : (the test of the island with nice water effect)

I think it uses shader, isn’t it ?

The framerate is ok, I do not know if it is low or not regarding my config, but I will say it is pretty fast (enough for playing in any case!)

I will do another test on my vaio too … I will see the result.

But something is odd here …

Ok I did something else, I DOWNGRADE version of motherboard driver : nForce 780i SLI 15.53 to 15.51.

And now rate is more decent!

Thank you for your help :slight_smile:

For other poeple If you have pb with rate for shader:

play with the version of MotherBoard too ! :slight_smile: (maybe not install the last one … :frowning: )

On my laptop I got ‘only’ 1032fps (it is a vaio 4Giga / i3 (4cores) ) maybe due to drivers … but it is ok.

hehe cool

Frigging hell, the link at the top of this page is broken. Where can I find this article now ?

Thanks for that.

Funny, I’ve never seen it before.

Well I guess you will learn not much from it now :stuck_out_tongue: (@FrozenShade)