← Pixel Dreamer Studio

Packed ORM maps on a StandardMaterial3D

Read roughness from green and metallic from blue, and set the roughness and metallic values to 1, because they multiply the maps.

An ORM texture packs three maps into one: ambient occlusion in red, roughness in green, metallic in blue. A StandardMaterial3D reads every map slot from the red channel unless you change it, and multiplies the map by the slot's value. In our Godot 4.7 test a smooth plastic ORM in the roughness slot gave no highlight at all, because the slot read the white AO channel as fully rough. A metal ORM with the channels set right still looked like plastic, because metallic was left at 0, and 0 times the map is 0. The script below sets the three channels and both values to 1: the ball matched a material with the same roughness and metallic typed in, to the pixel. ORMMaterial3D also got it right with no changes.

The code

Save it as orm_maps.gd and load it with const Orm := preload("res://orm_maps.gd"). Call Orm.apply(material, orm_texture) on a StandardMaterial3D. In the Inspector it is the same as setting Roughness › Texture Channel to Green, Metallic › Texture Channel to Blue, and the Roughness and Metallic values to 1.

extends RefCounted
## Use a packed ORM texture (R = ambient occlusion, G = roughness, B = metallic) on a StandardMaterial3D.
##   const Orm := preload("res://orm_maps.gd")
##   Orm.apply($Crate.get_active_material(0), preload("res://textures/crate_orm.png"))


static func apply(mat: StandardMaterial3D, orm: Texture2D) -> void:
	mat.ao_enabled = true
	mat.ao_texture = orm
	mat.ao_texture_channel = BaseMaterial3D.TEXTURE_CHANNEL_RED
	mat.roughness_texture = orm
	mat.roughness_texture_channel = BaseMaterial3D.TEXTURE_CHANNEL_GREEN
	mat.metallic_texture = orm
	mat.metallic_texture_channel = BaseMaterial3D.TEXTURE_CHANNEL_BLUE
	# the maps are multiplied by these two values: at metallic 0 a metallic map does nothing
	mat.roughness = 1.0
	mat.metallic = 1.0

What we measured

A grey ball under one directional light, and two flat ORM textures: smooth plastic (AO 1, roughness 0.2, metallic 0) and smooth metal (AO 1, roughness 0.2, metallic 1). On the rendered screen we took the mean brightness of the ball and counted highlight pixels brighter than 0.85. Two runs gave the same numbers.

Why it happens

Each map slot of a StandardMaterial3D takes one channel, chosen by its Texture Channel setting, and red is the default for all of them. An ORM has AO in red, so both roughness and metallic read the AO, which is usually close to white. The slot's value then multiplies the map: the material's roughness starts at 1, so a roughness map works, but metallic starts at 0, so the metallic map is multiplied away. ORMMaterial3D is a material made for packed maps and reads the three channels itself.

What to change

Ready-made materials: 24 Sci-Fi PBR Materials has 24 seamless sci-fi PBR materials as 2K PNG maps, plus a Godot 4 ready version.

Tested in Godot 4.7 with the Compatibility renderer.

Ready-made: 24 Sci-Fi PBR Materials has 24 seamless sci-fi PBR materials as 2K PNG maps, plus a Godot 4 ready version.

More how-tos: Shaders, materials and lights