Question

I currently work on a panoramic viewer based on Managed DX and C#.

I created a sphere mesh and now i want to texture it with an Earth map.

I load the texture in a Texture object but when I look at the result, the texture repeats in longitude and latitude.

I think that I need a pixel shader, but i must say that I have no idea how to create one.

Can someone help me?

Thank you!

Était-ce utile?

La solution

If it is textured but just repeated then it's not a shader problem. You should correct the clamping or U/V coordinates. Shaders just help you add material qualities to the texture rendering, not modify the layout (U/V) of the texture.

This is a rough attempt on how UV should be set in respect to a flat mesh:

Mesh
+----------+----------+----------+ V=1.00
|0        3|3        5|5        7|
| vertices |          |          |
|          |          |          |
|1        2|2        4|4        6|
+----------+----------+----------+ V=0.66
|          |          |          |
|          |          |          |
|          |          |          |
|          |          |          |
+----------+----------+----------+ V=0.33
|          |          |          |
|          |          |          |
|          |          |          |
|          |          |          |
+----------+----------+----------+ V=0.00
U=0        U=0.33     U=0.66     U=1.00

I hope this helps somehow. The mesh is larger then the texture if you want to put, say, the map of the earth on the mesh.

Vertex order and how they are connected is not pertinent, I just wrote some vertex indices to give the idea that this is just one whole mesh.

You are using a sphere, which is not flat, so there is a whole theory about how non-flat surfaces should be projected on flat surfaces.

This should help you a bit further:

Google for "Earth Spherical Texture Map"

Just out of curiosity: Why do you use MDX? Wasn't it superseded by XNA? And have you tried Unity3D? Something like this is possible nearly out of the box... just put a camera inside a sphere and tweak values in the editor... maybe I'm missing something. I'm just very curious :)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top