Jump to content
  • Advertisement
Sign in to follow this  
Dom_152

Multi pass vertex shader?

This topic is 3788 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

I know that one way of doing multi pass pixel shaders is to simply re-render the vertices with some blending mode on with each different shader you want. That's fine, I understand that but I was thinking about stuff like animation on the GPU. So you would write a vertex shader to take into account animation joint weights or whatever it is you have and calculate the vertex position. But what if you wanted to do that and then have a shader which transformed it on to a shadow plane. Is it possible to have separate shaders for each of those and then do a similar "multi-rendering" technique for getting them both done. If not are there are similar sort of alternatives or would you just have to have an "uber-shader"?

Share this post


Link to post
Share on other sites
Advertisement
I haven't looked into them at all, but my understanding is that geometry shaders are designed for doing this sort of thing. Also render vertex to texture maybe?

Share this post


Link to post
Share on other sites
I just had a thought that maybe rather than rendering the stuff I can somehow just get hold of the resulting vertex data and the push that into the next shader and so on, rather than continually using the original data. Can this be done somehow?

Share this post


Link to post
Share on other sites
Quote:
Original post by Dom_152
I just had a thought that maybe rather than rendering the stuff I can somehow just get hold of the resulting vertex data and the push that into the next shader and so on, rather than continually using the original data. Can this be done somehow?


This is a valid approach and could probably be a win for complex meshes. There are a few ways to accomplish it depending on the platform you're working on, off the top of my head you have:

-ATI's render to vertex buffer (R2VB). Uses a driver trick that allows you to render vertex data as to a vertex buffer as if it were a standard render target. Available in ATI DX9-class GPU's under D3D9. I believe Valve uses this for their facial animation system.

-Streamout through a geometry shader. Requires DX10-class hardware, can be done in D3D10 or in OpenGL via vendor-specific extensions.

-MEMEXPORT in the Xbox 360. Don't know much about it because I don't have an Xbox SDK, but it's obviously only available for that platform.

Share this post


Link to post
Share on other sites
Sorry its not render vertex to texture its render to vertexbuffer I was thinking of (thread).
Or geometry shaders. They both allow you to do what you are asking.

Share this post


Link to post
Share on other sites
Thanks for the information on Render-to-vertex buffer information, guys. I'll look into that more.

I've just read about a "ProcessVertices" method that D3D has. I think it processes the vertices (No waii!!?!?!111) and dumps them into the given vertex buffer. Not sure if it works with shaders I read it does the processing on the CPU. Can anyone confirm this?

Never mind I just read on MSDN: "Applies the vertex processing defined by the vertex shader to the set of input data streams, generating a single stream of interleaved vertex data to the destination vertex buffer."

This looks like a good way to do it, on D3D9 at least.

A shame that most of the methods seem to be API or GPU dependant which is slightly annoying.

Share this post


Link to post
Share on other sites
ProcessVertices does all of its work on the CPU, and has some restrictions (I think the VB has to be in system memory, for instance). Software skinning isn't too bad of an option on higher-end CPU's where you can run it on another core, or GPU's that do all of their vertex processing on the CPU anyway (integrated chipsets).

Share this post


Link to post
Share on other sites
Hmm, that's bit annoying. It's not skinning specifically. I'm just thinking about multiple vertex shaders in general in a similar fashion to pixel shaders. Another example might be having a single shader which does transform and lighting and then running it multiple times for different lights.

I suppose if it can't be done I can stick with a basic transform, lighting and skinning shader where number of lights and joint influences are limited to a set number.

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!