简体   繁体   中英

textureGrad function – Metal (MSL) equivalent

I'm currently trying to reimplement this technique for variation in tiling texture repetition – https://www.iquilezles.org/www/articles/texturerepetition/texturerepetition.htm – in Metal.

Some parts of the code refer to the textureGrad function ( https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/textureGrad.xhtml ). As it's not totally clear to me how this is implemented under the hood I wanted to ask if there is a MSL equivalent that I haven't found yet or maybe someone could give me a hint on how to reimplement it.

Thank you!

MSL equivalent:

fragment float4 Fragment(ColorInOut in [[stage_in]],
                            texture2d<float> texture [[texture(0)]])
{
    constexpr sampler sampleFilter(mip_filter::linear, mag_filter::linear, min_filter::linear);
    float4 color = texture.sample(sampleFilter, in.texCoord.xy, gradient2d(0, 0));
    return float4(color);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM