Skip to content

Commit c70560b

Browse files
committed
Implemented intensity support for point light rendering.
1 parent 26c3f4e commit c70560b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/main/java/engine/processing/LightRendererImpl.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,27 @@ public void render(PointLight light) {
7373
light.getPosition().getX(),
7474
light.getPosition().getY(),
7575
light.getPosition().getZ());
76+
77+
float intensity = light.getIntensity();
78+
79+
// Retrieve light color
80+
float red = light.getColor().getRed(); // Gives a value from 0 to 1
81+
float green = light.getColor().getGreen(); // Same for green
82+
float blue = light.getColor().getBlue(); // Same for blue
83+
84+
// Apply intensity to each color component
85+
red *= intensity;
86+
green *= intensity;
87+
blue *= intensity;
88+
89+
// Call pointLight() with adjusted color
90+
p.pointLight(
91+
red * 255, // Scale back to 0-255 range for Processing's pointLight
92+
green * 255, // Same for green
93+
blue * 255, // Same for blue
94+
light.getPosition().getX(),
95+
light.getPosition().getY(),
96+
light.getPosition().getZ());
7697
}
7798

7899
public void render(DirectionalLight light) {

0 commit comments

Comments
 (0)