#Using bool and/or Option<_> in a struct passed to a shader

3 messages · Page 1 of 1 (latest)

safe chasm
#

(I went over the character limit 😅)

Alternatively, is it possible to check if the texture is None from within the shader? I'm not sure how it get's handled behind the scenes but when returning the texture colour (when it's None, objects appear white. Maybe that's worth noting?

reef sky
#

The reason unloaded textures appear white is because of the fallback image, which is a renderapp resource. I don't think you'll be able to tell if your texture is there or not just by the pixel value, unless you're certain that your textures are never white.

it's probably the best route to just use the u32 since most gpu pipelining doesn't really support small types like this because they just get padded to 32 bits or some other SIMD width anyways. if the material.has_texture == 1u makes you nervous you can use the wgpu built-in bool(material.has_texture), but gpu crates that don't already support small types are unlikely to change because of the padding.

safe chasm