-
Notifications
You must be signed in to change notification settings - Fork 26
Post Process Shader format
The effect JSON is defined as an object. Accepted keys are targets
and passes
, both arrays of the corresponding type. There are no mandatory keys.
Can be in one of two forms:
- a string (assumed to resolve to a "target" key in the object),
- an object.
In the case of an object, the following keys are defined:
- name: a string identifying a Framebuffer
- width: an integer indicating the width of the framebuffer (optional)
- height: an integer indicating the height of the framebuffer (optional)
-
satin:format: only available with Satin, can be one of
RGBA8
,RGBA16
,RGBA16F
, orRGBA32F
- refer to the OpenGL documentation for more information
The target name minecraft:main
is a reserved identifier automatically provided for every shader effect, and identifies the effect's main target (Minecraft's main framebuffer by default). A unique framebuffer will otherwise be created for every declared target.
An auxiliary target is an object with the following mandatory keys:
- name: a string identifying an auxiliary target.
-
id: a string denoting a framebuffer
target
, or the name of a texture file (with the.png
extension omitted) located inassets/minecraft/textures/
.
Additionally, if the target refers to a texture, the following keys become mandatory:
- width: an integer indicating the width of the texture object. Does not need to match the actual texture width.
- height: an integer indicating the height of the texture object. Does not need to match the actual texture height.
-
bilinear:
true
if the texture should use linear filtering,false
if it should use nearest.
A uniform value is an object with the following mandatory keys:
- name: a string denoting a uniform declared in the program JSON definition.
- values: an array of numbers.
A pass is an object with the following keys, of which name
, intarget
, and outtarget
are mandatory:
-
name: a string identifying a pass. Must map to an existing JSON definition file in
assets/minecraft/shaders/program
. Satin adds the possibility of using an Identifier format here (domain:program_json
). -
intarget: string denoting the input framebuffer. Must resolve to an existing
target
. -
outtarget: string denoting the output framebuffer. Must resolve to an existing
target
. -
auxtargets: Contains an array of
AuxTarget
objects. Optional. -
uniforms: Contains an array of
UniformValue
objects. Optional.
The most basic non-empty post process definition is as follows:
{
"targets": [ "swap" ],
"passes": [
{
"name": "blit",
"intarget": "minecraft:main",
"outtarget": "swap"
},
{
"name": "blit",
"intarget": "swap",
"outtarget": "minecraft:main"
}
]
}
If you render this shader, you should see absolutely nothing out of the ordinary. This is because blit
simply copies the content of the input framebuffer into the output framebuffer. Thus, this shader effect just copies the main framebuffer's texture into an intermediary swap
target and back. However, blit
has a ColorModulate
uniform that we can use to alter the resulting color:
"uniforms": [
{ "name": "ColorModulate", "values": [ 1.0, 0.4, 0.7, 1.0 ]}
]
Adding the above value to one of the passes will make you see the world in pink!