godot/doc/classes/Mesh.xml
Omar El Sheikh d274284069 Octahedral Normal/Tangent Compression
Implement Octahedral Compression for normal/tangent vectors
*Oct32 for uncompressed vectors
*Oct16 for compressed vectors

Reduces vertex size for each attribute by
*Uncompressed: 12 bytes, vec4<float32> -> vec2<unorm16>
*Compressed: 2 bytes, vec4<unorm8> -> vec2<unorm8>

Binormal sign is encoded in the y coordinate of the encoded tangent

Added conversion functions to go from octahedral mapping to cartesian
for normal and tangent vectors

sprite_3d and soft_body meshes write to their vertex buffer memory
directly and need to convert their normals and tangents to the new oct
format before writing

Created a new mesh flag to specify whether a mesh is using octahedral
compression or not
Updated documentation to discuss new flag/defaults

Created shader flags to specify whether octahedral or cartesian vectors
are being used

Updated importers to use octahedral representation as the default format
for importing meshes

Updated ShaderGLES2 to support 64 bit version codes as we hit the limit
of the 32-bit integer that was previously used as a bitset to store
enabled/disabled flags
2021-07-30 10:29:09 -04:00

247 lines
11 KiB
XML

<?xml version="1.0" encoding="UTF-8" ?>
<class name="Mesh" inherits="Resource" version="3.4">
<brief_description>
A [Resource] that contains vertex array-based geometry.
</brief_description>
<description>
Mesh is a type of [Resource] that contains vertex array-based geometry, divided in [i]surfaces[/i]. Each surface contains a completely separate array and a material used to draw it. Design wise, a mesh with multiple surfaces is preferred to a single surface, because objects created in 3D editing software commonly contain multiple materials.
</description>
<tutorials>
<link title="3D Material Testers Demo">https://godotengine.org/asset-library/asset/123</link>
<link title="3D Kinematic Character Demo">https://godotengine.org/asset-library/asset/126</link>
<link title="3D Platformer Demo">https://godotengine.org/asset-library/asset/125</link>
<link title="Third Person Shooter Demo">https://godotengine.org/asset-library/asset/678</link>
</tutorials>
<methods>
<method name="create_convex_shape" qualifiers="const">
<return type="Shape">
</return>
<argument index="0" name="clean" type="bool" default="true">
</argument>
<argument index="1" name="simplify" type="bool" default="false">
</argument>
<description>
Calculate a [ConvexPolygonShape] from the mesh.
If [code]clean[/code] is [code]true[/code] (default), duplicate and interior vertices are removed automatically. You can set it to [code]false[/code] to make the process faster if not needed.
If [code]simplify[/code] is [code]true[/code], the geometry can be further simplified to reduce the amount of vertices. Disabled by default.
</description>
</method>
<method name="create_outline" qualifiers="const">
<return type="Mesh">
</return>
<argument index="0" name="margin" type="float">
</argument>
<description>
Calculate an outline mesh at a defined offset (margin) from the original mesh.
[b]Note:[/b] This method typically returns the vertices in reverse order (e.g. clockwise to counterclockwise).
</description>
</method>
<method name="create_trimesh_shape" qualifiers="const">
<return type="Shape">
</return>
<description>
Calculate a [ConcavePolygonShape] from the mesh.
</description>
</method>
<method name="generate_triangle_mesh" qualifiers="const">
<return type="TriangleMesh">
</return>
<description>
Generate a [TriangleMesh] from the mesh.
</description>
</method>
<method name="get_aabb" qualifiers="const">
<return type="AABB">
</return>
<description>
Returns the smallest [AABB] enclosing this mesh in local space. Not affected by [code]custom_aabb[/code]. See also [method VisualInstance.get_transformed_aabb].
[b]Note:[/b] This is only implemented for [ArrayMesh] and [PrimitiveMesh].
</description>
</method>
<method name="get_faces" qualifiers="const">
<return type="PoolVector3Array">
</return>
<description>
Returns all the vertices that make up the faces of the mesh. Each three vertices represent one triangle.
</description>
</method>
<method name="get_surface_count" qualifiers="const">
<return type="int">
</return>
<description>
Returns the amount of surfaces that the [Mesh] holds.
</description>
</method>
<method name="surface_get_arrays" qualifiers="const">
<return type="Array">
</return>
<argument index="0" name="surf_idx" type="int">
</argument>
<description>
Returns the arrays for the vertices, normals, uvs, etc. that make up the requested surface (see [method ArrayMesh.add_surface_from_arrays]).
</description>
</method>
<method name="surface_get_blend_shape_arrays" qualifiers="const">
<return type="Array">
</return>
<argument index="0" name="surf_idx" type="int">
</argument>
<description>
Returns the blend shape arrays for the requested surface.
</description>
</method>
<method name="surface_get_material" qualifiers="const">
<return type="Material">
</return>
<argument index="0" name="surf_idx" type="int">
</argument>
<description>
Returns a [Material] in a given surface. Surface is rendered using this material.
</description>
</method>
<method name="surface_set_material">
<return type="void">
</return>
<argument index="0" name="surf_idx" type="int">
</argument>
<argument index="1" name="material" type="Material">
</argument>
<description>
Sets a [Material] for a given surface. Surface will be rendered using this material.
</description>
</method>
</methods>
<members>
<member name="lightmap_size_hint" type="Vector2" setter="set_lightmap_size_hint" getter="get_lightmap_size_hint" default="Vector2( 0, 0 )">
Sets a hint to be used for lightmap resolution in [BakedLightmap]. Overrides [member BakedLightmap.default_texels_per_unit].
</member>
</members>
<constants>
<constant name="PRIMITIVE_POINTS" value="0" enum="PrimitiveType">
Render array as points (one vertex equals one point).
</constant>
<constant name="PRIMITIVE_LINES" value="1" enum="PrimitiveType">
Render array as lines (every two vertices a line is created).
</constant>
<constant name="PRIMITIVE_LINE_STRIP" value="2" enum="PrimitiveType">
Render array as line strip.
</constant>
<constant name="PRIMITIVE_LINE_LOOP" value="3" enum="PrimitiveType">
Render array as line loop (like line strip, but closed).
</constant>
<constant name="PRIMITIVE_TRIANGLES" value="4" enum="PrimitiveType">
Render array as triangles (every three vertices a triangle is created).
</constant>
<constant name="PRIMITIVE_TRIANGLE_STRIP" value="5" enum="PrimitiveType">
Render array as triangle strips.
</constant>
<constant name="PRIMITIVE_TRIANGLE_FAN" value="6" enum="PrimitiveType">
Render array as triangle fans.
</constant>
<constant name="BLEND_SHAPE_MODE_NORMALIZED" value="0" enum="BlendShapeMode">
Blend shapes are normalized.
</constant>
<constant name="BLEND_SHAPE_MODE_RELATIVE" value="1" enum="BlendShapeMode">
Blend shapes are relative to base weight.
</constant>
<constant name="ARRAY_FORMAT_VERTEX" value="1" enum="ArrayFormat">
Mesh array contains vertices. All meshes require a vertex array so this should always be present.
</constant>
<constant name="ARRAY_FORMAT_NORMAL" value="2" enum="ArrayFormat">
Mesh array contains normals.
</constant>
<constant name="ARRAY_FORMAT_TANGENT" value="4" enum="ArrayFormat">
Mesh array contains tangents.
</constant>
<constant name="ARRAY_FORMAT_COLOR" value="8" enum="ArrayFormat">
Mesh array contains colors.
</constant>
<constant name="ARRAY_FORMAT_TEX_UV" value="16" enum="ArrayFormat">
Mesh array contains UVs.
</constant>
<constant name="ARRAY_FORMAT_TEX_UV2" value="32" enum="ArrayFormat">
Mesh array contains second UV.
</constant>
<constant name="ARRAY_FORMAT_BONES" value="64" enum="ArrayFormat">
Mesh array contains bones.
</constant>
<constant name="ARRAY_FORMAT_WEIGHTS" value="128" enum="ArrayFormat">
Mesh array contains bone weights.
</constant>
<constant name="ARRAY_FORMAT_INDEX" value="256" enum="ArrayFormat">
Mesh array uses indices.
</constant>
<constant name="ARRAY_COMPRESS_BASE" value="9" enum="ArrayFormat">
Used internally to calculate other [code]ARRAY_COMPRESS_*[/code] enum values. Do not use.
</constant>
<constant name="ARRAY_COMPRESS_VERTEX" value="512" enum="ArrayFormat">
Flag used to mark a compressed (half float) vertex array.
</constant>
<constant name="ARRAY_COMPRESS_NORMAL" value="1024" enum="ArrayFormat">
Flag used to mark a compressed (half float) normal array.
</constant>
<constant name="ARRAY_COMPRESS_TANGENT" value="2048" enum="ArrayFormat">
Flag used to mark a compressed (half float) tangent array.
</constant>
<constant name="ARRAY_COMPRESS_COLOR" value="4096" enum="ArrayFormat">
Flag used to mark a compressed (half float) color array.
</constant>
<constant name="ARRAY_COMPRESS_TEX_UV" value="8192" enum="ArrayFormat">
Flag used to mark a compressed (half float) UV coordinates array.
</constant>
<constant name="ARRAY_COMPRESS_TEX_UV2" value="16384" enum="ArrayFormat">
Flag used to mark a compressed (half float) UV coordinates array for the second UV coordinates.
</constant>
<constant name="ARRAY_COMPRESS_BONES" value="32768" enum="ArrayFormat">
Flag used to mark a compressed bone array.
</constant>
<constant name="ARRAY_COMPRESS_WEIGHTS" value="65536" enum="ArrayFormat">
Flag used to mark a compressed (half float) weight array.
</constant>
<constant name="ARRAY_COMPRESS_INDEX" value="131072" enum="ArrayFormat">
Flag used to mark a compressed index array.
</constant>
<constant name="ARRAY_FLAG_USE_2D_VERTICES" value="262144" enum="ArrayFormat">
Flag used to mark that the array contains 2D vertices.
</constant>
<constant name="ARRAY_FLAG_USE_16_BIT_BONES" value="524288" enum="ArrayFormat">
Flag used to mark that the array uses 16-bit bones instead of 8-bit.
</constant>
<constant name="ARRAY_FLAG_USE_OCTAHEDRAL_COMPRESSION" value="2097152" enum="ArrayFormat">
Flag used to mark that the array uses an octahedral representation of normal and tangent vectors rather than cartesian.
</constant>
<constant name="ARRAY_COMPRESS_DEFAULT" value="2194432" enum="ArrayFormat">
Used to set flags [constant ARRAY_COMPRESS_VERTEX], [constant ARRAY_COMPRESS_NORMAL], [constant ARRAY_COMPRESS_TANGENT], [constant ARRAY_COMPRESS_COLOR], [constant ARRAY_COMPRESS_TEX_UV], [constant ARRAY_COMPRESS_TEX_UV2], [constant ARRAY_COMPRESS_WEIGHTS], and [constant ARRAY_FLAG_USE_OCTAHEDRAL_COMPRESSION] quickly.
</constant>
<constant name="ARRAY_VERTEX" value="0" enum="ArrayType">
Array of vertices.
</constant>
<constant name="ARRAY_NORMAL" value="1" enum="ArrayType">
Array of normals.
</constant>
<constant name="ARRAY_TANGENT" value="2" enum="ArrayType">
Array of tangents as an array of floats, 4 floats per tangent.
</constant>
<constant name="ARRAY_COLOR" value="3" enum="ArrayType">
Array of colors.
</constant>
<constant name="ARRAY_TEX_UV" value="4" enum="ArrayType">
Array of UV coordinates.
</constant>
<constant name="ARRAY_TEX_UV2" value="5" enum="ArrayType">
Array of second set of UV coordinates.
</constant>
<constant name="ARRAY_BONES" value="6" enum="ArrayType">
Array of bone data.
</constant>
<constant name="ARRAY_WEIGHTS" value="7" enum="ArrayType">
Array of weights.
</constant>
<constant name="ARRAY_INDEX" value="8" enum="ArrayType">
Array of indices.
</constant>
<constant name="ARRAY_MAX" value="9" enum="ArrayType">
Represents the size of the [enum ArrayType] enum.
</constant>
</constants>
</class>