Exporter fixes
This commit is contained in:
parent
a8c86b373f
commit
cda8276477
|
@ -20,6 +20,10 @@ void main() {
|
|||
// Velocity is assumed to be calculated for motion blur, so we need to inverse it for reprojection
|
||||
vec2 velocity = -textureLod(sveloc, texCoord, 0.0).rg;
|
||||
|
||||
#ifdef HLSL
|
||||
velocity.y = -velocity.y;
|
||||
#endif
|
||||
|
||||
// Reproject current coordinates and fetch previous pixel
|
||||
vec4 previous = textureLod(tex2, texCoord + velocity, 0.0);
|
||||
|
||||
|
|
|
@ -198,6 +198,7 @@ class DebugConsole extends Trait {
|
|||
var loc = selectedObject.transform.loc;
|
||||
var scale = selectedObject.transform.scale;
|
||||
var rot = selectedObject.transform.rot.getEuler();
|
||||
var dim = selectedObject.transform.dim;
|
||||
rot.mult(180 / 3.141592);
|
||||
var f = 0.0;
|
||||
|
||||
|
@ -266,6 +267,24 @@ class DebugConsole extends Trait {
|
|||
f = Std.parseFloat(ui.textInput(h, "Z"));
|
||||
if (ui.changed) scale.z = f;
|
||||
|
||||
ui.row(row4);
|
||||
ui.text("Dimensions");
|
||||
|
||||
h = Id.handle();
|
||||
h.text = Math.roundfp(dim.x) + "";
|
||||
f = Std.parseFloat(ui.textInput(h, "X"));
|
||||
if (ui.changed) dim.x = f;
|
||||
|
||||
h = Id.handle();
|
||||
h.text = Math.roundfp(dim.y) + "";
|
||||
f = Std.parseFloat(ui.textInput(h, "Y"));
|
||||
if (ui.changed) dim.y = f;
|
||||
|
||||
h = Id.handle();
|
||||
h.text = Math.roundfp(dim.z) + "";
|
||||
f = Std.parseFloat(ui.textInput(h, "Z"));
|
||||
if (ui.changed) dim.z = f;
|
||||
|
||||
selectedObject.transform.dirty = true;
|
||||
|
||||
if (selectedObject.traits.length > 0) {
|
||||
|
|
|
@ -827,7 +827,10 @@ class ArmoryExporter:
|
|||
for i in range(0, num_psys):
|
||||
self.export_particle_system_ref(bobject.particle_systems[i], i, o)
|
||||
|
||||
o['dimensions'] = [bobject.data.arm_aabb[0], bobject.data.arm_aabb[1], bobject.data.arm_aabb[2]]
|
||||
aabb = bobject.data.arm_aabb
|
||||
if aabb[0] == 0 and aabb[1] == 0 and aabb[2] == 0:
|
||||
self.calc_aabb(bobject)
|
||||
o['dimensions'] = [aabb[0], aabb[1], aabb[2]]
|
||||
|
||||
#shapeKeys = ArmoryExporter.get_shape_keys(objref)
|
||||
#if shapeKeys:
|
||||
|
@ -1164,6 +1167,14 @@ class ArmoryExporter:
|
|||
else:
|
||||
self.output['mesh_datas'].append(o)
|
||||
|
||||
def calc_aabb(self, bobject):
|
||||
aabb_center = 0.125 * sum((Vector(b) for b in bobject.bound_box), Vector())
|
||||
bobject.data.arm_aabb = [ \
|
||||
abs((bobject.bound_box[6][0] - bobject.bound_box[0][0]) / 2 + abs(aabb_center[0])) * 2, \
|
||||
abs((bobject.bound_box[6][1] - bobject.bound_box[0][1]) / 2 + abs(aabb_center[1])) * 2, \
|
||||
abs((bobject.bound_box[6][2] - bobject.bound_box[0][2]) / 2 + abs(aabb_center[2])) * 2 \
|
||||
]
|
||||
|
||||
def export_mesh_data(self, exportMesh, bobject, o, has_armature=False):
|
||||
exportMesh.calc_normals_split()
|
||||
# exportMesh.calc_loop_triangles()
|
||||
|
@ -1216,14 +1227,6 @@ class ArmoryExporter:
|
|||
if has_col:
|
||||
cdata = np.empty(num_verts * 3, dtype='<f4')
|
||||
|
||||
# Save aabb
|
||||
aabb_center = 0.125 * sum((Vector(b) for b in bobject.bound_box), Vector())
|
||||
bobject.data.arm_aabb = [ \
|
||||
abs((bobject.bound_box[6][0] - bobject.bound_box[0][0]) / 2 + abs(aabb_center[0])) * 2, \
|
||||
abs((bobject.bound_box[6][1] - bobject.bound_box[0][1]) / 2 + abs(aabb_center[1])) * 2, \
|
||||
abs((bobject.bound_box[6][2] - bobject.bound_box[0][2]) / 2 + abs(aabb_center[2])) * 2 \
|
||||
]
|
||||
|
||||
# Scale for packed coords
|
||||
maxdim = max(bobject.data.arm_aabb[0], max(bobject.data.arm_aabb[1], bobject.data.arm_aabb[2]))
|
||||
o['scale_pos'] = maxdim / 2
|
||||
|
@ -1481,6 +1484,10 @@ class ArmoryExporter:
|
|||
if len(exportMesh.uv_layers) > 2:
|
||||
log.warn(oid + ' exceeds maximum of 2 UV Maps supported')
|
||||
|
||||
# Update aabb
|
||||
self.calc_aabb(bobject)
|
||||
o['dimensions'] = [bobject.data.arm_aabb[0], bobject.data.arm_aabb[1], bobject.data.arm_aabb[2]]
|
||||
|
||||
# Process meshes
|
||||
if ArmoryExporter.optimize_enabled:
|
||||
vert_list = exporter_opt.export_mesh_data(self, exportMesh, bobject, o, has_armature=armature != None)
|
||||
|
@ -1546,7 +1553,7 @@ class ArmoryExporter:
|
|||
else:
|
||||
o['shadowmap_size'] = 0
|
||||
if o['type'] == 'sun': # Scale bias for ortho light matrix
|
||||
o['shadows_bias'] *= 25.0
|
||||
o['shadows_bias'] *= 20.0
|
||||
if o['shadowmap_size'] > 1024:
|
||||
o['shadows_bias'] *= 1 / (o['shadowmap_size'] / 1024) # Less bias for bigger maps
|
||||
if (objtype == 'POINT' or objtype == 'SPOT') and objref.shadow_soft_size > 0.1:
|
||||
|
|
|
@ -38,7 +38,7 @@ class Vertex:
|
|||
|
||||
def export_mesh_data(self, exportMesh, bobject, o, has_armature=False):
|
||||
exportMesh.calc_normals_split()
|
||||
exportMesh.calc_tessface() # free_mpoly=True
|
||||
# exportMesh.calc_loop_triangles()
|
||||
vert_list = { Vertex(exportMesh, loop) : 0 for loop in exportMesh.loops}.keys()
|
||||
num_verts = len(vert_list)
|
||||
num_uv_layers = len(exportMesh.uv_layers)
|
||||
|
@ -245,12 +245,12 @@ def export_skin(self, bobject, armature, vert_list, o):
|
|||
oskin['transformsI'] = []
|
||||
if rpdat.arm_skin == 'CPU':
|
||||
for i in range(bone_count):
|
||||
skeletonI = self.mulmat(armature.matrix_world, bone_array[i].matrix_local).inverted_safe()
|
||||
skeletonI = (armature.matrix_world @ bone_array[i].matrix_local).inverted_safe()
|
||||
oskin['transformsI'].append(self.write_matrix(skeletonI))
|
||||
else:
|
||||
for i in range(bone_count):
|
||||
skeletonI = self.mulmat(armature.matrix_world, bone_array[i].matrix_local).inverted_safe()
|
||||
skeletonI = self.mulmat(skeletonI, bobject.matrix_world)
|
||||
skeletonI = (armature.matrix_world @ bone_array[i].matrix_local).inverted_safe()
|
||||
skeletonI = (skeletonI @ bobject.matrix_world)
|
||||
oskin['transformsI'].append(self.write_matrix(skeletonI))
|
||||
|
||||
# Export the per-vertex bone influence data
|
||||
|
|
|
@ -225,13 +225,15 @@ def make_ao(context_id):
|
|||
|
||||
vert.add_uniform('mat4 W', '_worldMatrix')
|
||||
vert.write('uniform float4x4 W;')
|
||||
if rpdat.arm_voxelgi_revoxelize and rpdat.arm_voxelgi_camera:
|
||||
vert.add_uniform('vec3 eyeSnap', '_cameraPositionSnap')
|
||||
vert.write('uniform float3 eyeSnap;')
|
||||
vert.write('struct SPIRV_Cross_Input { float4 pos : TEXCOORD0; };')
|
||||
vert.write('struct SPIRV_Cross_Output { float4 svpos : SV_POSITION; };')
|
||||
vert.write('SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) {')
|
||||
vert.write(' SPIRV_Cross_Output stage_output;')
|
||||
voxHalfExt = str(round(rpdat.arm_voxelgi_dimensions / 2.0))
|
||||
if rpdat.arm_voxelgi_revoxelize and rpdat.arm_voxelgi_camera:
|
||||
vert.add_uniform('vec3 eyeSnap', '_cameraPositionSnap')
|
||||
vert.write(' stage_output.svpos.xyz = (mul(float4(stage_input.pos.xyz, 1.0), W).xyz- eyeSnap) / float3(' + voxHalfExt + ', ' + voxHalfExt + ', ' + voxHalfExt + ');')
|
||||
else:
|
||||
vert.write(' stage_output.svpos.xyz = mul(float4(stage_input.pos.xyz, 1.0), W).xyz / float3(' + voxHalfExt + ', ' + voxHalfExt + ', ' + voxHalfExt + ');')
|
||||
|
|
Loading…
Reference in a new issue