Jump to content
  • Advertisement
Sign in to follow this  

Artifact when mapping texture on sphere ( Mesh ? )

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I noticed, that when I try map texture on Sphere generated by
Mesh.Sphere(...) metod

this.mesh = Mesh.Sphere(this.device, this.planetRadius, 32, 32);
CustomVertex.PositionNormalTextured[] vb =
0, this.mesh.NumberVertices);

double R = this.planetRadius;
double theta, theta2;
double x1, y1;
for (int i = 0; i < this.mesh.NumberVertices; ++i)
theta = Math.Asin(vb.Y / R); //-PI/2~PI/2
theta2 = Math.Atan2(vb.Z, vb.X); //-PI~PI

x1 = (theta2 / Math.PI / 2.0) + 0.5; //0.0~ 1.0
y1 = ((theta / Math.PI * 2.0) + 1.0) / 2.0;

vb.Tu = (float)x1;
vb.Tv = 1.0f - (float)y1;

In place, when start and end of the tetxture connect togeter ( when
vb.Tu has values 0 i 1 ) a strange narrow strip occurs, which has
color of pixels like points with vb.Tu = 0.5.

It is not transparency / alpha blending - there could not be seen
pixel behind sphere.

It is not probably problems with ZBuffer ( like descripted here:
http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html ) - I had
presentParameters.AutoDepthStencilFormat = DepthFormat.D24X8;
and zNearClipPlane in device.Transform.Projection to 1.

I checked rounding and accuracy of calculations ( float, double
casting etc. )
I tried also values of vb.Tu close to 0 and 1 ( less to 0.001 or
higher to 0.999 ) set to 0 and 1, but it doesn't helps.

What is interesting, when I changed device.RenderState.FillMode to
WireFrame I can see, that this strip has not connected with vertex -
the wrong color is a small part of traingle - not cover whole triangle
from vertex to vertex.

For any help thanks in advance!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!