V-up texture coordinate support

2013-10-22 Thread August Lammersdorf, InteractiveMesh
My JavaFX 3D model importers convert geometric data to the JavaFX 3D 
coordinate sytem to support the default camera model (viewing into the 
screen along the +Z-axis). A Y-up right-handed coordinate system (e.g. 
COLLADA-, OBJ-, X3D-exports from modelling tools) is mapped as follows: 
+Y - -Y, +X - +X, +Z - -Z. This includes the adjustment of all 
transforms and also the v-flipping of the texture coordinates: v - 1 - 
v. In this case I prefer converted texture coordinates stored in the 
TriangelMesh instead of converting them 'backstage'.


Alternatively, I consider providing an ImportOption to omit this 
conversions if someone wants to simulate a Y-up right-handed coordinate 
system in JavaFX. This would result in TriangelMesh points and texture 
coordinates consistent with the imported file. Now an internal 
v-flipping is needed to avoid upside-down textures because the 
corresponding texture coordinates are typically v-up oriented. Right?


Simulating a Y-up right-handed coordinate system in JavaFX is discussed 
in Getting Started with JavaFX 3D Graphics/Camera/Y-down versus Y-up 
(http://docs.oracle.com/javafx/8/3d_graphics/camera.htm#CJAHFAHB). 
Doesn't this approach require an immediate availability of a v-flipping 
feature?


August

Am Donnerstag, den 17.10.2013, 15:08 +0200 schrieb Chien Yang 
chien.y...@oracle.com:

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




Re: V-up texture coordinate support

2013-10-22 Thread Chien Yang

Hi Remi,

  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 
possible.


- Chien

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);

Regards
-- Remi

From: Chien Yang chien.y...@oracle.commailto:chien.y...@oracle.com
Date: Thu, Oct 17, 2013 at 3:08 PM
Subject: V-up texture coordinate support
To: OpenJFX openjfx-dev@openjdk.java.netmailto:openjfx-dev@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




Re: V-up texture coordinate support

2013-10-21 Thread Arnaud, Remi
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);

Regards
-- Remi

From: Chien Yang chien.y...@oracle.commailto:chien.y...@oracle.com
Date: Thu, Oct 17, 2013 at 3:08 PM
Subject: V-up texture coordinate support
To: OpenJFX openjfx-dev@openjdk.java.netmailto:openjfx-dev@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


V-up texture coordinate support

2013-10-17 Thread Chien Yang

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