Mult Shaders

Hi guys,
I have a doubts…
shader (GLSL) are loaded in Material ??
[java]Material mat = new Material(“shader/my_shader.glsl”);[/java]
???
and how i add varius material in model,
example:
[java]Spatial myModel = assetManager.loadModel(“models/meuModel.obj”);[/java]
and i want set in myModel the shaders:
[java]Material mat1 = new Material(“shader/hdr.glsl”);
Material mat2 = new Material(“shader/blow.glsl”);
Material mat3 = new Material(“shader/light.glsl”);[/java]

thank you and sorry for my english :expressionless:

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_material

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:jme3_shaders

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:shader_video_tutorials

how do I add several shaders in a single model (.obj)??

[java]Spatial myModel = assetManager.loadModel(“models/meuModel.obj”);

Material mat1 = new Material(assetManager,“shader/hdr.glsl”);
Material mat2 = new Material(assetManager,“shader/blow.glsl”);
Material mat3 = new Material(assetManager,“shader/light.glsl”);

myModel.setMaterial(mat1);
myModel.setMaterial(mat2);
myModel.setMaterial(mat3);
[/java]

???

all will work or just the last?

You can’t at the moment (although something is being worked on).

One shader per material. One material per shader.

You can combine the functionality for multiple shaders into one though by writing your own shader and combining the code.

1 Like
@zarch said: You can't at the moment (although something is being worked on).

One shader per material. One material per shader.

You can combine the functionality for multiple shaders into one though by writing your own shader and combining the code.

that was what I wanted to know :slight_smile:

but how do I combine the code? the code glsl or java/jmonkey ??

thank very much

@sradkiller said: how do I add several shaders in a single model (.obj)??

[java]Spatial myModel = assetManager.loadModel(“models/meuModel.obj”);

Material mat1 = new Material(assetManager,“shader/hdr.glsl”);
Material mat2 = new Material(assetManager,“shader/blow.glsl”);
Material mat3 = new Material(assetManager,“shader/light.glsl”);

myModel.setMaterial(mat1);
myModel.setMaterial(mat2);
myModel.setMaterial(mat3);
[/java]

???

all will work or just the last?

None of them will work because none of them are properly defined materials.

Assuming you did go through the documentation and tutorials and figured out how to make a proper material, only the last one would work.

I can’t help but think that this would be obvious if you looked at even one piece of documentation, though.

None of them will work because none of them are properly defined materials.

Assuming you did go through the documentation and tutorials and figured out how to make a proper material, only the last one would work.

I can’t help but think that this would be obvious if you looked at even one piece of documentation, though.

Hello guy, this is like a pseudocode :slight_smile:

… and zarch…
how do I combine the code? the code glsl or java/jmonkey ??

The glsl code of course !
Yyou can have only one material per mesh. This is the limit of this system.

Read. The. Tutorials. I. Posted.

They cover all this in detail.

Ok guys, thank very much :slight_smile: