Rename tangent attrib

This commit is contained in:
Lubos Lenco 2017-03-02 10:15:22 +01:00
parent e4f25e4e11
commit 2e9b0451d1
6 changed files with 33 additions and 33 deletions

View file

@ -103,8 +103,7 @@ vec3 SSSSTransmittance(float translucency, float sssWidth, vec3 worldPosition, v
#endif
#ifndef _NoShadows
float shadowTest(vec4 lPos) {
lPos.xyz /= lPos.w;
float shadowTest(const vec3 lPos) {
#ifdef _Clampstc
// Filtering out of bounds, remove
@ -186,7 +185,7 @@ void main() {
#ifndef _NoShadows
vec4 lampPos = LWVP * vec4(p, 1.0);
if (lampPos.w > 0.0) {
visibility = shadowTest(lampPos);
visibility = shadowTest(lampPos.xyz / lampPos.w);
}
#endif

View file

@ -12,7 +12,7 @@ import armory.system.Keymap;
@:keep
class WalkNavigation extends Trait {
static inline var speed = 5.0;
static inline var speed = 50.0;
var camera:CameraObject;

View file

@ -1742,11 +1742,11 @@ class ArmoryExporter:
# Make tangents
if self.get_export_uvs(exportMesh) == True and self.get_export_tangents(exportMesh) == True and num_uv_layers > 0:
tana = {}
tana['attrib'] = "tangent"
tana['size'] = 3
tana['values'] = self.calc_tangents(pa['values'], na['values'], ta['values'], om['index_arrays'][0]['values'])
om['vertex_arrays'].append(tana)
tanga = {}
tanga['attrib'] = "tangent"
tanga['size'] = 3
tanga['values'] = self.calc_tangents(pa['values'], na['values'], ta['values'], om['index_arrays'][0]['values'])
om['vertex_arrays'].append(tanga)
return vert_list
@ -2033,11 +2033,11 @@ class ArmoryExporter:
# Export tangents
if self.get_export_tangents(exportMesh) == True and len(exportMesh.uv_textures) > 0:
tana = {}
tana['attrib'] = "tangent"
tana['size'] = 3
tana['values'] = self.calc_tangents(pa['values'], na['values'], ta['values'], om['index_arrays'][0]['values'])
om['vertex_arrays'].append(tana)
tanga = {}
tanga['attrib'] = "tangent"
tanga['size'] = 3
tanga['values'] = self.calc_tangents(pa['values'], na['values'], ta['values'], om['index_arrays'][0]['values'])
om['vertex_arrays'].append(tanga)
# Delete the new mesh that we made earlier
bpy.data.meshes.remove(exportMesh)
@ -2243,7 +2243,7 @@ class ArmoryExporter:
decals_used = True
uv_export = False
tan_export = False
tang_export = False
vcol_export = False
vs_str = ''
for elem in sd['vertex_structure']:
@ -2251,21 +2251,21 @@ class ArmoryExporter:
vs_str += ','
vs_str += elem['name']
if elem['name'] == 'tan':
tan_export = True
if elem['name'] == 'tang':
tang_export = True
elif elem['name'] == 'tex':
uv_export = True
elif elem['name'] == 'col':
vcol_export = True
material.vertex_structure = vs_str
if (material.export_tangents != tan_export) or \
if (material.export_tangents != tang_export) or \
(material.export_uvs != uv_export) or \
(material.export_vcols != vcol_export):
material.export_uvs = uv_export
material.export_vcols = vcol_export
material.export_tangents = tan_export
material.export_tangents = tang_export
mat_users = self.materialToObjectDict[material]
for ob in mat_users:
ob.data.mesh_cached = False

View file

@ -822,7 +822,7 @@ def parse_normal_map_color_input(inp, str_inp=None):
frag.write('vec3 n = ({0}) * 2.0 - 1.0;'.format(parse_vector_input(inp)))
parse_teximage_vector = True
frag.write('n = normalize(TBN * normalize(n));')
mat_state.data.add_elem('tan', 3)
mat_state.data.add_elem('tang', 3)
frag.write_pre = False
def parse_value_input(inp):

View file

@ -101,12 +101,12 @@ def make_base(con_mesh, parse_opacity):
make_tess.interpolate(tese, 'vcolor', 3, declare_out=frag.contains('vcolor'))
tese.write_pre = False
if mat_state.data.is_elem('tan'):
if mat_state.data.is_elem('tang'):
if tese != None:
vert.add_out('vec3 wnormal')
vert.add_out('vec3 wtangent')
write_norpos(vert)
vert.write('wtangent = normalize(mat3(N) * tan);')
vert.write('wtangent = normalize(mat3(N) * tang);')
tese.add_out('mat3 TBN')
make_tess.interpolate(tese, 'wtangent', 3, normalize=True)
tese.write('vec3 wbitangent = normalize(cross(wnormal, wtangent));')
@ -114,7 +114,7 @@ def make_base(con_mesh, parse_opacity):
else:
vert.add_out('mat3 TBN')
write_norpos(vert, declare=True)
vert.write('vec3 tangent = normalize(mat3(N) * tan);')
vert.write('vec3 tangent = normalize(mat3(N) * tang);')
vert.write('vec3 bitangent = normalize(cross(wnormal, tangent));')
vert.write('TBN = mat3(tangent, bitangent, wnormal);')
else:
@ -234,6 +234,15 @@ def make_forward_base(con_mesh, parse_opacity=False):
is_pcss = False
frag.write('float visibility = 1.0;')
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);')
if is_shadows:
if tese != None:
tese.add_out('vec4 lampPos')
@ -257,6 +266,7 @@ def make_forward_base(con_mesh, parse_opacity=False):
frag.write('if (receiveShadow && lampPos.w > 0.0) {')
frag.tab += 1
frag.write('vec3 lpos = lampPos.xyz / lampPos.w;')
# frag.write('float bias = clamp(shadowsBias * 1.0 * tan(acos(clamp(dotNL, 0.0, 1.0))), 0.0, 0.01);')
if is_pcss:
frag.write('visibility = PCSS(lpos.xy, lpos.z - shadowsBias);')
else:
@ -264,15 +274,6 @@ 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) {')

View file

@ -41,7 +41,7 @@ class ShaderData:
# TODO: temporary, Sort vertex data
for sd in self.data['shader_datas']:
vs = []
ar = ['pos', 'nor', 'tex', 'tex1', 'col', 'tan', 'bone', 'weight', 'off']
ar = ['pos', 'nor', 'tex', 'tex1', 'col', 'tang', 'bone', 'weight', 'off']
for ename in ar:
elem = self.get_elem(ename)
if elem != None: