Texture Mapping extension

RE: Texture Mapping extension
(2018-01-26, 21:39)Roland Melkert Wrote: I'm very interested in the way you are planning to implement it, In LDCad I decided to use a slightly different approach then the one described in the spec as  it helps with full spheres and doesn't seem to affect other usage (much) visually wise.

Thanks for the test mpd and for explaining the conventions you're using. I hope we can convince Joshua to clarify the spec but if we don't, at least our apps will be consistent.

I also tried following what the spec suggests but I don't think the value of v can be calculated that way. This is what I used, it's probably similar to what you mean by longitude and latitude:

lcVector3 VertexDir = Position - Center;
float DotPlane1 = lcDot(lcVector4(Position, 1.0f), Plane1);
lcVector3 PointInPlane1 = Position - lcVector3(Plane1) * DotPlane1;
float DotFrontPlane = lcDot(lcVector4(PointInPlane1, 1.0f), FrontPlane);
float DotPlane2 = lcDot(lcVector4(PointInPlane1, 1.0f), Plane2);

float Angle1 = atan2f(DotPlane2, DotFrontPlane) / LC_PI * TextureMap->Angle1;
TexCoord.x = 0.5f + 0.5f * Angle1;

float Angle2 = asinf(DotPlane1 / lcLength(VertexDir)) / LC_PI * TextureMap->Angle2;
TexCoord.y = 0.5f - Angle2;

Basically I project the vertex into p1 and get the atan of that point for u, and then for v it's the angle of the triangle where the opposite side is the distance to plane 1 and the hypotenuse is the distance to the center. 

This approach works well except at the north/south poles and at the back where the 2 sides of the projection meet (u jumps from 0 to 1). I only have the vertex positions when I calculate the UVs, I need to change how I do things so that I have triangles instead of points and then these problems will be trivial to fix. Did you run into similar problems?
« Next Oldest | Next Newest »

Messages In This Thread
Re: Texture Mapping extension - by Tim Gould - 2012-04-14, 22:08
Re: Texture Mapping extension - by Tim Gould - 2012-11-15, 22:51
RE: Texture Mapping extension - by Leonardo Zide - 2018-01-28, 0:29
Re: Texture Mapping extension - by Tim Gould - 2012-11-30, 21:55

Forum Jump:

Users browsing this thread: 1 Guest(s)