Light falloff
This commit is contained in:
parent
f7b4335f1f
commit
c6afed1507
|
@ -31,4 +31,12 @@ float linearize(const float depth) {
|
|||
return -cameraPlane.y * cameraPlane.x / (depth * (cameraPlane.y - cameraPlane.x) - cameraPlane.y);
|
||||
}
|
||||
|
||||
float attenuate(const float dist) {
|
||||
// float attenuate(float dist, float constant, float linear, float quadratic) {
|
||||
return 1.0 / (dist * dist);
|
||||
// 1.0 / (constant * 1.0)
|
||||
// 1.0 / (lienar * dist)
|
||||
// 1.0 / (quadratic * dist * dist);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2081,9 +2081,11 @@ class ArmoryExporter:
|
|||
o['strength'] = n.inputs[1].default_value
|
||||
# Normalize point/spot strength
|
||||
if o['type'] == 'point' or o['type'] == 'spot':
|
||||
o['strength'] /= 1000.0
|
||||
o['strength'] /= 40.0
|
||||
elif o['type'] == 'area':
|
||||
o['strength'] /= 1000.0
|
||||
o['strength'] /= 40.0
|
||||
elif o['type'] == 'sun':
|
||||
o['strength'] *= 0.4
|
||||
# Texture test..
|
||||
# if n.inputs[0].is_linked:
|
||||
# color_node = nodes.find_node_by_link(tree, n, n.inputs[0])
|
||||
|
|
|
@ -224,12 +224,6 @@ def make_forward_base(con_mesh, parse_opacity=False):
|
|||
frag.add_uniform('sampler2D senvmapBrdf', link='_envmapBrdf')
|
||||
frag.add_uniform('int envmapNumMipmaps', link='_envmapNumMipmaps')
|
||||
|
||||
frag.write('vec3 l = lightType == 0 ? lightDir : normalize(lightPos - wposition);')
|
||||
frag.write('vec3 h = normalize(v + l);')
|
||||
frag.write('float dotNL = dot(n, l);')
|
||||
frag.write('float dotNH = dot(n, h);')
|
||||
frag.write('float dotVH = dot(v, h);')
|
||||
|
||||
if '_NoShadows' in wrd.world_defs:
|
||||
is_shadows = False
|
||||
else:
|
||||
|
@ -271,6 +265,15 @@ def make_forward_base(con_mesh, parse_opacity=False):
|
|||
frag.tab -= 1
|
||||
frag.write('}')
|
||||
|
||||
|
||||
frag.write('vec3 l;')
|
||||
frag.write('if (lightType == 0) l = lightDir;')
|
||||
frag.write('else { l = normalize(lightPos - wposition); visibility *= attenuate(distance(wposition, lightPos)); }')
|
||||
frag.write('vec3 h = normalize(v + l);')
|
||||
frag.write('float dotNL = dot(n, l);')
|
||||
frag.write('float dotNH = dot(n, h);')
|
||||
frag.write('float dotVH = dot(v, h);')
|
||||
|
||||
frag.add_uniform('float spotlightCutoff', '_spotlampCutoff')
|
||||
frag.add_uniform('float spotlightExponent', '_spotlampExponent')
|
||||
frag.write('if (lightType == 2) {')
|
||||
|
|
Loading…
Reference in a new issue