Question

How exactly is Stage3D able to make a correct texture mapping when using a perspective matrix?

No information other than UV is transferred from vertex to fragment program, so I can only assume it's something behind the scenes.

I'm distorting textures with a 20x20 triangle mesh to circumvent the affine mapping effects but shouldn't it be possible to use the built-in perspective divide for the same effect?

Was it helpful?

Solution

When your vertex coordinates are transformed into clip space, the W component of your vertices will provide the coefficient for interpolating texture coordinates in a perspective correct fashion. As far as I'm aware, this is 'magic' provided to you by OpenGL frustum matrix and the 3D hardware should use this value during interpolation. The Stage3D library doesn't provide any guarantees of how interpolation is performed for the fragment shader for UV coordinates.

It's also worthwhile to note that according to reports, some OpenGL ES 1.1 spec Android phones do not support perspective correct texturing. So it's something that will vary between devices, even if Stage3D does support it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top