Skip to content

Instantly share code, notes, and snippets.

@onnowhere
Created June 2, 2020 12:29
Show Gist options
  • Save onnowhere/1a8aba4a9da45863ae36c006efed9364 to your computer and use it in GitHub Desktop.
Save onnowhere/1a8aba4a9da45863ae36c006efed9364 to your computer and use it in GitHub Desktop.
20w22a Depth Shader Example
#version 110
attribute vec4 Position;
uniform mat4 ProjMat;
uniform vec2 InSize;
varying vec2 texCoord;
varying vec2 oneTexel;
void main(){
vec4 outPos = ProjMat * vec4(Position.xy, 0.0, 1.0);
gl_Position = vec4(outPos.xy, 0.2, 1.0);
oneTexel = 1.0 / InSize;
texCoord = outPos.xy * 0.5 + 0.5;
}
#version 110
uniform sampler2D DiffuseSampler;
uniform sampler2D DiffuseDepthSampler;
varying vec2 texCoord;
varying vec2 oneTexel;
void main() {
gl_FragColor = 1.0-(1.0-texture2D(DiffuseDepthSampler, texCoord))*500.0;
}
{
"blend": {
"func": "add",
"srcrgb": "one",
"dstrgb": "zero"
},
"vertex": "blit_util",
"fragment": "depth_test",
"attributes": [ "Position" ],
"samplers": [
{ "name": "DiffuseSampler" },
{ "name": "DiffuseDepthSampler" }
],
"uniforms": [
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
{ "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
{ "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }
]
}
{
"targets": [
"water",
"translucent",
"itemEntity",
"particles",
"clouds",
"weather",
"final",
"swap"
],
"passes": [
{
"name": "transparency",
"intarget": "minecraft:main",
"outtarget": "swap",
"auxtargets": [
{
"name": "DiffuseDepthSampler",
"id": "minecraft:main:depth"
},
{
"name": "TranslucentSampler",
"id": "translucent"
},
{
"name": "TranslucentDepthSampler",
"id": "translucent:depth"
},
{
"name": "ItemEntitySampler",
"id": "itemEntity"
},
{
"name": "ItemEntityDepthSampler",
"id": "itemEntity:depth"
},
{
"name": "ParticlesSampler",
"id": "particles"
},
{
"name": "ParticlesDepthSampler",
"id": "particles:depth"
},
{
"name": "CloudsSampler",
"id": "clouds"
},
{
"name": "CloudsDepthSampler",
"id": "clouds:depth"
},
{
"name": "WeatherSampler",
"id": "weather"
},
{
"name": "WeatherDepthSampler",
"id": "weather:depth"
}
]
},
{
"name": "depth_test",
"intarget": "swap",
"outtarget": "final",
"auxtargets": [
{
"name": "DiffuseDepthSampler",
"id": "minecraft:main:depth"
}
]
},
{
"name": "blit",
"intarget": "final",
"outtarget": "minecraft:main",
"auxtargets": [
{
"name": "DiffuseDepthSampler",
"id": "minecraft:main:depth"
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment