full support of ObjectBase:: isReceiveShadows, isCastShadows, isAcceptLight and isAcceptFog
This commit is contained in:
@@ -37,6 +37,7 @@ vec4 pos, lpos, shp;
|
||||
vec3 li, si, ldir, halfV, bn, bn2, lwdir;
|
||||
vec3 vds, vds2;
|
||||
float rough_diff, rough_spec, dist, NdotL, NdotH, spot, ldist, diff, spec, sdist, shadow;
|
||||
uint flags;
|
||||
|
||||
|
||||
vec4 mapScreenToShadow(in int light_index, in vec3 offset) {
|
||||
@@ -74,12 +75,12 @@ void calcLight(in int index, in vec3 n, in vec3 v) {
|
||||
spot *= scos * step(qgl_light_parameter[index].angles.w, scos);
|
||||
spot *= smoothstep(qgl_light_parameter[index].angles.w, qgl_light_parameter[index].angles.y, scos);
|
||||
|
||||
if (qgl_light_parameter[index].flags == 1) {
|
||||
if (qgl_light_parameter[index].flags == 1 && bitfieldExtract(flags, 3, 1) == 1) {
|
||||
|
||||
float ds = ldist/300.;
|
||||
//float bias = ldist * 0.05;
|
||||
vds = ds * bn.xyz;
|
||||
vds2 = ds * bn2.xyz;
|
||||
//vds = ds * bn.xyz;
|
||||
//vds2 = ds * bn2.xyz;
|
||||
|
||||
int layer = index - lights_start;
|
||||
float shadow = 0.;
|
||||
@@ -192,16 +193,21 @@ void main(void) {
|
||||
float reflectivity = v2.b;
|
||||
float NdotV = dot(normal, v);
|
||||
float roughness3 = roughness*roughness*roughness;
|
||||
bn = normalize(cross(normal, view_dir));
|
||||
bn2 = normalize(cross(normal, bn));
|
||||
//bn = normalize(cross(normal, view_dir));
|
||||
//bn2 = normalize(cross(normal, bn));
|
||||
rough_diff = max(roughness, _min_rough);
|
||||
rough_spec = max(roughness3, _min_rough);
|
||||
float shlick = clamp(metalness + (1 - metalness) * pow(1 - NdotV, 5), 0, 1);
|
||||
flags = uint(v2.w);
|
||||
|
||||
li = vec3(0.);//qgl_AmbientLight.color.rgb * qgl_AmbientLight.intensity;
|
||||
si = vec3(0.);
|
||||
for (int i = 0; i < lights_count; ++i)
|
||||
calcLight(lights_start + i, normal, v);
|
||||
if (bitfieldExtract(flags, 0, 1) == 1) {
|
||||
for (int i = 0; i < lights_count; ++i)
|
||||
calcLight(lights_start + i, normal, v);
|
||||
} else {
|
||||
li = vec3(1.);
|
||||
}
|
||||
si *= shlick;
|
||||
li *= (1 - shlick);
|
||||
alpha = min(1, alpha * (1 + shlick));
|
||||
@@ -215,13 +221,16 @@ void main(void) {
|
||||
vec3 res_col = max(vec3(0), li * diffuse + si * spec_col + emission);
|
||||
res_col = mix(res_col, env_col, env_spec * reflectivity);
|
||||
|
||||
float plen = length(pos.xyz);
|
||||
float fog = 1 - exp(-plen / fog_decay);
|
||||
fog = clamp(fog * fog_color.a * fog_density, 0, 1);
|
||||
res_col = mix(res_col, fog_color.rgb, fog);
|
||||
if (bitfieldExtract(flags, 1, 1) == 1) {
|
||||
float plen = length(pos.xyz);
|
||||
float fog = 1 - exp(-plen / fog_decay);
|
||||
fog = clamp(fog * fog_color.a * fog_density, 0, 1);
|
||||
res_col = mix(res_col, fog_color.rgb, fog);
|
||||
}
|
||||
|
||||
qgl_FragColor = vec4(res_col, alpha);
|
||||
//qgl_FragColor.rgb = view_dir;
|
||||
//qgl_FragColor.rgb = vec3((v2.w/15));
|
||||
//qgl_FragColor.rgb = diffuse.rgb;
|
||||
/*
|
||||
#ifdef SPOT
|
||||
vec4 wpos = vec4(world_dir * z, 1);
|
||||
|
||||
Reference in New Issue
Block a user