Hi,
this is not directly related to OGRE, but I hope there is someone who could give me a hint what to do...
I am passing data to pixel shader via textures. I am pretty sure that this is a usual technique - every vertex has encoded a UV coordinates where to look for a data in the texture, which is dynamically changed according to the game state. This way I am able to change the data and the output itself.
This is working fine, but I would like to do similar thing in vertex shader and VS does not have an access to textures (only its UV coordinates). Is there a way to do similar thing in VS? What is the best way to do this?
Thank you very much for all advices.
Passing data to vertex shader
-
- OGRE Moderator
- Posts: 7157
- Joined: Sun Jan 25, 2004 7:35 am
- Location: Brisbane, Australia
- x 535
Re: Passing data to vertex shader
Vertex shaders can read from textures too, but only if you are using shader model 3 or above.
(Note, mip map level must be manually specified, since the info needed for automatic mip maps isn't known until the pixel shader)
(Note, mip map level must be manually specified, since the info needed for automatic mip maps isn't known until the pixel shader)
-
- Gnome
- Posts: 368
- Joined: Tue Jan 06, 2009 1:12 pm
- x 43
Re: Passing data to vertex shader
Hi Kojack,
thank you very much for your answer. I didn't know that it is possible to read it also in VS, however I am trying to target shader ps_2_1, vs_2_1. What is the best approach for these?
thank you very much for your answer. I didn't know that it is possible to read it also in VS, however I am trying to target shader ps_2_1, vs_2_1. What is the best approach for these?
-
- OGRE Team Member
- Posts: 5490
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1361
Re: Passing data to vertex shader
It is impossible to read data the way you want in these shader profiles. Note that these profiles are rather old (they target the old GeForce FX 5000 and ATI Radeon 9000 series; which are like 14 years old).kubatp wrote:Hi Kojack,
thank you very much for your answer. I didn't know that it is possible to read it also in VS, however I am trying to target shader ps_2_1, vs_2_1. What is the best approach for these?
The best way you can send data to the vertex shader is by setting an extra attribute to the vertex buffer (i.e. an extra TEXCOORD) or try to index a shader parameter (i.e. myConstParam[vertex.texcoord0.x]). However shader model 2.x has a limit of 256 uniform parameters (i.e. 256 float4)
-
- Gnome
- Posts: 368
- Joined: Tue Jan 06, 2009 1:12 pm
- x 43
Re: Passing data to vertex shader
Thank you.
What is your professional opinion about this? 256xfloat4 is more than enough. With every vertex I will add there special TEXCOORD, which will have encoded the "index" of the uniform parameter.
Is this possible to do? Does it have a performance impact?
What is your professional opinion about this? 256xfloat4 is more than enough. With every vertex I will add there special TEXCOORD, which will have encoded the "index" of the uniform parameter.
Is this possible to do? Does it have a performance impact?