As you note, there are a few different issues here. To answer your questions as best I can:

1 & 3. We should document that self-illum maps and specular only use the rgb components and that alpha should be ignored. It's possible (although I don't know for sure) that the image is being treated as a non- premultiplied color format, and is subsequently converted to a premultiplied format; if so, this could explain the color darkening.

2. This also needs to be documented. The diffuse component should have an alpha that applies whether from the diffuse color or from a diffuse map. I agree with you that the pixel fragment should not be discarded just because the diffuse component is transparent. A specular highlight should be possible on a fully transparent object.

4. It does seem that the result should be the same regardless of whether the color comes from a specular map or color, but I'd need to dig further.

Do all of the above issues happen with the OpenGL shaders, too?

-- Kevin


On 4/26/2022 11:41 AM, Nir Lisker wrote:
I found a comment [1] on JBS stating that specular and self-Illumination
alphas should be ignored, so it seems like there's at least 2 bugs here
already.

https://bugs.openjdk.java.net/browse/JDK-8090548?focusedCommentId=13771150&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13771150

On Tue, Apr 26, 2022 at 4:25 AM Nir Lisker <nlis...@gmail.com> wrote:

Hi,

Using the updated lighting test sample [1], I found some odd behavior with
regards to PhongMaterial:

1. The effect of the opacity (alpha channel) of a self-illumination map is
not documented, but lowering its value makes the object darker. I looked at
the pixel shader [2] and only the rgb components are sampled, so I'm a bit
confused here. What is the intended behavior?

2. The opacity of the object is controlled in the shader by both the
diffuse color and diffuse map. This is also not documented (although it
might be obvious for some). In the shader, the pixel (fragment) is
discarded only if the map is fully transparent (line 55), but not the
color. This leads to a situation where the object completely disappears
when the map is transparent, but not when the color is. In the shader, the
pixel should be transparent because of the multiplication of the alpha, but
it's not, so this is also confusing. Should they both have the same
contribution? Shouldn't it be valid to have a transparent diffuse but still
have specular reflections?

3. The specular map and color behave differently in regards to the
opacity. There is no documented behavior here. The alpha on the color is
ignored (it's used for the specular power), but not on the map - it
controls the reflection's strength, probably by making its color darker. In
the shader, lines 76-84 indeed ignore the alpha of the color, but take the
alpha of the map, although later in line 93 it's not used, so again I'm
confused. What's the intended behavior?

4. The specular map and color also behave differently in regards to the
reflection's strength. In the shader, this happens in line 78: the specular
power is corrected with NTSC_Gray if there is a map (with or without
color), but not if there's only a color. Shouldn't the contributions be the
same? Is the NTSC_Gray correction correct in this case?

Thanks,
  Nir

[1] https://github.com/openjdk/jfx/pull/787
[2]
https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/native-prism-d3d/hlsl/Mtl1PS.hlsl


Reply via email to