uniform samplerCube cubemap_texture;uniform sampler2D lightmap_texture;uniform vec3 view_position;uniform vec3 light_source;uniform mat3 light_matrix;varying vec3 normal;varying vec4 vertex;varying vec3 normal_VS;varying vec4 proj_coords;#include "Constants.inc"#include "CookTorrance.inc"#include "Postprocess.inc"const vec3 glass_color = vec3(95.0, 253.0, 215.0) / 255.0;void main(){ vec3 vNormal = -normal; vec3 vLight = light_source - vertex.xyz; vec3 vView = view_position - vertex.xyz; float fLightDistance = length(vLight); float fScattering = pow( 1.0 / (1.0 + fLightDistance * 0.0002), 6.0 ); vLight = normalize(vLight); vView = normalize(vView); vec2 vLightShading = LightFunction(vNormal, vLight, vView, 0.8925); vLightShading.x = 0.8 + 0.2 * vLightShading.x; float VdotN = max(0.0, dot(vView, vNormal)); float fFresnel = 1.0 / pow(1.0 + VdotN, 3.35); vec3 vReflection = textureCube( cubemap_texture, reflect(vView, vNormal) ).xyz; float fRefractionR = textureCube( cubemap_texture, -refract(vView, vNormal, GLASS_ETA ) ).r; float fRefractionG = textureCube( cubemap_texture, -refract(vView, vNormal, GLASS_ETA * 1.018) ).g; float fRefractionB = textureCube( cubemap_texture, -refract(vView, vNormal, GLASS_ETA * 1.035) ).b; vec3 vRefraction = vec3(fRefractionR, fRefractionG, fRefractionB); vec3 vColor = mix(vRefraction, vReflection, fFresnel); vColor = mix( vColor, glass_color * dot(vColor, LUMINANCE_VEC), 1.0 - VdotN ); vec3 result = (light_matrix[0] * fScattering + light_matrix[1] * vLightShading.x) * vColor + light_matrix[2] * vLightShading.y ; gl_FragColor = vec4( result, 1.0);}
float fRefractionR = textureCube( cubemap_texture, -refract(vView, vNormal, GLASS_ETA ) ).r; float fRefractionG = textureCube( cubemap_texture, -refract(vView, vNormal, GLASS_ETA * 1.018) ).g; float fRefractionB = textureCube( cubemap_texture, -refract(vView, vNormal, GLASS_ETA * 1.035) ).b;