Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMREMGenerator: Cleanup #23558

Merged
merged 2 commits into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions src/extras/PMREMGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
CubeUVReflectionMapping,
LinearEncoding,
LinearFilter,
NearestFilter,
NoToneMapping,
NoBlending,
RGBAFormat,
Expand All @@ -17,7 +16,6 @@ import { Mesh } from '../objects/Mesh.js';
import { OrthographicCamera } from '../cameras/OrthographicCamera.js';
import { PerspectiveCamera } from '../cameras/PerspectiveCamera.js';
import { RawShaderMaterial } from '../materials/RawShaderMaterial.js';
import { Vector2 } from '../math/Vector2.js';
import { Vector3 } from '../math/Vector3.js';
import { Color } from '../math/Color.js';
import { WebGLRenderTarget } from '../renderers/WebGLRenderTarget.js';
Expand Down Expand Up @@ -448,9 +446,6 @@ class PMREMGenerator {

const pingPongRenderTarget = this._pingPongRenderTarget;

cubeUVRenderTarget.texture.minFilter = NearestFilter;
pingPongRenderTarget.texture.minFilter = NearestFilter;

this._halfBlur(
cubeUVRenderTarget,
pingPongRenderTarget,
Expand All @@ -469,9 +464,6 @@ class PMREMGenerator {
'longitudinal',
poleAxis );

cubeUVRenderTarget.texture.minFilter = LinearFilter;
pingPongRenderTarget.texture.minFilter = LinearFilter;

}

_halfBlur( targetIn, targetOut, lodIn, lodOut, sigmaRadians, direction, poleAxis ) {
Expand Down Expand Up @@ -666,10 +658,6 @@ function _getBlurShader( lodMax, width, height ) {

name: 'SphericalGaussianBlur',

extensions: {
shaderTextureLOD: true
},

defines: {
'n': MAX_SAMPLES,
'CUBEUV_TEXEL_WIDTH': 1.0 / width,
Expand All @@ -691,6 +679,8 @@ function _getBlurShader( lodMax, width, height ) {

fragmentShader: /* glsl */`

#extension GL_EXT_shader_texture_lod : enable

precision mediump float;
precision mediump int;

Expand Down Expand Up @@ -790,7 +780,7 @@ function _getEquirectShader() {
vec2 uv = equirectUv( outputDirection );

gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );

}
`,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default /* glsl */`
uv.x *= CUBEUV_TEXEL_WIDTH;
uv.y *= CUBEUV_TEXEL_HEIGHT;

#ifdef TEXTURE_LOD_EXT
#ifdef texture2DGradEXT

return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; // disable anisotropic filtering

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default /* glsl */`

float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );

#ifdef TEXTURE_LOD_EXT
#ifdef texture2DLodEXT

return texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );

Expand Down
7 changes: 2 additions & 5 deletions src/renderers/webgl/WebGLProgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
prefixFragment = [

customExtensions,
customDefines,
parameters.rendererExtensionShaderTextureLod ? '#define TEXTURE_LOD_EXT' : ''
customDefines

].filter( filterEmptyLine ).join( '\n' );

Expand Down Expand Up @@ -666,8 +665,6 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '',

( ( parameters.extensionShaderTextureLOD || parameters.envMap ) && parameters.rendererExtensionShaderTextureLod ) ? '#define TEXTURE_LOD_EXT' : '',

'uniform mat4 viewMatrix;',
'uniform vec3 cameraPosition;',
'uniform bool isOrthographic;',
Expand Down Expand Up @@ -701,7 +698,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
vertexShader = unrollLoops( vertexShader );
fragmentShader = unrollLoops( fragmentShader );

if ( parameters.isWebGL2 ) {
if ( parameters.isWebGL2 && parameters.isRawShaderMaterial !== true ) {
mrdoob marked this conversation as resolved.
Show resolved Hide resolved

// GLSL 3.0 conversion for built-in materials and ShaderMaterial

Expand Down