Jump to content

Displacement map from canvas in ThreeJS (normalMap shader)


jurito
 Share

Recommended Posts

Hello yall!

I'm trying to make a dynamic displacementMap drawing (onmousemove) an html canvas.

The experiment is based on http://mrdoob.github.io/three.js/examples/webgl_materials_normalmap.html.
The problem is that updating uniforms.tDisplacement.value with new THREE.Texture(canvas) won't work at all.
I tried using THREE.ImageUtils.loadTexture( canvas.toDataUrl()) and it kinda works, but's too slow and messes up the canvas itself update.
To exclude problems with the canvas, I tried using THREE.Texture(canvas) as map of a MeshBasicMaterial and it worked fine onmousemove.

TIA

 

TL;DR What's the best/fastest way to update a displacement map in a ThreeJS normalmap shader from a canvas?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...