Moved dissolve shader to Minecraft's new custom shader rendertype.
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
#version 120
|
||||
#version 150
|
||||
|
||||
uniform int time; // Passed in, see ShaderHelper.java
|
||||
#moj_import <fog.glsl>
|
||||
|
||||
uniform sampler2D Sampler0;
|
||||
uniform sampler2D Sampler7;
|
||||
|
||||
uniform float GameTime;
|
||||
uniform vec4 ColorModulator;
|
||||
uniform float FogStart;
|
||||
uniform float FogEnd;
|
||||
uniform vec4 FogColor;
|
||||
|
||||
uniform float dissolve; // Passed in via Callback
|
||||
uniform int highlight;
|
||||
@@ -8,18 +17,23 @@ uniform int red;
|
||||
uniform vec3 blockpos;
|
||||
uniform vec3 firstpos;
|
||||
uniform vec3 secondpos;
|
||||
uniform sampler2D image;
|
||||
uniform sampler2D mask;
|
||||
|
||||
varying vec4 position;
|
||||
varying vec3 normal;
|
||||
in vec3 vertexPosition;
|
||||
in float vertexDistance;
|
||||
in vec4 vertexColor;
|
||||
in vec2 texCoord0;
|
||||
in vec4 normal;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
|
||||
vec3 pixelposition = floor(position.xyz * 8.0) / 8.0;
|
||||
//convert gametime to seconds (roughly)
|
||||
float time = GameTime * 1200;
|
||||
|
||||
vec3 pixelposition = floor(vertexPosition * 8.0) / 8.0;
|
||||
vec3 worldpos = blockpos + pixelposition.xyz;
|
||||
vec2 texcoord = vec2(gl_TexCoord[0]);
|
||||
vec4 texcolor = texture2D(image, texcoord);
|
||||
vec4 texcolor = texture2D(Sampler0, texCoord0) * vertexColor * ColorModulator;
|
||||
vec4 color = texcolor;
|
||||
vec3 firstposc = firstpos + 0.51; //center in block
|
||||
vec3 secondposc = secondpos + 0.5;
|
||||
@@ -41,10 +55,10 @@ void main() {
|
||||
maskcoord = vec2(worldpos.x, worldpos.y);
|
||||
|
||||
maskcoord /= 20.0;
|
||||
vec4 maskColor = texture2D(mask, maskcoord);
|
||||
vec4 maskColor = texture2D(Sampler7, maskcoord);
|
||||
float maskgs = maskColor.r;
|
||||
|
||||
color.rgb *= gl_Color.rgb;
|
||||
color.rgb *= vertexColor.rgb;
|
||||
|
||||
//desaturate
|
||||
color.rgb *= vec3(0.8);
|
||||
@@ -53,30 +67,18 @@ void main() {
|
||||
color.rgb += vec3(-0.1, 0.0, 0.2);
|
||||
|
||||
//add pulsing blue
|
||||
float pulse = (sin(time / 5.0) + 1.0) / 2.0;
|
||||
float pulse = (sin(time * 4.0) + 1.0) / 2.0;
|
||||
color.rgb += 0.4 * vec3(-0.5, 0.2, 0.6) * pulse;
|
||||
|
||||
//add diagonal highlights
|
||||
float diagTime = mod(time / 40.0, 1.4) - 0.2;
|
||||
float diagTime = mod(time / 2.0, 1.4) - 0.2;
|
||||
float diag = smoothstep(diagTime - 0.2, diagTime, place) - smoothstep(diagTime, diagTime + 0.2, place);
|
||||
color.rgb += 0.2 * diag * vec3(0.0, 0.2, 0.4);
|
||||
|
||||
float diagTime2 = mod(time / 70.0, 1.4) - 0.2;
|
||||
float diagTime2 = mod(time / 3.5, 1.4) - 0.2;
|
||||
float diag2 = smoothstep(diagTime2 - 0.2, diagTime2, place) - smoothstep(diagTime2, diagTime2 + 0.2, place);
|
||||
color.rgb += 0.2 * diag2 * vec3(0.0, 0.4, 0.8);
|
||||
|
||||
//add edge shading
|
||||
// vec3 p1;
|
||||
// //if (firstpos.x < secondpos.x)
|
||||
//
|
||||
// vec3 wmf = worldpos - firstposc;
|
||||
// vec3 wms = worldpos - (secondposc + vec3(0.0, 1.0, 1.0));
|
||||
// float distToEdge1 = min(length(wmf.xy), length(wmf.xz));
|
||||
// float distToEdge2 = min(length(wmf.yz), length(wms.xy));
|
||||
// float distToEdge3 = min(length(wms.xz), length(wms.yz));
|
||||
// float distToEdge = min(min(distToEdge1, distToEdge2), distToEdge3);
|
||||
// color.rgb += vec3(0.5 - smoothstep(0, 0.5, distToEdge)) * 0.5;
|
||||
|
||||
//add flat shading
|
||||
// if (abs(normal.x) > 0.5)
|
||||
// color.rgb -= 0.0;
|
||||
@@ -99,6 +101,6 @@ void main() {
|
||||
color.b = max(0, min(1, color.b));
|
||||
|
||||
if (maskgs * 0.3 + place * 0.7 <= dissolve)
|
||||
gl_FragColor = vec4(texcolor.rgb, 0.0);
|
||||
else gl_FragColor = color;
|
||||
fragColor = vec4(texcolor.rgb, 0.0);
|
||||
else fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"blend": {
|
||||
"func": "add",
|
||||
"srcrgb": "srcalpha",
|
||||
"dstrgb": "1-srcalpha"
|
||||
},
|
||||
"vertex": "effortlessbuilding:dissolve",
|
||||
"fragment": "effortlessbuilding:dissolve",
|
||||
"attributes": [
|
||||
"Position",
|
||||
"Color",
|
||||
"UV0",
|
||||
"UV2",
|
||||
"Normal"
|
||||
],
|
||||
"samplers": [
|
||||
{ "name": "Sampler0" },
|
||||
{ "name": "Sampler2" }
|
||||
],
|
||||
"uniforms": [
|
||||
{ "name": "ModelViewMat", "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": "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": "ChunkOffset", "type": "float", "count": 3, "values": [ 0.0, 0.0, 0.0 ] },
|
||||
{ "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] },
|
||||
{ "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] },
|
||||
{ "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] },
|
||||
{ "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] },
|
||||
{ "name": "GameTime", "type": "float", "count": 1, "values": [ 0.0 ] },
|
||||
|
||||
{ "name": "dissolve", "type": "float", "count": 1, "values": [0.0] },
|
||||
{ "name": "highlight", "type": "int", "count": 1, "values": [0] },
|
||||
{ "name": "red", "type": "int", "count": 1, "values": [0] },
|
||||
{ "name": "blockpos", "type": "float", "count": 3, "values": [0.0, 0.0, 0.0] },
|
||||
{ "name": "firstpos", "type": "float", "count": 3, "values": [0.0, 0.0, 0.0] },
|
||||
{ "name": "secondpos", "type": "float", "count": 3, "values": [0.0, 0.0, 0.0] }
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#version 150
|
||||
|
||||
#moj_import <light.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
in vec4 Color;
|
||||
in vec2 UV0;
|
||||
in ivec2 UV2;
|
||||
in vec3 Normal;
|
||||
|
||||
uniform sampler2D Sampler2;
|
||||
|
||||
uniform mat4 ModelViewMat;
|
||||
uniform mat4 ProjMat;
|
||||
uniform vec3 ChunkOffset;
|
||||
|
||||
out vec3 vertexPosition;
|
||||
out float vertexDistance;
|
||||
out vec4 vertexColor;
|
||||
out vec2 texCoord0;
|
||||
out vec4 normal;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position + ChunkOffset, 1.0);
|
||||
|
||||
vertexPosition = gl_Position.xyz;
|
||||
vertexDistance = length((ModelViewMat * vec4(Position + ChunkOffset, 1.0)).xyz);
|
||||
vertexColor = Color * minecraft_sample_lightmap(Sampler2, UV2);
|
||||
texCoord0 = UV0;
|
||||
normal = ProjMat * ModelViewMat * vec4(Normal, 0.0);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#version 120
|
||||
|
||||
varying vec4 position;
|
||||
varying vec3 normal;
|
||||
|
||||
void main() {
|
||||
gl_Position = ftransform();//gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
|
||||
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
|
||||
gl_FrontColor = gl_Color;
|
||||
//gl_BackColor = gl_Color;
|
||||
|
||||
position = gl_Vertex;
|
||||
normal = gl_Normal;
|
||||
}
|
||||
Reference in New Issue
Block a user