environmental map artifacts in DirectX

I did a test of environmental mapping with a simple sphere and an env map. There’s a solid color texture and then a environmental stage that I set up like this:

    nodePath.set_tex_gen(ts_shine,    TexGenAttrib::M_eye_sphere_map);

But when I add that stage I get pixel artifacts at the border of the sphere, notice in this picture the light pixel on the bottom left of the sphere:

This only happens in DirectX, not in OpenGL.

After experimentation it seems that those pixels are random colors that are inside the texture map, on the center. For example if I put a red circle in the middle of the environmental map I will get red pixels all around the border of the sphere, regardless of the perspective. Is there any way to avoid that?

This may seem unimportant in a static screenshot but when the camera is moving the pixels jump around intermittently making them very noticeable.

EDIT: Same thing happens with cube mapping. I see in DirectX Panda has to do the mapping manually, which is where the problem is…

I know that the equation used in the fixed-function DirectX sphere map calculation is different than the equation used in the fixed-function OpenGL sphere map calculation, so the map won’t match up precisely between the two API’s. Panda attempts to fiddle the numbers to make them as close as possible.

But what you’re describing sounds like it might be a driver bug. I don’t know what you mean about Panda computing the cube-map mapping manually. DirectX handles that automatically, the same as OpenGL; and in fact in cube mapping the two equations are the same. In any case, the precise placement of pixels is handled by the graphics driver, so it’s hard to know how Panda could affect this placement.

In general, it’s a good idea not to have high contrast areas in your environment maps. If you do, you’re likely to see artifacts like this, because the nature of environment mapping tends to put pixels from widely disparate parts of the map next to each other. If you didn’t have a red circle in the middle of the map, it would be less obvious when a pixel is pulled from the middle of the map. :slight_smile:


Yeah, by manually I mean that Panda transforms the coords manually with a matrix, translate it by half and scale it to a third I think.

But anyway, the thing is that the artifacts aren’t there in OpenGL, only in DirectX. It also happens with cube mapping. I know for certain that I shouldn’t get artifacts of any kind with cube mapping in directx, because I’ve run a DX demo of it, Panda is obviously doing something wrong.

Also, if I remove the transformation above although I don’t get the same reflection layout than GL_SPHERE_MAP (naturally) but I get no artifacts. The artifacts are really noticeable and they are not aliasing so it’s not a matter of contrast, they are pixels that shouldn’t be there at all.

Yeah, but the transform you’re referring to is the one that attempts to match up the DirectX sphere map with the OpenGL sphere map. Panda doesn’t apply any such transform for cube mapping.