Skip to content

Commit 46e4096

Browse files
allenwpAllen Pestaluky
authored andcommitted
Replace the term "color space" with "color encoding". Add additional detail to Color class description. State clearly that Color is expected to use the nonlinear sRGB transfer function.
1 parent fcd1cf8 commit 46e4096

17 files changed

+82
-78
lines changed

doc/classes/BaseMaterial3D.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
If the texture appears unexpectedly too dark or too bright, check [member albedo_texture_force_srgb].
6767
</member>
6868
<member name="albedo_texture_force_srgb" type="bool" setter="set_flag" getter="get_flag" default="false" keywords="diffuse_texture_force_srgb">
69-
If [code]true[/code], forces a conversion of the [member albedo_texture] from sRGB color space to linear color space. See also [member vertex_color_is_srgb].
69+
If [code]true[/code], forces a conversion of the [member albedo_texture] from nonlinear sRGB encoding to linear encoding. See also [member vertex_color_is_srgb].
7070
This should only be enabled when needed (typically when using a [ViewportTexture] as [member albedo_texture]). If [member albedo_texture_force_srgb] is [code]true[/code] when it shouldn't be, the texture will appear to be too dark. If [member albedo_texture_force_srgb] is [code]false[/code] when it shouldn't be, the texture will appear to be too bright.
7171
</member>
7272
<member name="albedo_texture_msdf" type="bool" setter="set_flag" getter="get_flag" default="false" keywords="diffuse_texture_force_srgb">
@@ -479,7 +479,7 @@
479479
If [code]true[/code], triplanar mapping for [code]UV2[/code] is calculated in world space rather than object local space. See also [member uv2_triplanar].
480480
</member>
481481
<member name="vertex_color_is_srgb" type="bool" setter="set_flag" getter="get_flag" default="false">
482-
If [code]true[/code], vertex colors are considered to be stored in sRGB color space and are converted to linear color space during rendering. If [code]false[/code], vertex colors are considered to be stored in linear color space and are rendered as-is. See also [member albedo_texture_force_srgb].
482+
If [code]true[/code], vertex colors are considered to be stored in nonlinear sRGB encoding and are converted to linear encoding during rendering. If [code]false[/code], vertex colors are considered to be stored in linear encoding and are rendered as-is. See also [member albedo_texture_force_srgb].
483483
[b]Note:[/b] Only effective when using the Forward+ and Mobile rendering methods, not Compatibility.
484484
</member>
485485
<member name="vertex_color_use_as_albedo" type="bool" setter="set_flag" getter="get_flag" default="false">
@@ -705,7 +705,7 @@
705705
Set [code]ALBEDO[/code] to the per-vertex color specified in the mesh.
706706
</constant>
707707
<constant name="FLAG_SRGB_VERTEX_COLOR" value="2" enum="Flags">
708-
Vertex colors are considered to be stored in sRGB color space and are converted to linear color space during rendering. See also [member vertex_color_is_srgb].
708+
Vertex colors are considered to be stored in nonlinear sRGB encoding and are converted to linear encoding during rendering. See also [member vertex_color_is_srgb].
709709
[b]Note:[/b] Only effective when using the Forward+ and Mobile rendering methods.
710710
</constant>
711711
<constant name="FLAG_USE_POINT_SIZE" value="3" enum="Flags">
@@ -736,7 +736,7 @@
736736
Use [code]UV2[/code] coordinates to look up from the [member emission_texture].
737737
</constant>
738738
<constant name="FLAG_ALBEDO_TEXTURE_FORCE_SRGB" value="12" enum="Flags">
739-
Forces the shader to convert albedo from sRGB space to linear space. See also [member albedo_texture_force_srgb].
739+
Forces the shader to convert albedo from nonlinear sRGB encoding to linear encoding. See also [member albedo_texture_force_srgb].
740740
</constant>
741741
<constant name="FLAG_DONT_RECEIVE_SHADOWS" value="13" enum="Flags">
742742
Disables receiving shadows from other objects.

