|
@@ -9,19 +9,9 @@ export class GroundProjectedEnv extends Mesh {
|
|
constructor( texture, options ) {
|
|
constructor( texture, options ) {
|
|
|
|
|
|
const isCubeMap = texture.isCubeTexture;
|
|
const isCubeMap = texture.isCubeTexture;
|
|
- const w =
|
|
|
|
- ( isCubeMap ? texture.image[ 0 ]?.width : texture.image.width ) ?? 1024;
|
|
|
|
- const cubeSize = w / 4;
|
|
|
|
- const _lodMax = Math.floor( Math.log2( cubeSize ) );
|
|
|
|
- const _cubeSize = Math.pow( 2, _lodMax );
|
|
|
|
- const width = 3 * Math.max( _cubeSize, 16 * 7 );
|
|
|
|
- const height = 4 * _cubeSize;
|
|
|
|
|
|
|
|
const defines = [
|
|
const defines = [
|
|
- isCubeMap ? '#define ENVMAP_TYPE_CUBE' : '',
|
|
|
|
- `#define CUBEUV_TEXEL_WIDTH ${1.0 / width}`,
|
|
|
|
- `#define CUBEUV_TEXEL_HEIGHT ${1.0 / height}`,
|
|
|
|
- `#define CUBEUV_MAX_MIP ${_lodMax}.0`,
|
|
|
|
|
|
+ isCubeMap ? '#define ENVMAP_TYPE_CUBE' : ''
|
|
];
|
|
];
|
|
|
|
|
|
const vertexShader = /* glsl */ `
|
|
const vertexShader = /* glsl */ `
|
|
@@ -38,7 +28,6 @@ export class GroundProjectedEnv extends Mesh {
|
|
}
|
|
}
|
|
`;
|
|
`;
|
|
const fragmentShader = defines.join( '\n' ) + /* glsl */ `
|
|
const fragmentShader = defines.join( '\n' ) + /* glsl */ `
|
|
- #define ENVMAP_TYPE_CUBE_UV
|
|
|
|
|
|
|
|
varying vec3 vWorldPosition;
|
|
varying vec3 vWorldPosition;
|
|
|
|
|
|
@@ -114,7 +103,6 @@ export class GroundProjectedEnv extends Mesh {
|
|
}
|
|
}
|
|
|
|
|
|
#include <common>
|
|
#include <common>
|
|
- #include <cube_uv_reflection_fragment>
|
|
|
|
|
|
|
|
void main()
|
|
void main()
|
|
{
|
|
{
|