Skip to content

Commit

Permalink
Don't apply lighting for damagedblock
Browse files Browse the repository at this point in the history
This seems weird but seems to be correct?
  • Loading branch information
leo60228 committed Jan 2, 2023
1 parent c712044 commit 541845b
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
34 changes: 34 additions & 0 deletions shaders/gbuffers_damagedblock.fsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#version 120

// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

//Diffuse (color) texture.
uniform sampler2D texture;
//Lighting from day/night + shadows + light sources.
uniform sampler2D lightmap;

//0-1 amount of blindness.
uniform float blindness;
//0 = default, 1 = water, 2 = lava.
uniform int isEyeInWater;

//Diffuse and lightmap texture coordinates.
varying vec2 coord0;
varying vec2 coord1;

void main()
{
//Sample texture
vec4 col = texture2D(texture,coord0);

//Calculate fog intensity in or out of water.
float fog = (isEyeInWater>0) ? 1.-exp(-gl_FogFragCoord * gl_Fog.density):
clamp((gl_FogFragCoord-gl_Fog.start) * gl_Fog.scale, 0., 1.);

//Apply the fog.
col.rgb = mix(col.rgb, gl_Fog.color.rgb, fog);

//Output the result.
/*DRAWBUFFERS:0*/
gl_FragData[0] = col;
}
41 changes: 41 additions & 0 deletions shaders/gbuffers_damagedblock.vsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#version 120

// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

#ifdef GLSLANG
#extension GL_GOOGLE_include_directive : enable
#endif

//Get Entity id.
attribute float mc_Entity;

//Model * view matrix and it's inverse.
uniform mat4 gbufferModelView;
uniform mat4 gbufferModelViewInverse;

//Pass vertex information to fragment shader.
varying vec2 coord0;
varying vec2 coord1;

uniform int frameCounter;

uniform float viewWidth, viewHeight;

#include "/bsl_lib/util/jitter.glsl"

void main()
{
//Calculate world space position.
vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
pos = (gbufferModelViewInverse * vec4(pos,1)).xyz;

//Output position and fog to fragment shader.
gl_Position = gl_ProjectionMatrix * gbufferModelView * vec4(pos,1);
gl_FogFragCoord = length(pos);

//Output diffuse and lightmap texture coordinates to fragment shader.
coord0 = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
coord1 = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;

gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
}

0 comments on commit 541845b

Please sign in to comment.