WebGL-Fluid-Simulation icon indicating copy to clipboard operation
WebGL-Fluid-Simulation copied to clipboard

Warp a background image?

Open thekevbot opened this issue 5 years ago • 2 comments

Would it be possible to add a background image that's warped by the shader? To simulate waves through an image instead of just over top of it?

I've started by modifying it as mentioned in #14 but obviously that just applies a static background-image.

thekevbot avatar Dec 10 '19 05:12 thekevbot

I have a version that warps the image here: https://github.com/tinarwhite/WebGL-Fluid-Simulation

Demo here: https://www.tinarwhite.com/fluids/paint/

tinarwhite avatar Feb 05 '20 06:02 tinarwhite

This will do it:

css

canvas {
  width: 100vw;
  height: 100vh;
  background-image: url("back.png");
  background-size: 100% 100%;
}

js

import WebglFluid from 'webgl-fluid'

WebglFluid(document.querySelector('canvas'), {
  TRANSPARENT: true
})

cloydlau avatar Nov 16 '20 14:11 cloydlau