# 3d Texture Clamp (Cube Maps with respect to length?)

This topic is 4871 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have been tinkering with the idea of using a 3d texture for a lighting function with distance attentuation (and shadows, making computation at runtime impossible) however there is a problem in that the clamping of the texture only seems to be possible with respect to a single texture coordinate, meaning that rather than acting like a cube map of the outer 6 sides of the texture [without respect for length once the the vector hits the edge of the 3d texture] the texel accessed will continue to change as the length of the vector changes. One solution to this would be to use a sequence of cube maps interpolating between them but this would probably be both hard to implement and slow. I am wondering whether or not there is any extension, clamping mode, texture type, or other that could solve this problem? In short I need a texture lookup that acts like a 3d texture unless the vector is outside of [0,0,0]->[1,1,1] in which case I need it to access the last texel along the vector that lies within the box (like a cube map). Hopefully I'm making some sense here, it's rather confusing to explain... Thanks, ~SPH Edit: I could also check bounds and if it is out of bounds then grab from a cube map, but this wouuld require a fragment shader and be rather slow.

##### Share on other sites
WRT 3d textures i think u can use GL_CLAMP... (defualt is repeat) thus this shouldnt be accuring
Quote:
 the texel accessed will continue to change as the length of the vector changes

one thing is u need to set the clamp method for all 3 axis's

##### Share on other sites

I should've clarified by saying that when the vector is out of the box I need the texel at the point of intersection with the box [0 0 0] -> [1 1 1].

Example:

The coordinates [0 0 0], [.5 1 0], [1 2 0], [2 4 0] are all colinear, but the clamped points [0 0 0], [.5 1 0], [1 1 0], [1 1 0] are not. The points that I need sampled are [0 0 0], [.5 1 0], [.5 1 0], [.5 1 0] because the point of intersection is [.5 1 0], and that's where it should be clamped (pictured like a cube map).

Thanks, ~SPH

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• 14
• 11
• 28
• 15
• 39
• ### Forum Statistics

• Total Topics
634836
• Total Posts
3019544
×