Jump to content


texture mapping, uv coordinates


4 replies to this topic

#1 kruseborn

    Member

  • Members
  • PipPip
  • 33 posts

Posted 02 February 2009 - 12:54 PM

Am trying to write diffuse light to a texture in uv coordinates.
My vertex shader look like this:
output.pos = float4( (input.tex.xy * 2.0) - 1.0, 0.5, 1.0);

If am trying to read from this texture later:
float3 res = texLightMapUV.Sample(LINEAR_CLAMP, input.tex);
return float4(res, 1.0f);

Am getting a small error, its lookes like the texture is too small for the object. So I was thinking it was some kind of offset error when am writing to the texture. So i was trying with:
float offset = (1.0/1024.0)*0.5;
input.tex.xy += offset;
//input.tex.xy -= offset;
//input.tex.xy += float2(offset, -offset);

When i do this its looks better but its not ok,
Am using directx 10.

#2 rouncer

    Senior Member

  • Members
  • PipPipPipPip
  • 2258 posts

Posted 03 February 2009 - 10:57 AM

try clamping the texture

#3 kusma

    Valued Member

  • Members
  • PipPipPip
  • 163 posts

Posted 03 February 2009 - 07:39 PM

Could you post a screen-shot?

#4 kruseborn

    Member

  • Members
  • PipPip
  • 33 posts

Posted 04 February 2009 - 10:10 AM

I find the problem, when I was writing to a new texture in texture space I just writing color to the pixels just inside the coordinates. Then when am reading from it i get aliasing problem. Because some pixels are black. When i was reading from a normal texture the picture is always a little bit bigger then the coordinates.

I solved it by doing a dilation filter after.

#5 kusma

    Valued Member

  • Members
  • PipPipPip
  • 163 posts

Posted 04 February 2009 - 10:11 AM

Ah, yes. Common problem :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users