52 lines
1.2 KiB
GLSL
52 lines
1.2 KiB
GLSL
// MinecraftPT — Terrain Vertex Shader
|
|
// Handles terrain, block entities, damaged blocks
|
|
|
|
#include "/Lib/Settings.glsl"
|
|
#include "/Lib/Utilities.glsl"
|
|
|
|
out vec2 texcoord;
|
|
out vec3 worldPos;
|
|
out vec3 worldNormal;
|
|
out vec3 vertexNormal;
|
|
out vec4 color;
|
|
out vec2 lightmap;
|
|
flat out int blockId;
|
|
flat out float blockLightLevel;
|
|
|
|
#ifdef WAVING_PLANTS
|
|
#include "/Lib/IndividualFunctions/WavingPlants.glsl"
|
|
#endif
|
|
|
|
void main(){
|
|
// World position
|
|
vec4 viewPos = gl_ModelViewMatrix * gl_Vertex;
|
|
vec4 wPos = gbufferModelViewInverse * viewPos;
|
|
worldPos = wPos.xyz;
|
|
|
|
// Normals
|
|
vertexNormal = normalize(gl_NormalMatrix * gl_Normal);
|
|
worldNormal = normalize(mat3(gbufferModelViewInverse) * vertexNormal);
|
|
worldNormal = normalize(worldNormal);
|
|
|
|
// Lightmap (blocklight, skylight)
|
|
lightmap = gl_MultiTexCoord1.xy / 240.0;
|
|
lightmap = saturate(lightmap);
|
|
|
|
// Block ID from mc_Entity
|
|
blockId = int(mc_Entity.x + 0.5);
|
|
blockLightLevel = at_midBlock.w;
|
|
|
|
// Waving plants
|
|
#ifdef WAVING_PLANTS
|
|
if (blockId == 4){
|
|
WavingPlants(wPos, lightmap.y);
|
|
}
|
|
#endif
|
|
|
|
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
|
|
color = gl_Color;
|
|
|
|
gl_Position = gl_ProjectionMatrix * viewPos;
|
|
gl_Position.xy += taaJitter * gl_Position.w;
|
|
}
|