compute_color_for_light.fs (pymol-v2.1.0.tar.bz2) | : | compute_color_for_light.fs (pymol-open-source-2.2.0) | ||
---|---|---|---|---|
#ifdef default | /* | |||
vec4 ComputeColorForLight(bool is_interior, | * Lighting fragment header | |||
vec3 L, vec3 H, vec4 ambient, vec4 diffuse, float spec | */ | |||
, float shine){ | ||||
uniform float shininess; | ||||
uniform float shininess_0; | ||||
uniform float spec_value; | ||||
uniform float spec_value_0; | ||||
#ifdef precomputed_lighting | ||||
uniform samplerCube lightingTex; | ||||
#else | ||||
uniform struct { | ||||
vec4 ambient; | ||||
vec4 diffuse; | ||||
vec4 specular; | ||||
vec4 position; | ||||
} g_LightSource[8]; | ||||
uniform struct { | ||||
vec4 ambient; | ||||
} g_LightModel; | ||||
#endif | #endif | |||
#ifdef sphere | ||||
vec4 ComputeColorForLight(vec3 NORMAL, vec3 L, vec3 H, vec4 ambient, vec4 diffus | #ifdef ray_transparency_oblique | |||
e, float spec, float shine){ | uniform float trans_oblique; | |||
uniform float oblique_power; | ||||
#endif | #endif | |||
#ifdef cylinder | ||||
vec4 ComputeColorForLight(vec3 NORMAL, vec3 L, vec3 H, vec4 ambient, vec4 diffus | /* | |||
e, float spec, float shine, vec4 COLOR){ | * Call this function for every light | |||
#endif | * | |||
float NdotL, NdotH; | * Return: (color intensity, specular (white) intensity) | |||
vec4 ret_val = vec4(0.); | */ | |||
#ifdef default | vec2 ComputeLighting(vec3 normal, // surface normal | |||
if (!is_interior){ | vec3 L, // gl_LightSource[i].position.xyz | |||
#endif | float diffuse, // gl_LightSource[i].diffuse.r | |||
ret_val += ambient * COLOR; | float spec, // specular intensity | |||
NdotL = dot(NORMAL, L); | float shine) // specular exponent | |||
if (NdotL > 0.0) { | { | |||
ret_val += diffuse * NdotL * COLOR; | // light direction (normalized) | |||
NdotH = max(dot(NORMAL, H), 0.0); | L = normalize(L); | |||
ret_val += spec * pow(NdotH, shine); | ||||
} | // cosine of angle between normal and light | |||
#ifdef default | float NdotL = dot(normal, L); | |||
} | ||||
if (two_sided_lighting_enabled && is_interior){ | // normals that don't point away from the light | |||
NdotL = dot(-NORMAL, L); | if (NdotL > 0.0) { | |||
if (NdotL > 0.0) { | ||||
ret_val += diffuse * NdotL * COLOR; | // diffuse | |||
NdotH = max(dot(-NORMAL, H), 0.0); | diffuse *= NdotL; | |||
ret_val += spec * pow(NdotH, shine); | ||||
} | // specular | |||
vec3 H = normalize(L + vec3(0., 0., 1.)); | ||||
float NdotH = max(dot(normal, H), 0.0); | ||||
spec *= pow(NdotH, shine); | ||||
return vec2(diffuse, spec); | ||||
} else { | ||||
return vec2(0.0); | ||||
} | } | |||
} | ||||
/* | ||||
* Apply lighting from all lights | ||||
* | ||||
* Return: lighted color | ||||
*/ | ||||
vec4 ApplyLighting(vec4 color, vec3 normal) { | ||||
#ifdef precomputed_lighting | ||||
vec2 lighting = textureCube(lightingTex, normal).ra; | ||||
#else | ||||
vec2 lighting = vec2(g_LightModel.ambient.r, 0.0); | ||||
// add to lighting for every light | ||||
#include CallComputeColorForLight | ||||
#endif | ||||
color.rgb *= min(lighting.x, 1.0); | ||||
color.rgb += lighting.y; | ||||
#ifdef ray_transparency_oblique | ||||
// see Ray.cpp | ||||
float oblique_factor = abs(normal.z); | ||||
oblique_factor = mix( | ||||
(0.5 + 0.5 * (1.0 - | ||||
pow((1.0 - oblique_factor) * 2.0, oblique_power))), | ||||
( 0.5 * ( | ||||
pow(( oblique_factor) * 2.0, oblique_power))), | ||||
step(oblique_factor, 0.5)); | ||||
float trans = (1. - color.a) * (trans_oblique * oblique_factor + (1. - trans_o | ||||
blique)); | ||||
color.a = 1. - clamp(trans, 0.0, 1.0); | ||||
#endif | #endif | |||
return ret_val; | ||||
return color; | ||||
} | } | |||
End of changes. 5 change blocks. | ||||
33 lines changed or deleted | 93 lines changed or added |