From 541845be6d5dc5051d9480c4f67d6d714e9da71a Mon Sep 17 00:00:00 2001 From: leo60228 Date: Mon, 2 Jan 2023 11:59:23 -0500 Subject: [PATCH] Don't apply lighting for damagedblock This seems weird but seems to be correct? --- shaders/gbuffers_damagedblock.fsh | 34 +++++++++++++++++++++++++ shaders/gbuffers_damagedblock.vsh | 41 +++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 shaders/gbuffers_damagedblock.fsh create mode 100644 shaders/gbuffers_damagedblock.vsh diff --git a/shaders/gbuffers_damagedblock.fsh b/shaders/gbuffers_damagedblock.fsh new file mode 100644 index 0000000..564f8dc --- /dev/null +++ b/shaders/gbuffers_damagedblock.fsh @@ -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; +} diff --git a/shaders/gbuffers_damagedblock.vsh b/shaders/gbuffers_damagedblock.vsh new file mode 100644 index 0000000..a9106e6 --- /dev/null +++ b/shaders/gbuffers_damagedblock.vsh @@ -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); +}