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

Commit

Permalink
Reworked shader-sources
Browse files Browse the repository at this point in the history
  • Loading branch information
ProggerFox committed Mar 18, 2019
1 parent 7261cfc commit a44f13f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,6 @@ void setAmbientLight(long nativeHandle, float r, float g, float b) {
glContext.setAmbientLight(nativeHandle, r, g, b);
}

/*
* FacloTheBold: - new operator, added parameters for attenuation coefficients
*/
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) {
glContext.setPointLight(nativeHandle, index, x, y, z, r, g, b, w, ra, ca, la, qa);
}
Expand Down
2 changes: 0 additions & 2 deletions modules/javafx.graphics/src/main/native-prism-d3d/D3DLight.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,3 @@ class D3DLight {
};

#endif /* D3DLIGHT_H */


Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,11 @@ void main()
float power = specular.a;

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

float att = 1.0 / (lights[0].atten.ca + lights[0].atten.la * dist + lights[0].atten.qa * (dist * dist)));

vec3 rez = (ambientColor+d) * (att * (diffuse.xyz + s*specular.rgb));
vec3 rez = (ambientColor+d) * (diffuse.xyz + s*specular.rgb);
rez += apply_selfIllum().xyz;

gl_FragColor = vec4(clamp(rez, 0.0, 1.0) , diffuse.a);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ void main()

vec3 d = vec3(0.0);
vec3 s = vec3(0.0);
vec3 rez = vec3(0.0);

vec3 refl = reflect(normalize(eyePos), n);
vec4 specular = apply_specular();
Expand All @@ -84,10 +85,10 @@ void main()
float dist = (lights[i].pos.xyz - gl_Position);
if(dist <= lights[i].atten.range){
vec3 l = normalize(lightTangentSpacePositions[i].xyz);
d += clamp(dot(n,l), 0.0, 1.0)*(lights[i].color).rgb;
s += pow(clamp(dot(-refl, l), 0.0, 1.0), power) * lights[i].color.rgb;
float att = 1.0 / (lights[i]].atten.ca + lights[i].atten.la * dist + lights[i].atten.qa * (dist * dist)));
vec3 rez = (ambientColor+d) * (att * (diffuse.xyz + s*specular.rgb));
float att = 1.0 / (lights[i]].atten.ca + lights[i].atten.la * dist + lights[i].atten.qa * (dist * dist));

This comment has been minimized.

Copy link
@nlisker

nlisker Mar 18, 2019

Looks like there's an extra ] in lights[i]].atten.ca.

d += clamp(dot(n,l), 0.0, 1.0)*(lights[i].color).rgb * att;
s += pow(clamp(dot(-refl, l), 0.0, 1.0), power) * lights[i].color.rgb *att;
rez = (ambientColor+d) * (diffuse.xyz + s*specular.rgb);
}
}
rez += apply_selfIllum().xyz;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ void main()

vec3 d = vec3(0.0);
vec3 s = vec3(0.0);
vec3 rez = vec3(0.0);

vec3 refl = reflect(normalize(eyePos), n);
vec4 specular = apply_specular();
Expand All @@ -84,10 +85,10 @@ void main()
float dist = (lights[i].pos.xyz - gl_Position);
if(dist <= lights[i].atten.range){
vec3 l = normalize(lightTangentSpacePositions[i].xyz);
d += clamp(dot(n,l), 0.0, 1.0)*(lights[i].color).rgb;
s += pow(clamp(dot(-refl, l), 0.0, 1.0), power) * lights[i].color.rgb;
float att = 1.0 / (lights[i]].atten.ca + lights[i].atten.la * dist + lights[i].atten.qa * (dist * dist)));
vec3 rez = (ambientColor+d) * (att * (diffuse.xyz + s*specular.rgb));
float att = 1.0 / (lights[i]].atten.ca + lights[i].atten.la * dist + lights[i].atten.qa * (dist * dist));

This comment has been minimized.

Copy link
@nlisker

nlisker Mar 18, 2019

Extra ] here too.

d += clamp(dot(n,l), 0.0, 1.0)*(lights[i].color).rgb * att;
s += pow(clamp(dot(-refl, l), 0.0, 1.0), power) * lights[i].color.rgb *att;
rez = (ambientColor+d) * (diffuse.xyz + s*specular.rgb);
}
}
rez += apply_selfIllum().xyz;
Expand Down

0 comments on commit a44f13f

Please sign in to comment.