ソースを参照

constants: adds mandatory WebGL2 PixelFormat to make internalFormat work in all cases

Some WebGL2 internal formats rely on new WebGL2 formats. This change
add the 4 new PixelFormat constants that are needed
David Peicho 5 年 前
コミット
2f188f69d8

+ 9 - 0
docs/api/en/constants/Textures.html

@@ -147,6 +147,8 @@
 		<h2>Formats</h2>
 		<code>
 		THREE.AlphaFormat
+		THREE.RedFormat
+		THREE.RedIntegerFormat
 		THREE.RGFormat
 		THREE.RGIntegerFormat
 		THREE.RGBFormat
@@ -165,6 +167,13 @@
 
 		[page:constant AlphaFormat] discards the red, green and blue components and reads just the alpha component.<br /><br />
 
+		[page:constant RedFormat] discards the green and blue components and reads just the red component.<br /><br />
+
+		[page:constant RedIntegerFormat] discards the green and blue components and reads just the red component.
+		The texels are read as integers instead of floating point.
+		(can only be used with a WebGL 2 rendering context).
+		<br /><br />
+
 		[page:constant RGFormat] discards the alpha, and blue components and reads the red, and green components.
 		(can only be used with a WebGL 2 rendering context).
 		<br /><br />

+ 5 - 0
src/constants.d.ts

@@ -176,6 +176,11 @@ export const RGBEFormat: PixelFormat;
 export const DepthFormat: PixelFormat;
 export const DepthStencilFormat: PixelFormat;
 export const RedFormat: PixelFormat;
+export const RedIntegerFormat: PixelFormat;
+export const RGFormat: PixelFormat;
+export const RGIntegerFormat: PixelFormat;
+export const RGBIntegerFormat: PixelFormat;
+export const RGBAIntegerFormat: PixelFormat;
 
 // Internal Pixel Formats
 export type PixelFormatGPU =

+ 5 - 0
src/constants.js

@@ -101,6 +101,11 @@ export var RGBEFormat = RGBAFormat;
 export var DepthFormat = 1026;
 export var DepthStencilFormat = 1027;
 export var RedFormat = 1028;
+export var RedIntegerFormat = 1029;
+export var RGFormat = 1030;
+export var RGIntegerFormat = 1031;
+export var RGBIntegerFormat = 1032;
+export var RGBAIntegerFormat = 1033;
 
 export var RGB_S3TC_DXT1_Format = 33776;
 export var RGBA_S3TC_DXT1_Format = 33777;

+ 9 - 1
src/renderers/webgl/WebGLUtils.js

@@ -2,7 +2,7 @@
  * @author thespite / http://www.twitter.com/thespite
  */
 
-import { RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, LuminanceAlphaFormat, LuminanceFormat, RedFormat, RGBAFormat, RGBFormat, AlphaFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort565Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType } from '../../constants.js';
+import { RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, LuminanceAlphaFormat, LuminanceFormat, RedFormat, RGBAFormat, RGBFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort565Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType } from '../../constants.js';
 
 function WebGLUtils( gl, extensions, capabilities ) {
 
@@ -51,6 +51,14 @@ function WebGLUtils( gl, extensions, capabilities ) {
 		if ( p === DepthStencilFormat ) return gl.DEPTH_STENCIL;
 		if ( p === RedFormat ) return gl.RED;
 
+		// WebGL2 formats.
+
+		if ( p === RedIntegerFormat ) return gl.RED_INTEGER;
+		if ( p === RGFormat ) return gl.RG;
+		if ( p === RGIntegerFormat ) return gl.RG_INTEGER;
+		if ( p === RGBIntegerFormat ) return gl.RGB_INTEGER;
+		if ( p === RGBAIntegerFormat ) return gl.RGBA_INTEGER;
+
 		if ( p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format ||
 			p === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format ) {
 

+ 5 - 0
utils/build/rollup.config.js

@@ -58,6 +58,11 @@ function glconstants() {
 		RGBA: 6408,
 		LUMINANCE: 6409,
 		LUMINANCE_ALPHA: 6410,
+		RED_INTEGER: 36244,
+		RG: 33319,
+		RG_INTEGER: 33320,
+		RGB_INTEGER: 36248,
+		RGBA_INTEGER: 36249,
 		VERSION: 7938,
 		NEAREST: 9728,
 		LINEAR: 9729,