Add support for bent normals for indirect lighting and specular occlusion

This commit is contained in:
Capry 2024-07-12 16:13:47 +02:00
parent 19bb18716e
commit 9828c365c3
16 changed files with 240 additions and 92 deletions

View file

@ -120,6 +120,15 @@
<member name="backlight_texture" type="Texture2D" setter="set_texture" getter="get_texture">
Texture used to control the backlight effect per-pixel. Added to [member backlight].
</member>
<member name="bent_normal_enabled" type="bool" setter="set_feature" getter="get_feature" default="false">
If [code]true[/code], the bent normal map is enabled. This allows for more accurate indirect lighting and specular occlusion.
</member>
<member name="bent_normal_texture" type="Texture2D" setter="set_texture" getter="get_texture">
Texture that specifies the average direction of incoming ambient light at a given pixel. The [member bent_normal_texture] only uses the red and green channels; the blue and alpha channels are ignored. The normal read from [member bent_normal_texture] is oriented around the surface normal provided by the [Mesh].
[b]Note:[/b] A bent normal map is different from a regular normal map. When baking a bent normal map make sure to use [b]a cosine distribution[/b] for the bent normal map to work correctly.
[b]Note:[/b] The mesh must have both normals and tangents defined in its vertex data. Otherwise, the shading produced by the bent normal map will not look correct. If creating geometry with [SurfaceTool], you can use [method SurfaceTool.generate_normals] and [method SurfaceTool.generate_tangents] to automatically generate normals and tangents respectively.
[b]Note:[/b] Godot expects the bent normal map to use X+, Y+, and Z+ coordinates. See [url=http://wiki.polycount.com/wiki/Normal_Map_Technical_Details#Common_Swizzle_Coordinates]this page[/url] for a comparison of normal map coordinates expected by popular engines.
</member>
<member name="billboard_keep_scale" type="bool" setter="set_flag" getter="get_flag" default="false">
If [code]true[/code], the shader will keep the scale set for the mesh. Otherwise, the scale is lost when billboarding. Only applies when [member billboard_mode] is not [constant BILLBOARD_DISABLED].
</member>
@ -461,6 +470,9 @@
<constant name="TEXTURE_NORMAL" value="4" enum="TextureParam">
Texture specifying per-pixel normal vector.
</constant>
<constant name="TEXTURE_BENT_NORMAL" value="18" enum="TextureParam">
Texture specifying per-pixel bent normal vector.
</constant>
<constant name="TEXTURE_RIM" value="5" enum="TextureParam">
Texture specifying per-pixel rim value.
</constant>
@ -500,7 +512,7 @@
<constant name="TEXTURE_ORM" value="17" enum="TextureParam">
Texture holding ambient occlusion, roughness, and metallic.
</constant>
<constant name="TEXTURE_MAX" value="18" enum="TextureParam">
<constant name="TEXTURE_MAX" value="19" enum="TextureParam">
Represents the size of the [enum TextureParam] enum.
</constant>
<constant name="TEXTURE_FILTER_NEAREST" value="0" enum="TextureFilter">
@ -596,7 +608,10 @@
<constant name="FEATURE_DETAIL" value="11" enum="Feature">
Constant for setting [member detail_enabled].
</constant>
<constant name="FEATURE_MAX" value="12" enum="Feature">
<constant name="FEATURE_BENT_NORMAL_MAPPING" value="12" enum="Feature">
Constant for setting [member bent_normal_enabled].
</constant>
<constant name="FEATURE_MAX" value="13" enum="Feature">
Represents the size of the [enum Feature] enum.
</constant>
<constant name="BLEND_MODE_MIX" value="0" enum="BlendMode">