Post

Replies

Boosts

Views

Activity

Reply to Pointers in MSL
Ok got it! This is what I ended up using! Thank you both! float3 outColor; float2 uv; }; void drawSomething(thread Context *context) { float d = length(context->uv); context->outColor *= d; } fragment float4 pointer(VertexOut input[[stage_in]]) { float2 uv = input.textureCoordinate; Context context; context.outColor = float3(0.5, 0.5, 0.0); context.uv = uv; drawSomething(&context); return float4(context.outColor.x, context.outColor.y, 0, 1); }
Topic: Graphics & Games SubTopic: General Tags:
Jul ’23
Reply to Pointers in MSL
Thanks for the comments, here is what I tried, but still getting black output from drawSomething. `struct Context { float3 outColor; float2 uv; }; thread Context ContextInit(float3 color, float2 uv) { Context context; context.outColor = color; context.uv = uv; return context; } void drawSomething(Context context) { float d = length(context.uv); context.outColor *= d; } fragment float4 pointer(VertexOut input[[stage_in]]) { float2 uv = input.textureCoordinate; thread Context context = ContextInit(float3(1, 0, 0), uv); context.outColor = float3(0,1,0); drawSomething(context); return float4(context.outColor.x, context.outColor.y, 0, 1); }`
Topic: Graphics & Games SubTopic: General Tags:
Jul ’23
Reply to Pointers in MSL
@Graphics and Games Engineer @jcookie Thank you both! Kind of failing to make it work. I am trying to imitate the glsl in out so I can draw on top of context without returning it. Can you please let me know how to do it? Tried to use the thread address space but still drawSomething returns black, not the circular ramp it supposed to return. Example in the reply.
Topic: Graphics & Games SubTopic: General Tags:
Jul ’23