Lightmapping problem

Blitz3D Forums/Blitz3D Programming/Lightmapping problem

Naughty Alien(Posted 2004) [#1]
Does anyone know how to solve problem with lightmaps?? I'm build excellent level in 3DSMAX, after that light everything with Radiosity, and thing looking good. Now, problem is how to export light information? I'm try to do texture baking, but it was wrong way..all textures (especially on bigger surfaces) was not good at all after baking..so, i try to use lightmap baking, but still cant properly apply lightmap texture on to exported 3DS file. I'm found tutorial how to do that with B3D and pudding exporter for max..nice thing, but somehow, exported B3D is not possible to load in to Blitz, and i get error message like memory acess violation, while with 3DS I no have problem at all..so, is it possible to apply lightmap texture on to 3DS inside Blitz3D? Anyone can help??


Dreamora(Posted 2004) [#2]
for 3DS you need 2 models as 3DS does not support multiple UV coords which you need for lightmapping.

-> export 1 3DS file with the regular geometry and texturing
-> export a second 3DS file with the geometry and the lightmap applied


Hujiklo(Posted 2004) [#3]
I don't think you'll get very good or accurate results using Max baked maps - it's a bit of a bodge and not really useful for large or outdoor areas. I tried experimenting a while back and in the end I bought Giles which does a fantastic job and has a few other possibilities besides just lightmaps such as way point plotting etc...


Naughty Alien(Posted 2004) [#4]
Dreamora...how to combine this two 3DS files??


AdrianT(Posted 2004) [#5]
no problem at all with lightmaps in max here, just that my system is old and slow. If your using radiosity or light tracer you just have to get used to the fairly complex setup required. For outdoors your generaly better off with light tracer, and for radiosity you should always use photometric lights as the radiosity doesn't work well at all otherwise, wasn't designed to work with regular lights.

If you are used to doing pre rendered stuff Max isn't hard to use and produces far better results than giles, but requires a lot more work and knowledge. Giles is nice a its so simple and easy to set up with almost no knowlege of lighting and 3dsmax at all.


Naughty Alien(Posted 2004) [#6]
max is not problem...we are friends quite long time...I'm just trying to found way how to compose my lightmap in to blitz3D...in fact, i have already something done with B3D file and it working well, but level is not so huge, this time, scene is very complex, and lighting is finished, but when I export my B3D file, and try to load it in to Blitz3D, it doesnt work...instead of that, 3DS working well..except i dont know how to apply lightmap on it..Dreamora mention something about 2 different meshes, one with textures and normal ambient light and second one with lightmap applied on it...looking good, but I'm wondering how to combine that 2 meshes in Blitz3D..and does that mean i will get double heavy scene if we talking about polys...


Dreamora(Posted 2004) [#7]
load both meshes then read out the UV datas of the second mesh and add them to the first as UV 1. if you didn't alter the hierarchy it should just be a collection of 2 "for next" loops to combine it after loading


Naughty Alien(Posted 2004) [#8]
Dreamora...I will apprechiate if you can put down some piece of code what will do exactly what your explanations talking about..sorry for boring with this...


Dreamora(Posted 2004) [#9]
mesh = loadanimmesh( "level.3ds" )
lmesh = loadanimmesh( "lightmap.3ds" )

for i = 1 to countchildren(lmesh)
  for j = 1 to countsurfaces( lmesh )
    lsurf = getsurface( lmesh, j )
    surf = getsurface( mesh, j )
    for k = 1 to countvertices( lsurf )
      u# = VertexU( lsurf, k )
      v# = VertexV( lsurf, k )
      VertexTexCoords surf, k, u#, v#, 1, 1
    next
  next
next




As mentioned this needs that you have the similar geometry on both models, otherwise this is useless.
For texturing you will have to investigate the whole thing a little on your own :)


AdrianT(Posted 2004) [#10]
hey sub zero? since your using 3dsmax I'd suggest using B3d pipeline for your export and ignoring .3ds alltogether.

http://www.onigirl.com/pipeline/

its a great exporter with a custom material and map type that supports all ob bltiz 3d material features natively and really easy to set up the lightmaps with. Anyone with max should really be using that as an exporter even without using the extensions it's the best max to B3d exporter out there, and it's free :)


Gabriel(Posted 2004) [#11]
As Evak says, it's really quite easy ( if rather laborious and time consuming if you have lots of materials. ) You simply choose a Blitz3d brush instead of standard in Max's material editor and scroll down to the texture slots. Click on the first one and pick Blitz3d texture from the new list of material types. Pick the diffuse ( base ) texture from the texture dialog and drop back to the brush ( not texture ) again. Now click on the second texture slot and create another Blitz3d Texture. This time pick the lightmap texture and change the the uv channel from one to two. Again drop back to the Blitz3d Brush material and drag it onto your object. Export as b3d. Simple as that.

EDIT : Fixed my terminology so that it fits with the dialog boxes Evak has posted below.


AdrianT(Posted 2004) [#12]
just to illustrate Sybixus text, here's some pics from the UI.

B3d Brush material type:



Map panel:


If your doing lightmaps in max, you may also want to try Bakersfield scripts:

http://www.chuggnut.com/scripts/bakersfield/bakersfield.htm

These simplify the whole process a fair bit by putting all the lightmap settings under one UI Panel, and giving you a node list so its quick and easy to re render sections of your scene lightmaps with all its presets intact with the click of a couple of buttons.


PowerPC603(Posted 2004) [#13]
Did you upgrade to Blitz3D V1.87?

If you still have an older version, then it is logical that you receive a "memory access violation" when loading a b3d-file, because the b3d-fileformat didn't exist yet in older versions (tried that too when I had an older version).

If you intend to load the entire scene with the LoadAnimMesh command, be sure that you check the "add scene root"-option when exporting.
This way all objects in that scene are children of a pivot (Blitz cannot handle multiple objects on the top of the hierarchy when using LoadAnimMesh).

If you use LoadMesh, then you can uncheck this option, but then you don't have access to the separate objects in the scene, as they will be "merged" as one object (AFAIK, correct me if I'm wrong).


Naughty Alien(Posted 2004) [#14]
Thanks Dreamora..I will try your code..by the way, my blitz3D is upgraded on to 1.87, and working well, except somehow exported B3D file from max was damaged, anyway, it working now, but I'm still interested in to 3DS if we talking about static meshes...I'll drop you few words when I complete this Dreamora..


Naughty Alien(Posted 2004) [#15]
Well..I'm try code you suggest me, but thing still not working..maybe code i'm using for adding lightmap is not correct..anyway here is listing..

This is your code...

mesh = loadanimmesh( "level.3ds" )
lmesh = loadanimmesh( "lightmap.3ds" )

for i = 1 to countchildren(lmesh)
for j = 1 to countsurfaces( lmesh )
lsurf = getsurface( lmesh, j )
surf = getsurface( mesh, j )
for k = 1 to countvertices( lsurf )
u# = VertexU( lsurf, k )
v# = VertexV( lsurf, k )
VertexTexCoords surf, k, u#, v#, 1, 1
next
next
next

..and this is piece of code what I'm trying to use to put lightmap on to mesh..

EntityFX mesh,2
Lightmap=LoadTexture("lmap.tga")
TextureCoords Lightmap,1
EntityTexture mesh,Lightmap,0,1

so..result is, mesh but only with lightmapped texture...

anyone can help...