mirror of https://github.com/AxioDL/metaforce.git
Lightmap UV fixes
This commit is contained in:
parent
4a490e7d43
commit
54d2759ace
|
@ -35,6 +35,7 @@ void ReadBabeDeadLightToBlender(hecl::blender::PyOutStream& os,
|
||||||
os.format("lamp = bpy.data.lamps.new('LAMP_%01u_%03u', 'POINT')\n"
|
os.format("lamp = bpy.data.lamps.new('LAMP_%01u_%03u', 'POINT')\n"
|
||||||
"lamp.color = (%f,%f,%f)\n"
|
"lamp.color = (%f,%f,%f)\n"
|
||||||
"lamp_obj = bpy.data.objects.new(lamp.name, lamp)\n"
|
"lamp_obj = bpy.data.objects.new(lamp.name, lamp)\n"
|
||||||
|
"lamp.shadow_soft_size = 1.0\n"
|
||||||
"lamp.shadow_method = '%s'\n"
|
"lamp.shadow_method = '%s'\n"
|
||||||
"\n", s, l, light.color.vec[0], light.color.vec[1], light.color.vec[2],
|
"\n", s, l, light.color.vec[0], light.color.vec[1], light.color.vec[2],
|
||||||
light.castShadows ? "RAY_SHADOW" : "NOSHADOW");
|
light.castShadows ? "RAY_SHADOW" : "NOSHADOW");
|
||||||
|
@ -47,6 +48,7 @@ void ReadBabeDeadLightToBlender(hecl::blender::PyOutStream& os,
|
||||||
"lamp_obj = bpy.data.objects.new(lamp.name, lamp)\n"
|
"lamp_obj = bpy.data.objects.new(lamp.name, lamp)\n"
|
||||||
"lamp_obj.rotation_mode = 'QUATERNION'\n"
|
"lamp_obj.rotation_mode = 'QUATERNION'\n"
|
||||||
"lamp_obj.rotation_quaternion = Vector((0,0,-1)).rotation_difference(Vector((%f,%f,%f)))\n"
|
"lamp_obj.rotation_quaternion = Vector((0,0,-1)).rotation_difference(Vector((%f,%f,%f)))\n"
|
||||||
|
"lamp.shadow_soft_size = 0.5\n"
|
||||||
"lamp.shadow_method = '%s'\n"
|
"lamp.shadow_method = '%s'\n"
|
||||||
"\n", s, l, light.color.vec[0], light.color.vec[1], light.color.vec[2],
|
"\n", s, l, light.color.vec[0], light.color.vec[1], light.color.vec[2],
|
||||||
zeus::degToRad(light.spotCutoff),
|
zeus::degToRad(light.spotCutoff),
|
||||||
|
@ -77,7 +79,7 @@ void ReadBabeDeadLightToBlender(hecl::blender::PyOutStream& os,
|
||||||
switch (light.falloff)
|
switch (light.falloff)
|
||||||
{
|
{
|
||||||
case BabeDeadLight::Falloff::Constant:
|
case BabeDeadLight::Falloff::Constant:
|
||||||
os << "falloff_node.inputs[0].default_value *= 75.0\n"
|
os << "falloff_node.inputs[0].default_value *= 150.0\n"
|
||||||
"lamp.node_tree.links.new(falloff_node.outputs[2], lamp.node_tree.nodes['Emission'].inputs[1])\n";
|
"lamp.node_tree.links.new(falloff_node.outputs[2], lamp.node_tree.nodes['Emission'].inputs[1])\n";
|
||||||
if (light.q > FLT_EPSILON)
|
if (light.q > FLT_EPSILON)
|
||||||
os.format("lamp.constant_coefficient = 2.0 / %f\n", light.q);
|
os.format("lamp.constant_coefficient = 2.0 / %f\n", light.q);
|
||||||
|
|
|
@ -497,12 +497,19 @@ void InitGeomBlenderContext(hecl::blender::PyOutStream& os,
|
||||||
"\n"
|
"\n"
|
||||||
" return face, ret_mesh\n"
|
" return face, ret_mesh\n"
|
||||||
"\n"
|
"\n"
|
||||||
"def expand_lightmap_triangle(uva, uvb, uvc):\n"
|
"def expand_lightmap_triangle(lightmap_tri_tracker, uva, uvb, uvc):\n"
|
||||||
" result = ([uva[0],uva[1]], [uvb[0],uvb[1]], [uvc[0],uvc[1]])\n"
|
" result = ([uva[0],uva[1]], [uvb[0],uvb[1]], [uvc[0],uvc[1]])\n"
|
||||||
|
" inst = 0\n"
|
||||||
|
" if uva in lightmap_tri_tracker:\n"
|
||||||
|
" inst = lightmap_tri_tracker[uva]\n"
|
||||||
|
" lightmap_tri_tracker[uva] = inst + 1\n"
|
||||||
" if uva == uvb:\n"
|
" if uva == uvb:\n"
|
||||||
" result[1][0] += 0.005\n"
|
" result[1][0] += 0.005\n"
|
||||||
" if uva == uvc:\n"
|
" if uva == uvc:\n"
|
||||||
" result[2][1] -= 0.005\n"
|
" result[2][1] -= 0.005\n"
|
||||||
|
" if inst & 0x1 and uva == uvb and uva == uvc:\n"
|
||||||
|
" result[0][0] += 0.005\n"
|
||||||
|
" result[0][1] -= 0.005\n"
|
||||||
" return result\n"
|
" return result\n"
|
||||||
"\n";
|
"\n";
|
||||||
|
|
||||||
|
@ -619,7 +626,9 @@ atUint32 ReadGeomSectionsToBlender(hecl::blender::PyOutStream& os,
|
||||||
"od_list = []\n"
|
"od_list = []\n"
|
||||||
"\n"
|
"\n"
|
||||||
"orig_pidx_lay = bm.verts.layers.int.new('CMDLOriginalPosIdxs')\n"
|
"orig_pidx_lay = bm.verts.layers.int.new('CMDLOriginalPosIdxs')\n"
|
||||||
"orig_nidx_lay = bm.loops.layers.int.new('CMDLOriginalNormIdxs')\n";
|
"orig_nidx_lay = bm.loops.layers.int.new('CMDLOriginalNormIdxs')\n"
|
||||||
|
"\n"
|
||||||
|
"lightmap_tri_tracker = {}\n";
|
||||||
|
|
||||||
if (rp.first)
|
if (rp.first)
|
||||||
os << "dvert_lay = bm.verts.layers.deform.verify()\n";
|
os << "dvert_lay = bm.verts.layers.deform.verify()\n";
|
||||||
|
@ -908,7 +917,7 @@ atUint32 ReadGeomSectionsToBlender(hecl::blender::PyOutStream& os,
|
||||||
for (unsigned j=0 ; j<matUVCount ; ++j)
|
for (unsigned j=0 ; j<matUVCount ; ++j)
|
||||||
{
|
{
|
||||||
if (j==0 && matShortUVs)
|
if (j==0 && matShortUVs)
|
||||||
os.format(" uv_tri = expand_lightmap_triangle(suv_list[%u], suv_list[%u], suv_list[%u])\n"
|
os.format(" uv_tri = expand_lightmap_triangle(lightmap_tri_tracker, suv_list[%u], suv_list[%u], suv_list[%u])\n"
|
||||||
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[0]\n"
|
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[0]\n"
|
||||||
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[1]\n"
|
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[1]\n"
|
||||||
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[2]\n",
|
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[2]\n",
|
||||||
|
@ -942,7 +951,7 @@ atUint32 ReadGeomSectionsToBlender(hecl::blender::PyOutStream& os,
|
||||||
for (unsigned j=0 ; j<matUVCount ; ++j)
|
for (unsigned j=0 ; j<matUVCount ; ++j)
|
||||||
{
|
{
|
||||||
if (j==0 && matShortUVs)
|
if (j==0 && matShortUVs)
|
||||||
os.format(" uv_tri = expand_lightmap_triangle(suv_list[%u], suv_list[%u], suv_list[%u])\n"
|
os.format(" uv_tri = expand_lightmap_triangle(lightmap_tri_tracker, suv_list[%u], suv_list[%u], suv_list[%u])\n"
|
||||||
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[0]\n"
|
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[0]\n"
|
||||||
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[1]\n"
|
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[1]\n"
|
||||||
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[2]\n",
|
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[2]\n",
|
||||||
|
@ -988,7 +997,7 @@ atUint32 ReadGeomSectionsToBlender(hecl::blender::PyOutStream& os,
|
||||||
for (unsigned j=0 ; j<matUVCount ; ++j)
|
for (unsigned j=0 ; j<matUVCount ; ++j)
|
||||||
{
|
{
|
||||||
if (j==0 && matShortUVs)
|
if (j==0 && matShortUVs)
|
||||||
os.format(" uv_tri = expand_lightmap_triangle(suv_list[%u], suv_list[%u], suv_list[%u])\n"
|
os.format(" uv_tri = expand_lightmap_triangle(lightmap_tri_tracker, suv_list[%u], suv_list[%u], suv_list[%u])\n"
|
||||||
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[0]\n"
|
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[0]\n"
|
||||||
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[1]\n"
|
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[1]\n"
|
||||||
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[2]\n",
|
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[2]\n",
|
||||||
|
@ -1034,7 +1043,7 @@ atUint32 ReadGeomSectionsToBlender(hecl::blender::PyOutStream& os,
|
||||||
for (unsigned j=0 ; j<matUVCount ; ++j)
|
for (unsigned j=0 ; j<matUVCount ; ++j)
|
||||||
{
|
{
|
||||||
if (j==0 && matShortUVs)
|
if (j==0 && matShortUVs)
|
||||||
os.format(" uv_tri = expand_lightmap_triangle(suv_list[%u], suv_list[%u], suv_list[%u])\n"
|
os.format(" uv_tri = expand_lightmap_triangle(lightmap_tri_tracker, suv_list[%u], suv_list[%u], suv_list[%u])\n"
|
||||||
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[0]\n"
|
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[0]\n"
|
||||||
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[1]\n"
|
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[1]\n"
|
||||||
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[2]\n",
|
" loop_from_facevert(last_mesh, last_face, %u)[last_mesh.loops.layers.uv[%u]].uv = uv_tri[2]\n",
|
||||||
|
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
||||||
Subproject commit 9120c838d48a0660501949c92a6ca47668637096
|
Subproject commit 343aae42e2ff945ed5436a3c250901a2101db625
|
Loading…
Reference in New Issue