#version 120 #if @useUBO #extension GL_ARB_uniform_buffer_object : require #endif #if @useGPUShader4 #extension GL_EXT_gpu_shader4: require #endif #include "lib/core/vertex.h.glsl" #include "lib/nature/leaves.h.glsl" #if @diffuseMap varying vec2 diffuseMapUV; #endif varying vec3 passNormal; varying vec3 passViewPos; varying float euclideanDepth; varying float linearDepth; varying float passFalloff; uniform bool useFalloff; uniform vec4 falloffParams; #if @treeAnim attribute vec3 aLeafParams; #endif #include "lib/view/depth.glsl" #include "compatibility/vertexcolors.glsl" #include "compatibility/shadows_vertex.glsl" void main(void) { vec4 vertex = gl_Vertex; #if @treeAnim vertex = transformLeafVertex(LeafParams( aLeafParams.x, aLeafParams.y, aLeafParams.z ), gl_Vertex, gl_Color, gl_Normal.xyz); #endif #if @diffuseMap diffuseMapUV = (gl_TextureMatrix[@diffuseMapUV] * gl_MultiTexCoord@diffuseMapUV).xy; #endif #if @shadowCasting gl_Position = gl_ModelViewProjectionMatrix * vertex; gl_ClipVertex = (gl_ModelViewMatrix * vertex); return; #endif vec4 viewPos = modelToView(vertex); gl_ClipVertex = viewPos; euclideanDepth = length(viewPos.xyz); linearDepth = getLinearDepth(gl_Position.z, viewPos.z); passColor = gl_Color; passViewPos = viewPos.xyz; passNormal = gl_Normal.xyz; if (useFalloff) { vec3 viewNormal = gl_NormalMatrix * normalize(gl_Normal.xyz); vec3 viewDir = normalize(viewPos.xyz); float viewAngle = abs(dot(viewNormal, viewDir)); passFalloff = smoothstep(falloffParams.x, falloffParams.y, viewAngle); float startOpacity = min(falloffParams.z, 1.0); float stopOpacity = max(falloffParams.w, 0.0); passFalloff = mix(startOpacity, stopOpacity, passFalloff); } else { passFalloff = 1.0; } #if @shadows_enabled vec3 viewNormal = normalize(gl_NormalMatrix * passNormal); setupShadowCoords(viewPos, viewNormal); #endif }