Created
June 18, 2020 20:10
-
-
Save DragoniteSpam/f12463eb3d6be874df1a25a46cbb1ef5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
varying vec2 v_vTexcoord; | |
varying vec4 v_vColour; | |
#pragma include("lighting.f.xsh") | |
/// https://github.com/GameMakerDiscord/Xpanda | |
uniform float lightBuckets; | |
varying vec4 v_lightColour; | |
void CommonLighting(inout vec4 baseColor); | |
void CommonLighting(inout vec4 baseColor) { | |
baseColor *= clamp(floor(v_lightColour * lightBuckets + vec4(0.5)) / lightBuckets, vec4(0.), vec4(1.)); | |
} | |
// include("lighting.f.xsh") | |
#pragma include("fog.f.xsh") | |
/// https://github.com/GameMakerDiscord/Xpanda | |
uniform float fogStrength; | |
uniform float fogStart; | |
uniform float fogEnd; | |
uniform vec3 fogColor; | |
varying vec3 v_worldPosition; | |
varying vec3 v_cameraPosition; | |
void CommonFog(inout vec4 baseColor); | |
void CommonFog(inout vec4 baseColor) { | |
float dist = length(v_worldPosition - v_cameraPosition); | |
float f = clamp((dist - fogStart) / (fogEnd - fogStart) * fogStrength, 0., 1.); | |
baseColor.rgb = mix(baseColor.rgb, fogColor, f); | |
} | |
// include("fog.f.xsh") | |
uniform sampler2D displacementMap; | |
uniform float displacement; | |
uniform vec2 time; | |
uniform float baseAlpha; | |
void main() { | |
vec4 colorDM = texture2D(displacementMap, v_vTexcoord - vec2(mod(2. * time.x / 10., 1.), mod(-time.y / 10., 1.))); | |
vec2 offset = vec2((colorDM.r + colorDM.g + colorDM.b) / 3. - 0.5) * displacement; | |
vec4 finalColor = texture2D(gm_BaseTexture, v_vTexcoord + vec2(mod(time.x / 10., 1.), mod(time.y / 10., 1.)) + offset); | |
finalColor.a = clamp(length(finalColor.rgb) / 4., 0., 1.) + baseAlpha; | |
CommonLighting(finalColor); | |
CommonFog(finalColor); | |
gl_FragColor = finalColor; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment