Skip to content

Commit

Permalink
GlobalUniformValues: changed LightColor from vec4 to vec3
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Aug 9, 2023
1 parent 3a1187e commit 3280901
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class GlobalUniformValues {
/**
* color of the lights
*/
final private Vector4f lightColor = new Vector4f();
final private Vector3f lightColor = new Vector3f(1f, 1f, 1f);
// *************************************************************************
// new methods exposed

Expand Down Expand Up @@ -98,8 +98,8 @@ static int numBytes() {
result = Utils.align(result, 16);
result += 3 * Float.BYTES;

// vec4 LightColor
result += 4 * Float.BYTES;
// vec3 LightColor
result += 3 * Float.BYTES;

// mat4 viewMatrix
result = Utils.align(result, 16);
Expand Down Expand Up @@ -143,9 +143,9 @@ void writeTo(ByteBuffer target) {
lightDirectionWorldspace.get(byteOffset, target);
byteOffset += 3 * Float.BYTES;

// vec4 LightColor
// vec3 LightColor
lightColor.get(byteOffset, target);
byteOffset += 4 * Float.BYTES;
byteOffset += 3 * Float.BYTES;

// mat4 viewMatrix
byteOffset = Utils.align(byteOffset, 16);
Expand Down
4 changes: 2 additions & 2 deletions lib/src/main/resources/Shaders/Phong/Distant/Monochrome.frag
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
layout(binding = 0) uniform Global { // global uniforms:
float ambientStrength;
vec3 LightDirection_worldspace;
vec4 LightColor;
vec3 LightColor;
mat4 viewMatrix;
mat4 projectionMatrix;
} global;
Expand Down Expand Up @@ -56,5 +56,5 @@ void main() {

vec3 color = (global.ambientStrength + cosTheta) * ubo.BaseMaterialColor.rgb;
color = color + cosAlpha8 * ubo.SpecularMaterialColor.rgb;
fragColor = color * global.LightColor.rgb;
fragColor = color * global.LightColor;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
layout(binding = 0) uniform Global { // global uniforms:
float ambientStrength;
vec3 LightDirection_worldspace;
vec4 LightColor;
vec3 LightColor;
mat4 viewMatrix;
mat4 projectionMatrix;
} global;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/main/resources/Shaders/Unshaded/Texture.vert
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
layout(binding = 0) uniform Global { // global uniforms:
float ambientStrength;
vec3 LightDirection_worldspace;
vec4 LightColor;
vec3 LightColor;
mat4 viewMatrix;
mat4 projectionMatrix;
} global;
Expand Down

0 comments on commit 3280901

Please sign in to comment.