Skip to content

Commit

Permalink
Parallel light source
Browse files Browse the repository at this point in the history
  • Loading branch information
monman53 committed Jun 21, 2024
1 parent df1fdb8 commit 15f15e2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Canvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,17 @@ const draw = () => {
// Parallel light source
if (light.type === Light.Parallel) {
const l = Vec.sub(light.t, light.s)
const ln = l.copy().normalize()
const length = l.length()
const nRays = Math.floor((length / (2 * Math.PI)) * (1 << params.nRaysLog) * 0.01)
for (let i = 0; i < nRays; i++) {
const s = light.s.copy().add(ln.copy().mul(i / nRays * length))
// Find image position of the light source
const image = fGaussian(lens.value.f, lens.value.x - s.x, -s.y)
const v = vec(l.y, -l.x)
drawRay(image, light, s, v, sensorDataTmp)
}
}
}
Expand Down

0 comments on commit 15f15e2

Please sign in to comment.