Texture Issue?

48 views
Skip to first unread message

Jon Prime

unread,
Nov 1, 2012, 9:13:05 AM11/1/12
to pr...@googlegroups.com
Hey Dean, awesome library! I was playing with the texture cube demo and noticed that the textures seem to distort near the center of the faces? If you have a simple cube that is not moving, zoomed in,  and slowly rotating round y it's easier to see. Take a look at the attached image. You can see the word monsters on the left face has a particular warping, but the one on the right face (same texture) is "sagging" relative to the rest of the cube?

Any ideas what is going on?

Thanks,
-J
Untitled-2_03.jpg

Dean

unread,
Nov 1, 2012, 9:40:58 AM11/1/12
to pr...@googlegroups.com
Hmm, I can't see very clearly from the screenshot. One thing to note
about Pre3d or any canvas approach is that you can't do proper
perspective correct texturing, basically what happens for a quad is
the image is split in two triangles and a 2d transformation skews the
image...

I think it would help if you applied a checkerboard texture and can
then tell if it's just the fact it's a 2d warp or something else
happening.
> --
> You received this message because you are subscribed to the Google Groups
> "pre3d" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/pre3d/-/FfapF2HTL_UJ.
> To post to this group, send email to pr...@googlegroups.com.
> To unsubscribe from this group, send email to
> pre3d+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pre3d?hl=en.

Jon Prime

unread,
Nov 1, 2012, 10:10:54 AM11/1/12
to pr...@googlegroups.com
Dean, thanks for getting back to me so quickly. Attached is the same test with checkerboard. It's hard to tell but it's a cube, rotated round Y at about 45 deg. so the cube corner (vertical corner) is right about in the center of the pattern. As you can see there is a sort of "warping" up on the left face and warping down on the right face. I think this is probably due to the perspective error you were talking about but I just wanted to make sure I was not doing something wrong?

Thanks again,
-Jon
Untitled-2_03.jpg

Dean

unread,
Nov 1, 2012, 10:34:21 AM11/1/12
to pr...@googlegroups.com
http://en.wikipedia.org/wiki/Texture_mapping#Perspective_correctness

What Pre3d is doing is the "Affine texture mapping" (as show in the
Wikipedia image), so unfortunately that looks like the sort of
artifacts that come with it.

Thatcher Ulrich (who worked out the original mapping math) has a demo
of trying to subdivide the geometry to achieve better results:

http://tulrich.com/geekstuff/canvas/perspective.html

In the end you're just basically just slightly masking the problem, or
going down to the pixel level, but a few levels of subdivision can
definitely help.
> --
> You received this message because you are subscribed to the Google Groups
> "pre3d" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/pre3d/-/gL9BqErMTAAJ.

Jon Prime

unread,
Nov 1, 2012, 11:00:19 AM11/1/12
to pr...@googlegroups.com
OK. Thanks. Would the problem go away if the projection was parallel or non-perspective?

-Jon

Dean

unread,
Nov 1, 2012, 11:05:00 AM11/1/12
to pr...@googlegroups.com
No, I believe the artifacts would be the same with an orthographic
projection, it doesn't have to do with how the vertices are projected,
but how the texture is mapped.

You could try it though by removing the division by z in projectPointToCanvas.
> https://groups.google.com/d/msg/pre3d/-/08rPjbnjgBgJ.
Reply all
Reply to author
Forward
0 new messages