Skip to content
This repository was archived by the owner on Jun 24, 2021. It is now read-only.

Commit a44f13f

Browse files
committed
Reworked shader-sources
1 parent 7261cfc commit a44f13f

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

modules/javafx.graphics/src/main/java/com/sun/prism/es2/ES2Context.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,6 @@ void setAmbientLight(long nativeHandle, float r, float g, float b) {
449449
glContext.setAmbientLight(nativeHandle, r, g, b);
450450
}
451451

452-
/*
453-
* FacloTheBold: - new operator, added parameters for attenuation coefficients
454-
*/
455452
void setPointLight(long nativeHandle, int index, float x, float y, float z, float r, float g, float b, float w, float ra, float ca, float la, float qa) {
456453
glContext.setPointLight(nativeHandle, index, x, y, z, r, g, b, w, ra, ca, la, qa);
457454
}

modules/javafx.graphics/src/main/native-prism-d3d/D3DLight.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,3 @@ class D3DLight {
4747
};
4848

4949
#endif /* D3DLIGHT_H */
50-
51-

modules/javafx.graphics/src/main/resources/com/sun/prism/es2/glsl/main1Light.frag

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,11 @@ void main()
8383
float power = specular.a;
8484

8585
vec3 l = normalize(lightTangentSpacePositions[0].xyz);
86-
d = clamp(dot(n,l), 0.0, 1.0)*(lights[0].color).rgb;
87-
s = pow(clamp(dot(-refl, l), 0.0, 1.0), power)*lights[0].color.rgb;
86+
float att = 1.0 / (lights[0].atten.ca + lights[0].atten.la * dist + lights[0].atten.qa * (dist * dist));
87+
d = clamp(dot(n,l), 0.0, 1.0)*(lights[0].color).rgb * att;
88+
s = pow(clamp(dot(-refl, l), 0.0, 1.0), power)*lights[0].color.rgb * att;
8889

89-
float att = 1.0 / (lights[0].atten.ca + lights[0].atten.la * dist + lights[0].atten.qa * (dist * dist)));
90-
91-
vec3 rez = (ambientColor+d) * (att * (diffuse.xyz + s*specular.rgb));
90+
vec3 rez = (ambientColor+d) * (diffuse.xyz + s*specular.rgb);
9291
rez += apply_selfIllum().xyz;
9392

9493
gl_FragColor = vec4(clamp(rez, 0.0, 1.0) , diffuse.a);

modules/javafx.graphics/src/main/resources/com/sun/prism/es2/glsl/main2Lights.frag

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ void main()
7575

7676
vec3 d = vec3(0.0);
7777
vec3 s = vec3(0.0);
78+
vec3 rez = vec3(0.0);
7879

7980
vec3 refl = reflect(normalize(eyePos), n);
8081
vec4 specular = apply_specular();
@@ -84,10 +85,10 @@ void main()
8485
float dist = (lights[i].pos.xyz - gl_Position);
8586
if(dist <= lights[i].atten.range){
8687
vec3 l = normalize(lightTangentSpacePositions[i].xyz);
87-
d += clamp(dot(n,l), 0.0, 1.0)*(lights[i].color).rgb;
88-
s += pow(clamp(dot(-refl, l), 0.0, 1.0), power) * lights[i].color.rgb;
89-
float att = 1.0 / (lights[i]].atten.ca + lights[i].atten.la * dist + lights[i].atten.qa * (dist * dist)));
90-
vec3 rez = (ambientColor+d) * (att * (diffuse.xyz + s*specular.rgb));
88+
float att = 1.0 / (lights[i]].atten.ca + lights[i].atten.la * dist + lights[i].atten.qa * (dist * dist));
89+
d += clamp(dot(n,l), 0.0, 1.0)*(lights[i].color).rgb * att;
90+
s += pow(clamp(dot(-refl, l), 0.0, 1.0), power) * lights[i].color.rgb *att;
91+
rez = (ambientColor+d) * (diffuse.xyz + s*specular.rgb);
9192
}
9293
}
9394
rez += apply_selfIllum().xyz;

modules/javafx.graphics/src/main/resources/com/sun/prism/es2/glsl/main3Lights.frag

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ void main()
7575

7676
vec3 d = vec3(0.0);
7777
vec3 s = vec3(0.0);
78+
vec3 rez = vec3(0.0);
7879

7980
vec3 refl = reflect(normalize(eyePos), n);
8081
vec4 specular = apply_specular();
@@ -84,10 +85,10 @@ void main()
8485
float dist = (lights[i].pos.xyz - gl_Position);
8586
if(dist <= lights[i].atten.range){
8687
vec3 l = normalize(lightTangentSpacePositions[i].xyz);
87-
d += clamp(dot(n,l), 0.0, 1.0)*(lights[i].color).rgb;
88-
s += pow(clamp(dot(-refl, l), 0.0, 1.0), power) * lights[i].color.rgb;
89-
float att = 1.0 / (lights[i]].atten.ca + lights[i].atten.la * dist + lights[i].atten.qa * (dist * dist)));
90-
vec3 rez = (ambientColor+d) * (att * (diffuse.xyz + s*specular.rgb));
88+
float att = 1.0 / (lights[i]].atten.ca + lights[i].atten.la * dist + lights[i].atten.qa * (dist * dist));
89+
d += clamp(dot(n,l), 0.0, 1.0)*(lights[i].color).rgb * att;
90+
s += pow(clamp(dot(-refl, l), 0.0, 1.0), power) * lights[i].color.rgb *att;
91+
rez = (ambientColor+d) * (diffuse.xyz + s*specular.rgb);
9192
}
9293
}
9394
rez += apply_selfIllum().xyz;

0 commit comments

Comments
 (0)