External Publication
Visit Post

Shader Pipeline: PrimShader and Random Face Colours

Haskell Community [Unofficial] April 7, 2026
Source

The difficulty I have with this is that I can only generate anything once - whether it’s a StdGen or VertexColour: my entry point is canvasLoop :: IO () and I get one single StdGen via initStdGen.

The primShader is retrieved via the getPrimShaderrecord accessor to the the overall Shader and is deeply embedded in the objShaderPipeline function. Therefore, whatever colour I set on randomColourShader is set and cannot be changed unless I can thread the new state through to subsequent calls effectively creating some kind of global state or dependency chain where every call to primShader needs to know about any calls to other primShader.

@wiz suggested making the Shader types some kind of State monad Shader → (a, Shader) so I’m going to try that?

Discussion in the ATmosphere

Loading comments...