Jump to content
  • Advertisement
Sign in to follow this  

Texel - pixel mapping

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

Hi, if I'm doing post processing and I'm setting texel -> pixel mapping like this:
public void RenderToTexture(Effect effect, int width, int height)
  CustomVertex.TransformedTextured[] vertices = new CustomVertex.TransformedTextured[4];

  #region Vertex initialization
  // To correctly map from texels->pixels we offset the coordinates by -0.5
  vertices[0].Position = new Vector4(-0.5f, -0.5f, 0.0f, 1.0f);
  vertices[0].Tu = 0.0f; vertices[0].Tv = 0.0f;

  vertices[1].Position = new Vector4(width - 0.5f, -0.5f, 0.0f, 1.0f);
  vertices[1].Tu = 1.0f; vertices[1].Tv = 0.0f;

  vertices[2].Position = new Vector4(-0.5f, height - 0.5f, 0.0f, 1.0f);
  vertices[2].Tu = 0.0f; vertices[2].Tv = 1.0f;

  vertices[3].Position = new Vector4(width - 0.5f, height - 0.5f, 0.0f, 1.0f);
  vertices[3].Tu = 1.0f; vertices[3].Tv = 1.0f;


  device.VertexFormat = CustomVertex.TransformedTextured.Format;

  if (effect != null)
    int passes = effect.Begin(0);
    for (int pass = 0; pass < passes; pass++)
      device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, vertices);
    device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, vertices);

If the whole post processing is done in the pixel shader, do I need to use vertex shader at all (and if yes, how should it look like)? Or can I do something like this:
technique UpdateLocalLuminance
  pass P0
    VertexShader = null;
    PixelShader  = compile ps_2_0 PS_UpdateLocalLuminance();

? [Edited by - g0nzo on October 19, 2006 8:38:51 AM]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!