Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a built-in way to layer textures within the standard PBR shader?

Tags:

three.js

I want to have an effect similar to this question, in Aframe, to have layered swappable textures on a single model:

I am wondering if there is a standard process I have missed in Threejs so that I can continue to use the standard shader; or do I have to fork it and add the multi-texture capability myself in a custom shader?

Thanks!

like image 906
Anthony Scavarelli Avatar asked Apr 07 '18 01:04

Anthony Scavarelli


1 Answers

You want to layer materials or textures using three.js.

Here is a pattern that currently works:

var geometry = new THREE.BoxGeometry( 10, 10, 10 );
geometry.clearGroups();
geometry.addGroup( 0, Infinity, 0 );
geometry.addGroup( 0, Infinity, 1 );
geometry.addGroup( 0, Infinity, 2 );
geometry.addGroup( 0, Infinity, 3 );

var materials = [ material0, material1, material2, material3 ];

// mesh
mesh = new THREE.Mesh( geometry, materials );
scene.add( mesh );

three.js r.144

like image 86
WestLangley Avatar answered Oct 17 '22 22:10

WestLangley