i use D3DXCreateSphere
method to create sphere mesh. and i want to apply an earth texture on it. i calculate the texture coordinate in pixel shader with following code:
sampler ShadeSampler = sampler_state
{
Texture = (ShadeTex);
AddressU = Mirror;
AddressV = Mirror;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = LINEAR;
};
PS_OUTPUT PSMain(VS_OUTPUT input){
PS_OUTPUT output = (PS_OUTPUT)0;
vector uv;
uv.x = 0.5 + atan2(input.normal.z, input.normal.x) / piMul2;
uv.y = 0.5f - asin(input.normal.y) / pi;
vector b = tex2D(ShadeSampler, uv.xy);
output.diffuse = b * input.diffuse;
return output;
}
i use D3DXCreateTextureFromFileEx
method to create the IDirect3DTexture9
, but when i enable the mipmap capability by using D3DX_DEFAULT
value for the MipLevels
parameter, the render result goes a little wrong that there is always one pixel line at the seam. the picture below shows the problem, but when i disable the mipmap capability by using D3DX_FROM_FILE
value for the MipLevels
parameter, the line disappears. i don't know why this would happen, any advice?