Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Vertex Shader responsabilities if I have Tessellation Shader


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 jjtulip   Members   -  Reputation: 148

Like
0Likes
Like

Posted 19 July 2014 - 03:17 AM

Hi all!

I'm recently considering adding an Tessellation shaders to my pipeline, but I have some question that I'd like to clear off my mind before moving on. 

 

At the moment my VS calculates the positions of vertices in various spaces (world space, view space, screen space) but also for example coordinates in light space for the shadow calculation. Moreover I also calculate the TBN vectors for normal mapping in the fragment shader. Nothing more. 

As after the vertex shader new vertices are created by the tessellation step, should I move all the above to the TES leaving the vertex shader with the only responsabilities of transforming to world space and passing stuff to the TCS? 

I believe the answer is yes, but being I a complete newbie in this I'd like to ask first as such change will require a big change in other parts of my applications.

Also, this will obviously decrease the performances as the instructions are executed more often, so what can I still do, safely, in the vertex shader? 

 

Thank you very much


Edited by jjtulip, 19 July 2014 - 03:19 AM.


Sponsor:

#2 marcjulian   Members   -  Reputation: 312

Like
1Likes
Like

Posted 19 July 2014 - 05:41 AM

It helps to think of the shader pipeline as a set of refinement steps in my experience.

 

The earlier you can calculate something in the pipeline the cheaper it usually is (barring interpolator costs etc. so caveat empor).

 

If you have a calculation you can do in the vertex shader because it affects all triangle emitted by the tesselation the same then do it there instead of in the tesselation stage.

One example would be shader based skinning. Usually your vertices are affected by the bones and all tesselation generated triangles move the same based on the "basis" triangle coming from the vertex shader stage. This would speak for performing the skinning calculations in the vertex shader as it is called less often (and you benefit from the vertex reuse cache as well).

 

It always depends on what exactly you want to achieve. For example your vertex shader can transform all vertices to world space and then your tesselation stuff can do it's operation in world space. If on the other hand you have some calculation which needs to happen in object space (in the tesselation stage) you need to move the transform step further back.

 

The usual implementations I have seen have used world space for most operations after the vertex shader so it was safe to have TBN calculations etc. in the vertex shader stage. Often you can also find transformations to move your problem between the stages even if it doesn't look like that first.

 

Bye,

Marc



#3 jjtulip   Members   -  Reputation: 148

Like
0Likes
Like

Posted 19 July 2014 - 12:35 PM

It helps to think of the shader pipeline as a set of refinement steps in my experience.

 

The earlier you can calculate something in the pipeline the cheaper it usually is (barring interpolator costs etc. so caveat empor).

 

If you have a calculation you can do in the vertex shader because it affects all triangle emitted by the tesselation the same then do it there instead of in the tesselation stage.

One example would be shader based skinning. Usually your vertices are affected by the bones and all tesselation generated triangles move the same based on the "basis" triangle coming from the vertex shader stage. This would speak for performing the skinning calculations in the vertex shader as it is called less often (and you benefit from the vertex reuse cache as well).

 

It always depends on what exactly you want to achieve. For example your vertex shader can transform all vertices to world space and then your tesselation stuff can do it's operation in world space. If on the other hand you have some calculation which needs to happen in object space (in the tesselation stage) you need to move the transform step further back.

 

The usual implementations I have seen have used world space for most operations after the vertex shader so it was safe to have TBN calculations etc. in the vertex shader stage. Often you can also find transformations to move your problem between the stages even if it doesn't look like that first.

 

Bye,

Marc

 

 

Thank you! 


Edited by jjtulip, 19 July 2014 - 12:35 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS