Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions docs/api/en/constants/Textures.html
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,18 @@ <h2>BPTC Compressed Texture Format</h2>
[link:https://www.khronos.org/registry/webgl/extensions/EXT_texture_compression_bptc/ EXT_texture_compression_bptc] extension. <br /><br />
</p>

<h2>Texture Comparison functions</h2>
<code>
THREE.NeverCompare
THREE.LessCompare
THREE.EqualCompare
THREE.LessEqualCompare
THREE.GreaterCompare
THREE.NotEqualCompare
THREE.GreaterEqualCompare
THREE.AlwaysCompare
</code>

<h2>Internal Formats</h2>
<code>
'ALPHA'
Expand Down
7 changes: 7 additions & 0 deletions docs/api/en/textures/Texture.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ <h3>[property:number format]</h3>
formats.
</p>

<h3>[property:String compareFunc]</h3>
<p>
This is used to define the comparison function used when comparing texels in the depth texture to the value in the depth buffer.<br /><br/>

See the [page:Textures texture constants] page for details of other functions.
</p>

<h3>[property:String internalFormat]</h3>
<p>
The default value is obtained using a combination of [page:Texture.format .format] and [page:Texture.type .type].<br />
Expand Down
9 changes: 9 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ export const NotEqualStencilFunc = 517;
export const GreaterEqualStencilFunc = 518;
export const AlwaysStencilFunc = 519;

export const NeverCompare = 512;
export const LessCompare = 513;
export const EqualCompare = 514;
export const LessEqualCompare = 515;
export const GreaterCompare = 516;
export const NotEqualCompare = 517;
export const GreaterEqualCompare = 518;
export const AlwaysCompare = 519;

export const StaticDrawUsage = 35044;
export const DynamicDrawUsage = 35048;
export const StreamDrawUsage = 35040;
Expand Down
20 changes: 19 additions & 1 deletion src/renderers/webgl/WebGLTextures.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, UnsignedByteType, _SRGBAFormat, NoColorSpace, LinearSRGBColorSpace, SRGBColorSpace } from '../../constants.js';
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, UnsignedByteType, _SRGBAFormat, NoColorSpace, LinearSRGBColorSpace, SRGBColorSpace, NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare } from '../../constants.js';
import * as MathUtils from '../../math/MathUtils.js';
import { ImageUtils } from '../../extras/ImageUtils.js';
import { createElementNS } from '../../utils.js';
Expand Down Expand Up @@ -526,6 +526,17 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
[ LinearMipmapLinearFilter ]: _gl.LINEAR_MIPMAP_LINEAR
};

const compareToGL = {
[ NeverCompare ]: _gl.NEVER,
[ AlwaysCompare ]: _gl.ALWAYS,
[ LessCompare ]: _gl.LESS,
[ LessEqualCompare ]: _gl.LEQUAL,
[ EqualCompare ]: _gl.EQUAL,
[ GreaterEqualCompare ]: _gl.GEQUAL,
[ GreaterCompare ]: _gl.GREATER,
[ NotEqualCompare ]: _gl.NOTEQUAL
};

function setTextureParameters( textureType, texture, supportsMips ) {

if ( supportsMips ) {
Expand Down Expand Up @@ -570,6 +581,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

}

if ( texture.compareFunc ) {

_gl.texParameteri( textureType, _gl.TEXTURE_COMPARE_MODE, _gl.COMPARE_REF_TO_TEXTURE );
_gl.texParameteri( textureType, _gl.TEXTURE_COMPARE_FUNC, compareToGL[ texture.compareFunc ] );

}

if ( extensions.has( 'EXT_texture_filter_anisotropic' ) === true ) {

const extension = extensions.get( 'EXT_texture_filter_anisotropic' );
Expand Down