CodingTrain / CodingTrain/Suggestion-Box

Refraction - Fisheye lens effect for water droplets on a windowpane

Open
#1,728 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
570
Forks
85
PR merge metrics
No merged PRs in 30d

Description

I spent some time attempting to fake refraction through rain droplets on a window, but had very limited success. I checked the math, and it looked very daunting. Eventually, I settled on just using roughly the average color of the background:
[Portable Rainy Day](https://editor.p5js.org/thejoshvickers/full/GqLNRL6d_)

That being said, is it possible to do real-time refraction in Javascript from scratch? My thought would be to:
1) Create an image from the current frame of the canvas.
2) Scale down that image to the size of the "lens" (water droplet)
3) Flip that image on the x axis
4) Perform some sort of operation that creates a fisheye effect. Perhaps sampling pixels exponentially distant from the center of the image. (I just can't figure out how to actually do this.)
5) Use this as a new fill for the lens object.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.