#version 330 core uniform vec3 u_campos; in vec3 v_position; in vec3 v_normal; in vec2 v_texcoord; layout (location=0) out vec4 v_output; uniform sampler2D u_texture; float get_fog_factor(float d) { const float FogMax = 10.0; const float FogMin = 0.0; if (d >= FogMax) return 1.0; if (d <= FogMin) return 0.0; return 1 - (FogMax - d) / (FogMax - FogMin); } struct Light { vec3 position; vec3 diffuse; }; float lambert(vec3 n, vec3 l) { vec3 nrmn = normalize(n); vec3 nrml = normalize(l); float res = dot(nrmn, nrml); return max(res, 0.0); } float dist(vec2 p0, vec2 pf){return sqrt((pf.x-p0.x)*(pf.x-p0.x)+(pf.y-p0.y)*(pf.y-p0.y));} void main() { Light light; light.position = vec3(0.0, 0.0, 0.0); light.diffuse = vec3(1.0, 1.0, 1.0); vec2 tc = v_texcoord; tc.x = (v_texcoord.x)+u_campos.x/1000.0; //mod(u_campos.x/1024.0, 10.0); tc.y = (v_texcoord.y)+u_campos.z/1000.0; //mod(u_campos.z/1024.0, 10.0); tc.x *= 1000.0; tc.y *= 1000.0; vec4 tex = texture(u_texture, tc); vec3 norm = normalize(v_normal); vec3 res = light.diffuse * lambert(norm, light.position); float a = dist(v_position.xy, vec2(0.0, 0.0)) * 2.0f; v_output = vec4(tex.rgb, tex.a - a); }