<div dir="ltr">I've done a preliminary study and assessment for changes in regards to textures.<div><br></div><div>Texture metadata (addressing, filtering, wrapping, blending...) is supported by both OpenGL and D3D in a similar enough way that makes a uniform API possible and not convoluted. This metadata can be added to Texture, or perhaps better, TextureMap.</div><div>Unfortunately, there is no ideal way of creating the public API because the textures in PhongMaterial are represented as Images. Interestingly, there are comments on the map properties in PhongMaterial that touch on this, "// TODO: 3D - Texture or Image? For Media it might be better to have it as a Texture", but I think that the question didn't get resolved in time and Image stayed.</div><div><br></div><div>Because we can't change the type, we have the following options:</div><div>1. Duplicate the methods in PhongMaterial that use ObjectProperty<Image> and have a set that uses ObjectProperty<Texture> (or TextureMap) with it taking precedence. I think that this is a bad option as it creates API noise and is confusing to use.</div><div>2. Add the metadata to Image and enhance its public API. I don't think that this is a good option either because it will bloat Image with specific data that is not widely used.</div><div>3. Create a new Material, placeholder name PhongMaterial2, that uses textures instead. We might want to look at other breaking enhancements for PhongMaterial so we can plan ahead better this time. I think that this is a reasonable option whose eligibility depends on how much we can't update the current PhongMaterial. Mipmaping, which requires a set of images, might be one of them.</div><div>4. Create a separate set of methods inside PhongMaterial that deal with the texture metadata only. These will be something like `ObjectProperty<TextureData> diffuseTextureDataProperty()` and similarly for the other maps. I think that this option is also reasonable, although it also creates API noise (these only take effect if the maps are used to begin with).</div><div><br></div><div>I didn't look deeply into texture aspects outside of the discussed filtering, but I think we should take the opportunity to do so. For filtering, I have the following ideas:</div><div><br></div><div>For min/mag filters: an enum with NEAREST (nearest-point/neighbor sampling) and LINEAR ((bi)linear sampling).<br></div><div>For mipmap filters: an enum with NEAREST (nearest mipmap level) and LINEAR (linear interpolation between levels). While some APIs have a NONE mode to disable mipmaping, the inexistence of mipmaps can be used as a disabled mode.</div><div>Even though they use the same constant names, the meaning is different, so I think the enums should be separate.</div><div><br></div><div>For mipmaps: a List<Image>. Autogeneration of mipmaps can also be considered.</div><div><br></div><div>Anisotropy is supported in D3D via a filter type (ANISOTROPIC) plus a strength factor, and in OpenGL since version 4.6 (which version does JavaFX use?). Metal and Vulkan just use a strength factor to turn it on regardless of the filter. I think that this is a more flexible approach and we could add a single int/double property to control anisotropy.</div><div><br></div><div><div>References:</div><div><div>Metal specs [1] (section 2.10)</div><div>Vulkan specs [2] (Section 16.8.3)</div><div>D3D docs [3][4][5]</div><div>OpenGL (external resource) [6][7]</div></div></div><div><br></div><div>[1] <a href="https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf">https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf</a></div><div>[2] <a href="https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html">https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html</a></div><div>[3] <a href="https://learn.microsoft.com/en-us/windows/win32/direct3d9/texture-filtering">https://learn.microsoft.com/en-us/windows/win32/direct3d9/texture-filtering</a></div><div>[4] <a href="https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3dtexturefiltertype">https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3dtexturefiltertype</a></div><div>[5] <a href="https://learn.microsoft.com/en-us/windows/win32/api/d3d9helper/nf-d3d9helper-idirect3ddevice9-setsamplerstate">https://learn.microsoft.com/en-us/windows/win32/api/d3d9helper/nf-d3d9helper-idirect3ddevice9-setsamplerstate</a></div><div>[6] <a href="https://learnopengl.com/Getting-started/Textures">https://learnopengl.com/Getting-started/Textures</a></div><div>[7] <a href="https://gregs-blog.com/2008/01/17/opengl-texture-filter-parameters-explained/">https://gregs-blog.com/2008/01/17/opengl-texture-filter-parameters-explained/</a></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jun 25, 2023 at 9:03 PM Nir Lisker <<a href="mailto:nlisker@gmail.com">nlisker@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Perhaps Jay and Kevin can weigh in on this.<div><br></div><div>By the way, I see that the com.sun.prism.Texture interface already defines get/setLinearFiltering methods that specify if the filtering is not linear then it uses a nearest neighbor algorithm. It's not used by the 3D side it seems.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jun 25, 2023 at 8:54 PM Matija Brown <<a href="mailto:Matija.Brown@outlook.de" target="_blank">Matija.Brown@outlook.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>
<div lang="en-DE">
<div>
<p class="MsoNormal">This is a good point you’re bringing up Nir!</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I’m really not sure on that. On the one hand your interpretation seems the most sensible, but on the other hand I can’t see any use case of NEAREST filtering in specular or self-illumination maps.</p>
<p class="MsoNormal">However giving more options is also always good, and the same way there aren’t really many places (that I’m aware of) one would have NEAREST filtered diffuse maps and use any of the others at all.</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">TLDL: Would work excellently your way API wise, but I’m not certain if it makes sense use-case wise.</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks,</p>
<p class="MsoNormal">Matija.</p>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0cm 0cm">
<p class="MsoNormal" style="border:none;padding:0cm"><b>From: </b><a href="mailto:nlisker@gmail.com" target="_blank">Nir Lisker</a><br>
<b>Sent: </b>Sunday, 25 June 2023 19:49<br>
<b>To: </b><a href="mailto:Matija.Brown@outlook.de" target="_blank">Matija Brown</a><br>
<b>Cc: </b><a href="mailto:jayathirth.d.v@oracle.com" target="_blank">Jayathirth Rao Daarapuram Venkatesh Murthy</a>;
<a href="mailto:kevin.rushforth@oracle.com" target="_blank">Kevin Rushforth</a>; <a href="mailto:openjfx-dev@openjdk.org" target="_blank">
openjfx-dev@openjdk.org</a><br>
<b>Subject: </b>Re: [JavaFX 3D ( | Feature Request)] Setting Texture Nearest-Sampling on PhongMaterial</p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">I think that the first question to answer is whether the filtering method is applied to all maps/textures of the material (diffuse, specular, self-illumination) or to each individually. I would imagine that the former makes more sense.
If that's the case, the texture filtering parameter will be just one more property in PhongMaterial (perhaps in the Material supertype if it also makes sense for other possible materials - that can be figured out later in any case).<u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Sun, Jun 25, 2023 at 3:20 PM Matija Brown <<a href="mailto:Matija.Brown@outlook.de" target="_blank">Matija.Brown@outlook.de</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<div>
<p class="MsoNormal"><span lang="en-DE">Unfortunately it took a little longer (got busy), but have just had a quick look at the<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE">OpenGL side of things.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE"> <u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE">The ES2Texture class appears to handle everything there. There are two create-Methods, but the other<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE">one is responsible for MediaFrame stuff and it doesn’t really? make sense to have non-linear filtering there?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE">What’s your opinion?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE"> <u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE">The create method seems to parse in all texture parameters simply as arguments (<a href="https://github.com/openjdk/jfx/blob/0d9dcf38275528e1b621d71631aac5bdb9452110/modules/javafx.graphics/src/main/java/com/sun/prism/es2/ES2Texture.java#L98" target="_blank">https://github.com/openjdk/jfx/blob/0d9dcf38275528e1b621d71631aac5bdb9452110/modules/javafx.graphics/src/main/java/com/sun/prism/es2/ES2Texture.java#L98</a>),<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE">it would probably be best to just add the filtering in there as well.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE"> <u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE">API-wise it’s probably best to have a Texture or DiffuseMap class that the PhongMaterial uses and stores metadata about the Image.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE">However this might be slightly overkill considering there is only this one single parameter we’re trying to add,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE">thus maybe just a flag in PhongMaterial would suffice?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE"> <u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE">Have a nice day,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE">Matija.<u></u><u></u></span></p>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0cm 0cm">
<p class="MsoNormal"><b><span lang="en-DE">From:
</span></b><span lang="en-DE"><a href="mailto:Matija.Brown@outlook.de" target="_blank">Matija Brown</a><br>
<b>Sent: </b>Thursday, 22 June 2023 18:37<br>
<b>To: </b><a href="mailto:jayathirth.d.v@oracle.com" target="_blank">Jayathirth Rao Daarapuram Venkatesh Murthy</a>;
<a href="mailto:nlisker@gmail.com" target="_blank">Nir Lisker</a>; <a href="mailto:kevin.rushforth@oracle.com" target="_blank">
Kevin Rushforth</a><br>
<b>Cc: </b><a href="mailto:openjfx-dev@openjdk.org" target="_blank">openjfx-dev@openjdk.org</a><br>
<b>Subject: </b>RE: [JavaFX 3D ( | Feature Request)] Setting Texture Nearest-Sampling on PhongMaterial<u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span lang="en-DE"> <u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE">I’ll do the OpenGL – have done quite a bit with Vulkan and GL in the past so there’s no problem there.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE">Certainly usefull if you would do some reviewing – if you finish the Metal texture maps someone will surely find<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE">themselves to expand it with sampling.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE"> <u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE">Tomorrow I’ll give a short summary on what would be to do for OpenGL, as we have that for D3D already.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE">Then do a little example probably – doesn’t really seem too much work to me?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE"> <u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE">Thanks,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE">Matija.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE"> <u></u><u></u></span></p>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0cm 0cm">
<p class="MsoNormal"><b><span lang="en-DE">From:
</span></b><span lang="en-DE"><a href="mailto:jayathirth.d.v@oracle.com" target="_blank">Jayathirth Rao Daarapuram Venkatesh Murthy</a><br>
<b>Sent: </b>Thursday, 22 June 2023 06:28<br>
<b>To: </b><a href="mailto:nlisker@gmail.com" target="_blank">Nir Lisker</a>; <a href="mailto:kevin.rushforth@oracle.com" target="_blank">
Kevin Rushforth</a><br>
<b>Cc: </b><a href="mailto:openjfx-dev@openjdk.org" target="_blank">openjfx-dev@openjdk.org</a><br>
<b>Subject: </b>Re: [JavaFX 3D ( | Feature Request)] Setting Texture Nearest-Sampling on PhongMaterial<u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span lang="en-DE"> <u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-IN">Correcting myself:</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-IN">Currently I am working on Metal implementation of Texture maps in JavaFX 3D :
<a href="https://bugs.openjdk.org/browse/JDK-8310109" target="_blank">https://bugs.openjdk.org/browse/JDK-8310109</a> and not on adding nearest sampling(which last mail can imply).</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-IN">Thanks,</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-IN">Jay</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<div id="m_-6307084536453969354m_-6205322515822456995m_376544303615863523mail-editor-reference-message-container">
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12pt"><b><span lang="EN-IN" style="font-size:12pt;color:black">From:
</span></b><span lang="EN-IN" style="font-size:12pt;color:black">openjfx-dev <<a href="mailto:openjfx-dev-retn@openjdk.org" target="_blank">openjfx-dev-retn@openjdk.org</a>> on behalf of Jayathirth Rao Daarapuram Venkatesh Murthy <<a href="mailto:jayathirth.d.v@oracle.com" target="_blank">jayathirth.d.v@oracle.com</a>><br>
<b>Date: </b>Thursday, 22 June 2023 at 9:22 AM<br>
<b>To: </b>Nir Lisker <<a href="mailto:nlisker@gmail.com" target="_blank">nlisker@gmail.com</a>>, Kevin Rushforth <<a href="mailto:kevin.rushforth@oracle.com" target="_blank">kevin.rushforth@oracle.com</a>><br>
<b>Cc: </b><a href="mailto:openjfx-dev@openjdk.org" target="_blank">openjfx-dev@openjdk.org</a> <<a href="mailto:openjfx-dev@openjdk.org" target="_blank">openjfx-dev@openjdk.org</a>><br>
<b>Subject: </b>Re: [JavaFX 3D ( | Feature Request)] Setting Texture Nearest-Sampling on PhongMaterial</span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span lang="EN-IN">Currently I am working on Metal implementation of the same and has no bandwidth to work on additional OpenGL thing.</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-IN">But I can help in reviewing the code if we come up with addition of nearest filtering.</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-IN">Thanks,</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-IN">Jay</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<div id="m_-6307084536453969354m_-6205322515822456995m_376544303615863523mail-editor-reference-message-container">
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12pt"><b><span lang="EN-IN" style="font-size:12pt;color:black">From:
</span></b><span lang="EN-IN" style="font-size:12pt;color:black">openjfx-dev <<a href="mailto:openjfx-dev-retn@openjdk.org" target="_blank">openjfx-dev-retn@openjdk.org</a>> on behalf of Nir Lisker <<a href="mailto:nlisker@gmail.com" target="_blank">nlisker@gmail.com</a>><br>
<b>Date: </b>Wednesday, 21 June 2023 at 9:40 PM<br>
<b>To: </b>Kevin Rushforth <<a href="mailto:kevin.rushforth@oracle.com" target="_blank">kevin.rushforth@oracle.com</a>><br>
<b>Cc: </b><a href="mailto:openjfx-dev@openjdk.org" target="_blank">openjfx-dev@openjdk.org</a> <<a href="mailto:openjfx-dev@openjdk.org" target="_blank">openjfx-dev@openjdk.org</a>><br>
<b>Subject: </b>Re: [JavaFX 3D ( | Feature Request)] Setting Texture Nearest-Sampling on PhongMaterial</span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt">
<p class="MsoNormal" style="margin-left:9.6pt">
<span lang="EN-IN">If I remember correctly, in OpenGL you parse the texture filter when the texture is being created, while in DirectX as it is bound</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:9.6pt">
<span lang="EN-IN">to the sampler (it is a sampler state after all) it would have to be set before every render call. However it shouldn’t make any</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:9.6pt">
<span lang="EN-IN">API difference really, as we can just have a field somewhere and the parse it along when needed.</span><span lang="en-DE"><u></u><u></u></span></p>
</blockquote>
<p class="MsoNormal"><span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span lang="EN-IN">Yes, the JBS ticket mentions this difference as well.</span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-IN">Since Kevin approved this feature and the API seems to converge nicely between the pipelines, we can start the work. I'm somewhat busy with other tasks as of
late, but I will try to formulate an API. Matija or Jay, if one of you can start investigating the changes to the OpenGL pipeline we could create a branch in the sandbox repo and work there.</span><span lang="en-DE"><u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<div>
<div>
<p class="MsoNormal"><span lang="EN-IN">On Wed, Jun 21, 2023 at 4:03 PM Kevin Rushforth <<a href="mailto:kevin.rushforth@oracle.com" target="_blank">kevin.rushforth@oracle.com</a>> wrote:</span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt">
<div>
<p class="MsoNormal" style="margin-bottom:12pt;margin-left:9.6pt">
<span lang="EN-IN">My preference would be to add support only for Linear and Nearest in any case.<br>
<br>
-- Kevin</span><span lang="en-DE"><u></u><u></u></span></p>
<div>
<p class="MsoNormal" style="margin-left:9.6pt">
<span lang="EN-IN">On 6/21/2023 4:48 AM, Matija Brown wrote:</span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<blockquote style="margin-top:5pt;margin-bottom:5pt">
<div>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">As Jayathrith said, in OpenGL as well as Metal only NEAREST and LINEAR filters are available.</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">There might be a way of getting around it by implementing some own algorithm for OpenGL and Metal but that seem slightly</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">over the top. So either one would have to keep the options limited to the two supported everywhere</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">or go with the “conditional” features.</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">Having had a look at DirectX the APIs seem not to differ too much.</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">If I remember correctly, in OpenGL you parse the texture filter when the texture is being created, while in DirectX as it is bound</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">to the sampler (it is a sampler state after all) it would have to be set before every render call. However it shouldn’t make any</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">API difference really, as we can just have a field somewhere and the parse it along when needed.</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">Cheers,</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">Matija.</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0cm 0cm">
<p class="MsoNormal" style="margin-left:81.6pt">
<b><span lang="EN-IN">From: </span></b><span lang="EN-IN"><a href="mailto:jayathirth.d.v@oracle.com" target="_blank">Jayathirth Rao Daarapuram Venkatesh Murthy</a><br>
<b>Sent: </b>Wednesday, 21 June 2023 13:09<br>
<b>To: </b><a href="mailto:nlisker@gmail.com" target="_blank">Nir Lisker</a>; <a href="mailto:Matija.Brown@outlook.de" target="_blank">
Matija Brown</a><br>
<b>Cc: </b><a href="mailto:openjfx-dev@openjdk.org" target="_blank">openjfx-dev@openjdk.org</a><br>
<b>Subject: </b>Re: [JavaFX 3D ( | Feature Request)] Setting Texture Nearest-Sampling on PhongMaterial</span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">In OpenGL we set GL_LINEAR by default at : <a href="https://github.com/openjdk/jfx/blob/0d9dcf38275528e1b621d71631aac5bdb9452110/modules/javafx.graphics/src/main/java/com/sun/prism/es2/ES2Texture.java#L221" target="_blank">
https://github.com/openjdk/jfx/blob/0d9dcf38275528e1b621d71631aac5bdb9452110/modules/javafx.graphics/src/main/java/com/sun/prism/es2/ES2Texture.java#L221</a></span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">And Metal supports only two types of Min/Max filters : Nearest(default) and Linear. So even if D3D supports multiple types we might be limited to support only these 2 filters for all platforms.</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">Thanks,</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">Jay</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<div id="m_-6307084536453969354m_-6205322515822456995m_376544303615863523m_4252637545766470404mail-editor-reference-message-container">
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12pt;margin-left:81.6pt">
<b><span lang="EN-IN" style="font-size:12pt;color:black">From: </span></b><span lang="EN-IN" style="font-size:12pt;color:black">openjfx-dev
<a href="mailto:openjfx-dev-retn@openjdk.org" target="_blank"><openjfx-dev-retn@openjdk.org></a> on behalf of Nir Lisker
<a href="mailto:nlisker@gmail.com" target="_blank"><nlisker@gmail.com></a><br>
<b>Date: </b>Wednesday, 21 June 2023 at 3:57 PM<br>
<b>To: </b>Matija Brown <a href="mailto:Matija.Brown@outlook.de" target="_blank">
<Matija.Brown@outlook.de></a><br>
<b>Cc: </b><a href="mailto:openjfx-dev@openjdk.org" target="_blank">openjfx-dev@openjdk.org</a>
<a href="mailto:openjfx-dev@openjdk.org" target="_blank"><openjfx-dev@openjdk.org></a><br>
<b>Subject: </b>Re: [JavaFX 3D ( | Feature Request)] Setting Texture Nearest-Sampling on PhongMaterial</span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt">
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-GB">First of all, please excuse directly e-mailing you earlier today. Working with mailing lists is quite new for me and apparently I forgot to add</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-GB">the mailing list to cc.</span><span lang="en-DE"><u></u><u></u></span></p>
</blockquote>
<div>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">I didn't get any private email, so you seem to be doing better than you thought with the mailing list :)</span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt">
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN">With the OpenGL-side I do have some experience. Concerning the D3D-side of things it would probably mean convincing</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN">Somebody that it is a good idea to finally apply the suggested change.</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN">There would be some API change required of course. As a basic concept it would probably be sensible to add this as a parameter to the PhonMaterial-class.</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN">Alternatively it might make sense to add a “Texture” class that is used a a DiffuseMap in the PhonMaterial. But that seems slightly overkill.</span><span lang="en-DE"><u></u><u></u></span></p>
</blockquote>
<div>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">Where to put the new methods in the Java side is not the concerning part, it's how to create methods that match all the pipelines. In D3D, the method for setting the filter is detailed in [1], and its possible parameters in [2][3][4]. So
suppose that I'm looking at the list of available filter types there:</span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">D3DTEXF_NONE, D3DTEXF_POINT, D3DTEXF_LINEAR, D3DTEXF_ANISOTROPIC, D3DTEXF_PYRAMIDALQUAD, D3DTEXF_GAUSSIANQUAD, D3DTEXF_CONVOLUTIONMONO,</span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">if OpenGL supports a somewhat different set of filters, we will have some clashes in the Java API side.</span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">Generally, we would like to give as much flexibility to the user as possible, but need to be careful with platform-specific functionality. We could round *some* corners. For example, I think that if we have an enum for the filter types above
that is a union of the ones available in the different pipelines, and if a few are supported by only one of the pipelines, we could note it in the docs and get away with it (something similar to a conditional feature). However, if the whole native pipeline
setup for texture filtering is different, which means a different set of Java API methods per pipeline, then that's too much.</span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">All this means is that to continue we need to figure out what the API for each pipeline looks like, what's the most functionality we can have for each pipeline, and then how we can unite them into a single Java API with the hopes of being
able to reconcile the differences "well enough" (whatever that will mean).</span><span lang="en-DE"><u></u><u></u></span></p>
<div>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">[1] <a href="https://learn.microsoft.com/en-us/windows/win32/api/d3d9helper/nf-d3d9helper-idirect3ddevice9-setsamplerstate" target="_blank">https://learn.microsoft.com/en-us/windows/win32/api/d3d9helper/nf-d3d9helper-idirect3ddevice9-setsamplerstate</a></span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">[2] <a href="https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3dtexturefiltertype" target="_blank">https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3dtexturefiltertype</a></span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">[3] <a href="https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3dsamplerstatetype" target="_blank">https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3dsamplerstatetype</a></span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">[4] <a href="https://learn.microsoft.com/en-us/windows/win32/direct3d9/vertex-textures-in-vs-3-0" target="_blank">https://learn.microsoft.com/en-us/windows/win32/direct3d9/vertex-textures-in-vs-3-0</a></span><span lang="en-DE"><u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<div>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN">On Wed, Jun 21, 2023 at 12:45 PM Matija Brown <<a href="mailto:Matija.Brown@outlook.de" target="_blank">Matija.Brown@outlook.de</a>> wrote:</span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt">
<div>
<div>
<div>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-GB">First of all, please excuse directly e-mailing you earlier today. Working with mailing lists is quite new for me and apparently I forgot to add</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-GB">the mailing list to cc.</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-GB"> </span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN">With the OpenGL-side I do have some experience. Concerning the D3D-side of things it would probably mean convincing</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN">Somebody that it is a good idea to finally apply the suggested change.</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN">There would be some API change required of course. As a basic concept it would probably be sensible to add this as a parameter to the PhonMaterial-class.</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN">Alternatively it might make sense to add a “Texture” class that is used a a DiffuseMap in the PhonMaterial. But that seems slightly overkill.</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN">As I am not very well acquainted with current design principles of this library, these things should lie in more experience contributors hands.</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0cm 0cm">
<p class="MsoNormal" style="margin-left:96pt">
<b><span lang="EN-IN">From: </span></b><span lang="EN-IN"><a href="mailto:nlisker@gmail.com" target="_blank">Nir Lisker</a><br>
<b>Sent: </b>Tuesday, 20 June 2023 20:50<br>
<b>To: </b><a href="mailto:Matija.Brown@outlook.de" target="_blank">Matija Brown</a><br>
<b>Cc: </b><a href="mailto:openjfx-dev@openjdk.org" target="_blank">openjfx-dev@openjdk.org</a><br>
<b>Subject: </b>Re: [JavaFX 3D ( | Feature Request)] Setting Texture Nearest-Sampling on PhongMaterial</span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt">
<p class="MsoNormal" style="margin-left:110.4pt">
<span lang="EN-IN">Which leads to the question; Does there, in JavaFX exist something comparable to setting the texture-sampler to NEAREST</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:110.4pt">
<span lang="EN-IN">instead of LINEAR sampling?</span><span lang="en-DE"><u></u><u></u></span></p>
</blockquote>
<div>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN">There is no API to set the texture filter. If you would like to contribute and add it, I can help. It needs to be compatible with both Direct3D and OpenGL (not sure how the work on Metal is going), so this can be a challenge.</span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN">For the D3D side, see this issue in JBS [1]. The relevant code is at [2]. I didn't look at the OpenGL side.</span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN">- Nir</span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN">[1] <a href="https://bugs.openjdk.org/browse/JDK-8092272" target="_blank">https://bugs.openjdk.org/browse/JDK-8092272</a> </span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN">[2] <a href="https://github.com/openjdk/jfx/blob/0d9dcf38275528e1b621d71631aac5bdb9452110/modules/javafx.graphics/src/main/native-prism-d3d/D3DContext.cc#L621" target="_blank">https://github.com/openjdk/jfx/blob/0d9dcf38275528e1b621d71631aac5bdb9452110/modules/javafx.graphics/src/main/native-prism-d3d/D3DContext.cc#L621</a></span><span lang="en-DE"><u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<div>
<div>
<p class="MsoNormal" style="margin-left:96pt">
<span lang="EN-IN">On Mon, Jun 19, 2023 at 10:15 PM Matija Brown <<a href="mailto:Matija.Brown@outlook.de" target="_blank">Matija.Brown@outlook.de</a>> wrote:</span><span lang="en-DE"><u></u><u></u></span></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt">
<div>
<div>
<div>
<p class="MsoNormal" style="margin-left:110.4pt">
<span lang="EN-IN">On my never ending journey of building a Minecraft-clone in every graphics-framework available,</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:110.4pt">
<span lang="EN-IN">I have come across JavaFX for the next attempt.</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:110.4pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:110.4pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:110.4pt">
<span lang="EN-IN">However a minor inconvenience has crossed my path in the process:</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:110.4pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:110.4pt">
<span lang="EN-IN">Using the (very well developed!) 2D-Graphics displaying pixel-art style images is no trouble whatsoever.</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:110.4pt">
<span lang="EN-IN">Simply rendering it to a canvas and disabling smoothing does the job just fine. Unfortunately, I have been</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:110.4pt">
<span lang="EN-IN">unable to figure out how to achieve a similar thing using the 3D-Graphics engine and the PhongMaterial that comes with it.</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:110.4pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:110.4pt">
<span lang="EN-IN">Which leads to the question; Does there, in JavaFX exist something comparable to setting the texture-sampler to NEAREST</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:110.4pt">
<span lang="EN-IN">instead of LINEAR sampling?</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:110.4pt">
<span lang="EN-IN">Unfortunately the latest information I could find online was from about 2013 and much has (probably)</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:110.4pt">
<span lang="EN-IN">changed since then. Thus the question is being posed once again.</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:110.4pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:110.4pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:110.4pt">
<span lang="EN-IN">I whish to excuse myself for probably repeating a fairly common question,</span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:110.4pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal" style="margin-left:100.8pt">
<span lang="EN-IN">Kind regards,<br>
Matija Brown.</span><span lang="en-DE"><u></u><u></u></span></p>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
<p class="MsoNormal" style="margin-left:86.4pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:81.6pt">
<span lang="EN-IN" style="font-size:10pt"> </span><span lang="en-DE"><u></u><u></u></span></p>
</div>
</blockquote>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:5pt;margin-left:4.8pt">
<span lang="EN-IN"> </span><span lang="en-DE"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="en-DE" style="font-size:10pt"> </span><span lang="en-DE"><u></u><u></u></span></p>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal" style="margin-left:4.8pt">
<span lang="en-DE"> <u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div></blockquote></div>
</blockquote></div>