Hi Risto,

There is some work on this already here:
https://github.com/openjdk/jfx/pull/1281. I didn't have time to continue
with it, so it was auto-closed. To answer your points specifically:

Hi, sometimes it is useful to clamp texture coordinates that exceed the
> normal 0-1 range, however currently the default behaviour is to repeat them
> and there is no way to configure it.
> It would be useful to have a TextureWrap property in the PhongMaterial
> class that would have options like REPEAT, CLAMP, MIRRORED_REPEAT, but the
> first 2 would be enough.


I think you're talking about two options that are different, yet similar.
There's texture addressing [1] and texture wrapping [2] (showing links for
D3D). Wrapping mode is a render state and is performed before texture
addressing, which is a sampler state.

I am currently trying to replicate the rendering of a custom engine that
> clamps texture coordinates using the JavaFX 3D api however currently it
> doesn't seem like it's possible.
>

You might have a way of doing that with the mesh's texture coordinates.
Also have a look at the FXyz library [3] and this SO question [4].

Alternative would be to have some sort of a Texture class that is part of
> the PhongMaterial which would have that property instead, it could also
> have additional properties like texture filtering mode (as right now there
> is no way to configure that either).


Texture filtering is the first thing that is implemented in the above PR.
Bilinear and nearest-point are available for mag and min filters; mipmap
isn't really working for reasons I couldn't determine. You can try it out;
see my results from August last year [5].
The next step in that PR is figuring out what configuration options go into
this class (more can be added later, and it should probably be an interface
instead of a class anyway). We don't want to cram too many unrelated things
into it, making it a kitchen sink class, so I suggested starting
conservatively. We also need a unified API for the different current and
(possible) future piplines (D3D9, D3D11, OpenGL, Metal, Vulkan), but I did
some of that research already and the piplines agree rather nicely
[6], so I'm more confident on that front. Specifically, finding out if
render states and sampler states both belong there together because this
configuration class is applied *per map* (diffuse, specular, emissive,
normal), not *per material*. By the way, filtering is also a sampler
state, like addressing, so at the very least addressing can be added there.

- Nir

[1]
https://learn.microsoft.com/en-us/windows/win32/direct3d9/texture-addressing-modes
[2]
https://learn.microsoft.com/en-us/windows/win32/direct3d9/texture-wrapping
[3] https://github.com/FXyz/FXyz
[4]
https://stackoverflow.com/questions/49130485/javafx-shape3d-texturing-dont-strectch-the-image
[5] https://mail.openjdk.org/pipermail/openjfx-dev/2023-August/042181.html
[6] https://mail.openjdk.org/pipermail/openjfx-dev/2023-August/042136.html

On Sat, Jun 8, 2024 at 10:52 PM Risto Vaher <ristovaher1...@gmail.com>
wrote:

> Hi, sometimes it is useful to clamp texture coordinates that exceed the
> normal 0-1 range, however currently the default behaviour is to repeat them
> and there is no way to configure it.
> It would be useful to have a TextureWrap property in the PhongMaterial
> class that would have options like REPEAT, CLAMP, MIRRORED_REPEAT, but the
> first 2 would be enough.
> I am currently trying to replicate the rendering of a custom engine that
> clamps texture coordinates using the JavaFX 3D api however currently it
> doesn't seem like it's possible.
>
> Alternative would be to have some sort of a Texture class that is part of
> the PhongMaterial which would have that property instead, it could also
> have additional properties like texture filtering mode (as right now there
> is no way to configure that either).
>

Reply via email to