Exception when sampling 2 different textures in DrawShader

hey,

i run into troubles when writing a simple DrawShader that samples from 2 different textures in the pixelshader.

The shader is as simple as this:

[Summary("")]
shader MultiTexture_DrawFX : VS_PS_Base, ColorBase, ShaderUtils, Texturing
{
    [Color]
    stage float4 ColorInput = float4(1, 1, 1, 1);

    override stage void VSMain()
    {
        streams.ShadingPosition = mul(streams.Position, WorldViewProjection);
    }

    override stage void PSMain() 
    {
        float4 tCol01 = Texture0.Sample(LinearSampler, streams.TexCoord);
        float4 tCol02 = Texture1.Sample(LinearSampler, streams.TexCoord1);
        //float4 tCol02 = float4(1,0,0,1);
        streams.ColorTarget = tCol01 * tCol02;
    }
};

as soon as the i add the line with Texture1.Sample(…), VVVV breaks with this exception (gamma 5.2 stable)

Summary

SharpDXException: "HRESULT: [0x80070057], Module: [General], ApiCode: [E_INVALIDARG/Invalid Arguments], Message: Falscher Parameter.
"
StackTrace:
SharpDX.Direct3D11.Device { internal void CreateInputLayout(SharpDX.Direct3D11.InputElement inputElementDescsRef, int numElements, System.IntPtr shaderBytecodeWithInputSignatureRef, SharpDX.PointerSize bytecodeLength, SharpDX.Direct3D11.InputLayout inputLayoutOut) { … } }

    Stride.Graphics.PipelineState { private void CreateInputLayout(Stride.Graphics.InputElementDescription[] inputElements) { ... } } 
    
    Stride.Graphics.PipelineState { public static Stride.Graphics.PipelineState New(Stride.Graphics.GraphicsDevice graphicsDevice, Stride.Graphics.PipelineStateDescription& pipelineStateDescription) { ... } } 
    Stride.Graphics.MutablePipelineState { public void Update() { ... } } 
    VL.Stride.Graphics.GraphicsNodes+<>c { internal Stride.Graphics.PipelineState <GetNodeDescriptions>b__2_19(Stride.Graphics.MutablePipelineState x) { ... } } 
    VL.Stride.CustomNodeDesc`1+CachedOutputPin`1 { public virtual T get_Value() { ... } } 
    _VL_Stride_Rendering_.Stride.Rendering.MeshRenderer_C { public _VL_Stride_Rendering_.Stride.Rendering.MeshRenderer_C DrawInternal(Stride.Rendering.RenderDrawContext Context_In) { ... } } 
    _VL_Stride_Rendering_.Stride.Rendering.MeshRenderer_C { public _VL_Stride_Rendering_.Stride.Rendering.MeshRenderer_C Draw_(Stride.Rendering.RenderDrawContext Context_In) { ... } } 
    _VL_Stride_Rendering_.Stride.Rendering.MeshRenderer_C { private virtual void Stride.Rendering.IGraphicsRendererBase.Draw(Stride.Rendering.RenderDrawContext context) { ... } } 
    VL.Stride.Rendering.EntityRendererRenderFeature { public virtual void Draw(Stride.Rendering.RenderDrawContext context, Stride.Rendering.RenderView renderView, Stride.Rendering.RenderViewStage renderViewStage, int startIndex, int endIndex) { ... } } 
    System.Runtime.ExceptionServices.ExceptionDispatchInfo { public void Throw() { ... } } 
    VL.Lang.Platforms.RuntimeHost { private void SharedStep() { ... } } 

and in Gamma 6.0273 preview

Summary

NullReferenceException: “Object reference not set to an instance of an object.”
StackTrace:
Stride.Graphics.ResourceBinder { public void BindResources(Stride.Graphics.CommandList commandList, Stride.Graphics.DescriptorSet descriptorSets) { … } }
Stride.Rendering.EffectInstance { public void Apply(Stride.Graphics.GraphicsContext graphicsContext) { … } }
VL_Stride_Rendering.Stride.Rendering.MeshRenderer_C { public VL_Stride_Rendering.Stride.Rendering.MeshRenderer_C DrawInternal(Stride.Rendering.RenderDrawCon
text Context_In) { … } }
VL_Stride_Rendering.Stride.Rendering.MeshRenderer_C { private virtual void Stride.Rendering.IGraphicsRendererBase.Draw(Stride.Rendering.RenderDrawContext cont
ext) { … } }
VL.Stride.Rendering.EntityRendererRenderFeature { public virtual void Draw(Stride.Rendering.RenderDrawContext context, Stride.Rendering.RenderView renderView, S
tride.Rendering.RenderViewStage renderViewStage, int startIndex, int endIndex) { … } }
System.Runtime.ExceptionServices.ExceptionDispatchInfo { public void Throw() { … } }
VL.Lang.Platforms.RuntimeHost { private void SharedStep() { … } }

as well as

Summary

[null]
System.NullReferenceException: Object reference not set to an instance of an object.
at Stride.Graphics.ResourceBinder.BindResources(CommandList commandList, DescriptorSet descriptorSets)
at Stride.Rendering.EffectInstance.Apply(GraphicsContext graphicsContext)
at VL_Stride_Rendering.Stride.Rendering.MeshRenderer_C.DrawInternal(RenderDrawContext Context_In)
at VL_Stride_Rendering.Stride.Rendering.MeshRenderer_C.Stride.Rendering.IGraphicsRendererBase.Draw(RenderDrawContext context)
at VL.Stride.Rendering.EntityRendererRenderFeature.Draw(RenderDrawContext context, RenderView renderView, RenderViewStage renderViewStage, Int32 startIndex, Int32 en
dIndex)

what’s wrong here?

MultiTextureShader.zip (6.1 KB)

works for me in preview 0221
if you use both times “streams.TexCoord”

1 Like

oh, yes this was actually a stupid mistake on my side. thanks!