Procedural texture with shaders

Hello! I would like to create a texture using shaders. I have a vague idea how one should do it: create a framebuffer, render to the framebuffer applying shaders, store the data from the framebuffer into the texture. However, I’m not sure how to do it in a concrete manner. Can someone offer some guide on this, please?

P.S. I know how to render to texture using offscreen viewport and camera.

Theres a manual in the SDK, press F1 or use the text search in the top right. Using that you will find the same information as on this page:

http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:jme3_shaders

Thanks for the answer. I’ve already read that manual pages. However, it only talks about shaders and does not mention how to render texture using shaders. I mean, I do not want to render texture every frame. I want to apply shaders once and save the result as a normal, static texture.

Sure it mentions using textures. To get a texture back from the GPU do the same as the screenshot utility - or if you want to use it on the GPU side see the render to texture example.

Thank you. Can you give me links to render to texture example and screenshot utility, please? I’ve found only this link http://jmonkeyengine.googlecode.com/svn/trunk/engine/src/test/jme3test/post/TestRenderToTexture.java

New Project → JmeTests

Thank you.

Ok, I’ve managed to do it via render to texture. The core part of the code goes like this

        picture = new Picture("picture");
        picture.setLocalScale(512);
        Material material = new Material(assetManager, "MatDefs/SimpleColor/SimpleColor.j3md");
        material.setInt("Size", 512);
//        material.setColor("Color", ColorRGBA.Blue);
        picture.setMaterial(material);
        offView.attachScene(picture);
        picture.updateGeometricState();

So, I set a material with a custom shader on a picture. Is it a correct way to do it?