mirror of
https://github.com/wisplite/crystalline-sky.git
synced 2026-10-30 13:32:18 -05:00
salt in the wound
add sodium compat
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
vec4 projection_from_position(vec4 position) {
|
||||
vec4 projection = position * 0.5;
|
||||
projection.xy = vec2(projection.x + projection.w, projection.y + projection.w);
|
||||
projection.zw = position.zw;
|
||||
return projection;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
#version 330 core
|
||||
|
||||
#import <sodium:include/fog.glsl>
|
||||
|
||||
in vec4 v_Color; // The interpolated vertex color
|
||||
in vec4 v_TexProj; // The interpolated sky texture coordinates
|
||||
in vec2 v_FragDistance; // The fragment's distance from the camera (cylindrical and spherical)
|
||||
|
||||
in float v_MaterialMipBias;
|
||||
in float v_MaterialAlphaCutoff;
|
||||
|
||||
uniform sampler2D u_BlockTex; // The block (sky) texture
|
||||
|
||||
uniform vec4 u_FogColor; // The color of the shader fog
|
||||
uniform vec2 u_EnvironmentFog; // The start and end position for environmental fog
|
||||
uniform vec2 u_RenderFog; // The start and end position for border fog
|
||||
|
||||
uniform vec4 u_ColorModulator;
|
||||
|
||||
out vec4 fragColor; // The output fragment for the color framebuffer
|
||||
|
||||
#define SCALE 1
|
||||
#define BAYER_BIAS 0.03125
|
||||
|
||||
const mat4x4 bayerMatrix4x4 = mat4x4(
|
||||
0.0, 8.0, 2.0, 10.0,
|
||||
12.0, 4.0, 14.0, 6.0,
|
||||
3.0, 11.0, 1.0, 9.0,
|
||||
15.0, 7.0, 13.0, 5.0
|
||||
) / 16.0;
|
||||
|
||||
void main() {
|
||||
vec4 diffuseColor = textureProj(u_BlockTex, v_TexProj, v_MaterialMipBias);//texture(u_BlockTex, v_TexCoord, v_MaterialMipBias);
|
||||
|
||||
/*// Apply per-vertex color
|
||||
diffuseColor *= v_Color;*/
|
||||
diffuseColor *= vec4(u_ColorModulator.rgb, 1.0);
|
||||
|
||||
#ifdef USE_FRAGMENT_DISCARD
|
||||
int x = int(gl_FragCoord.x / SCALE) % 4;
|
||||
int y = int(gl_FragCoord.y / SCALE) % 4;
|
||||
float bayer = bayerMatrix4x4[y][x];
|
||||
|
||||
if (u_ColorModulator.a <= bayer + BAYER_BIAS) {
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
fragColor = _linearFog(diffuseColor, v_FragDistance, u_FogColor, u_EnvironmentFog, u_RenderFog);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
#version 330 core
|
||||
|
||||
#import <sodium:include/fog.glsl>
|
||||
#import <sodium:include/chunk_vertex.glsl>
|
||||
#import <sodium:include/chunk_matrices.glsl>
|
||||
#import <sodium:include/chunk_material.glsl>
|
||||
|
||||
#import <crystalline_sky:include/projection.glsl>
|
||||
|
||||
out vec4 v_Color;
|
||||
out vec4 v_TexProj;
|
||||
|
||||
out float v_MaterialMipBias;
|
||||
#ifdef USE_FRAGMENT_DISCARD
|
||||
out float v_MaterialAlphaCutoff;
|
||||
#endif
|
||||
|
||||
#ifdef USE_FOG
|
||||
out vec2 v_FragDistance;
|
||||
#endif
|
||||
|
||||
uniform vec3 u_RegionOffset;
|
||||
|
||||
uvec3 _get_relative_chunk_coord(uint pos) {
|
||||
// Packing scheme is defined by LocalSectionIndex
|
||||
return uvec3(pos) >> uvec3(5u, 0u, 2u) & uvec3(7u, 3u, 7u);
|
||||
}
|
||||
|
||||
vec3 _get_draw_translation(uint pos) {
|
||||
return _get_relative_chunk_coord(pos) * vec3(16.0);
|
||||
}
|
||||
|
||||
void main() {
|
||||
_vert_init();
|
||||
|
||||
// Transform the chunk-local vertex position into world model space
|
||||
vec3 translation = u_RegionOffset + _get_draw_translation(_draw_id);
|
||||
vec3 position = _vert_position + translation;
|
||||
|
||||
#ifdef USE_FOG
|
||||
v_FragDistance = getFragDistance(position);
|
||||
#endif
|
||||
|
||||
// Transform the vertex position into model-view-projection space
|
||||
gl_Position = u_ProjectionMatrix * u_ModelViewMatrix * vec4(position, 1.0);
|
||||
|
||||
v_Color = _vert_color;
|
||||
v_TexProj = projection_from_position(gl_Position);
|
||||
|
||||
v_MaterialMipBias = _material_mip_bias(_material_params);
|
||||
#ifdef USE_FRAGMENT_DISCARD
|
||||
v_MaterialAlphaCutoff = _material_alpha_cutoff(_material_params);
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user