Skip to main content
gamedev.net
🔒 Locked

Spotlight

Started by bleyblue2 Nov 20, 2004 at 5:20 PM 4 replies 1.2k views
Original Post
bleyblue2
bleyblue2
Hi everyone, i'm currently implementing a spotlight by projective texturing and pixel&vertex shaders (HLSL) but i've got some artifacts, like that : I'm implementing a clip plane at the spotlight position, to prevent the light from showing at both sides. I am setting the spotlight texture addressing mode at CLAMP on U and V. Has already someone experienced that sort of problem ? Any help will be appreciated. Feel free to ask me of renderstates and code if you need it.
_code_fly
_code_fly
man, you could be the same person who hacked my pc.

the answer is that it's definately the filter you've applied.
It happens when I use trilinear filtering on texture stage 2.
Namethatnobodyelsetook
Namethatnobodyelsetook
Don't start your UVs at 0,0. Start them at 0.5 texels (ie 0.5/256.0 for a 256x256 texture). When you say UV 0,0 you're saying it's half the first pixel and half the last pixel, resulting in guaranteed wrapping with anything but a point filter.

In OpenGL starting at 0,0 would be correct. In DirectX it's not.

edit: Oh, and since you're projecting... perhaps you should use CLAMP or BORDER texture addressing (and set border to transparent, or black or whatever won't show up for you).

You might be able to adjust your clipping planes to cut off at the 0.5 texel mark instead of the changing the addressing instead. Whichever is easiest.
bleyblue2
bleyblue2
Quote:
Original post by Namethatnobodyelsetook
Don't start your UVs at 0,0. Start them at 0.5 texels (ie 0.5/256.0 for a 256x256 texture). When you say UV 0,0 you're saying it's half the first pixel and half the last pixel, resulting in guaranteed wrapping with anything but a point filter.

In OpenGL starting at 0,0 would be correct. In DirectX it's not.


Thank you !! The problem disappeared when i added those 0.5 texels. (btw my addressing mode was CLAMP).
_code_fly
_code_fly
that's not what worked for me ...
I have got a function that set's a texel aligning projection matrix and I definately use a clamp address mode.

when I apply a trilinear filter to the projected texture channel I get the artifact as shown in the picture.

How could the trilinear filter mess with the texel alignment in order to produce such an effect?

I can post code and screenshots if you want/.
bleyblue2
bleyblue2
i suppose the trilinear filter interpolates the color value located at the texture's edges, so that they are no longer black and transparent, therefore this problem.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.