Merge pull request 'use three-hex-tiling for ground material' (#1) from hexTiling into master

Reviewed-on: #1
This commit is contained in:
Adrien MALINGREY 2023-11-18 12:48:30 +01:00
commit 9187d8d9ef
2 changed files with 27 additions and 8 deletions

View File

@ -12,8 +12,9 @@
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/three@0.157/build/three.module.js?module",
"three/addons/": "https://unpkg.com/three@0.157/examples/jsm/"
"three": "https://unpkg.com/three@0.158/build/three.module.js?module",
"three/addons/": "https://unpkg.com/three@0.158/examples/jsm/",
"three-hex-tiling": "https://cdn.jsdelivr.net/npm/three-hex-tiling@0.1.1/dist/index.js"
}
}
</script>

30
main.js
View File

@ -10,6 +10,8 @@ import Stats from 'three/addons/libs/stats.module.js';
import MazeMesh from './MazeMesh.js';
import 'three-hex-tiling';
const playerHeight = 0.5;
const mazeWidth = 23
@ -86,6 +88,7 @@ scene.background = new THREE.CubeTextureLoader(loadMngr)
'lf.jpg',
] );
scene.backgroundBlurriness = 0.03;
scene.backgroundIntensity = 1.4;
scene.environment = scene.background;
window.scene = scene;
@ -103,7 +106,7 @@ const wallMaterial = new THREE.MeshStandardMaterial({
normalMap : loader.load('textures/Poly-cobblestone-wall/normal_map_opengl.jpg'),
aoMap : loader.load('textures/Poly-cobblestone-wall/ao_map.jpg'),
roughnessMap : loader.load('textures/Poly-cobblestone-wall/roughness_map.jpg'),
roughness : 1,
roughness : 1
})
const maze = new MazeMesh(mazeWidth, mazeWidth, 1, wallMaterial);
@ -138,37 +141,43 @@ const groundMaterial = new THREE.MeshStandardMaterial({
'textures/angled-blocks-vegetation/albedo.png',
texture => {
texture.wrapS = texture.wrapT = THREE.RepeatWrapping
texture.repeat.set(mazeWidth / 4, mazeWidth / 4)
texture.repeat.set(mazeWidth / 2, mazeWidth / 2)
}
),
aoMap: loader.load(
'textures/angled-blocks-vegetation/ao.png',
texture => {
texture.wrapS = texture.wrapT = THREE.RepeatWrapping
texture.repeat.set(mazeWidth / 4, mazeWidth / 4)
texture.repeat.set(mazeWidth / 2, mazeWidth / 2)
}
),
metalnessMap: loader.load(
'textures/angled-blocks-vegetation/metallic.png',
texture => {
texture.wrapS = texture.wrapT = THREE.RepeatWrapping
texture.repeat.set(mazeWidth / 4, mazeWidth / 4)
texture.repeat.set(mazeWidth / 2, mazeWidth / 2)
}
),
normalMap: loader.load(
'textures/angled-blocks-vegetation/normal-dx.png',
texture => {
texture.wrapS = texture.wrapT = THREE.RepeatWrapping
texture.repeat.set(mazeWidth / 4, mazeWidth / 4)
texture.repeat.set(mazeWidth / 2, mazeWidth / 2)
}
),
roughnessMap: loader.load(
'textures/angled-blocks-vegetation/roughness.png',
texture => {
texture.wrapS = texture.wrapT = THREE.RepeatWrapping
texture.repeat.set(mazeWidth / 4, mazeWidth / 4)
texture.repeat.set(mazeWidth / 2, mazeWidth / 2)
}
),
hexTiling: {
patchScale: 1,
useContrastCorrectedBlending: true,
lookupSkipThreshold: 0.01,
textureSampleCoefficientExponent: 32,
}
})
const sideGroundMaterial = new THREE.MeshStandardMaterial({
@ -385,6 +394,7 @@ if (dev) {
raftRotationFolder.add(raft.rotation, "x")
raftRotationFolder.add(raft.rotation, "y")
raftRotationFolder.add(raft.rotation, "z")
raftFolder.close();
const skyFolder = gui.addFolder('Sky');
skyFolder.add(parameters, 'elevation', 0, 90, 0.1).onChange(updateSun);
@ -488,6 +498,14 @@ if (dev) {
});
waveCFolder.open();
const HexTilingFolder = gui.addFolder('Hex Tiling')
const groundMaterialFolder = HexTilingFolder.addFolder("ground")
groundMaterialFolder.add(groundMaterial.hexTiling, "patchScale", 0, 10)
groundMaterialFolder.add(groundMaterial.hexTiling, "useContrastCorrectedBlending")
groundMaterialFolder.add(groundMaterial.hexTiling, "lookupSkipThreshold", 0, 1)
groundMaterialFolder.add(groundMaterial.hexTiling, "textureSampleCoefficientExponent", 0, 64).name("SampleCoefExp")
HexTilingFolder.close()
}
//