santyhamer
05-30-2006, 05:00 PM
Hi! I know how to blur a 2D texture using a filter kernel.. Something like:
vec2 off = vec2(1/texWidth,1/texHeight);
vec2 uv = gl_TexCoord[0];
vec4 col = texture2D(myTex,uv)*0.25 +
texture2D(myTex,uv+off)*0.25 +
texture2D(myTex,uv+vec2(off.x,0))*0.25 +
texture2D(myTex,uv+vec2(0,off.y))*0.25you know the concept...
BUT, how can I do that with a cubemap texture if I only know the normalized vector? I see somebody does this:
textureCube(myTex,dir+vec3(2.0,1.0,-1))
textureCube(myTex,dir+vec(-1.0,2.0,1.0))But I don't know why... Adding those vectors you will get only weird data... How can I get the offsets to get the neighbor pixels in a cubemap??? Divide by greatest XYZ element and see signs to know the face and then use the texture2D approach? Derivatives? Hooooooooooow? Ofc I don't want to unwrap the cubemap into a 2D texture like in the ShaderX3 and neither like NVIDIA did with Mike's demo...
Notice perhaps is very easy to achieve this using "texture-coord wrapping mode", specifying a (s,t)+(1.0,-1.0) and using special texture clamp mode perhaps could give you the neighbors... I think thats why some people do the textureCube(tex,off+(2,1,-1)). Any ideas?
thx.
vec2 off = vec2(1/texWidth,1/texHeight);
vec2 uv = gl_TexCoord[0];
vec4 col = texture2D(myTex,uv)*0.25 +
texture2D(myTex,uv+off)*0.25 +
texture2D(myTex,uv+vec2(off.x,0))*0.25 +
texture2D(myTex,uv+vec2(0,off.y))*0.25you know the concept...
BUT, how can I do that with a cubemap texture if I only know the normalized vector? I see somebody does this:
textureCube(myTex,dir+vec3(2.0,1.0,-1))
textureCube(myTex,dir+vec(-1.0,2.0,1.0))But I don't know why... Adding those vectors you will get only weird data... How can I get the offsets to get the neighbor pixels in a cubemap??? Divide by greatest XYZ element and see signs to know the face and then use the texture2D approach? Derivatives? Hooooooooooow? Ofc I don't want to unwrap the cubemap into a 2D texture like in the ShaderX3 and neither like NVIDIA did with Mike's demo...
Notice perhaps is very easy to achieve this using "texture-coord wrapping mode", specifying a (s,t)+(1.0,-1.0) and using special texture clamp mode perhaps could give you the neighbors... I think thats why some people do the textureCube(tex,off+(2,1,-1)). Any ideas?
thx.