Fix area lamp links.
This commit is contained in:
parent
a7577cb6d0
commit
aca381d515
|
@ -43,10 +43,10 @@ uniform sampler2D gbuffer1;
|
|||
//!uniform sampler3D voxels;
|
||||
#endif
|
||||
|
||||
// #ifdef _PolyLight
|
||||
//! uniform sampler2D sltcMat;
|
||||
//! uniform sampler2D sltcMag;
|
||||
// #endif
|
||||
#ifdef _PolyLight
|
||||
//!uniform sampler2D sltcMat;
|
||||
//!uniform sampler2D sltcMag;
|
||||
#endif
|
||||
|
||||
uniform mat4 invVP;
|
||||
uniform mat4 LWVP;
|
||||
|
@ -58,12 +58,12 @@ uniform float lightStrength;
|
|||
uniform float shadowsBias;
|
||||
uniform float spotlightCutoff;
|
||||
uniform float spotlightExponent;
|
||||
// #ifdef _PolyLight
|
||||
#ifdef _PolyLight
|
||||
uniform vec3 lampArea0;
|
||||
uniform vec3 lampArea1;
|
||||
uniform vec3 lampArea2;
|
||||
uniform vec3 lampArea3;
|
||||
// #endif
|
||||
#endif
|
||||
uniform vec3 eye;
|
||||
// uniform vec3 eyeLook;
|
||||
// uniform vec2 screenSize;
|
||||
|
@ -177,25 +177,28 @@ void main() {
|
|||
|
||||
// Direct
|
||||
vec3 direct;
|
||||
// #ifdef _PolyLight
|
||||
|
||||
#ifdef _PolyLight
|
||||
if (lightType == 3) { // Area
|
||||
float theta = acos(dotNV);
|
||||
vec2 tuv = vec2(metrough.y, theta / (0.5 * PI));
|
||||
tuv = tuv * LUT_SCALE + LUT_BIAS;
|
||||
vec4 t = texture(sltcMat, tuv);
|
||||
mat3 Minv = mat3(
|
||||
// vec4 t = texture(sltcMat, tuv);
|
||||
vec4 t = clamp(texture(sltcMat, tuv), 0.0, 1.0);
|
||||
mat3 invM = mat3(
|
||||
vec3(1.0, 0.0, t.y),
|
||||
vec3(0.0, t.z, 0.0),
|
||||
vec3(t.w, 0.0, t.x));
|
||||
|
||||
vec3 ltcspec = ltcEvaluate(n, v, dotNV, p, Minv, lampArea0, lampArea1, lampArea2, lampArea3, false);
|
||||
vec3 ltcspec = ltcEvaluate(n, v, dotNV, p, invM, lampArea0, lampArea1, lampArea2, lampArea3, true);
|
||||
ltcspec *= texture(sltcMag, tuv).a;
|
||||
|
||||
vec3 ltcdiff = ltcEvaluate(n, v, dotNV, p, mat3(1.0), lampArea0, lampArea1, lampArea2, lampArea3, false);
|
||||
direct = ltcdiff * albedo;// + ltcspec;
|
||||
vec3 ltcdiff = ltcEvaluate(n, v, dotNV, p, mat3(1.0), lampArea0, lampArea1, lampArea2, lampArea3, true);
|
||||
direct = ltcdiff * albedo + ltcspec;
|
||||
direct = clamp(direct, 0.0, 10.0);
|
||||
}
|
||||
else {
|
||||
// #endif
|
||||
#endif
|
||||
|
||||
#ifdef _OrenNayar
|
||||
direct = orenNayarDiffuseBRDF(albedo, metrough.y, dotNV, dotNL, dotVH) + specularBRDF(f0, metrough.y, dotNL, dotNH, dotNV, dotVH);
|
||||
|
@ -211,7 +214,9 @@ void main() {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef _PolyLight
|
||||
}
|
||||
#endif
|
||||
|
||||
// Aniso spec
|
||||
// #ifdef _Aniso
|
||||
|
|
|
@ -62,32 +62,32 @@
|
|||
{
|
||||
"name": "lampArea0",
|
||||
"link": "_lampArea0",
|
||||
"ifndef": ["_ifndefPolyLight"]
|
||||
"ifdef": ["_PolyLight"]
|
||||
},
|
||||
{
|
||||
"name": "lampArea1",
|
||||
"link": "_lampArea1",
|
||||
"ifndef": ["_ifndefPolyLight"]
|
||||
"ifdef": ["_PolyLight"]
|
||||
},
|
||||
{
|
||||
"name": "lampArea2",
|
||||
"link": "_lampArea2",
|
||||
"ifndef": ["_ifndefPolyLight"]
|
||||
"ifdef": ["_PolyLight"]
|
||||
},
|
||||
{
|
||||
"name": "lampArea3",
|
||||
"link": "_lampArea3",
|
||||
"ifndef": ["_ifndefPolyLight"]
|
||||
"ifdef": ["_PolyLight"]
|
||||
},
|
||||
{
|
||||
"name": "sltcMat",
|
||||
"link": "_ltcMat",
|
||||
"ifndef": ["_ifndefPolyLight"]
|
||||
"ifdef": ["_PolyLight"]
|
||||
},
|
||||
{
|
||||
"name": "sltcMag",
|
||||
"link": "_ltcMag",
|
||||
"ifndef": ["_ifndefPolyLight"]
|
||||
"ifdef": ["_PolyLight"]
|
||||
},
|
||||
{
|
||||
"name": "eye",
|
||||
|
|
|
@ -6,9 +6,9 @@ precision mediump float;
|
|||
|
||||
#include "../compiled.glsl"
|
||||
#include "../std/brdf.glsl"
|
||||
// #ifdef _PolyLight
|
||||
//#include "../std/ltc.glsl"
|
||||
// #endif
|
||||
#ifdef _PolyLight
|
||||
#include "../std/ltc.glsl"
|
||||
#endif
|
||||
#ifdef _Rad
|
||||
#include "../std/math.glsl"
|
||||
#endif
|
||||
|
@ -25,10 +25,10 @@ precision mediump float;
|
|||
// shIrradiance()
|
||||
//!uniform float shirr[27];
|
||||
|
||||
// #ifdef _PolyLight
|
||||
//-! uniform sampler2D sltcMat;
|
||||
//-! uniform sampler2D sltcMag;
|
||||
// #endif
|
||||
#ifdef _PolyLight
|
||||
//!uniform sampler2D sltcMat;
|
||||
//!uniform sampler2D sltcMag;
|
||||
#endif
|
||||
|
||||
#ifdef _BaseTex
|
||||
uniform sampler2D sbase;
|
||||
|
@ -82,12 +82,12 @@ uniform float spotlightCutoff;
|
|||
uniform float spotlightExponent;
|
||||
uniform float shadowsBias;
|
||||
uniform vec3 eye;
|
||||
// #ifdef _PolyLight
|
||||
// uniform vec3 lampArea0;
|
||||
// uniform vec3 lampArea1;
|
||||
// uniform vec3 lampArea2;
|
||||
// uniform vec3 lampArea3;
|
||||
// #endif
|
||||
#ifdef _PolyLight
|
||||
uniform vec3 lampArea0;
|
||||
uniform vec3 lampArea1;
|
||||
uniform vec3 lampArea2;
|
||||
uniform vec3 lampArea3;
|
||||
#endif
|
||||
|
||||
#ifdef _VoxelGI
|
||||
uniform sampler2D ssaotex;
|
||||
|
@ -288,24 +288,26 @@ void main() {
|
|||
// Direct
|
||||
vec3 direct;
|
||||
|
||||
// #ifdef _PolyLight
|
||||
// if (lightType == 3) { // Area
|
||||
// float theta = acos(dotNV);
|
||||
// vec2 tuv = vec2(roughness, theta / (0.5 * PI));
|
||||
// tuv = tuv * LUT_SCALE + LUT_BIAS;
|
||||
// vec4 t = texture(sltcMat, tuv);
|
||||
// mat3 Minv = mat3(
|
||||
// vec3(1.0, 0.0, t.y),
|
||||
// vec3(0.0, t.z, 0.0),
|
||||
// vec3(t.w, 0.0, t.x));
|
||||
#ifdef _PolyLight
|
||||
if (lightType == 3) { // Area
|
||||
float theta = acos(dotNV);
|
||||
vec2 tuv = vec2(roughness, theta / (0.5 * PI));
|
||||
tuv = tuv * LUT_SCALE + LUT_BIAS;
|
||||
// vec4 t = texture(sltcMat, tuv);
|
||||
vec4 t = clamp(texture(sltcMat, tuv), 0.0, 1.0);
|
||||
mat3 invM = mat3(
|
||||
vec3(1.0, 0.0, t.y),
|
||||
vec3(0.0, t.z, 0.0),
|
||||
vec3(t.w, 0.0, t.x));
|
||||
|
||||
// vec3 ltcspec = ltcEvaluate(n, v, dotNV, position, Minv, lampArea0, lampArea1, lampArea2, lampArea3, true);
|
||||
// ltcspec *= texture(sltcMag, tuv).a;
|
||||
vec3 ltcspec = ltcEvaluate(n, v, dotNV, position, invM, lampArea0, lampArea1, lampArea2, lampArea3, false);
|
||||
ltcspec *= texture(sltcMag, tuv).a;
|
||||
|
||||
// vec3 ltcdiff = ltcEvaluate(n, v, dotNV, position, mat3(1.0), lampArea0, lampArea1, lampArea2, lampArea3, true);
|
||||
// direct = ltcspec + ltcdiff * albedo;
|
||||
// }
|
||||
// else {
|
||||
vec3 ltcdiff = ltcEvaluate(n, v, dotNV, position, mat3(1.0), lampArea0, lampArea1, lampArea2, lampArea3, false);
|
||||
direct = ltcdiff * albedo + ltcspec;
|
||||
}
|
||||
else {
|
||||
#endif
|
||||
|
||||
// Direct
|
||||
#ifdef _OrenNayar
|
||||
|
@ -322,12 +324,11 @@ void main() {
|
|||
}
|
||||
}
|
||||
|
||||
//} ////
|
||||
|
||||
#ifdef _PolyLight
|
||||
}
|
||||
#endif
|
||||
|
||||
direct = direct * lightColor * lightStrength;
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef _VoxelGI
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
uniform sampler2D sltcMat;
|
||||
uniform sampler2D sltcMag;
|
||||
|
||||
const float LUT_SIZE = 64.0;
|
||||
const float LUT_SIZE = 64.0;
|
||||
const float LUT_SCALE = (LUT_SIZE - 1.0) / LUT_SIZE;
|
||||
const float LUT_BIAS = 0.5 / LUT_SIZE;
|
||||
const float LUT_BIAS = 0.5 / LUT_SIZE;
|
||||
|
||||
vec3 L0;
|
||||
vec3 L1;
|
||||
|
|
|
@ -1312,7 +1312,7 @@ class ArmoryExporter:
|
|||
self.export_object_transform(bobject, scene, o)
|
||||
|
||||
# 6 directional lamps
|
||||
if type == kNodeTypeLamp and objref.lamp_omni_shadows:
|
||||
if type == kNodeTypeLamp and objref.type == 'POINT' and objref.lamp_omni_shadows:
|
||||
self.make_fake_omni_lamps(o, bobject)
|
||||
|
||||
# Viewport Camera - overwrite active camera matrix with viewport matrix
|
||||
|
|
|
@ -202,7 +202,7 @@ def parse_shader(sres, c, con, defs, lines, parse_attributes):
|
|||
if 'ifndef' in l:
|
||||
def_found = False
|
||||
for d in defs:
|
||||
for link_def in l['ifdef']:
|
||||
for link_def in l['ifndef']:
|
||||
if d == link_def:
|
||||
def_found = True
|
||||
break
|
||||
|
|
|
@ -84,6 +84,12 @@ def build_node_tree(world):
|
|||
wrd.world_defs += '_Probes'
|
||||
break
|
||||
|
||||
# Area lamps
|
||||
for lamp in bpy.data.lamps:
|
||||
if lamp.type == 'AREA':
|
||||
wrd.world_defs += '_PolyLight'
|
||||
break
|
||||
|
||||
# Data will be written after render path has been processed to gather all defines
|
||||
return output
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ def init_properties():
|
|||
bpy.types.World.generate_radiance_sky_type = EnumProperty(
|
||||
items=[('Fake', 'Fake', 'Fake'),
|
||||
('Hosek', 'Hosek', 'Hosek')],
|
||||
name="Type", description="Prefiltered maps to be used for radiance.", default='Fake')
|
||||
name="Type", description="Prefiltered maps to be used for radiance.", default='Fake', update=assets.invalidate_envmap_data)
|
||||
bpy.types.World.arm_world_advanced = bpy.props.BoolProperty(name="Effects", default=False)
|
||||
bpy.types.World.generate_clouds = bpy.props.BoolProperty(name="Clouds", default=False, update=assets.invalidate_shader_cache)
|
||||
bpy.types.World.generate_clouds_density = bpy.props.FloatProperty(name="Density", default=0.5, min=0.0, max=10.0, update=assets.invalidate_shader_cache)
|
||||
|
|
|
@ -164,10 +164,11 @@ class DataPropsPanel(bpy.types.Panel):
|
|||
layout.prop(obj.data, 'lamp_clip_end')
|
||||
layout.prop(obj.data, 'lamp_fov')
|
||||
layout.prop(obj.data, 'lamp_shadows_bias')
|
||||
layout.prop(obj.data, 'lamp_omni_shadows')
|
||||
if obj.data.lamp_omni_shadows:
|
||||
layout.label('Warning: Will result in performance loss.')
|
||||
layout.label('Temporary implementation.')
|
||||
if obj.data.type == 'POINT':
|
||||
layout.prop(obj.data, 'lamp_omni_shadows')
|
||||
if obj.data.lamp_omni_shadows:
|
||||
layout.label('Warning: Will result in performance loss.')
|
||||
layout.label('Temporary implementation.')
|
||||
elif obj.type == 'SPEAKER':
|
||||
layout.prop(obj.data, 'loop')
|
||||
layout.prop(obj.data, 'stream')
|
||||
|
|
Loading…
Reference in a new issue