• Advertisement
Sign in to follow this  

Texture coordinates for a straight line and a point

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

How to genrate or calculate the texture coordinates for a straight line and a point ? Basically I have a HLSL shadre code for blur effect, it works fine with quads and triangles when I use "texCoord = Input.Position*0.5 + 0.5", but the same shader does not work when I use to blur a straight line or a point.

Regards.

Share this post


Link to post
Share on other sites
Advertisement

A pixel shader only affects the pixels that are within your rendered geometry. For the triangle case, only the pixels within your triangle are rendered by the shader. This means that the pixels that are outside of your triangle will not be affected. If you are drawing a triangle with a shader that blurs the texture you will get a blurry texture within the triangle only - it will not blur the edges to the outside of the triangle area.

 

When using the graphics card to draw lines or points, the same applies. The shader will only calculate the texture for the pixels within the line or the single point. You will thus never be able to draw blurred lines using only a shader attached to the line drawing.

 

In order to draw blurred lines you have to do a screen blur by first rendering your lines and points to an off-screen texture. Then you draw this texture to the screen using a quad and attach your blur shader to the drawing of that quad.

 

The other approach to drawing blurred lines and points is to use a pre-created semi-transparent texture of a blurred point. Instead of drawing a single line using the line drawing of the graphics card you create a thick "box"-line using two triangles to create a quad where you want the line or point to be drawn. Then just apply the "blurred point"-texture and draw the quad to the screen using a simple alpha-blending shader.

Share this post


Link to post
Share on other sites

yeh you need a pixel shader to do it.   full screen blurring is a really wicked way to spice a game up, can make a car game look really fast if you make the lines blur from the centre of the screen outwards. (doesnt just do that either, you can have full correct vectoral motion blurs on everything with a worldspace coordinate render)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement