From 180aad05decc7eefa87e4e45d6747c48f40e5361 Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Mon, 17 Apr 2023 12:12:01 -0400 Subject: save --- assets/shaders/Chunk_VS.glsl | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 assets/shaders/Chunk_VS.glsl (limited to 'assets/shaders/Chunk_VS.glsl') diff --git a/assets/shaders/Chunk_VS.glsl b/assets/shaders/Chunk_VS.glsl new file mode 100755 index 0000000..6c5e3dc --- /dev/null +++ b/assets/shaders/Chunk_VS.glsl @@ -0,0 +1,35 @@ +#version 130 + +in vec3 position; +in vec2 textureCoordinates; +in float baseLightingValue; +in float layer; + +out vec2 pass_textureCoordinates; +out float pass_baseLightingValue; +out float pass_layer; +out float visibility; + +uniform mat4 transformationMatrix; +uniform mat4 projectionMatrix; +uniform mat4 viewMatrix; +uniform vec3 playerPosition; +uniform int renderDistance; + +const float density = 0.5; +const float gradient = 1.5; + +void main(void){ + vec4 worldPosition = transformationMatrix * vec4(position,1.0); + gl_Position = projectionMatrix * viewMatrix * worldPosition; + pass_textureCoordinates = textureCoordinates; + pass_layer = layer; + pass_baseLightingValue = baseLightingValue; + + float distance = sqrt(pow(worldPosition.x - playerPosition.x, 2)+ pow(worldPosition.z - playerPosition.z,2)); + visibility = 1; + if(distance / 16 > renderDistance-2){ + visibility = 1-(distance - (16*(renderDistance-2)))/16.0; + } + visibility = clamp(visibility,0.0,1.0); +} -- cgit v1.2.3-freya