summaryrefslogtreecommitdiffstatshomepage
path: root/bgfx
diff options
context:
space:
mode:
author Westley M. Martinez <anikom15@gmail.com>2018-10-07 08:42:30 -0700
committer R. Belmont <rb6502@users.noreply.github.com>2018-10-07 11:42:30 -0400
commitb5a54b761c94c543ce950dee0bc4aa0610ba8cba (patch)
tree9593e366a3f3da82074dec2b431c3dc8ada08d1c /bgfx
parent7b42e2f79950adc1dd6d3c07df5513eda87b507c (diff)
HLSL Color Transforms and 3D LUT (#4043)
* Remove broken scanline uniform from post_pass * Add 3D LUT to HLSL * Allow individual LUTs for screen and UI * WIP: Port 3D LUT to BGFX * Finish porting LUT to BGFX * Add individual phosphor color conversion for HLSL new file: hlsl/chroma.fx Shader for converting xyY3 to sRGB modified: hlsl/phosphor.fx Minor changes to emphasize idea that phosphors are color agnostic modified: hlsl/post.fx Conversion from signal RGB to xyY3 modified: src/osd/modules/render/d3d/d3dhlsl.cpp modified: src/osd/modules/render/d3d/d3dhlsl.h modified: src/osd/windows/winmain.cpp modified: src/osd/windows/winmain.h * Add phosphor examples and update presets * Port phosphor color shaders to BGFX * Fix missing newlines at EOF
Diffstat (limited to 'bgfx')
-rw-r--r--bgfx/chains/hlsl.json183
-rw-r--r--bgfx/chains/lut.json36
-rw-r--r--bgfx/effects/hlsl/chroma.json33
-rw-r--r--bgfx/effects/hlsl/post.json6
-rw-r--r--bgfx/effects/misc/lut.json32
-rw-r--r--bgfx/shaders/dx11/chains/hlsl/fs_chroma.binbin0 -> 1556 bytes
-rw-r--r--bgfx/shaders/dx11/chains/hlsl/fs_post.binbin2411 -> 2635 bytes
-rw-r--r--bgfx/shaders/dx11/chains/hlsl/vs_chroma.binbin0 -> 577 bytes
-rw-r--r--bgfx/shaders/dx11/chains/misc/fs_lut.binbin0 -> 756 bytes
-rw-r--r--bgfx/shaders/dx11/chains/misc/vs_lut.binbin0 -> 577 bytes
-rw-r--r--bgfx/shaders/dx9/chains/hlsl/fs_chroma.binbin0 -> 1029 bytes
-rw-r--r--bgfx/shaders/dx9/chains/hlsl/fs_post.binbin2112 -> 2368 bytes
-rw-r--r--bgfx/shaders/dx9/chains/hlsl/vs_chroma.binbin0 -> 320 bytes
-rw-r--r--bgfx/shaders/dx9/chains/misc/fs_lut.binbin0 -> 501 bytes
-rw-r--r--bgfx/shaders/dx9/chains/misc/vs_lut.binbin0 -> 320 bytes
-rw-r--r--bgfx/shaders/essl/chains/hlsl/fs_chroma.binbin0 -> 1693 bytes
-rw-r--r--bgfx/shaders/essl/chains/hlsl/fs_post.binbin3516 -> 3987 bytes
-rw-r--r--bgfx/shaders/essl/chains/hlsl/vs_chroma.binbin0 -> 419 bytes
-rw-r--r--bgfx/shaders/essl/chains/misc/fs_lut.binbin0 -> 828 bytes
-rw-r--r--bgfx/shaders/essl/chains/misc/vs_lut.binbin0 -> 419 bytes
-rw-r--r--bgfx/shaders/glsl/chains/hlsl/fs_chroma.binbin0 -> 1612 bytes
-rw-r--r--bgfx/shaders/glsl/chains/hlsl/fs_post.binbin3333 -> 3792 bytes
-rw-r--r--bgfx/shaders/glsl/chains/hlsl/vs_chroma.binbin0 -> 377 bytes
-rw-r--r--bgfx/shaders/glsl/chains/misc/fs_lut.binbin0 -> 786 bytes
-rw-r--r--bgfx/shaders/glsl/chains/misc/vs_lut.binbin0 -> 377 bytes
-rw-r--r--bgfx/shaders/metal/chains/hlsl/fs_chroma.binbin0 -> 2245 bytes
-rw-r--r--bgfx/shaders/metal/chains/hlsl/fs_post.binbin4020 -> 4499 bytes
-rw-r--r--bgfx/shaders/metal/chains/hlsl/vs_chroma.binbin0 -> 778 bytes
-rw-r--r--bgfx/shaders/metal/chains/misc/fs_lut.binbin0 -> 1300 bytes
-rw-r--r--bgfx/shaders/metal/chains/misc/vs_lut.binbin0 -> 778 bytes
30 files changed, 228 insertions, 62 deletions
diff --git a/bgfx/chains/hlsl.json b/bgfx/chains/hlsl.json
index 378102444fe..ee76366efaa 100644
--- a/bgfx/chains/hlsl.json
+++ b/bgfx/chains/hlsl.json
@@ -21,13 +21,13 @@
"sliders": [
// type (required): The sliders's conceptual type. Is it a list of string selections? Is it a single floating-point value? Does it require RGB values, or XY values?
// values: "intenum", "int", "float", "vec2", "color"
- //
+ //
// name (required): The internal name of the slider, used to attach it to entry uniforms.
// value: Any valid ASCII string.
- //
+ //
// text (required): The description of the slider, to which "X" or "Y" is appended for the "vec2" type, and to which "Red", "Green" or "Blue" will be appended for the "color" type.
// value: Any valid user-understandable ASCII string.
- //
+ //
// default (required): The value that this slider should have upon creation.
// type: Either a single integer value or an array of integer values corresponding to the size of the slider type:
// "intenum": Single integer value
@@ -35,23 +35,23 @@
// "float": Single integer value
// "vec2": Array of two integer values
// "color": Array of three integer values
- //
+ //
// max (required): The upper limit to which the slider can be adjusted by a user.
// type: See type for "default"
- //
+ //
// min (required): The lower limit to which the slider can be adjusted by a user.
// type: See type for "default"
- //
+ //
// step (required): How much does a single left/right adjustment adjust the slider?
// type: Integer value
- //
+ //
// format (required): A C-style formatting string to use when displaying the slider's value.
// type: Any standard C-style formatting string (%s, %d, %1.2f, and so on)
- //
+ //
// screen (required): The type of screens for which we should populate this slider [NOT YET IMPLEMENTED]
// values: "none", "raster", "vector", "crt", "vectorraster", "lcd", "nonvector", "lcdraster", "lcdvector", "any", "all"
// "crt", "nonvector", and "all" are provided as aliases for "vectorraster", "lcdraster", and "any"
- //
+ //
// strings (optional): A list of strings to use with the "intenum" type, to select from a list of text options instead of simply numbers.
// value: An array of 2 or more entries, with one entry per possible slider setting from "min" to "max" inclusive.
@@ -86,8 +86,6 @@
{ "type": "vec2", "name": "defocus", "text": "Defocus, ", "default": [ 0.5, 0.5 ], "max": [ 2.0, 2.0 ], "min": [ 0.0, 0.0 ], "step": 0.1, "format": "%1.1f", "screen": "crt" },
- { "type": "color", "name": "phosphor", "text": "Phosphor Persistence, ", "default": [ 0.45, 0.45, 0.45 ], "max": [ 1.00, 1.00, 1.00 ], "min": [ 0.00, 0.00, 0.00 ], "step": 0.01, "format": "%1.2f", "screen": "crt" },
-
{ "type": "float", "name": "scanline_alpha", "text": "Scanline Amount", "default": 0.50, "max": 1.00, "min": 0.0, "step": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "scanline_scale", "text": "Overall Scanline Scale", "default": 1.00, "max": 4.00, "min": 0.0, "step": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "scanline_height", "text": "Individual Scanline Scale", "default": 1.00, "max": 4.00, "min": 0.0, "step": 0.01, "format": "%1.2f", "screen": "crt" },
@@ -96,7 +94,7 @@
{ "type": "float", "name": "scanline_bright_offset", "text": "Scanline Brightness Offset", "default": 1.50, "max": 4.00, "min": 0.0, "step": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "scanline_jitter_amount", "text": "Scanline Jitter Amount", "default": 0.00, "max": 4.00, "min": 0.0, "step": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "scanline_variation", "text": "Scanline Variation", "default": 1.00, "max": 4.00, "min": 0.0, "step": 0.01, "format": "%1.2f", "screen": "crt" },
-
+
{ "type": "intenum", "name": "shadow_tile_mode", "text": "Shadow Mask Tile Mode", "default": 0, "max": 1, "min": 0, "step": 1, "format": "%s", "screen": "any", "strings": [ "Screen", "Source" ] },
{ "type": "float", "name": "shadow_alpha", "text": "Shadow Mask Amount", "default": 0.50, "max": 1.00, "min": 0.00, "step": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "vec2", "name": "shadow_uv_count", "text": "Shadow Mask Pixel Count ", "default": [ 12, 12 ], "max": [ 128, 128 ], "min": [ 1, 1 ], "step": 1, "format": "%3f", "screen": "crt" },
@@ -109,29 +107,40 @@
{ "type": "color", "name": "floor", "text": "Signal Floor, ", "default": [ 0.05, 0.05, 0.05 ], "max": [ 1.00, 1.00, 1.00 ], "min": [ 0.00, 0.00, 0.00 ], "step": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "color", "name": "power", "text": "Signal Exponent, ", "default": [ 1.00, 1.00, 1.00 ], "max": [ 4.00, 4.00, 4.00 ], "min": [ 0.00, 0.00, 0.00 ], "step": 0.01, "format": "%1.2f", "screen": "crt" },
+ { "type": "intenum", "name": "chroma_mode", "text": "Color Mode", "default": 3, "max": 3, "min": 1, "step": 1, "format": "%s", "screen": "any", "strings": [ " ", "Monochrome", "Dichrome", "Trichrome" ] },
+ { "type": "color", "name": "chroma_conversion_gain", "text": "Chroma Conversion Gain, ", "default": [ 0.299, 0.587, 0.114 ], "max": [ 1.0, 1.0, 1.0 ], "min": [ 0.0, 0.0, 0.0 ], "step": 0.0001, "format": "%1.4f", "screen": "any" },
+ { "type": "vec2", "name": "chroma_a", "text": "Phosphor A Chromaticity ", "default": [ 0.630, 0.340 ], "max": [ 1.0, 1.0 ], "min": [ 0.0, 0.0 ], "step": 0.001, "format": "%1.3f", "screen": "any" },
+ { "type": "vec2", "name": "chroma_b", "text": "Phosphor B Chromaticity ", "default": [ 0.310, 0.595 ], "max": [ 1.0, 1.0 ], "min": [ 0.0, 0.0 ], "step": 0.001, "format": "%1.3f", "screen": "any" },
+ { "type": "vec2", "name": "chroma_c", "text": "Phosphor C Chromaticity ", "default": [ 0.155, 0.070 ], "max": [ 1.0, 1.0 ], "min": [ 0.0, 0.0 ], "step": 0.001, "format": "%1.3f", "screen": "any" },
+ { "type": "color", "name": "chroma_y_gain", "text": "Phosphor Gain, ", "default": [ 0.2124, 0.7011, 0.0866 ], "max": [ 1.0, 1.0, 1.0 ], "min": [ 0.0, 0.0, 0.0 ], "step": 0.0001, "format": "%1.4f", "screen": "any" },
+
+ { "type": "color", "name": "phosphor", "text": "Phosphor Persistence, ", "default": [ 0.45, 0.45, 0.45 ], "max": [ 1.00, 1.00, 1.00 ], "min": [ 0.00, 0.00, 0.00 ], "step": 0.01, "format": "%1.2f", "screen": "crt" },
+
{ "type": "float", "name": "distortion", "text": "Quadric Distortion Amount", "default": 0.05, "max": 2.00, "min": -2.00, "step": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "cubic_distortion", "text": "Cubic Distortion Amount", "default": 0.00, "max": 2.00, "min": -2.00, "step": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "distort_corner", "text": "Distorted Corner Amount", "default": 0.05, "max": 2.00, "min": 0.00, "step": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "round_corner", "text": "Rounded Corner Amount", "default": 0.05, "max": 2.00, "min": 0.00, "step": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "smooth_border", "text": "Smooth Border Amount", "default": 0.03, "max": 2.00, "min": 0.00, "step": 0.01, "format": "%1.2f", "screen": "crt" },
{ "type": "float", "name": "vignetting", "text": "Vignetting Amount", "default": 0.08, "max": 2.00, "min": 0.00, "step": 0.01, "format": "%1.2f", "screen": "crt" },
- { "type": "float", "name": "reflection", "text": "Reflection Amount", "default": 0.05, "max": 2.00, "min": 0.00, "step": 0.01, "format": "%1.2f", "screen": "crt" }
+ { "type": "float", "name": "reflection", "text": "Reflection Amount", "default": 0.05, "max": 2.00, "min": 0.00, "step": 0.01, "format": "%1.2f", "screen": "crt" },
+
+ { "type": "intenum", "name": "lut_enable", "text": "3D LUT", "default": 0, "max": 1, "min": 0, "step": 1, "format": "%s", "screen": "any", "strings": [ "Off", "On" ] }
],
// parameters (optional): A list of procedurally-generated parameters that can be bound to entry uniforms.
"parameters": [
// name (required): The internal name of the parameter that will be used when binding to an entry uniform.
// value: Any valid ASCII string.
- //
+ //
// type (required): The type of the parameter.
// values:
// "frame": Increment by 1 for each rendered frame. Limited to a given value range. Can be use for A/B field jitter and such.
// "window": Contains the index of the window to which this screen belongs.
// "time": The current time, in milliseconds. Can be limited to a given value range.
- //
+ //
// period (required by type "frame"): The range of frames across which to count. A value of 20 will make the value loop from 0-19.
// value: Any integer value.
- //
+ //
// limit (required by type "time"): The range of time across which to loop. 0.0 means run indefinitely.
// value: Any numeric value.
@@ -143,21 +152,21 @@
"targets": [
// name (required): The name of the target. Will be used to bind it as a texture and as an output in chain entries.
// value: Any valid ASCII string.
- //
+ //
// mode (required): The mode of the target. Can be used for different implicit and explicit sizing options.
// values:
// "guest": Use the size of the emulated screen that is being processed (e.g. 256x256 when running "targ")
// "native": Use the size of the displayed screen inside the window that is being displayed (the same size as the window size, for single-screen games with no artwork)
// "custom": Use a custom size.
- //
+ //
// bilinear (optional): Whether or not to apply bilinear filtering to this render target.
// values: true, false
// default: true
- //
+ //
// doublebuffer (optional): Whether or not this render target will be needed as a source texture. If you don't know what this means, omit it or set it to true.
// values: true, false
// default: true
- //
+ //
// scale (optional): Multiply the internal size of this render target by this amount. Certain effects benefit from operating at a higher internal resolution. If you're not sure, omit it.
// values: Any integer value
// default: 1
@@ -225,19 +234,19 @@
"disablewhen": [
// type (optional): Reserved for future expansion. Currently only "slider" is supported.
// value: "slider"
- //
+ //
// condition (optional): The disabler is active when the named slider is either equal or not equal to the reference value.
// values: "equal", "notequal"
// default: "equal"
- //
+ //
// combine (optional): All "and" conditions are ANDed together, all "or" conditions are OR'd together, then these two
// values are OR'd together to finally determine whether this pass should run or not.
// values: "or", "and"
// default: "or"
- //
+ //
// name (required): The name of the slider to use for this condition.
// value: Any valid ASCII string.
- //
+ //
// value (required): The value against which we are comparing to determine whether this disabler is active.
// type: Either a single integer value or an array of integer values corresponding to the size of the slider's type:
// "intenum": Single integer value
@@ -253,15 +262,15 @@
"uniforms": [
// uniform (required): The name of the uniform, as it is referenced in the shader source code itself.
// value: Any valid ASCII string.
- //
+ //
// The remaining options can be one of either "slider", "parameter", or "value":
- //
+ //
// slider (optional): The name of the slider to bind to this uniform.
// value: Any valid ASCII string that corresponds to the name of a slider.
//
// parameter (optional): The name of the dynamic parameter to bind to this uniform.
// value: Any valid ASCII string that corresponds to the name of a parameter.
- //
+ //
// value (optional): An array of numeric values that should be loaded into this uniform.
// values: Should be an array containing anywhere from 1-16 numeric values, corresponding to the size of the uniform's type.
@@ -278,28 +287,28 @@
"input": [
// sampler (required): The name of the sampler, as it is referenced in the shader source code itself.
// value: Any valid ASCII string.
- //
+ //
// The remaining options can be one of either "texture", "target", or "option".
- //
+ //
// texture (optional): Either "screen" for the texture that MAME provided for this chain's screen, or the name of a texture file in the artwork directory.
// value: Any valid ASCII string.
- //
+ //
// target (optioanl): Any target from the "targets" list, or "previous" or "output" for two native-sized automatically-generated targets.
// value: Any valid ASCII string that names a target.
- //
+ //
// option (optional): The name of any MAME option, which will have its value fetched and used as the name of a PNG to load from the artwork directory.
// value: Any valid MAME INI option name.
- //
+ //
// bilinear (optional, texture and target only): Whether to apply bilinear filtering to the sampler.
// values: true, false
// default: true
- //
+ //
// selection (optional, option and texture only): Determines the name of the selection and alowes to select other textures in the same directory as the specified texture file.
// values: Any valid ASCII string.
{ "sampler": "s_tex", "target": "ntsc" }
],
- // output (required): The target to use as the output for this pass. Can be one of the named targets in "targets", or "output"
+ // output (required): The target to use as the output for this pass. Can be one of the named targets in "targets", or "output"
// or "previous" for one of two automatically-generated targets.
// value: Any valid ASCII string that names a target.
"output": "ntsc"
@@ -427,6 +436,36 @@
],
"output": "internal"
},
+ { "effect": "hlsl/post",
+ "name": "Non-Bloom Post Pass",
+ "disablewhen": [
+ { "type": "slider", "condition": "equal", "combine": "or", "name": "adjustments", "value": 0 },
+ { "type": "slider", "condition": "equal", "combine": "and", "name": "shadow_alpha", "value": 0.0 },
+ { "type": "slider", "condition": "equal", "combine": "and", "name": "humbar_alpha", "value": 0.0 },
+ { "type": "slider", "condition": "equal", "combine": "and", "name": "floor", "value": [ 0, 0, 0 ] },
+ { "type": "slider", "condition": "equal", "combine": "and", "name": "power", "value": [ 0, 0, 0 ] },
+ { "type": "slider", "condition": "equal", "combine": "and", "name": "chroma_mode", "value": 3 }
+ ],
+ "uniforms": [
+ { "uniform": "u_shadow_tile_mode", "slider": "shadow_tile_mode" },
+ { "uniform": "u_shadow_alpha", "slider": "shadow_alpha" },
+ { "uniform": "u_shadow_count", "slider": "shadow_uv_count" },
+ { "uniform": "u_shadow_uv", "slider": "shadow_uv_size" },
+ { "uniform": "u_shadow_uv_offset", "slider": "shadow_uv_offset" },
+ { "uniform": "u_humbar_alpha", "slider": "humbar_alpha" },
+ { "uniform": "u_humbar_hertz_rate", "slider": "humbar_hertz_rate" },
+ { "uniform": "u_floor", "slider": "floor" },
+ { "uniform": "u_power", "slider": "power" },
+ { "uniform": "u_chroma_mode", "slider": "chroma_mode" },
+ { "uniform": "u_conversion_gain", "slider": "chroma_conversion_gain" },
+ { "uniform": "u_time", "parameter": "time" }
+ ],
+ "input": [
+ { "sampler": "s_tex", "target": "internal" },
+ { "sampler": "s_shadow", "option": "bgfx_shadow_mask", "selection": "Shadow Mask" }
+ ],
+ "output": "internal"
+ },
{ "effect": "hlsl/phosphor",
"name": "Phosphor Decay",
"disablewhen": [
@@ -459,32 +498,22 @@
],
"output": "previous"
},
- { "effect": "hlsl/post",
- "name": "Non-Bloom Post Pass",
- "disablewhen": [
- { "type": "slider", "condition": "equal", "combine": "or", "name": "adjustments", "value": 0 },
- { "type": "slider", "condition": "equal", "combine": "and", "name": "shadow_alpha", "value": 0.0 },
- { "type": "slider", "condition": "equal", "combine": "and", "name": "humbar_alpha", "value": 0.0 },
- { "type": "slider", "condition": "equal", "combine": "and", "name": "floor", "value": [ 0, 0, 0 ] },
- { "type": "slider", "condition": "equal", "combine": "and", "name": "power", "value": [ 0, 0, 0 ] }
- ],
- "uniforms": [
- { "uniform": "u_shadow_tile_mode", "slider": "shadow_tile_mode" },
- { "uniform": "u_shadow_alpha", "slider": "shadow_alpha" },
- { "uniform": "u_shadow_count", "slider": "shadow_uv_count" },
- { "uniform": "u_shadow_uv", "slider": "shadow_uv_size" },
- { "uniform": "u_shadow_uv_offset", "slider": "shadow_uv_offset" },
- { "uniform": "u_humbar_alpha", "slider": "humbar_alpha" },
- { "uniform": "u_humbar_hertz_rate", "slider": "humbar_hertz_rate" },
- { "uniform": "u_floor", "slider": "floor" },
- { "uniform": "u_power", "slider": "power" },
- { "uniform": "u_time", "parameter": "time" }
- ],
- "input": [
- { "sampler": "s_tex", "target": "internal" },
- { "sampler": "s_shadow", "option": "bgfx_shadow_mask", "selection": "Shadow Mask" }
- ],
- "output": "internal"
+ {
+ "effect": "hlsl/chroma",
+ "name": "Phosphor Chromaticity Conversion",
+ "disablewhen": [
+ { "type": "slider", "condition": "equal", "name": "adjustments", "value": 0 }
+ ],
+ "uniforms": [
+ { "uniform": "u_y_gain", "slider": "chroma_y_gain" },
+ { "uniform": "u_chroma_a", "slider": "chroma_a" },
+ { "uniform": "u_chroma_b", "slider": "chroma_b" },
+ { "uniform": "u_chroma_c", "slider": "chroma_c" }
+ ],
+ "input": [
+ { "sampler": "s_tex", "target": "internal" }
+ ],
+ "output": "internal"
},
{ "effect": "hlsl/distortion",
"name": "Distortion Pass",
@@ -512,6 +541,40 @@
],
"output": "internal"
},
+ {
+ "effect": "misc/lut",
+ "name": "Apply LUT",
+ "disablewhen": [
+ {
+ "type": "slider",
+ "condition": "equal",
+ "combine": "or",
+ "name": "adjustments",
+ "value": 0
+ },
+ {
+ "type": "slider",
+ "condition": "equal",
+ "combine": "or",
+ "name": "lut_enable",
+ "value": 0
+ }
+ ],
+ "input": [
+ {
+ "sampler": "s_tex",
+ "target": "internal"
+ },
+ {
+ "sampler": "s_3dlut",
+ "option": "bgfx_lut",
+ "bilinear": false,
+ "clamp": true,
+ "selection": "LUT Texture"
+ }
+ ],
+ "output": "internal"
+ },
{ "effect": "misc/blit",
"name": "Final Blit",
"input": [
diff --git a/bgfx/chains/lut.json b/bgfx/chains/lut.json
new file mode 100644
index 00000000000..50353b5292b
--- /dev/null
+++ b/bgfx/chains/lut.json
@@ -0,0 +1,36 @@
+{
+ "name": "3D LUT",
+ "author": "W. M. Martinez",
+ "targets": [
+ {
+ "name": "temp",
+ "mode": "guest"
+ }
+ ],
+ "passes": [
+ {
+ "effect": "misc/blit",
+ "name": "Copy To Filtered Texture",
+ "input": [
+ { "sampler": "s_tex", "texture": "screen" }
+ ],
+ "output": "temp"
+ }, {
+ "effect": "misc/lut",
+ "name": "Apply LUT",
+ "input": [
+ {
+ "sampler": "s_tex",
+ "target": "temp"
+ }, {
+ "sampler": "s_3dlut",
+ "option": "bgfx_lut",
+ "bilinear": false,
+ "clamp": true,
+ "selection": "LUT Texture"
+ }
+ ],
+ "output": "output"
+ }
+ ]
+}
diff --git a/bgfx/effects/hlsl/chroma.json b/bgfx/effects/hlsl/chroma.json
new file mode 100644
index 00000000000..6f7879cdc48
--- /dev/null
+++ b/bgfx/effects/hlsl/chroma.json
@@ -0,0 +1,33 @@
+// license:BSD-3-Clause
+// copyright-holders:W. M. Martinez
+//============================================================
+//
+// chroma.json: Phosphor chromaticity conversion
+//
+//============================================================
+{
+ "blend": {
+ "equation": "add",
+ "srcColor": "srcalpha",
+ "dstColor": "1-srcalpha",
+ "srcAlpha": "srcalpha",
+ "dstAlpha": "1-srcalpha"
+ },
+ "depth": {
+ "function": "always"
+ },
+ "cull": { "mode": "none" },
+ "write": {
+ "rgb": true,
+ "alpha": true
+ },
+ "vertex": "chains/hlsl/vs_chroma",
+ "fragment": "chains/hlsl/fs_chroma",
+ "uniforms": [
+ { "name": "s_tex", "type": "int", "values": [ 0.0 ] },
+ { "name": "u_y_gain", "type": "vec4", "values": [ 0.2124, 0.7011, 0.0866, 0.0 ] },
+ { "name": "u_chroma_a", "type": "vec4", "values": [ 0.630, 0.340, 0.0, 0.0 ] },
+ { "name": "u_chroma_b", "type": "vec4", "values": [ 0.310, 0.595, 0.0, 0.0 ] },
+ { "name": "u_chroma_c", "type": "vec4", "values": [ 0.155, 0.070, 0.0, 0.0 ] }
+ ]
+}
diff --git a/bgfx/effects/hlsl/post.json b/bgfx/effects/hlsl/post.json
index 904a27fb336..e4565978d21 100644
--- a/bgfx/effects/hlsl/post.json
+++ b/bgfx/effects/hlsl/post.json
@@ -42,6 +42,8 @@
{ "name": "u_shadow_uv", "type": "vec4", "values": [ 0.25, 0.25, 0.0, 0.0 ] },
{ "name": "u_shadow_uv_offset", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
{ "name": "u_power", "type": "vec4", "values": [ 1.0, 1.0, 1.0, 0.0 ] },
- { "name": "u_floor", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] }
+ { "name": "u_floor", "type": "vec4", "values": [ 0.0, 0.0, 0.0, 0.0 ] },
+ { "name": "u_chroma_mode", "type": "vec4", "values": [ 3.0, 0.0, 0.0, 0.0 ] },
+ { "name": "u_conversion_gain", "type": "vec4", "values": [ 0.299, 0.587, 0.114, 0.0 ] }
]
-} \ No newline at end of file
+}
diff --git a/bgfx/effects/misc/lut.json b/bgfx/effects/misc/lut.json
new file mode 100644
index 00000000000..fede670f016
--- /dev/null
+++ b/bgfx/effects/misc/lut.json
@@ -0,0 +1,32 @@
+{
+ "blend": {
+ "equation": "add",
+ "srcColor": "srcalpha",
+ "dstColor": "1-srcalpha",
+ "srcAlpha": "srcalpha",
+ "dstAlpha": "1-srcalpha"
+ },
+ "depth": {
+ "function": "always"
+ },
+ "cull": {
+ "mode": "none"
+ },
+ "write": {
+ "rgb": true,
+ "alpha": true
+ },
+ "vertex": "chains/misc/vs_lut",
+ "fragment": "chains/misc/fs_lut",
+ "uniforms": [
+ {
+ "name": "s_tex",
+ "type": "int",
+ "values": [ 1.0 ]
+ }, {
+ "name": "s_3dlut",
+ "type": "int",
+ "values": [ 1.0 ]
+ }
+ ]
+}
diff --git a/bgfx/shaders/dx11/chains/hlsl/fs_chroma.bin b/bgfx/shaders/dx11/chains/hlsl/fs_chroma.bin
new file mode 100644
index 00000000000..babc5ee8386
--- /dev/null
+++ b/bgfx/shaders/dx11/chains/hlsl/fs_chroma.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/chains/hlsl/fs_post.bin b/bgfx/shaders/dx11/chains/hlsl/fs_post.bin
index 86f083ae517..b455d3dbf59 100644
--- a/bgfx/shaders/dx11/chains/hlsl/fs_post.bin
+++ b/bgfx/shaders/dx11/chains/hlsl/fs_post.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/chains/hlsl/vs_chroma.bin b/bgfx/shaders/dx11/chains/hlsl/vs_chroma.bin
new file mode 100644
index 00000000000..d97141ff5f2
--- /dev/null
+++ b/bgfx/shaders/dx11/chains/hlsl/vs_chroma.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/chains/misc/fs_lut.bin b/bgfx/shaders/dx11/chains/misc/fs_lut.bin
new file mode 100644
index 00000000000..ca3fdb8661b
--- /dev/null
+++ b/bgfx/shaders/dx11/chains/misc/fs_lut.bin
Binary files differ
diff --git a/bgfx/shaders/dx11/chains/misc/vs_lut.bin b/bgfx/shaders/dx11/chains/misc/vs_lut.bin
new file mode 100644
index 00000000000..d97141ff5f2
--- /dev/null
+++ b/bgfx/shaders/dx11/chains/misc/vs_lut.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/chains/hlsl/fs_chroma.bin b/bgfx/shaders/dx9/chains/hlsl/fs_chroma.bin
new file mode 100644
index 00000000000..00438717467
--- /dev/null
+++ b/bgfx/shaders/dx9/chains/hlsl/fs_chroma.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/chains/hlsl/fs_post.bin b/bgfx/shaders/dx9/chains/hlsl/fs_post.bin
index 499b7d46a1e..caadf337fab 100644
--- a/bgfx/shaders/dx9/chains/hlsl/fs_post.bin
+++ b/bgfx/shaders/dx9/chains/hlsl/fs_post.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/chains/hlsl/vs_chroma.bin b/bgfx/shaders/dx9/chains/hlsl/vs_chroma.bin
new file mode 100644
index 00000000000..923fba0a293
--- /dev/null
+++ b/bgfx/shaders/dx9/chains/hlsl/vs_chroma.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/chains/misc/fs_lut.bin b/bgfx/shaders/dx9/chains/misc/fs_lut.bin
new file mode 100644
index 00000000000..054e545e421
--- /dev/null
+++ b/bgfx/shaders/dx9/chains/misc/fs_lut.bin
Binary files differ
diff --git a/bgfx/shaders/dx9/chains/misc/vs_lut.bin b/bgfx/shaders/dx9/chains/misc/vs_lut.bin
new file mode 100644
index 00000000000..923fba0a293
--- /dev/null
+++ b/bgfx/shaders/dx9/chains/misc/vs_lut.bin
Binary files differ
diff --git a/bgfx/shaders/essl/chains/hlsl/fs_chroma.bin b/bgfx/shaders/essl/chains/hlsl/fs_chroma.bin
new file mode 100644
index 00000000000..1bddda86292
--- /dev/null
+++ b/bgfx/shaders/essl/chains/hlsl/fs_chroma.bin
Binary files differ
diff --git a/bgfx/shaders/essl/chains/hlsl/fs_post.bin b/bgfx/shaders/essl/chains/hlsl/fs_post.bin
index cf41b694573..4704bd96769 100644
--- a/bgfx/shaders/essl/chains/hlsl/fs_post.bin
+++ b/bgfx/shaders/essl/chains/hlsl/fs_post.bin
Binary files differ
diff --git a/bgfx/shaders/essl/chains/hlsl/vs_chroma.bin b/bgfx/shaders/essl/chains/hlsl/vs_chroma.bin
new file mode 100644
index 00000000000..02eb754eaa3
--- /dev/null
+++ b/bgfx/shaders/essl/chains/hlsl/vs_chroma.bin
Binary files differ
diff --git a/bgfx/shaders/essl/chains/misc/fs_lut.bin b/bgfx/shaders/essl/chains/misc/fs_lut.bin
new file mode 100644
index 00000000000..f87f98dbbad
--- /dev/null
+++ b/bgfx/shaders/essl/chains/misc/fs_lut.bin
Binary files differ
diff --git a/bgfx/shaders/essl/chains/misc/vs_lut.bin b/bgfx/shaders/essl/chains/misc/vs_lut.bin
new file mode 100644
index 00000000000..02eb754eaa3
--- /dev/null
+++ b/bgfx/shaders/essl/chains/misc/vs_lut.bin
Binary files differ
diff --git a/bgfx/shaders/glsl/chains/hlsl/fs_chroma.bin b/bgfx/shaders/glsl/chains/hlsl/fs_chroma.bin
new file mode 100644
index 00000000000..6f9655c3c84
--- /dev/null
+++ b/bgfx/shaders/glsl/chains/hlsl/fs_chroma.bin
Binary files differ
diff --git a/bgfx/shaders/glsl/chains/hlsl/fs_post.bin b/bgfx/shaders/glsl/chains/hlsl/fs_post.bin
index 226bbd57b86..cf1638a8d4c 100644
--- a/bgfx/shaders/glsl/chains/hlsl/fs_post.bin
+++ b/bgfx/shaders/glsl/chains/hlsl/fs_post.bin
Binary files differ
diff --git a/bgfx/shaders/glsl/chains/hlsl/vs_chroma.bin b/bgfx/shaders/glsl/chains/hlsl/vs_chroma.bin
new file mode 100644
index 00000000000..391ef1fda40
--- /dev/null
+++ b/bgfx/shaders/glsl/chains/hlsl/vs_chroma.bin
Binary files differ
diff --git a/bgfx/shaders/glsl/chains/misc/fs_lut.bin b/bgfx/shaders/glsl/chains/misc/fs_lut.bin
new file mode 100644
index 00000000000..3d52149d27c
--- /dev/null
+++ b/bgfx/shaders/glsl/chains/misc/fs_lut.bin
Binary files differ
diff --git a/bgfx/shaders/glsl/chains/misc/vs_lut.bin b/bgfx/shaders/glsl/chains/misc/vs_lut.bin
new file mode 100644
index 00000000000..391ef1fda40
--- /dev/null
+++ b/bgfx/shaders/glsl/chains/misc/vs_lut.bin
Binary files differ
diff --git a/bgfx/shaders/metal/chains/hlsl/fs_chroma.bin b/bgfx/shaders/metal/chains/hlsl/fs_chroma.bin
new file mode 100644
index 00000000000..5fbf69c557d
--- /dev/null
+++ b/bgfx/shaders/metal/chains/hlsl/fs_chroma.bin
Binary files differ
diff --git a/bgfx/shaders/metal/chains/hlsl/fs_post.bin b/bgfx/shaders/metal/chains/hlsl/fs_post.bin
index a7881efd77d..f767a135e26 100644
--- a/bgfx/shaders/metal/chains/hlsl/fs_post.bin
+++ b/bgfx/shaders/metal/chains/hlsl/fs_post.bin
Binary files differ
diff --git a/bgfx/shaders/metal/chains/hlsl/vs_chroma.bin b/bgfx/shaders/metal/chains/hlsl/vs_chroma.bin
new file mode 100644
index 00000000000..00695b802d3
--- /dev/null
+++ b/bgfx/shaders/metal/chains/hlsl/vs_chroma.bin
Binary files differ
diff --git a/bgfx/shaders/metal/chains/misc/fs_lut.bin b/bgfx/shaders/metal/chains/misc/fs_lut.bin
new file mode 100644
index 00000000000..daf4df95f01
--- /dev/null
+++ b/bgfx/shaders/metal/chains/misc/fs_lut.bin
Binary files differ
diff --git a/bgfx/shaders/metal/chains/misc/vs_lut.bin b/bgfx/shaders/metal/chains/misc/vs_lut.bin
new file mode 100644
index 00000000000..00695b802d3
--- /dev/null
+++ b/bgfx/shaders/metal/chains/misc/vs_lut.bin
Binary files differ