V-up texture coordinate support
chien.yang at oracle.com
Tue Oct 22 13:49:26 PDT 2013
Thanks for the feedback. Since we have decided to go with a
Y-down 3D coordinate system it is natural, and for internal consistency,
that we stick with a V-down texture.
Yes, we have considered both (1-v) coordinates flip and image
flip. Our preference is to do the coordinates flip in the shader if
On 10/21/2013 3:56 PM, Arnaud, Remi wrote:
> Hi Kevin and Chien,
> Most 3D data formats/files are using the 'openGL' convention (right handed, and V-up textures). A lot are using y-up, but this does not matter that much in regards to the texture V-up issue.
> Of course there is also the 'directX' convention (left handed, V-down textures).
> I think you have to decide which one of those two systems you want to use, and take ALL the conversions from one or the other system. There is no point creating yet another set of conventions.
> If you stick with a V-down texture, it would be nice to have a way to let the rendering engine take care of this. In all modern graphics API it is very simple to add (1-v) math to the vertex shader for instance.
> Without direct access to the shader, I would think a flag to set the V-up or V-down for a model would be a simple addition to the API.
> It is not hard to calculate new UV coordinates at load time, but it is prone to errors in case some other calculations depend on the UV coordinate system. Makes the code non portable.
> Alternatively, you may want to adopt the same help method used by WebGL (OpenGL convention) that has to live in a web browser, where Canvas 2D images are the other direction by default.
> In this case, the shader is not changed, but the image loader is loading the image upside down, keep 2 copies of the image in memory…
> see: gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
> -- Remi
> From: Chien Yang <chien.yang at oracle.com><mailto:chien.yang at oracle.com>
> Date: Thu, Oct 17, 2013 at 3:08 PM
> Subject: V-up texture coordinate support
> To: OpenJFX <openjfx-dev at openjdk.java.net><mailto:openjfx-dev at openjdk.java.net>
> Hi all,
> Java images are defined such that (0, 0) references the top left most pixel of the image. In JavaFX, the texture coordinate system for 3D objects is defined with its U axis increasing from left to right and the V axis increasing from top to bottom. Hence a texture coordinate of (0, 0) references pixel (0, 0), which is the top left corner of the texture, and a texture coordinate of (1, 1) references the bottom right corner of the texture. This system matches the layout of the image, which is stored such that the top-most row of pixels ends up in memory in row 0. It also matches with the default 3D coordinate system used in JavaFX where the X axis increases from left to right and the Y axis increases from top to bottom.
> We understand that this V-down coordinate system maybe confusing or hard to work with for some 3D content developers when using models that are defined with Y-up. We could add a V-up option (as a boolean property of Shape3D). If set, we would flip the texture coordinates when rendering, such that: V' = 1 - V.
> However it is very late in this release to consider any more changes, so our plan is to add this option in a post FX 8 release if it turns out to be needed. Please let us know right away if there is a compelling need for V-up support in the FX 8 release.
> - Kevin and Chien
More information about the openjfx-dev