Three.js: Refraction with custom geometry

Created on 1 Jul 2018  路  8Comments  路  Source: mrdoob/three.js

Description of the problem

Hello,

I noticed an issue with the Refraction example :

https://threejs.org/examples/?q=refr#webgl_refraction

If I change the plane by a box and rotate it, some times the shader show weird things :

image

Modifications of the example :

Line 81 :
var refractorGeometry = new THREE.BoxBufferGeometry( 4, 4, 4 );

function render() { 

    refractor.material.uniforms.time.value += clock.getDelta();

    refractor.rotation.y += 0.02;

    renderer.render( scene, camera );

}
Three.js version
  • [x] r94
Browser
  • [x] All of them
OS
  • [x] All of them

All 8 comments

Reflector and Refractor are intended to be used with a planar geometry.

Reflector and Refractor are intended to be used with PlaneGeometry.

Actually, in webgl_mirror.html, a CircleBufferGeometry is used.

@mrdoob Should I correct your edit? 馃槈

You can also use an arbitrary shape:

var shape = new THREE.Shape( points );
var geometry = new THREE.ShapeBufferGeometry( shape );

I noticed that all kind of geometry seems to work if we keep the camera looking at the Z object axis.

Might be a nice feature to have it working for all point of view ?

I tried to fix it, but I don't really understang how it works, especially with the refractorPlane thing.

@mrdoob Should I correct your edit? 馃槈

Hehe, ops! I tried to make it more clear. I should have said PlaneGeometry, CircleGeometry, ShapeGeometry, ...

I noticed that all kind of geometry seems to work if we keep the camera looking at the Z object axis.

Might be a nice feature to have it working for all point of view ?

@Mugen87 Have you investigated this?

The algorithm of Reflector and Refractor assumes there is a single reflection/refraction plane. I think you need a different approach if you want to support an arbitrary amount of planes defined by a group of planar polygon faces.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

boyravikumar picture boyravikumar  路  3Comments

ghost picture ghost  路  3Comments

konijn picture konijn  路  3Comments

akshaysrin picture akshaysrin  路  3Comments

danieljack picture danieljack  路  3Comments