|
|
@@ -23,7 +23,7 @@ import CubeRenderTarget from '../../renderers/common/CubeRenderTarget.js';
|
|
|
|
|
|
import BindGroup from '../../renderers/common/BindGroup.js';
|
|
|
|
|
|
-import { REVISION, IntType, UnsignedIntType, LinearFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, LinearMipmapLinearFilter, NormalBlending } from '../../constants.js';
|
|
|
+import { REVISION, IntType, UnsignedIntType, LinearFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, LinearMipmapLinearFilter, NormalBlending, RedFormat, RGFormat, RGBFormat, RedIntegerFormat, RGIntegerFormat, RGBIntegerFormat } from '../../constants.js';
|
|
|
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
|
import { Color } from '../../math/Color.js';
|
|
|
import { Vector2 } from '../../math/Vector2.js';
|
|
|
@@ -535,6 +535,61 @@ class NodeBuilder {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Returns the type of the color output based on the renderer's render target.
|
|
|
+ *
|
|
|
+ * @param {number} [index=0] - The index of the render target texture.
|
|
|
+ * @return {string} The type.
|
|
|
+ */
|
|
|
+ getOutputType( index = 0 ) {
|
|
|
+
|
|
|
+ let type = 'vec4';
|
|
|
+
|
|
|
+ const renderTarget = this.renderer.getRenderTarget();
|
|
|
+
|
|
|
+ if ( renderTarget !== null ) {
|
|
|
+
|
|
|
+ const renderTargetType = renderTarget.textures[ index ].type;
|
|
|
+ const renderTargetFormat = renderTarget.textures[ index ].format;
|
|
|
+
|
|
|
+ let typeStr = 'vec';
|
|
|
+
|
|
|
+ if ( renderTargetType === IntType ) {
|
|
|
+
|
|
|
+ typeStr = 'ivec';
|
|
|
+
|
|
|
+ } else if ( renderTargetType === UnsignedIntType ) {
|
|
|
+
|
|
|
+ typeStr = 'uvec';
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( renderTargetFormat === RedFormat || renderTargetFormat === RedIntegerFormat ) {
|
|
|
+
|
|
|
+ if ( renderTargetType === IntType ) type = 'int';
|
|
|
+ else if ( renderTargetType === UnsignedIntType ) type = 'uint';
|
|
|
+ else type = 'float';
|
|
|
+
|
|
|
+ } else if ( renderTargetFormat === RGFormat || renderTargetFormat === RGIntegerFormat ) {
|
|
|
+
|
|
|
+ type = `${ typeStr }2`;
|
|
|
+
|
|
|
+ } else if ( renderTargetFormat === RGBFormat || renderTargetFormat === RGBIntegerFormat ) {
|
|
|
+
|
|
|
+ type = `${ typeStr }3`;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ type = `${ typeStr }4`;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return type;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Returns the output struct name which is required by
|
|
|
* {@link OutputStructNode}.
|
|
|
@@ -1469,12 +1524,10 @@ class NodeBuilder {
|
|
|
|
|
|
const type = texture.type;
|
|
|
|
|
|
- if ( texture.isDataTexture ) {
|
|
|
+ if ( texture.isDepthTexture === true ) return 'float';
|
|
|
|
|
|
- if ( type === IntType ) return 'int';
|
|
|
- if ( type === UnsignedIntType ) return 'uint';
|
|
|
-
|
|
|
- }
|
|
|
+ if ( type === IntType ) return 'int';
|
|
|
+ if ( type === UnsignedIntType ) return 'uint';
|
|
|
|
|
|
return 'float';
|
|
|
|