Component:LUT Material: Difference between revisions

From Resonite Wiki
Added further detail to LUT construction and usage. Still need to add examples and images.
Add examples that need to be added
 
(7 intermediate revisions by 4 users not shown)
Line 8: Line 8:
}}
}}


An LUT or Lookup Table is a way of mapping input values to output values via sampling a [[StaticTexture3D_(Component)|3D Texture]].  This 3D table of values allows for any arbitrary function to be applied to an input.
An LUT or Lookup Table is a way of mapping input values to output values via sampling a [[Component:StaticTexture3D|3D Texture]].  This 3D table of values allows for any arbitrary function to be applied to an input.
 
How the sampling works is that it takes a color behind it (for example, a magenta color) and maps it's RGB values to a 0-1 [[Type:Float3|Float3]] as XYZ, it then samples the provided 3D texture at point XYZ multipled by the texture's size, and uses the pixel's color as the result which is applied to what the user sees through this material.
 
For more info on how pixels are arranged on a 3D texture and can be retrieved using an [[Type:Int3|Int3]], see [[Component:StaticTexture3D|3D Texture]].


<!--T:2-->
<!--T:2-->
== Fields ==
== Fields ==
{{Table ComponentFields
{{Table ComponentFields
|HighPriorityIntegration|Bool|
|HighPriorityIntegration|Bool|{{Asset HighPriorityIntegration Field}}
|Rect|Rect|
|Rect|Rect|
|RectClip|Bool|
|RectClip|Bool|
|ColorMask|ColorMask|The color channels to affect
|ColorMask|ColorMask|The color channels to affect
|StencilComparison|StencilComparison|
|StencilComparison|StencilComparison|{{Template:Material_StencilComparison_Desc}}
|StencilOperation|StencilOperation|
|StencilOperation|StencilOperation|{{Template:Material_StencilOperation_Desc}}
|StencilID|Byte|
|StencilID|Byte|{{Template:Material_StencilID_Desc}}
|StencilWriteMask|Byte|
|StencilWriteMask|Byte|{{Template:Material_StencilWriteMask_Desc}}
|StencilReadMask|Byte|
|StencilReadMask|Byte|{{Template:Material_StencilReadMask_Desc}}
|RenderQueue|Int|
|RenderQueue|Int|{{Template:Material_RenderQueue_Desc}}
|_shader|IAssetProvider`1|TypeString10=IAssetProvider<Shader>|
|_shader|{{RootFieldType|AssetRef`1|[[Type:Shader|Shader]]}}|TypeAdv10=true| Internal.
|LUT|IAssetProvider`1|TypeString11=IAssetProvider<Texture3D>|The 3D texture to use as a lookup table
|LUT|{{RootFieldType|AssetRef`1|[[Type:Texture3D|Texture3D]]}}|TypeAdv11=true|The 3D texture to use as a lookup table
|SecondaryLUT|IAssetProvider`1|TypeString12=IAssetProvider<Texture3D>|A secondary 3D texture to use to lerp between
|SecondaryLUT|{{RootFieldType|AssetRef`1|[[Type:Texture3D|Texture3D]]}}|TypeAdv12=true|A secondary 3D texture to use to lerp between
|UseSRGB|Bool| Whether to use the SRGB color space when spitting out colors.
|Lerp|Float|Allows blending from the first LUT (0) or the secondary LUT (1)
|Lerp|Float|Allows blending from the first LUT (0) or the secondary LUT (1)
|BlendMode|BlendMode|
|BlendMode|BlendMode|{{Template:Material_BlendMode_Desc}}
|Sidedness|Sidedness|
|Sidedness|Sidedness|{{Template:Material_Sidedness_Desc}}
|ZWrite|ZWrite|
|ZWrite|ZWrite|{{Template:Material_ZWrite_Desc}}
|ZTest|ZTest|
|ZTest|ZTest|{{Template:Material_ZTest_Desc}}
}}
}}


<!--T:3-->
<!--T:3-->
== Usage ==
== Usage ==
An LUT is commonly constructed via 2D slices of a [[StaticTexture3D_(Component)|3D Texture]].  These slices represent XY planes of incremental Z coordinates ranging from 0 to 1.  This can either be packed into a single 2D image, or imported as multiple 2D images in a folder where each slice is alphabetically organized.
Currently the maximum packed 2D image that the importer detects as a valid LUT is 1024x32.  In this orientation there are 32 total cells arranged as 32x32 pixel sub images.  A 1:1 mapping LUT which simply maps its inputs directly to the same value on its outputs is shown below which demonstrates the coordinate system:
[[File:LUT_BaseLinear.png|center|alt=Linear LUT|Linear LUT|thumb|800x800px]]
* The '''Red''' channel increases constantly from 0 to 1 from left to right within each cell and repeats.
[[File:LUT_BaseLinear_RED.png|center|alt=Linear LUT Red Channel|Linear LUT Red channel|thumb|800x800px]]
* The '''Green''' channel linearly increases from the top to bottom.
[[File:LUT_BaseLinear_GREEN.png|center|alt=Linear LUT Green Channel|Linear LUT Green channel|thumb|800x800px]]
* The '''Blue''' channel increases step wise within each cell itself, the first cell being all 0, and the last cell is all 1.
[[File:LUT_BaseLinear_BLUE.png|center|alt=Linear LUT Blue Channel|Linear LUT Blue channel|thumb|800x800px]]
The mapping function of an LUT takes an input RGB value and then samples the 3D Texture at that corresponding coordinate to find the output RGB value, using the [[StaticTexture3D_(Component)|3D Texture]]'s [[Type:TextureFilterMode|Filter Mode]] and [[Type:TextureWrapMode|Wrap Mode]] to resolve how intermediate values work.
The mapping function of an LUT takes an input RGB value and then samples the 3D Texture at that corresponding coordinate to find the output RGB value, using the [[StaticTexture3D_(Component)|3D Texture]]'s [[Type:TextureFilterMode|Filter Mode]] and [[Type:TextureWrapMode|Wrap Mode]] to resolve how intermediate values work.




