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);
}
Post
Replies
Boosts
Views
Activity
Hi,
What is the equivelant of GLSL textureLod to Metal?
I am translating a shader and stuck on this line:
return textureLod(sampler, uv, 0.0 );
Thanks