Jump to content
  • Advertisement
Sign in to follow this  
JDX_John

Spatial transforms in shaders

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

Let's say I define a spline-based coord system. Vertex positions are set relative to a straight line, and we view bending the spline as deforming the coordinate system. Or another example would be modeling a gravity well... situations where a coordinate system is not linear.

How can you move this kind of task to the (vertex?) shader, so it knows how to transform the vertex from its special coordinate system to a regular 3D cartesian space? You'd have to have a way to describe the coordinate system in some way - the spline example means the shader would need to understand how the spline works, etc.

Any good articles on this?

Share this post


Link to post
Share on other sites
Advertisement
A shader is code you're writing, so if that's how you want to deform vertices then go for it. Nothing is stopping you, except possibly data representation. If you wanted to use a Bezier curve as your basis, you could have a constant array in the shader that defines the coefficients of the desired curve. The math for transforming the vertices will be no different than they would be anywhere else.
spline example means the shader would need to understand how the spline works, etc.[/quote]I think that's a given. The vertex shader is doing the transform, it has to be aware of the transformations being done. In most graphics work the transformation can be represented as a basis change with translation (yielding a 4x4 matrix), but it certainly doesn't have to be that way.

Share this post


Link to post
Share on other sites
A spline can be a fairly complex bit of code, working out the axes at any point along the spline. So I suppose my question is how easily you can move all that to shaders... big arrays of the spline control points and so on.
Is it sensible to put all of that into the VS,,, or to pre-calculate a bunch of stuff on the CPU so the VS has much simpler calculations to do? I'm targeting SM3, which probably is relevant to this discussion.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!