doc/classes/Color.xml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
</brief_description>
66
<description>
77
A color represented in RGBA format by a red ([member r]), green ([member g]), blue ([member b]), and alpha ([member a]) component. Each component is a 32-bit floating-point value, usually ranging from [code]0.0[/code] to [code]1.0[/code]. Some properties (such as [member CanvasItem.modulate]) may support values greater than [code]1.0[/code], for overbright or HDR (High Dynamic Range) colors.
8-
Colors can be created in various ways: By the various [Color] constructors, by static methods such as [method from_hsv], and by using a name from the set of standardized colors based on [url=https://en.wikipedia.org/wiki/X11_color_names]X11 color names[/url] with the addition of [constant TRANSPARENT]. GDScript also provides [method @GDScript.Color8], which uses integers from [code]0[/code] to [code]255[/code] and doesn't support overbright colors.
9-
Color data may be stored in many color spaces and encodings. The [method srgb_to_linear] and [method linear_to_srgb] methods can convert between nonlinear sRGB encoding and linear RGB encoding.
10-
[b]Note:[/b] In a boolean context, a Color will evaluate to [code]false[/code] if it is equal to [code]Color(0, 0, 0, 1)[/code] (opaque black). Otherwise, a Color will always evaluate to [code]true[/code].
8+
Colors can be created in a number of ways: By the various [Color] constructors, by static methods such as [method from_hsv], and by using a name from the set of standardized colors based on [url=https://en.wikipedia.org/wiki/X11_color_names]X11 color names[/url] with the addition of [constant TRANSPARENT]. GDScript also provides [method @GDScript.Color8], which uses integers from [code]0[/code] to [code]255[/code] and doesn't support overbright colors.
119
[url=https://raw.githubusercontent.com/godotengine/godot-docs/master/img/color_constants.png]Color constants cheatsheet[/url]
10+
Although [Color] may be used to store values of any encoding, the red ([member r]), green ([member g]), and blue ([member b]) properties of [Color] are expected by Godot to be encoded using the [url=https://en.wikipedia.org/wiki/SRGB#Transfer_function_(%22gamma%22)]nonlinear sRGB transfer function[/url] unless otherwise stated. This color encoding is used by many traditional art and web tools, making it easy to match colors between Godot and these tools. Godot uses [url=https://en.wikipedia.org/wiki/Rec._709]Rec. ITU-R BT.709[/url] color primaries, which are used by the sRGB standard.
11+
All physical simulation, such as lighting calculations, and colorimetry transformations, such as [method get_luminance], must be performed on linearly encoded values to produce correct results. When performing these calculations, convert [Color] to and from linear encoding using [method srgb_to_linear] and [method linear_to_srgb].
12+
[b]Note:[/b] In a boolean context, a Color will evaluate to [code]false[/code] if it is equal to [code]Color(0, 0, 0, 1)[/code] (opaque black). Otherwise, a Color will always evaluate to [code]true[/code].
1213
</description>
1314
<tutorials>
1415
<link title="2D GD Paint Demo">https://godotengine.org/asset-library/asset/2768</link>
@@ -214,7 +215,7 @@
214215
<return type="float" />
215216
<description>
216217
Returns the light intensity of the color, as a value between 0.0 and 1.0 (inclusive). This is useful when determining light or dark color. Colors with a luminance smaller than 0.5 can be generally considered dark.
217-
[b]Note:[/b] [method get_luminance] relies on the color being in the linear color space to return an accurate relative luminance value. If the color is in the sRGB color space, use [method srgb_to_linear] to convert it to the linear color space first.
218+
[b]Note:[/b] [method get_luminance] relies on the color using linear encoding to return an accurate relative luminance value. If the color uses the default nonlinear sRGB encoding, use [method srgb_to_linear] to convert it to linear encoding first.
218219
</description>
219220
</method>
220221
<method name="hex" qualifiers="static">
@@ -364,15 +365,15 @@
364365
<method name="linear_to_srgb" qualifiers="const">
365366
<return type="Color" />
366367
<description>
367-
Returns the color converted to the [url=https://en.wikipedia.org/wiki/SRGB]sRGB[/url] color space. This method assumes the original color is in the linear color space. See also [method srgb_to_linear] which performs the opposite operation.
368-
[b]Note:[/b] The color's [member a]lpha channel is not affected. The alpha channel is always stored with linear encoding, regardless of the color space of the other color channels.
368+
Returns a copy of the color that is encoded using the [url=https://en.wikipedia.org/wiki/SRGB]nonlinear sRGB transfer function[/url]. This method requires the original color to use linear encoding. See also [method srgb_to_linear] which performs the opposite operation.
369+
[b]Note:[/b] The color's [member a]lpha channel is not affected. The alpha channel is always stored with linear encoding, regardless of the encoding of the other color channels.
369370
</description>
370371
</method>
371372
<method name="srgb_to_linear" qualifiers="const">
372373
<return type="Color" />
373374
<description>
374-
Returns the color converted to the linear color space. This method assumes the original color already is in the sRGB color space. See also [method linear_to_srgb] which performs the opposite operation.
375-
[b]Note:[/b] The color's [member a]lpha channel is not affected. The alpha channel is always stored with linear encoding, regardless of the color space of the other color channels.
375+
Returns a copy of the color that uses linear encoding. This method requires the original color to be encoded using the [url=https://en.wikipedia.org/wiki/SRGB]nonlinear sRGB transfer function[/url]. See also [method linear_to_srgb] which performs the opposite operation.
376+
[b]Note:[/b] The color's [member a]lpha channel is not affected. The alpha channel is always stored with linear encoding, regardless of the encoding of the other color channels.
376377
</description>
377378
</method>
378379
<method name="to_abgr32" qualifiers="const">
@@ -495,7 +496,7 @@
495496
<members>
496497
<member name="a" type="float" setter="" getter="" default="1.0">
497498
The color's alpha component, typically on the range of 0 to 1. A value of 0 means that the color is fully transparent. A value of 1 means that the color is fully opaque.
498-
[b]Note:[/b] The alpha channel is always stored with linear encoding, regardless of the color space of the other color channels. The [method linear_to_srgb] and [method srgb_to_linear] methods do not affect the alpha channel.
499+
[b]Note:[/b] The alpha channel is always stored with linear encoding, regardless of the encoding of the other color channels. The [method linear_to_srgb] and [method srgb_to_linear] methods do not affect the alpha channel.
499500
</member>
500501
<member name="a8" type="int" setter="" getter="" default="255">
501502
Wrapper for [member a] that uses the range 0 to 255, instead of 0 to 1.

doc/classes/ColorPicker.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
If [code]true[/code], shows an alpha channel slider (opacity).
7575
</member>
7676
<member name="edit_intensity" type="bool" setter="set_edit_intensity" getter="is_editing_intensity" default="true">
77-
If [code]true[/code], shows an intensity slider. The intensity is applied as follows: multiply the color by [code]2 ** intensity[/code] in linear RGB space, and then convert it back to sRGB.
77+
If [code]true[/code], shows an intensity slider. The intensity is applied as follows: convert the color to linear encoding, multiply it by [code]2 ** intensity[/code], and then convert it back to nonlinear sRGB encoding.
7878
</member>
7979
<member name="hex_visible" type="bool" setter="set_hex_visible" getter="is_hex_visible" default="true">
8080
If [code]true[/code], the hex color code input field is visible.

doc/classes/Gradient.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
[b]Note:[/b] Setting this property updates all colors at once. To update any color individually use [method set_color].
8383
</member>
8484
<member name="interpolation_color_space" type="int" setter="set_interpolation_color_space" getter="get_interpolation_color_space" enum="Gradient.ColorSpace" default="0">
85-
The color space used to interpolate between points of the gradient. It does not affect the returned colors, which will always be in sRGB space.
85+
The color space used to interpolate between points of the gradient. It does not affect the returned colors, which will always use nonlinear sRGB encoding.
8686
[b]Note:[/b] This setting has no effect when [member interpolation_mode] is set to [constant GRADIENT_INTERPOLATE_CONSTANT].
8787
</member>
8888
<member name="interpolation_mode" type="int" setter="set_interpolation_mode" getter="get_interpolation_mode" enum="Gradient.InterpolationMode" default="0">

doc/classes/Image.xml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@
325325
<method name="linear_to_srgb">
326326
<return type="void" />
327327
<description>
328-
Converts the entire image from the linear colorspace to the sRGB colorspace. Only works on images with [constant FORMAT_RGB8] or [constant FORMAT_RGBA8] formats.
328+
Converts the entire image from linear encoding to nonlinear sRGB encoding by using a lookup table. Only works on images with [constant FORMAT_RGB8] or [constant FORMAT_RGBA8] formats.
329329
</description>
330330
</method>
331331
<method name="load">
@@ -450,7 +450,7 @@
450450
<method name="rgbe_to_srgb">
451451
<return type="Image" />
452452
<description>
453-
Converts a standard RGBE (Red Green Blue Exponent) image to an sRGB image.
453+
Converts a standard linear RGBE (Red Green Blue Exponent) image to an image that uses nonlinear sRGB encoding.
454454
</description>
455455
</method>
456456
<method name="rotate_90">
@@ -618,7 +618,8 @@
618618
<method name="srgb_to_linear">
619619
<return type="void" />
620620
<description>
621-
Converts the raw data from the sRGB colorspace to a linear scale. Only works on images with [constant FORMAT_RGB8] or [constant FORMAT_RGBA8] formats.
621+
Converts the raw data from nonlinear sRGB encoding to linear encoding using a lookup table. Only works on images with [constant FORMAT_RGB8] or [constant FORMAT_RGBA8] formats.
622+
[b]Note:[/b] The 8-bit formats required by this method are not suitable for storing linearly encoded values; a significant amount of color information will be lost in darker values. To maintain image quality, this method should not be used.
622623
</description>
623624
</method>
624625
</methods>
@@ -648,11 +649,11 @@
648649
</constant>
649650
<constant name="FORMAT_RGB8" value="4" enum="Format">
650651
OpenGL texture format [code]RGB[/code] with three components, each with a bitdepth of 8.
651-
[b]Note:[/b] When creating an [ImageTexture], an sRGB to linear color space conversion is performed.
652+
[b]Note:[/b] When creating an [ImageTexture], a nonlinear sRGB to linear encoding conversion is performed.
652653
</constant>
653654
<constant name="FORMAT_RGBA8" value="5" enum="Format">
654655
OpenGL texture format [code]RGBA[/code] with four components, each with a bitdepth of 8.
655-
[b]Note:[/b] When creating an [ImageTexture], an sRGB to linear color space conversion is performed.
656+
[b]Note:[/b] When creating an [ImageTexture], a nonlinear sRGB to linear encoding conversion is performed.
656657
</constant>
657658
<constant name="FORMAT_RGBA4444" value="6" enum="Format">
658659
OpenGL texture format [code]RGBA[/code] with four components, each with a bitdepth of 4.
@@ -689,15 +690,15 @@
689690
</constant>
690691
<constant name="FORMAT_DXT1" value="17" enum="Format">
691692
The [url=https://en.wikipedia.org/wiki/S3_Texture_Compression]S3TC[/url] texture format that uses Block Compression 1, and is the smallest variation of S3TC, only providing 1 bit of alpha and color data being premultiplied with alpha.
692-
[b]Note:[/b] When creating an [ImageTexture], an sRGB to linear color space conversion is performed.
693+
[b]Note:[/b] When creating an [ImageTexture], a nonlinear sRGB to linear encoding conversion is performed.
693694
</constant>
694695
<constant name="FORMAT_DXT3" value="18" enum="Format">
695696
The [url=https://en.wikipedia.org/wiki/S3_Texture_Compression]S3TC[/url] texture format that uses Block Compression 2, and color data is interpreted as not having been premultiplied by alpha. Well suited for images with sharp alpha transitions between translucent and opaque areas.
696-
[b]Note:[/b] When creating an [ImageTexture], an sRGB to linear color space conversion is performed.
697+
[b]Note:[/b] When creating an [ImageTexture], a nonlinear sRGB to linear encoding conversion is performed.
697698
</constant>
698699
<constant name="FORMAT_DXT5" value="19" enum="Format">
699700
The [url=https://en.wikipedia.org/wiki/S3_Texture_Compression]S3TC[/url] texture format also known as Block Compression 3 or BC3 that contains 64 bits of alpha channel data followed by 64 bits of DXT1-encoded color data. Color data is not premultiplied by alpha, same as DXT3. DXT5 generally produces superior results for transparent gradients compared to DXT3.
700-
[b]Note:[/b] When creating an [ImageTexture], an sRGB to linear color space conversion is performed.
701+
[b]Note:[/b] When creating an [ImageTexture], a nonlinear sRGB to linear encoding conversion is performed.
701702
</constant>
702703
<constant name="FORMAT_RGTC_R" value="20" enum="Format">
703704
Texture format that uses [url=https://www.khronos.org/opengl/wiki/Red_Green_Texture_Compression]Red Green Texture Compression[/url], normalizing the red channel data using the same compression algorithm that DXT5 uses for the alpha channel.
@@ -707,7 +708,7 @@
707708
</constant>
708709
<constant name="FORMAT_BPTC_RGBA" value="22" enum="Format">
709710
Texture format that uses [url=https://www.khronos.org/opengl/wiki/BPTC_Texture_Compression]BPTC[/url] compression with unsigned normalized RGBA components.
710-
[b]Note:[/b] When creating an [ImageTexture], an sRGB to linear color space conversion is performed.
711+
[b]Note:[/b] When creating an [ImageTexture], a nonlinear sRGB to linear encoding conversion is performed.
711712
</constant>
712713
<constant name="FORMAT_BPTC_RGBF" value="23" enum="Format">
713714
Texture format that uses [url=https://www.khronos.org/opengl/wiki/BPTC_Texture_Compression]BPTC[/url] compression with signed floating-point RGB components.
@@ -732,15 +733,15 @@
732733
</constant>
733734
<constant name="FORMAT_ETC2_RGB8" value="30" enum="Format">
734735
[url=https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC]Ericsson Texture Compression format 2[/url] ([code]RGB8[/code] variant), which is a follow-up of ETC1 and compresses RGB888 data.
735-
[b]Note:[/b] When creating an [ImageTexture], an sRGB to linear color space conversion is performed.
736+
[b]Note:[/b] When creating an [ImageTexture], a nonlinear sRGB to linear encoding conversion is performed.
736737
</constant>
737738
<constant name="FORMAT_ETC2_RGBA8" value="31" enum="Format">
738739
[url=https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC]Ericsson Texture Compression format 2[/url] ([code]RGBA8[/code]variant), which compresses RGBA8888 data with full alpha support.
739-
[b]Note:[/b] When creating an [ImageTexture], an sRGB to linear color space conversion is performed.
740+
[b]Note:[/b] When creating an [ImageTexture], a nonlinear sRGB to linear encoding conversion is performed.
740741
</constant>
741742
<constant name="FORMAT_ETC2_RGB8A1" value="32" enum="Format">
742743
[url=https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC]Ericsson Texture Compression format 2[/url] ([code]RGB8_PUNCHTHROUGH_ALPHA1[/code] variant), which compresses RGBA data to make alpha either fully transparent or fully opaque.
743-
[b]Note:[/b] When creating an [ImageTexture], an sRGB to linear color space conversion is performed.
744+
[b]Note:[/b] When creating an [ImageTexture], a nonlinear sRGB to linear encoding conversion is performed.
744745
</constant>
745746
<constant name="FORMAT_ETC2_RA_AS_RG" value="33" enum="Format">
746747
[url=https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC]Ericsson Texture Compression format 2[/url] ([code]RGBA8[/code] variant), which compresses RA data and interprets it as two channels (red and green). See also [constant FORMAT_ETC2_RGBA8].
@@ -831,7 +832,7 @@
831832
Source texture (before compression) is a regular texture. Default for all textures.
832833
</constant>
833834
<constant name="COMPRESS_SOURCE_SRGB" value="1" enum="CompressSource">
834-
Source texture (before compression) is in sRGB space.
835+
Source texture (before compression) uses nonlinear sRGB encoding.
835836
</constant>
836837
<constant name="COMPRESS_SOURCE_NORMAL" value="2" enum="CompressSource">
837838
Source texture (before compression) is a normal texture (e.g. it can be compressed into two channels).

0 commit comments

Comments
 (0)