X-Git-Url: http://git.mutantstargoat.com?a=blobdiff_plain;f=gl_shaders%2Fmorphing.f.glsl;h=ddb05794a52320646f1a64823c013ad39f7a12e8;hb=9148ff7614b1dc22fd5d1dcf6d74e2fb4ff13706;hp=490efabef796096809fbbc85c6079aaff90cc149;hpb=f4ba93a902613f2b2c4a397d5a526fb4a4161e86;p=demo diff --git a/gl_shaders/morphing.f.glsl b/gl_shaders/morphing.f.glsl index 490efab..ddb0579 100644 --- a/gl_shaders/morphing.f.glsl +++ b/gl_shaders/morphing.f.glsl @@ -1,31 +1,42 @@ #version 450 uniform sampler2D tex; +uniform samplerCube dstex; uniform vec4 diffuse; -uniform vec4 specular; -uniform float shininess; +// uniform vec4 specular; +// uniform float shininess; + +uniform float fog_density; +const vec3 sky_color = vec3(0.35, 0.5, 0.65); varying vec3 pos; -varying vec3 normal; -varying vec3 ldir; +// varying vec3 normal; +// varying vec3 ldir; varying vec2 tex_coord; +varying vec3 world_normal; out vec4 color; void main() { - vec3 p = normalize(pos); - vec3 n = normalize(normal); - vec3 l = normalize(ldir); + vec4 itexel = textureCube(dstex, normalize(world_normal)); + // vec3 p = normalize(pos); + // vec3 n = normalize(normal); + // vec3 l = normalize(ldir); - vec3 r = normalize(-reflect(l, n)); - vec3 vdir = normalize(-p); + // vec3 r = normalize(-reflect(l, n)); + // vec3 vdir = normalize(-p); - float cdiff = max(dot(l, n), 0.0); - float cspec = pow(max(dot(r, vdir), 0.0), shininess); + // float cdiff = max(dot(l, n), 0.0); + // float cspec = pow(max(dot(r, vdir), 0.0), shininess); vec4 texel = texture2D(tex, tex_coord); - color.xyz = diffuse.xyz * cdiff * texel.xyz + specular.xyz * cspec; + // vec3 object_color = diffuse.xyz * cdiff * texel.xyz + specular.xyz * cspec; + vec3 object_color = diffuse.xyz * texel.xyz * itexel.xyz; + float dist = -pos.z; + float fog = clamp(exp(-fog_density * dist), 0.0, 1.0); + + color.xyz = mix(sky_color, object_color, fog); color.w = 1.0; }