Bilinear interpolation for quad vertex data via geometry shader #12
No files matched your search
@@ -2,12 +2,20 @@
|
||||
|
||||
#import <sodium:include/fog.glsl>
|
||||
|
||||
in vec4 v_Color; // The interpolated vertex color
|
||||
in vec2 v_TexCoord; // The interpolated block texture coordinates
|
||||
in float v_FragDistance; // The fragment's distance from the camera
|
||||
in VS_OUT
|
||||
{
|
||||
vec4 v_Color; // The interpolated vertex color
|
||||
vec2 v_TexCoord; // The interpolated block texture coordinates
|
||||
|
||||
in float v_MaterialMipBias;
|
||||
in float v_MaterialAlphaCutoff;
|
||||
float v_MaterialMipBias;
|
||||
#ifdef USE_FRAGMENT_DISCARD
|
||||
float v_MaterialAlphaCutoff;
|
||||
#endif
|
||||
|
||||
#ifdef USE_FOG
|
||||
float v_FragDistance; // The fragment's distance from the camera
|
||||
#endif
|
||||
} fs_in;
|
||||
|
||||
uniform sampler2D u_BlockTex; // The block texture
|
||||
|
||||
@@ -25,31 +33,31 @@ uniform float u_FogDensity; // The density of the shader fog
|
||||
out vec4 fragColor; // The output fragment for the color framebuffer
|
||||
|
||||
void main() {
|
||||
vec4 diffuseColor = texture(u_BlockTex, v_TexCoord, v_MaterialMipBias);
|
||||
vec4 diffuseColor = texture(u_BlockTex, fs_in.v_TexCoord, fs_in.v_MaterialMipBias);
|
||||
|
||||
#ifdef USE_FRAGMENT_DISCARD
|
||||
if (diffuseColor.a < v_MaterialAlphaCutoff) {
|
||||
if (diffuseColor.a < fs_in.v_MaterialAlphaCutoff) {
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_VANILLA_COLOR_FORMAT
|
||||
// Apply per-vertex color. AO shade is applied ahead of time on the CPU.
|
||||
diffuseColor *= v_Color;
|
||||
diffuseColor *= fs_in.v_Color;
|
||||
#else
|
||||
// Apply per-vertex color
|
||||
diffuseColor.rgb *= v_Color.rgb;
|
||||
diffuseColor.rgb *= fs_in.v_Color.rgb;
|
||||
|
||||
// Apply ambient occlusion "shade"
|
||||
diffuseColor.rgb *= v_Color.a;
|
||||
diffuseColor.rgb *= fs_in.v_Color.a;
|
||||
#endif
|
||||
|
||||
#ifdef USE_FOG
|
||||
#ifdef USE_FOG_EXP2
|
||||
fragColor = _exp2Fog(diffuseColor, v_FragDistance, u_FogColor, u_FogDensity);
|
||||
fragColor = _exp2Fog(diffuseColor, fs_in.v_FragDistance, u_FogColor, u_FogDensity);
|
||||
#endif
|
||||
#ifdef USE_FOG_SMOOTH
|
||||
fragColor = _linearFog(diffuseColor, v_FragDistance, u_FogColor, u_FogStart, u_FogEnd);
|
||||
fragColor = _linearFog(diffuseColor, fs_in.v_FragDistance, u_FogColor, u_FogStart, u_FogEnd);
|
||||
#endif
|
||||
#else
|
||||
fragColor = diffuseColor;
|
||||
|
||||
@@ -5,17 +5,20 @@
|
||||
#import <sodium:include/chunk_matrices.glsl>
|
||||
#import <sodium:include/chunk_material.glsl>
|
||||
|
||||
out vec4 v_Color;
|
||||
out vec2 v_TexCoord;
|
||||
out VS_OUT
|
||||
{
|
||||
vec4 v_Color;
|
||||
vec2 v_TexCoord;
|
||||
|
||||
out float v_MaterialMipBias;
|
||||
float v_MaterialMipBias;
|
||||
#ifdef USE_FRAGMENT_DISCARD
|
||||
out float v_MaterialAlphaCutoff;
|
||||
float v_MaterialAlphaCutoff;
|
||||
#endif
|
||||
|
||||
#ifdef USE_FOG
|
||||
out float v_FragDistance;
|
||||
float v_FragDistance;
|
||||
#endif
|
||||
} vs_out;
|
||||
|
||||
uniform int u_FogShape;
|
||||
uniform vec3 u_RegionOffset;
|
||||
@@ -45,7 +48,7 @@ void main() {
|
||||
vec3 position = _vert_position + translation;
|
||||
|
||||
#ifdef USE_FOG
|
||||
v_FragDistance = getFragDistance(u_FogShape, position);
|
||||
vs_out.v_FragDistance = getFragDistance(u_FogShape, position);
|
||||
#endif
|
||||
|
||||
// Transform the vertex position into model-view-projection space
|
||||
@@ -53,14 +56,14 @@ void main() {
|
||||
|
||||
// Add the light color to the vertex color, and pass the texture coordinates to the fragment shader
|
||||
#ifdef CELERITAS_NO_LIGHTMAP
|
||||
v_Color = _vert_color;
|
||||
vs_out.v_Color = _vert_color;
|
||||
#else
|
||||
v_Color = _vert_color * _sample_lightmap(u_LightTex, _vert_tex_light_coord);
|
||||
vs_out.v_Color = _vert_color * _sample_lightmap(u_LightTex, _vert_tex_light_coord);
|
||||
#endif
|
||||
v_TexCoord = _vert_tex_diffuse_coord;
|
||||
vs_out.v_TexCoord = _vert_tex_diffuse_coord;
|
||||
|
||||
v_MaterialMipBias = _material_mip_bias(_material_params);
|
||||
vs_out.v_MaterialMipBias = _material_mip_bias(_material_params);
|
||||
#ifdef USE_FRAGMENT_DISCARD
|
||||
v_MaterialAlphaCutoff = _material_alpha_cutoff(_material_params);
|
||||
vs_out.v_MaterialAlphaCutoff = _material_alpha_cutoff(_material_params);
|
||||
#endif
|
||||
}
|
||||
Reference in new issue
Block a user