Jump to content

Generating mission lighting on load


Prometheus

Recommended Posts

I'm tinkering around with Legions: Overdrive again, and one thing I'd really like to do is have the mission lighting generated during mission load, then saved/cached. I believe most Torque games act/acted like this, such as Tribes 2. I can only assume this feature exists within the Legions engine somewhere, as it's based on TGE / TGEA, but I could very likely be incorrect.


I did check out the Tribes 2 client preferences and saw a few promising options, such as cacheLighting, but unfortunately it doesn't have any effect within Legions. I'm sure something needs to be done from the server level to tell those connecting to generate the lighting file, but I'm pretty lost where to start.


Can anyone point me in the right direction to get started?

Link to comment
Share on other sites

Torque3D has baked lighting for terrains, but it is only used for basic lighting, which is deprecated or close to being deprecated. I think since those old games only consist of terrain, it worked fine back then, it may have also worked for the old model file format Torque used which is now also not used anymore.


I'm not sure what you want, but the answer is either what you want is deprecated, useless, or there are better ways to do it now.


If you really need even more performance you can bake the lightmaps, then Torque does not even have to calculate them once and does not need to create any cache files, combined with basic lighting you will get more performance than you will ever need.

Link to comment
Share on other sites

Torque3D has baked lighting for terrains, but it is only used for basic lighting, which is deprecated or close to being deprecated. I think since those old games only consist of terrain, it worked fine back then, it may have also worked for the old model file format Torque used which is now also not used anymore.


I'm not sure what you want, but the answer is either what you want is deprecated, useless, or there are better ways to do it now.


If you really need even more performance you can bake the lightmaps, then Torque does not even have to calculate them once and does not need to create any cache files, combined with basic lighting you will get more performance than you will ever need.

 

Thanks. To be a bit more clear, I'm trying to make server-side maps just...work. Right now when you have a map on the server that you've altered, people can connect to it just fine but unfortunately it doesn't reference or utilize the original mission lighting file, so the terrain is super bright and models are completely black. I never really played Tribes 2, but I'm fairly certain server-side maps were a thing, just like Tribes 1. Having the lighting file created during mission load then saved would solve my issues I think.


If Legions were on T3D I probably wouldn't even be having this discussion (though that brings up the question: does T3D support server-side maps?). Legions on T3D, or any modern engine would be pretty great. Sadly with how licensing is, we're left tinkering with a 13 year old game on an incomplete Torque engine stuck somewhere between TGEA and T3D.


I'll probably just drop this project at the moment, as it's likely more work than it's worth. Thanks though.

Link to comment
Share on other sites

I'll probably just drop this project at the moment, as it's likely more work than it's worth. Thanks though.

 

Thank god that someone can use common sense. Yes it will likely more work than it is worth, but if you really want to stick to it, you could just rebuild it on the new engine, should only take a couple of months and to solve your problem with server side maps, someone posted a resource for cooperative editing in Torque3D, so you can edit levels with multiple people, but I can't remember where it was at and how finished it was. Server sided maps already work in Torque3D, the problem are just some objects like the terrain that do not properly network, since it is a big file that cannot be transmitted on the fly. So you have to limited yourself to placing objects or using the sketch tool or something like that.

Link to comment
Share on other sites

Is it possible that since its edited that you have changed the name of the mission file (.mis) and it is not corresponding via the network with the the .ml file(the mission lighting file probably associated with the original level) ?

 

I'm sure it could be, but keeping the filename the same isn't ideal. I want to keep the original map (Map.mis) so it can be played, but also have a modified version (Map_v2.mis) of it as well. If everything looks decent, fine with me. I don't care if I add new shapes and they don't have shadows in Map_v2.mis. Not sure how T2 or other Torque Games handled this other than generating the lighting file on first load then saving it.

Link to comment
Share on other sites

This level.mis file is stored in the memory of the server like all the server side scripts. How Torque works is it packs up all the script files and sends it to every client including the .mis file. Clients cannot change anything except legal actions such as adding objects to the .mis file, which is part of a normal game process, for example if a player joins, he is added to the .mis file.


The problem with this is that non editable files like binary files, cannot be transmitted on the fly by default at least not in the open source version.

It may be possible that if you are using an older proprietary version of the engine that they have features like this implemented, since it seemed to have existed in the past, for example I found this: http://www.garagegames.com/products/tcwdt


There was an newer implementation, it was developed by Winterleaf Entertainment I think, but cannot find it, the search for garagegames.com is a bit broken. They were developing their own engine based on Torque3D with additional features and add ons for Torque3D.

