Post

Replies

Boosts

Views

Activity

Pointers in MSL
Hello! I have to use a specific pattern with pointers for a shader and I am not sure what's wrong. The shader renders with artefacts. Seems to be something messed up with the pointers and the UVs. Here is a simplified version: float3 outColor; float2 uv; }; device Context *ContextInit(float3 color, float2 uv) { device Context *context = nullptr; context->outColor = color; context->uv = uv; return context; } void drawSomething(device Context &context) { float d = length(context.uv); context.outColor *= d; } void manupulateUV(device Context &context, float2 uv) { uv +=0.5; float d = length(sin(uv)); context.outColor -=d; } fragment float4 pointer(VertexOut input[[stage_in]]) { float2 uv = input.textureCoordinate; device Context *context = ContextInit(float3(1, 0, 0), uv); drawSomething(*context); return float4(context->outColor.x, context->outColor.y, 0, 1); }
5
0
658
Jul ’23