Replies: 1 comment 5 replies
-
Nope, the texture should be left in the roughness slot and handled by your PBR shader, as in Raylib's shaders_basic_pbr example. Game engines typically use an "ORM" texture which is Ambient Occlusion, Roughness, and Metalness packed into the RGB channels. Raylib's PBR example uses an "MRA" texture packed in the opposite order; switch .b and .g in the shader to use ORM. For models without an ORM texture you could set the roughness texture to rlGetTextureIdDefault() and adjust the ao/roughness/metalness shader uniforms. (@raysan5 - would you like me to submit a GLTF+ORM version of the PBR example?) There's a trick mentioned in the Blender GLTF exporter documentation to export ORM textures. You need to enable "Shader Editor Add-ons" in the preferences for the "glTF 2.0 format" addon. Then in the shader editor you add a "glTF Material Output" node and connect the red channel to it, like this: |
Beta Was this translation helpful? Give feedback.
-
GLTF and by extension GLB files support embedding various textures including data for PBR roughness and metallic channels. That data, however, is internally stored in a single GB texture (green is roughness, blue is metallic FWICT from looking at blender shader nodes). While raylib supports loading GLTF files, it simply puts the texture into its
MATERIAL_MAP_ROUGHNESS
slot.Now, the question is, should this texture be separated into two textures on load-time? This would add to memory consumption, albeit only during loading, as the
Image
s would be immediately deleted, and two R8 textures should take roughly the same VRAM as one RG8 texture (±overhead for metadata depending on the driver). Additionally, the process would take longer overall, just to copy all the data around (I can't think of any smart ways to separate these channels, either on the CPU or while uploading to the GPU). On the other hand, this would be much more inline with how raylib's material system is already designed, and be much less confusing when you first start out loading PBR models.I understand the implications of such a change, and my use case would actually allow that I simply do this on my end, but I feel like this would also benefit other members of the raylib community. Any thoughts?
Beta Was this translation helpful? Give feedback.
All reactions