-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GLTF KHR_materials_anisotropy support (#25580)
* plumbing * refactored tangents * fix bump map * fix bump map again * added IBL anisotropy support * added direct anisotropy support * reshuffle chunks * fix clearcoat * fix dangling endif * separate physical BRDF from blinnPhong * prod CI * move Schlick to common * fixed plumbing * fixed shader compilation * fixed mappings * fixed tangents * changed IBL mapping * fix typo * fixed direct lighting * linearized mappings * added anisotropyDirection * fixed angle direction * added references * fix anisotropy map * Angle -> Rotation * fixed tangent sign * rename anisotropyMat * fix 90 deg rotation * update to spec * updated alphaT mapping * Revert "updated alphaT mapping" This reverts commit cebace1. * WebGLProgram: Added missing ANISOTROPYMAP_UV define. * Reverted builds. * WebGLPrograms: Fixed typo. * update to spec * updated golden * update texture definition * added example * add build files * added screenshot --------- Co-authored-by: Mr.doob <[email protected]>
- Loading branch information
Showing
31 changed files
with
786 additions
and
101 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>three.js webgl - GLTFloader + Anisotropy</title> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> | ||
<link type="text/css" rel="stylesheet" href="main.css"> | ||
</head> | ||
|
||
<body> | ||
<div id="info"> | ||
<a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> - GLTFLoader + <a href="https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_anisotropy" target="_blank" rel="noopener">KHR_materials_anisotropy</a><br /> | ||
Anisotropy Barn Lamp from <a href="https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/AnisotropyBarnLamp" target="_blank" rel="noopener">glTF-Sample-Models</a><br /> | ||
<a href="https://hdrihaven.com/hdri/?h=venice_sunset" target="_blank" rel="noopener">Venice Sunset</a> by <a href="https://hdrihaven.com/" target="_blank" rel="noopener">HDRI Haven</a> | ||
</div> | ||
|
||
<!-- Import maps polyfill --> | ||
<!-- Remove this when import maps will be widely supported --> | ||
<script async src="https://unpkg.com/[email protected]/dist/es-module-shims.js"></script> | ||
|
||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
"three": "../build/three.module.js", | ||
"three/addons/": "./jsm/" | ||
} | ||
} | ||
</script> | ||
|
||
<script type="module"> | ||
|
||
import * as THREE from 'three'; | ||
|
||
import { OrbitControls } from 'three/addons/controls/OrbitControls.js'; | ||
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js'; | ||
import { RGBELoader } from 'three/addons/loaders/RGBELoader.js'; | ||
|
||
let renderer, scene, camera, controls; | ||
|
||
init().catch( function ( err ) { | ||
|
||
console.error( err ); | ||
|
||
} ); | ||
|
||
async function init() { | ||
|
||
renderer = new THREE.WebGLRenderer( { antialias: true } ); | ||
renderer.setPixelRatio( window.devicePixelRatio ); | ||
renderer.setSize( window.innerWidth, window.innerHeight ); | ||
renderer.toneMapping = THREE.ACESFilmicToneMapping; | ||
document.body.appendChild( renderer.domElement ); | ||
|
||
scene = new THREE.Scene(); | ||
|
||
camera = new THREE.PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 0.25, 20 ); | ||
camera.position.set( 0.35, 0.05, 0.35 ); | ||
|
||
controls = new OrbitControls( camera, renderer.domElement ); | ||
controls.addEventListener( 'change', render ); | ||
controls.target.set( 0, -0.05, 0.1 ); | ||
controls.update(); | ||
|
||
const rgbeLoader = new RGBELoader() | ||
.setPath( 'textures/equirectangular/' ); | ||
|
||
const gltfLoader = new GLTFLoader().setPath( 'models/gltf/' ); | ||
|
||
const [ texture, gltf ] = await Promise.all( [ | ||
rgbeLoader.loadAsync( 'venice_sunset_1k.hdr' ), | ||
gltfLoader.loadAsync( 'AnisotropyBarnLamp.glb' ), | ||
] ); | ||
|
||
// environment | ||
|
||
texture.mapping = THREE.EquirectangularReflectionMapping; | ||
|
||
scene.background = texture; | ||
scene.environment = texture; | ||
|
||
// model | ||
|
||
scene.add( gltf.scene ); | ||
|
||
render(); | ||
|
||
window.addEventListener( 'resize', onWindowResize ); | ||
|
||
} | ||
|
||
function onWindowResize() { | ||
|
||
camera.aspect = window.innerWidth / window.innerHeight; | ||
|
||
camera.updateProjectionMatrix(); | ||
|
||
renderer.setSize( window.innerWidth, window.innerHeight ); | ||
|
||
render(); | ||
|
||
} | ||
|
||
function render() { | ||
|
||
renderer.render( scene, camera ); | ||
|
||
} | ||
|
||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.