Loading in lightmap textures
Blitz3D Forums/Blitz3D Programming/Loading in lightmap textures
| ||
how would i load a uv lightmap i made into blitz and apply it to a model so that it is used as a lightmap? |
| ||
doesnt anyone know this? |
| ||
You made a model and it has a lightmap and you want it to load it? For me, Blitz has automatically just loaded it with my *.b3d file. Try exporting your model to a .b3d and then put the lightmap in the same folder. Works for me! |
| ||
i cant export to b3d because lightwave doesnt have a decent program for that yet, i have .x models that i need to load a lightmap for, how do i do that? |
| ||
i cant export to b3d because lightwave doesnt have a decent program for that yet ? If you have LW then all you need is Lee's free convertor. Problem solved, lightmapped models converted to .b3d with one click. |
| ||
Plus there's a converter in the Code Archives to convert .x to .b3d |
| ||
... (accidental double-post) |
| ||
ok so lets say i have a b3d file then, how do i load a lightmap to it? |
| ||
? anyone? |
| ||
The B3D file will contain both sets of UVs (texture and lighting) as well as references to your texture and lightmap image files. So just load the B3D and you're done. ...or are you hoping to load and swap multiple lightmap images? |
| ||
how do i add a lightmap image to a b3d file???? i have a uv texture i want to use as a lightmap, and a model. |
| ||
bleh |
| ||
I think perhaps people are misunderstanding your question. You need a special piece of software that generates the lightmap as an external image (not part of the mesh/model). Try SlimShady in the Tools section. The resulting file is (usually) a bitmap. For example, if your model is 'house.b3d' then the lightmap should be called 'house_lm.bmp'. If the '_lm.bmp' letters are added to the basic name of the model then Blitz will know what it is, and automatically load and implement it as it loads your model. |
| ||
thanks a lot john, finally an answer i could use. Does this work for .x models too or just b3ds? |
| ||
Yes, for any model that Blitz can load. Actually I couldn't believe that it was that easy when I first realised, but Mark Sibly does think ahead, and he implemented a very easy method for users. You should also check out Maplet (which is free elsewhere within the Blitz sight). It's a nice simple program by Mark Sibly which (a) gets you going if (like me) you'd never modelled before, and (b) can produce a lightmap from your model. |
| ||
Even if you wanna use 3DS or X file format. You have to export 2 meshes. One with textures you normally apply on it, and second with only lightmap texture applied on it. Here is the code.. Graphics3D 800,600,32,2 camera=CreateCamera() map=LoadAnimMesh("MESH.3ds") litemap=LoadAnimMesh("Mesh1.3ds") t=LoadTexture("lmap.tga") MapVertices(map,litemap,t) FreeEntity litemap FreeTexture t MoveEntity camera,0,200,-500 PointEntity camera,map While Not KeyHit(1) TurnEntity map,0,0.1,0 UpdateWorld RenderWorld Flip Wend End ;===================== Function MapVertices(model,copy,texture) WriteLine Log,"Limb "+EntityName(model)+" contains "+CountChildren(model)+" children, "+CountSurfaces(model)+" surfaces. For n=1 To CountSurfaces(model) surf=GetSurface(model,n) WriteLine Log,"Limb "+EntityName(model)+", surface "+n+" contains "+CountVertices(surf)+" vertices." Next For n=1 To CountSurfaces(model) surf=GetSurface(model,n) lsurf=GetSurface(copy,n) For v=0 To CountVertices(surf)-1 tu#=VertexU#(lsurf,v) tv#=VertexV#(lsurf,v) tw#=VertexW#(lsurf,v) VertexTexCoords surf,v,tu,tv,tw,1 Next Next TextureCoords texture,1 EntityTexture model,texture,0,1 For e=1 To CountChildren(Model) limb=GetChild(model,e) limb2=GetChild(copy,e) MapVertices(limb,limb2,texture) Next End Function |
| ||
Even if you wanna use 3DS or X file format. You have to export 2 meshes. One with textures you normally apply on it, and second with only lightmap texture applied on it. Here is the code.. That's not true if you use the b3d format, which is why you should never be using .x and .3ds formats. |
| ||
also might want to play around with brush blendmodes to get the desired lightmapping effect you want. 2xmultiply/fullbright etc. |
| ||
Well...as I know , procedure i explain working well with .3ds and X files.. |
| ||
This brings up a question... Is it possible to swap lightmaps ? Say in your game, you would like to load lightmap A for daytime, lightmap B at sunset, and lightmap C for nighttime, etc... Or... what about load no lightmap at night... |
| ||
Well...as I know , procedure i explain working well with .3ds and X files.. That still doesn't address the issue of why you would use .3ds or .x files in the first place. They have absolutely no advantages over b3d that I can see, and they have a whole set of disadvantages, quite apart from the fact that you need to code around their lack of support for 2 UV channels. |
| ||
I agree Sybixsus, what I was try to explain is way how to load separately lightmap with different types of meshes since EvilMeowChi using Lightwave and no have B3D exporter..I was just explain possible solutions for him with formats he can use without b3d exporter, according to his question..I wasnt try to compare B3D with rest of the formats..soo.. |
| ||
Check out Decorator in the Tools section... I generally export from any modeller I use in .X format, then load into Decorator and export as .B3D - a cheap option. |
| ||
For manually loading a lightmap after the fact of a b3d model:map=LoadMesh("testmap.b3d") lmap=LoadTexture("testmap_lm.bmp",16+32) TextureCoords lmap,1 TextureBlend lmap,2 EntityTexture map,lmap,0,1 EntityFX map,1 You can load and apply alternate day/night lightmaps this way. |