Generate shaders

Is there good way to generate shaders on the fly? Essentially I want to convert a string to a shader at runtime. Is it possible in JME?

http://hub.jmonkeyengine.org/javadoc/com/jme3/material/TechniqueDef.html#setShaderFile(java.lang.String,%20java.lang.String,%20java.lang.String)



<= here we go!

By meaning of “Generate on the fly”, you think about a Node-base Shader Generation System? …



http://www.3dworldmag.com/files/2011/02/TDW137.mach2_.13_shadereditor.jpg

P/s: I didn’t test the method out, so don’t know what penalty the result can come across… By the way, I’m doing the same things like in the figure :stuck_out_tongue: if you interest!

@atomix Almost, but I want to generate shader source at runtime. Having a java program that generates the shader I want :slight_smile:

You could make your own loader for that, basically assembling the text for the shader when you are asked for a certain file. (using asset manager)

@normen ahh, should have thought of that. Can I change the shader for a material at runtime or do I have to load a new material?

No you have to upload the new shader to the GPU, so basically a new material, yeah.

But that could be done on runtime, get old amterial, get textures ect, then create new, set the parameters from the old and done.

@kwando :

Java program for GLSL shader generation, current NO!



Java program has “texture” making

We have NeoTexture(godlike). :stuck_out_tongue:



ArtOfIllusion have one

http://aoi.sourceforge.net/scrshots/fullsize/texture.png

with ability to link directly to a fixed shader!

@kwando said:
@atomix Almost, but I want to generate shader source at runtime. Having a java program that generates the shader I want :)


For code generation, I recommend a link here (which do it with Velocity)

http://onjava.com/pub/a/onjava/2004/05/05/cg-vel1.html?page=2