stride3d/stride · error · NotSupportedException

Only texture cube are currently supported as input of…

Error message

Only texture cube are currently supported as input of 'LambertianPrefilteringNoCompute' effect.

What it means

LambertianPrefilteringSHNoCompute is the raster (non-compute) variant of SH prefiltering and likewise only accepts cubemap inputs. DrawCore throws NotSupportedException when the input texture is not a TextureCube.

Solutions

  1. Supply a cubemap texture as input.
  2. Convert 2D environment maps to cubemaps first.
  3. Guard with inputTexture.ViewDimension == TextureDimension.TextureCube before invoking.

Example fix

// before
noComputePrefilter.Draw(context, equirectTexture);
// after
if (equirectTexture.ViewDimension != TextureDimension.TextureCube) equirectTexture = ConvertToCubemap(context, equirectTexture);
noComputePrefilter.Draw(context, equirectTexture);
Defensive patterns

Strategy: validation

Validate before calling

if (inputTexture?.ViewDimension != TextureDimension.TextureCube) throw new ArgumentException("LambertianPrefilteringNoCompute requires a TextureCube input");

Type guard

bool IsCube(Texture t) => t?.ViewDimension == TextureDimension.TextureCube;

Try / catch

try { prefilter.Draw(context, inputTexture); } catch (NotSupportedException ex) { log.Error(ex, "SH NoCompute prefiltering needs a cubemap input"); }

Prevention

When it happens

Trigger: Drawing the effect with inputTexture whose ViewDimension is Texture2D (or null handling path returning early not taken).

Common situations: Same as the compute variant: passing a panorama/2D environment texture; a configuration mix-up in the lighting precompute step.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/8213ba9283de0ed2. Report an issue: GitHub.

Appendix: source

Thrown at sources/engine/Stride.Rendering/Rendering/ComputeEffect/LambertianPrefiltering/LambertianPrefilteringSHNoCompute.cs:66

            : base(context, "LambertianPrefilteringSHNoCompute")
        {
            firstPassEffect = new ImageEffectShader("LambertianPrefilteringSHNoComputeEffectPass1");
            secondPassEffect = new ImageEffectShader("LambertianPrefilteringSHNoComputePass2");

            HarmonicOrder = 3;
        }

        protected override void DrawCore(RenderDrawContext context)
        {
            var inputTexture = RadianceMap;
            if (inputTexture == null)
                return;

            var coefficientsCount = harmonicalOrder * harmonicalOrder;
            var faceCount = inputTexture.ViewDimension == TextureDimension.TextureCube ? 6 : 1;
            if (faceCount == 1)
            {
                throw new NotSupportedException("Only texture cube are currently supported as input of 'LambertianPrefilteringNoCompute' effect.");
            }
            firstPassEffect.Parameters.Set(SphericalHarmonicsParameters.HarmonicsOrder, harmonicalOrder);
            firstPassEffect.Parameters.Set(LambertianPrefilteringSHNoComputePass1Keys.RadianceMap, inputTexture);

            // Create a tree of power-of-two textures for summing up coefficients
            var intermediateSize = new Int2(MathUtil.NextPowerOfTwo(inputTexture.Width), MathUtil.NextPowerOfTwo(inputTexture.Height));
            var intermediateTextures = new List<Texture>();

            intermediateTextures.Add(NewScopedRenderTarget2D(intermediateSize.X, intermediateSize.Y, PixelFormat.R32G32B32A32_Float));
            while (intermediateSize.X > 1 || intermediateSize.Y > 1)
            {
                if (intermediateSize.X > 1)
                    intermediateSize.X >>= 1;
                if (intermediateSize.Y > 1)
                    intermediateSize.Y >>= 1;

                intermediateTextures.Add(NewScopedRenderTarget2D(intermediateSize.X, intermediateSize.Y, PixelFormat.R32G32B32A32_Float));
            }

View on GitHub (pinned to 96fad776d2)