Sign in to follow this  
g0nzo

Texel - pixel mapping

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;

  #endregion

  device.VertexFormat = CustomVertex.TransformedTextured.Format;

  if (effect != null)
  {
    int passes = effect.Begin(0);
    for (int pass = 0; pass < passes; pass++)
    {
      effect.BeginPass(pass);
      device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, vertices);
      effect.EndPass();
    }
    effect.End();
  }
  else
  {
    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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this