-
Notifications
You must be signed in to change notification settings - Fork 128
Output Merger blend state override
Custom shaders are at the mercy of whatever OM blend state the game has left bound, which may not be suitable for our needs. Define a number of options in the CustomShader section that can be used to create a custom blend state.
The simplest form is disabling the blend state, like:
[CustomShader]
blend = disable
To do something more advanced you may specify an arbitrary blend mode (any option can be omitted to use the default documented in MSDN):
[CustomShader]
blend = OP SRC DST
alpha = OP SRC DST
mask = 0xff
alpha_to_coverage = 1
blend_factor[0] = 0.5
blend_factor[1] = 1.2
blend_factor[2] = 3.25
blend_factor[3] = 5.0
sample_mask = 0xff00ff00
Where OP is one of:
ADD, SUBTRACT, REV_SUBTRACT, MIN, MAX
SRC and DST are of:
ZERO, ONE, SRC_COLOR, INV_SRC_COLOR, SRC_ALPHA, INV_SRC_ALPHA,
DEST_ALPHA, INV_DEST_ALPHA, DEST_COLOR, INV_DEST_COLOR,
SRC_ALPHA_SAT, BLEND_FACTOR, INV_BLEND_FACTOR, SRC1_COLOR,
INV_SRC1_COLOR, SRC1_ALPHA, INV_SRC1_ALPHA
Refer to MSDN for the meanings of these:
https://msdn.microsoft.com/en-us/library/windows/desktop/ff476086(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/ff476088(v=vs.85).aspx
When specified like the above, blend, alpha and mask set the blend mode for all render targets. To set the blend mode for a specific render target, use blend[0], blend[1], ... blend[7], etc. Both can be specified, the version without the render target will be set on all render targets that did not get set explicitly.
Due to the complexity of these, they are restricted to CustomShader sections for now, though you could call a custom shader and have it effectively replace the original by adding a discard instruction in the original shader.