Now they don't seem to exist anymore, but it seems they contributed some things back to Torque3D, like this may be a hint https://github.com/GarageGames/Torque3D/pull/959


But to make it short, if you are using an older proprietary engine version, you are likely working on a dead end.

Link to comment
Share on other sites

I tried looking in the source for things . Its a bit complicated for me . No real blaring straight-forward heres where you save the .ml . There are a couple references to the .ml file and they are associated with the mission filename .

In addition to the couple of files referenced below ,you might also find scenePersist.cpp of interest .


//-------------------------------

gameConnesction.cpp

//-------------------------------

line#

995

stream->writeString(Con::getVariable("$Client::MissionFile"));


1078

Con::setVariable("$Client::MissionFile",buf);


2160

DefineEngineMethod( GameConnection, setMissionCRC, void, (S32 CRC),,


"@brief On the server, transmits the mission file's CRC value to the client.\n\n"



"Typically, during the standard mission start phase 1, the mission file's CRC value "


"on the server is send to the client. This allows the client to determine if the mission "


"has changed since the last time it downloaded this mission and act appropriately, such as "


"rebuilt cached lightmaps.\n\n"


2299

// After demo has loaded, execute the scene re-light the scene


//SceneLighting::lightScene(0, 0);

GameConnection::smPlayingDemo.trigger();



//-----------------------------------------------------------------------------

/

//-----------------------------------------------------------------------------

/

//----------------------

sceneLighting.cpp

//----------------------



461

void SceneLighting::getMLName(const char* misName, const U32 missionCRC, const U32 buffSize, char* filenameBuffer)


{


dSprintf(filenameBuffer, buffSize, "%s_%x.ml", misName, missionCRC);


}


927

void SceneLighting::processCache()


{


// get size in kb


S32 quota = Con::getIntVariable("$sceneLighting::cacheSize", -1);



Vector files;



Vector fileNames;


Torque::FS::FindByPattern(Torque::Path(Platform::getMainDotCsDir()), "*.ml", true, fileNames);



S32 curCacheSize = 0;



for(S32 i = 0;i < fileNames.size();++i)


{


if(! Torque::FS::IsFile(fileNames))


continue;



Torque::FS::FileNodeRef fileNode = Torque::FS::GetFileNode(fileNames);


if(fileNode == NULL)


continue;



if(dStrstr(fileNames, mFileName) == 0)


{


// Don't allow the current file to be removed


CacheEntry entry;


entry.mFileObject = fileNode;


entry.mFileName = StringTable->insert(fileNames);


files.push_back(entry);


}


else


curCacheSize += fileNode->getSize();


}



// remove old files


for(S32 i = files.size() - 1; i >= 0; i--)


{


FileStream *stream;


if((stream = FileStream::createAndOpen( files.mFileObject->getName(), Torque::FS::File::Read )) == NULL)


continue;




// read in the version


U32 version;


bool ok = (stream->read(&version) && (version == PersistInfo::smFileVersion));


delete stream;




// ok?


if(ok)


continue;




// no sneaky names


if(!dStrstr(files.mFileName, ".."))


{


Con::warnf("Removing old lighting file '%s'.", files.mFileName);


dFileDelete(files.mFileName);


}




files.pop_back();


}



// no size restriction?


if(quota == -1 || !files.size())


return;


for(U32 i = 0; i < files.size(); i++)


curCacheSize += files.mFileObject->getSize();



// need to remove?


if(quota > (curCacheSize >> 10))


return;




// sort the entries by the correct method


const char * purgeMethod = Con::getVariable("$sceneLighting::purgeMethod");


if(!purgeMethod)


purgeMethod = "";



// determine the method (default to least recently used)


if(!dStricmp(purgeMethod, "minSize"))


dQsort(files.address(), files.size(), sizeof(CacheEntry), minSizeSort);


else if(!dStricmp(purgeMethod, "maxSize"))


dQsort(files.address(), files.size(), sizeof(CacheEntry), maxSizeSort);


else if(!dStricmp(purgeMethod, "lastCreated"))


dQsort(files.address(), files.size(), sizeof(CacheEntry), lastCreatedSort);


else


dQsort(files.address(), files.size(), sizeof(CacheEntry), lastModifiedSort);




// go through and remove the best candidate first (sorted reverse)


while(((curCacheSize >> 10) > quota) && files.size())


{


CacheEntry& lastFile = files.last();


curCacheSize -= lastFile.mFileObject->getSize();



// no sneaky names


if (!dStrstr(lastFile.mFileName, ".."))


{


Con::warnf("Removing lighting file '%s'.", lastFile.mFileName);


dFileDelete(lastFile.mFileName);


}



files.pop_back();


}


}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...