How to get vertex position after translate in shader?

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
jayiscool
Gnoblar
Posts: 9
Joined: Fri Mar 08, 2013 8:16 am

How to get vertex position after translate in shader?

Post by jayiscool »

I creat a plane in the scene and set it a material, in vertex program I set some translate to mesh position, but when I use getMeshInfo() only get the original vertex position, how could I get the translated position?

in VS : oPosition = mul(worldViewProj, position+ float4(0,z,0,0));
User avatar
areay
Bugbear
Posts: 819
Joined: Wed May 05, 2010 4:59 am
Location: Auckland, NZ
x 69

Re: How to get vertex position after translate in shader?

Post by areay »

So you want the vertex program to update your mesh? That's a bit unrealistic because you would need to go and retrieve this data from the GPU at the end of the frame resulting in an FPS-crushing slowdown.

If you want to update your mesh as a one-off then you can get access to its vertex data and run the same simulation/modifications as your VS does (but in C++) and then save that into said vertex data of the mesh. Getting the data from the GPU after running the vertex program is a bit of a dead end.
jayiscool
Gnoblar
Posts: 9
Joined: Fri Mar 08, 2013 8:16 am

Re: How to get vertex position after translate in shader?

Post by jayiscool »

areay wrote:So you want the vertex program to update your mesh? That's a bit unrealistic because you would need to go and retrieve this data from the GPU at the end of the frame resulting in an FPS-crushing slowdown.

If you want to update your mesh as a one-off then you can get access to its vertex data and run the same simulation/modifications as your VS does (but in C++) and then save that into said vertex data of the mesh. Getting the data from the GPU after running the vertex program is a bit of a dead end.
Thank you for your advice! But if transliation in program, how to verification the result of cpu is equal to gpu.
drwbns
Orc Shaman
Posts: 788
Joined: Mon Jan 18, 2010 6:06 pm
Location: Costa Mesa, California
x 24

Re: How to get vertex position after translate in shader?

Post by drwbns »

Interesting topic, is there no way to tell the mesh of a translation using a geometry shader? Maybe http://www.ogre3d.org/docs/api/html/cla ... uffer.html could help here?
User avatar
areay
Bugbear
Posts: 819
Joined: Wed May 05, 2010 4:59 am
Location: Auckland, NZ
x 69

Re: How to get vertex position after translate in shader?

Post by areay »

It's probably OK to do as a one-off, just not every frame.
jayiscool
Gnoblar
Posts: 9
Joined: Fri Mar 08, 2013 8:16 am

Re: How to get vertex position after translate in shader?

Post by jayiscool »

drwbns wrote:Interesting topic, is there no way to tell the mesh of a translation using a geometry shader? Maybe http://www.ogre3d.org/docs/api/html/cla ... uffer.html could help here?
There is little examples about geometry shader, I have never use it. But the link here may couldn't do what I want.
Post Reply