Skip to content

Commit

Permalink
Clamp colors in the range 0 - 1
Browse files Browse the repository at this point in the history
  • Loading branch information
hollance committed Jan 18, 2017
1 parent 8c256e4 commit 91d66a5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ThreeDee/Render.swift
Expand Up @@ -828,6 +828,10 @@ fileprivate func drawSpans() {
g *= (ambientG*ambientIntensity + factor*diffuseG*diffuseIntensity)
b *= (ambientB*ambientIntensity + factor*diffuseB*diffuseIntensity)

r = max(min(r, 1), 0) // clamp the colors
g = max(min(g, 1), 0) // so they don't
b = max(min(b, 1), 0) // become too bright

setPixel(x: x, y: y, r: r, g: g, b: b, a: a)
}

Expand Down

0 comments on commit 91d66a5

Please sign in to comment.