JDK-8094279 : Zero specular power can lead to rendering artifacts.
Type:Bug
Component:javafx
Sub-Component:graphics
Affected Version:8u20
Priority:P4
Status:Resolved
Resolution:Fixed
Submitted:2014-03-17
Updated:2025-04-23
Resolved:2014-03-21
The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
As was seen in RT-35681, setting specular power to 0.0 leads to undefined behavior in GLSL shader resulting in differences in rendering on various hardware.
+1. I've tested this fix on my INTEL HD laptop and the result looks good. BTW, it will be good to add a comment in the code on why this clamp is needed. Thanks!
18-03-2014
Chien proposed to clamp not to 1.0, but to some low epsilon value, like 0.001
I'll try to better illustrate the effect of these values using Ensemble's 3d sphere sample without any maps, so just white diffuse and white specular color.
Attached are 4 images:
specPower_0.png
This is what we will get with specularPower equals 0.0 on the d3d pipeline and on the es2 pipeline except Intel HD, where it will look like specPower_1e-3.png
specPower_1.png
This is with specularPower equals 1.0
specPower_1e-3.png
0.001
specPower_32.png
Default value of 32
So with clamping the specular power value we will not be able to get specPower_0 result, instead we will get specPower_1e-3.
I don't see any reason to use such low values (and with the value 0.0 you will simply get all white washed out specular highlight), so any clamping value is ok, 0.001 seems to be reasonable.
18-03-2014
OK to hold pending discussion.
17-03-2014
Clamping it to 1.0 might not be the best solution in term of specification. Let's hold the push and a discussion first.
17-03-2014
Chien, Kevin, please review the fix:
I'm thinking about clamping the power value to the minimum of 1.0.
I'm not sure what would be the right place for this, but the PhongMaterial API doesn't look like the good place, better hide it in the implementation.
diff -r a595dd55588f modules/graphics/src/main/java/com/sun/javafx/sg/prism/NGPhongMaterial.java
--- a/modules/graphics/src/main/java/com/sun/javafx/sg/prism/NGPhongMaterial.java Mon Mar 17 14:14:38 2014 +0400
+++ b/modules/graphics/src/main/java/com/sun/javafx/sg/prism/NGPhongMaterial.java Mon Mar 17 14:33:17 2014 +0400
@@ -115,6 +115,9 @@
}
public void setSpecularPower(float specularPower) {
+ if (specularPower < 1.0f) {
+ specularPower = 1.0f;
+ }
this.specularPower = specularPower;
specularPowerDirty = true;
}