stride3d / stride3d/stride

why this simple shader crashes the game?

Open
#1,890 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
C#
Stars
7.8k
Forks
1.2k
Avg merge
2d 17h
Merged PRs (30d)
49

Description

i got a very simple shader, when i run my game with it, it instantly crashes.

the shader:

shader TileMapShader<Texture2D TTexture>: Texturing, ComputeColor
{
    compose ComputeColor albedoTexture;
    override float4 Compute()
    {        
        return TTexture.Sample(Texturing.Sampler, float2(0.5f,0.5f));
    }    
};

both textures are set (the generic one and the composed one):

grafik

this is the log from my machine:

System.AggregateException: One or more errors occurred. (Could not compile shader. See error messages.[(1,1)]: Error:  E0237: The variable [Material] in class [TileMapShader_Min1691143736] is not defined
[(1,1)]: Error:  E0238: Unable to infer type for [Material] in class [TileMapShader_Min1691143736]
[(1,1)]: Warning:  W0003: Unable to find type reference for member [Material.DiffuseMap]
)
 ---> System.InvalidOperationException: Could not compile shader. See error messages.[(1,1)]: Error:  E0237: The variable [Material] in class [TileMapShader_Min1691143736] is not defined
[(1,1)]: Error:  E0238: Unable to infer type for [Material] in class [TileMapShader_Min1691143736]
[(1,1)]: Warning:  W0003: Unable to find type reference for member [Material.DiffuseMap]

   at Stride.Rendering.EffectSystem.CheckResult(LoggerResult compilerResult) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Rendering\Rendering\EffectSystem.cs:line 181
   at Stride.Rendering.EffectSystem.CreateEffect(String effectName, EffectBytecodeCompilerResult effectBytecodeCompilerResult, CompilerResults compilerResult) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Rendering\Rendering\EffectSystem.cs:line 203
   at Stride.Rendering.EffectSystem.<>c__DisplayClass20_0.<LoadEffect>b__0(Task`1 x) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Rendering\Rendering\EffectSystem.cs:line 164
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at Stride.Rendering.RootEffectRenderFeature.PrepareEffectPermutations(RenderDrawContext context) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Rendering\Rendering\RootEffectRenderFeature.cs:line 552
   at Stride.Rendering.RenderSystem.Prepare(RenderDrawContext context) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Rendering\Rendering\RenderSystem.cs:line 233
   at Stride.Rendering.Compositing.GraphicsCompositor.DrawCore(RenderDrawContext context) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Engine\Rendering\Compositing\GraphicsCompositor.cs:line 181
   at Stride.Rendering.RendererBase.Draw(RenderDrawContext context) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Rendering\Rendering\RendererBase.cs:line 49
   at Stride.Engine.SceneSystem.Draw(GameTime gameTime) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Engine\Engine\SceneSystem.cs:line 234
   at Stride.Games.GameSystemCollection.Draw(GameTime gameTime)
   at Stride.Games.GameBase.Draw(GameTime gameTime)
   at Stride.Games.GameBase.RawTick(TimeSpan elapsedTimePerUpdate, Int32 updateCount, Single drawInterpolationFactor, Boolean drawFrame)
   at Stride.Games.GameBase.RawTickProducer()
   at Stride.Games.GameBase.Tick()
   at Stride.Games.GamePlatform.Tick()
   at Stride.Games.GamePlatform.OnRunCallback()
   at Stride.Games.GameWindowWinforms.<>c__DisplayClass19_0.<Run>b__0()
   at Stride.Games.WindowsMessageLoop.Run(Control form, RenderCallback renderCallback, Boolean useApplicationDoEvents)
   at Stride.Games.GameWindowWinforms.Run()
   at Stride.Games.GamePlatform.Run(GameContext gameContext)
   at Stride.Games.GameBase.Run(GameContext gameContext)
   at MinerGame2dPlusStride.MinerGame2dPlusStrideApp.Main(String[] args) in D:\Stride\MinerGame2dPlusStride\MinerGame2dPlusStride.Windows\MinerGame2dPlusStrideApp.cs:line 11`
```

and the one from another person on discord that tried the sahder for me on his machine in his project just for test porpuse:

```
`LastActions: * +[Update transformation]
    * {AssetContentValueChangeOperation: Position = X:9.331909 Y:0 Z:8.982578}
* +[Update transformation]
    * {AssetContentValueChangeOperation: Position = X:9.331909 Y:0.79604363 Z:8.982578}
* +[Execute CreateNewInstance]
    * {AssetContentValueChangeOperation: DiffuseMap = Shader}
* +[Update property ]
    * {AssetContentValueChangeOperation: MixinReference = }
* +[Update property ]
    * {AssetContentValueChangeOperation: MixinReference = TileMapShader}

CurrentDirectory: %USERPROFILE%\.nuget\packages\stride.gamestudio\4.1.0.1948\tools\net6.0-windows7.0
CommandArgs: %USERPROFILE%\Documents\Stride Projects\FirstPersonShooter\FirstPersonShooter.sln
OsVersion: Microsoft Windows 11 Pro 10.0.22621 x64
ProcessorCount: 32
Exception: NullReferenceException: Object reference not set to an instance of an object.
   at Stride.Core.Threading.Dispatcher.For[TLocal](Int32 fromInclusive, Int32 toExclusive, Func`1 initializeLocal, Action`2 action, Action`1 finalizeLocal) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\core\Stride.Core\Threading\Dispatcher.cs:line 122
   at Stride.Rendering.RootEffectRenderFeature.Prepare(RenderDrawContext context) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Rendering\Rendering\RootEffectRenderFeature.cs:line 0
   at Stride.Rendering.MeshRenderFeature.Prepare(RenderDrawContext context) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Rendering\Rendering\MeshRenderFeature.cs:line 112
   at Stride.Rendering.RenderSystem.Prepare(RenderDrawContext context) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Rendering\Rendering\RenderSystem.cs:line 229
   at Stride.Rendering.Compositing.GraphicsCompositor.DrawCore(RenderDrawContext context) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Engine\Rendering\Compositing\GraphicsCompositor.cs:line 116
   at Stride.Rendering.RendererBase.Draw(RenderDrawContext context) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Rendering\Rendering\RendererBase.cs:line 52
   at Stride.Engine.SceneSystem.Draw(GameTime gameTime) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\engine\Stride.Engine\Engine\SceneSystem.cs:line 302
   at Stride.Games.GameSystemCollection.Draw(GameTime gameTime)
   at Stride.Games.GameBase.Draw(GameTime gameTime)
   at Stride.Editor.EditorGame.Game.EditorServiceGame.Draw(GameTime gameTime) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\editor\Stride.Editor\EditorGame\Game\EditorServiceGame.cs:line 226``

```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the TileMapShader example with the reported texture and mixin setup, then inspect the shader-compilation path in Stride.Rendering.EffectSystem.cs and the render preparation path in RootEffectRenderFeature.cs. Compare the reported E0237/E0238 diagnostics and NullReferenceException across both repros; done means the shader failure is handled without crashing and the resulting error identifies the invalid setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
computer-graphics, game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.