<!--T:4-->
<!--T:4-->
== Examples ==
== Examples ==
 
{{stub}}
We need (an image of a scene behind a plane as well as the cube of the 3d texture being used):
* an example of an LUT material making a Gameboy effect of materials behind it
* an example of an LUT making a grayscale effect of materials behind it
* an example of an LUT that inverts materials behind it
* an example of an LUT that makes materials behind it that have shades of red in their surface spit out random nonsensical colors depending on brightness (yes this is possible with an LUT)


<!--T:5-->
<!--T:5-->
Line 67: Line 57:
[[Category:ComponentStubs]]
[[Category:ComponentStubs]]
[[Category:Components{{#translation:}}|LUT Material]]
[[Category:Components{{#translation:}}|LUT Material]]
[[Category:Materials:Filters{{#translation:}}|LUT Material]]
[[Category:Materials{{#translation:}}|LUT Material]]
[[Category:Components:Assets:Materials:Filters{{#translation:}}|LUT Material]]
[[Category:Components:Assets:Materials:Filters{{#translation:}}|LUT Material]]

Latest revision as of 17:00, 21 November 2024


This article or section is a Stub. You can help the Resonite Wiki by expanding it.


Component image 
LUT Material component as seen in the Scene Inspector


An LUT or Lookup Table is a way of mapping input values to output values via sampling a 3D Texture. This 3D table of values allows for any arbitrary function to be applied to an input.

How the sampling works is that it takes a color behind it (for example, a magenta color) and maps it's RGB values to a 0-1 Float3 as XYZ, it then samples the provided 3D texture at point XYZ multipled by the texture's size, and uses the pixel's color as the result which is applied to what the user sees through this material.

For more info on how pixels are arranged on a 3D texture and can be retrieved using an Int3, see 3D Texture.

Fields

Fields
Name Type Description
persistent Bool Determines whether or not this item will be saved to the server.
UpdateOrder Int Controls the order in which this component is updated.
Enabled Bool Controls whether or not this component is enabled.
HighPriorityIntegration Bool If true, integrating this asset (e.g. processing procedural assets) gets higher priority than assets with this flag off. An example is user laser procedural meshes.
Rect Rect
RectClip Bool
ColorMask ColorMask The color channels to affect
StencilComparison StencilComparison See Type:StencilComparison for an in depth explanation on what this does.
StencilOperation StencilOperation See Type:StencilOperation for an in depth explanation on what this does.
StencilID Byte The Stencil ID of this material. This is sometimes written to the frame buffer's Stencil mask, or used to determine whether this material should render for a particular pixel.
StencilWriteMask Byte does a Bitwise AND with this number for every pixel in the frame buffer this is rendering on top of when this object is drawn, after reading from the buffer.
StencilReadMask Byte is bitwise ANDed with the Stencil in the frame buffer before the test compares them.
RenderQueue Int changes at which point a material renders on the render stack
_shader Shader Internal.
LUT Texture3D The 3D texture to use as a lookup table
SecondaryLUT Texture3D A secondary 3D texture to use to lerp between
UseSRGB Bool Whether to use the SRGB color space when spitting out colors.
Lerp Float Allows blending from the first LUT (0) or the secondary LUT (1)
BlendMode BlendMode How to blend this material's colors vs what it rendered on top of.
Sidedness Sidedness Render on both sides of the mesh, front, or back.
ZWrite ZWrite whether this material should respect the distance it is from the camera.
ZTest ZTest Determines whether this object should render when it is in front of or behind other objects that respect depth from the camera

Usage

The mapping function of an LUT takes an input RGB value and then samples the 3D Texture at that corresponding coordinate to find the output RGB value, using the 3D Texture's Filter Mode and Wrap Mode to resolve how intermediate values work.


Examples

This article or section is a Stub. You can help the Resonite Wiki by expanding it.


We need (an image of a scene behind a plane as well as the cube of the 3d texture being used):

  • an example of an LUT material making a Gameboy effect of materials behind it
  • an example of an LUT making a grayscale effect of materials behind it
  • an example of an LUT that inverts materials behind it
  • an example of an LUT that makes materials behind it that have shades of red in their surface spit out random nonsensical colors depending on brightness (yes this is possible with an LUT)

Related Components