Hi,
I'm creating terrains textures in IRB and they are done in real time from shaders. Is there a way to "bake" the shader rendering using the terrain UV, so I could use the terrain mesh and generated texture in other applications? The rendering of the shader will be done in UV space...
Is there a code example somewhere? The only thing I was thinking and could probably do myself is take a RTT from a camera from a top angle (since a terrain come from a flat plane). I'm pretty sure the texture will get more and more stretched when there are mountain and would only look good on "mostly flat" areas. So I was wondering if a RTT could be done from UV space of the model instead of a camera view.
Rendering something in UV space.
-
- Posts: 1638
- Joined: Mon Apr 30, 2007 3:24 am
- Location: Montreal, CANADA
- Contact:
Re: Rendering something in UV space.
In the vertex shader you could try setting x = u, y = v, z = far/2.
-
- Posts: 1638
- Joined: Mon Apr 30, 2007 3:24 am
- Location: Montreal, CANADA
- Contact:
Re: Rendering something in UV space.
This would give me a picture of the UV Map with the texture rendered? I would need to "bake" the texture of the terrain that is done with the shader.
Re: Rendering something in UV space.
The pixel shader does the "baking". The vertex shader just flattens the scene, proportionately to the UV coordinates. In any case, the picture of the UV map is what you asked for!
Re: Rendering something in UV space.
That way you'd flatten the terrain. What if the shader is needs some height information? Instead, Pick the terrain bounding box, build an orthographic projection around it (it is surprisingly easy ), and set the camera with the z axis being the height. That way you can render the terrain from the top into a perspective less view. Picking the terrain bounding box as the reference for the orthographic projection makes it so the render fills the whole texture space, and you should be pretty much done. And unless you're doing something with the perspective in your shader, (perhaps some mipmapping or stuff like that to avoid atlas border glitches) you don't need to change it.In the vertex shader you could try setting x = u, y = v, z = far/2.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Re: Rendering something in UV space.
You could have a look at the Blender Python scripts that deal with baking Procedural
Textures onto an image using the existing UV Map assigned to the given material..
(I know there is one somewhere)
I think I understand your question and Googled it, but Google don't
seem to have much on the subject.. (or we are using the wrong terminology)
Python is very like C++ so there should be some clues there.
Perhaps Max scripts could also offer some clues.
Interesting thing though..
Like to hear what you find out!
Textures onto an image using the existing UV Map assigned to the given material..
(I know there is one somewhere)
I think I understand your question and Googled it, but Google don't
seem to have much on the subject.. (or we are using the wrong terminology)
Python is very like C++ so there should be some clues there.
Perhaps Max scripts could also offer some clues.
Interesting thing though..
Like to hear what you find out!
Re: Rendering something in UV space.
You can't really get anything back from your shaders, so you might have to "re-code" those
procedures from your shaders into a C++ function which would then plot those
pixels onto an image using a Specific Formula (which I can't find) that uses your UV Map Coords
and probably all your Vertex 3D positions as well.
Looks like a extremely complex problem..
Definitely the kind of thing that would be used to program 3D Apps that
can "Bake" procedural textures onto an image.
This looks interesting
http://libnoise.sourceforge.net/example ... index.html
Google "baking procedural textures programmatically"..
procedures from your shaders into a C++ function which would then plot those
pixels onto an image using a Specific Formula (which I can't find) that uses your UV Map Coords
and probably all your Vertex 3D positions as well.
Looks like a extremely complex problem..
Definitely the kind of thing that would be used to program 3D Apps that
can "Bake" procedural textures onto an image.
This looks interesting
http://libnoise.sourceforge.net/example ... index.html
Google "baking procedural textures programmatically"..
Re: Rendering something in UV space.
That reminds me of a program called "Genetica" which was capable of generating seamless textures
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt