Jump to content
  • Advertisement
Sign in to follow this  
Medium9

Mesh to Texture?

This topic is 3465 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

G'day, it's me again with something that probably is quite simple, but I have difficulties getting this straight. For some fancy shader-stuff, I need to know all vertex positions (in world space) of a given mesh. So I thought that passing a ABGR32F texture that contains all vertice coordinates could be a possible solution. I only need the raw position, no normals or colors or such things. I've two issues with this: 1) First, I wanted to do this in my actual application by reading out the vertices from a Mesh object (SlimDX) that I loaded from a .x file. Problem 1 was born: How to access individual vertices from there, and how do I know what these vertices look like? 2) Then it came to my mind that I might want dynamic meshes, in which case filling this texture for each frame would probably take too much time. So I thought about a pre-pass of shaders that would output this texture, but I have a hard time coming up with a combination of vertex+pixelshader that will output the vertex positions in such a fashion, since I don't neccessarly get to "see" all vertices in the PS, and other reasons. It would be nice if I somehow could write to a texture from within a VS, and additionally had access to some kind of index to know in the VS which vertex I currently process, thus where to put it in this texture. Is anything like this even possible? Thanks in advance for any idea. My mind is quite stuck at the moment.

Share this post


Link to post
Share on other sites
Advertisement
Hi,

If you must process the entire mesh in a shader, I suggest you rethink your approach.. I guess you're much better of leaving that to the CPU. But that's only my two cents.

Share this post


Link to post
Share on other sites
The point is, that I need them in the pixelshader no matter how. I of course could fill a texture entirely on the CPU (see question 1), but as soon as any kind of movement is involved this won't be practicable anymore for each frame, which is what #2 aims at.

If this is entirely impossible I'll have to scrap that effect, but until someone says so, I'll keep looking for a way :)

Share this post


Link to post
Share on other sites
I don't really understand why you need to update the position parameters each frame if the object moves. The idea of saving raw position is that you can modify them by a matrix to a given animated position, based on bone movements. Using those transformation matrices ON the vertices in a texture from the ORIGINAL model would be an idea, but i don't totally get what you want tbh :)

Unless you are using an old way of rendering, which means key frame animation? Then you could try to reduce your vertex use, save each position of each animation in a texture and create an offset list, so that depending on what animation frame your object is, you can retrieve the vertexPosition + animationOffset from the texture.

dunno if this helps though :oD

Share this post


Link to post
Share on other sites
The goal was a proximity shader that works on texel-to-vertex distances. For that I would need some sort of access to the actual vertex data from within the PS, best in an array-like fashion.
So far, there is no animation used. I plan to, but most probably not by keyframing.
It isn't even THAT much of an important thing, more a (quite) nice to have. But from the responses for now I conclude that this may not likely be doable with a relatively simple approach as I imagined =)

Share this post


Link to post
Share on other sites
I think you are up against a tough problem - it is not easy to take a manifold mesh and dynamically put it into a texture. However, you can check out the work that Hugues Hoppe has done on 'Geometry Textures'. In his original paper on the topic, he mentions some ways to choose a cutting line and some parameters for doing so.

Keep in mind that you will need some way to know what vertex data is in a particular part of the texture so that you aren't trying to search through the whole thing. This is the tricky part - due to the irregularity of the mesh you have to be able to work backwards from texture coordinates to a local area, then sample the textures. If you get something up and running I would love to see you post about how you did it and what types of problems you ran into and solved!

Share this post


Link to post
Share on other sites
Given the apparent complexity of this, and the comparably minor use I'd draw from it, I'll postpone this to when the rest is more or less done. But I certainly have not given up on it!
Also many thanks for pointing at the paper - just from the name of it, it already exactly sounds like what I try to do.

I bookmarked this, so that I don't forget to update you whenever I have some results.

Share this post


Link to post
Share on other sites
Quote:
Original post by Medium9
Given the apparent complexity of this, and the comparably minor use I'd draw from it, I'll postpone this to when the rest is more or less done. But I certainly have not given up on it!
Also many thanks for pointing at the paper - just from the name of it, it already exactly sounds like what I try to do.

I bookmarked this, so that I don't forget to update you whenever I have some results.


Good luck on it, whenever you find or invent something I am curious about it as well!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!