- is it possible to access and edit the vertex colours in the vertex shader?
- is it possible to store vertex colour value in vertex shader for later use?
- is it possible to use 2 shaders in one material? i.e.: (first shader -> render -> second shader)
- Yes
- No: shaders are (essentially) completely renewed every frame
- No, but you can have two objects or play with RenderToTexture
You may want to manipulate vertex colours via python instead. It is slower, but will allow easier control (probably)
I wrote a resource on Render Passes
*2. Theoretically there are ways to store values that are generated in a shader and read it back in the next frame (for example with fbos) but it is more complicated than just simply create a variable or something like that, so I wouldn’t use it for simple stuff.
(Also the bge hasn’t a right way (API) to create fbos or something like this, there are only hacky ways with pyopengl/bgl)… so I would go the way that sdfgeoff has mentioned.
@Maujoe:
There is now a proper way to create FBO’s (or FBO-like objects) I believe:
https://www.blender.org/api/blender_python_api_2_76_2/gpu.offscreen.html
But I’ve never used them.
Hi, the correct API for FBOs inside bge has been commited after 2.77 release->https://developer.blender.org/rB40f1c4f34337d7dfb3fa5bcbd2daa2f602e12011 (VideoTexture module)
Interesting…
I never heard of FBO before, can someone please explain me more about it? Or some example .blend file will be so helpful
Hi, I tried to make an fbo example with the new FBO API (to be opened with last blender buildbot version): http://www.pasteall.org/blend/42900
-
On the renderedplane I made a GLSL shader to render what is around mouse cursor in red. Then I copied the result into a FBO (fbo.py).
-
On the other plane I used the image rendered into fbo in a second shader (mainshader.py) and I superimposed fbo color (the red cursor) with the colored grid of Plane.001.
The goal was to use the output (the rendered texture into the fbo) in another shader… This is a bit complex and I’m wondering if it can be simplified (avoiding copyTex as I did) but the goal is to use the output of a shader as input in a second shader.
A more entertaining example: http://www.pasteall.org/blend/42902 (I guess this is a kind of “ping pong” technique but with copyTex it is very slow)(I made it in upbge so you have to check GLSL in render tab)