|
3 registered members (AndrewAMD, Grant, Neb),
908
guests, and 6
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: ingame light mapper
[Re: DavidLancaster]
#135222
06/21/07 10:12
06/21/07 10:12
|
Joined: Sep 2003
Posts: 5,900 Bielefeld, Germany
Pappenheimer
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
|
Just a fast way to get the model with a second uv-map:
Save the model with its name and an addition like _lm, then click through the skins and groups in the Skin Editor and change the skinsettings, that all parts of the mesh share the texture of the first one, choose all, and scale them down to the tenth or so of the skin texture (maybe, you have to do this several times switching from group to group etc.), then switch to the 3D Editor and choose a single triangle of that side that you want to be mapped in the upper left corner of your lightmap, (Options -> Sync Skin Selection must be checked) switch back to the Skin Editor and click Select connected, move that part of the uv to the upper left corner, switch to 3D Editor again, choose the next part which you want to line up the first one etc. etc. Save the model again.
@DavidLancaster : From my photographs, made seamless in the Seamless Texture Generator.
Last edited by Pappenheimer; 06/21/07 10:45.
|
|
|
Re: ingame light mapper
[Re: Pappenheimer]
#135223
07/31/07 22:39
07/31/07 22:39
|
Joined: Sep 2003
Posts: 5,900 Bielefeld, Germany
Pappenheimer
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
|
Once again: A hurray to the programmer of the meshplugin: Long live Ventilator!  I just try to force me to write down the workflow of how to achieve something like this simply with MED, WED and ventilator's meshplugin and lightmapper. Anyone interested? 
|
|
|
Re: ingame light mapper
[Re: Uhrwerk]
#135227
08/16/07 20:10
08/16/07 20:10
|
Joined: Sep 2003
Posts: 5,900 Bielefeld, Germany
Pappenheimer
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
|
Just a short addition to the things that I already mentioned in this thread about the workflow, because I won't find time to give you a step by step explanation within the next two weeks:
Beside the model which shall have a second uv-map for the shadowing you need the second version of the model with a mapping of its skin where every polygon has its own place of the map!
Then you need two scripts. One for getting the mesh-file of the model's second version and producing and ingame-editing of the lightmap, and saving the lightmap as a png-file. And a second script for including the already shadowed model in a game.
Assign the needed script in WED, you can't use them both at once!
#1 Script(note, you have to check the model's polygon flag and flag8 in the properties:
It is the light.wdl of ventilator's lightmapper, there is only one small addition in the function 'lightallentities':
function lightallentities()//light the entities and save them as pngs { tempentity = ent_next(0); while(tempentity != 0) { if(tempentity.flag8) { tempmaterial = tempentity.material; l_light(tempentity, tempmaterial.skin1); str_for_entfile(tempstring, tempentity); str_trunc(tempstring, 4); str_cat(tempstring, "_lm.png"); bmap_save(tempmaterial.skin1,tempstring); wait(2); } tempentity = ent_next(tempentity); } }
----------------------------------------------------------------- #2 Script is this:
var video_mode = 8;
plugindir = "."; dllfunction ent_exportmesh(entity, filename); dllfunction ent_importmesh(entity, filename); dllfunction ent_loadseconduvset(entity1, entity2);
material* tempmaterial; entity* tempentity; entity* tempentity2; string tempstring;
//----------------------------------------------------------------------------- mtl_lightmap
material mtl_lightmap { effect= " texture mtlSkin1; texture entSkin1;
technique t0 { pass p0 { Texture[0]=<mtlSkin1>; Texture[1]=<entSkin1>; // mix light map with dynamic lighting TexCoordIndex[0] = 1; ColorArg1[0] = Texture; ColorOp[0] = AddSigned; ColorArg2[0] = Diffuse; // apply lighting to texture TexCoordIndex[1] = 0; ColorArg1[1] = Texture; ColorOp[1] = Modulate2x; ColorArg2[1] = Current; } } "; }
//----------------------------------------------------------------------------- main function file_exists(filename) { var filehandle; filehandle = file_open_read(filename); if(filehandle) { file_close(filehandle); return(1); } else { return(0); } }
string tempstring1; string tempstring2; material* tempmaterial;
function applylightmaps() { you = ent_next(0); while(you != 0) { str_for_entfile(tempstring1, you); str_trunc(tempstring1, 4); str_cpy(tempstring2, tempstring1); str_cat(tempstring1, "_lm.mdl"); str_cat(tempstring2, "_lm.png");
if(file_exists(tempstring1) && file_exists(tempstring2)) { you.material = mtl_create(); // they should be removed again when changing the level tempmaterial = you.material; tempmaterial.effect = mtl_lightmap.effect; tempmaterial.skin1 = bmap_create(tempstring2); // they should be removed again when changing the level tempentity = ent_create(tempstring1, nullvector, 0); ent_loadseconduvset(you, tempentity); ent_remove(tempentity); } you = ent_next(you); } }
function main() { wait(3); level_load("example.wmb"); wait(1); vec_set(sky_color, vector(250, 175, 75)); vec_set(sun_angle, vector(160, -35, 0)); sun_light = 20; vec_set(camera.x, vector(300, 0, 200)); camera.pan = 180;
applylightmaps(); }
----------------------------------------------------------------------- Again, thanks to ventilator, who helped me to complete these scripts!
(The shadowmap is saved as png, because it is the only format that the directx function saves without a mistake, if you want to save it as tga or bmp, you can change that in the script, but after saving in that formats, you have to open them each in a grafic tool and save them again, to get the correct results!)
|
|
|
Re: ingame light mapper
[Re: ventilator]
#238697
11/29/08 12:49
11/29/08 12:49
|
Joined: Jun 2006
Posts: 379 Flevoland, 5 meters under wate...
Roel
Senior Member
|
Senior Member
Joined: Jun 2006
Posts: 379
Flevoland, 5 meters under wate...
|
To get rid of artifarcts, you could use a small margin between two uv triangles that shouldn't merge. Blender uses this option, and I think the margin should be around 2 pixels. Another thing that could cause artifarcts is mip mapping, but I think you already disabled it
Last edited by Roel; 11/29/08 12:50.
|
|
|
|