Modernization Kit Beta Thread 2
by ArmedGeek · in Torque Game Engine · 06/27/2007 (8:46 pm) · 344 replies
I think it is way past time to create a new thread for MK.
The original thread can be found here www.garagegames.com/mg/forums/result.thread.php?qt=58532
Modernization Kit website : tmk.superiorcode.com/
Username: torqueUser
Password: tMK60152
The original thread can be found here www.garagegames.com/mg/forums/result.thread.php?qt=58532
Modernization Kit website : tmk.superiorcode.com/
Username: torqueUser
Password: tMK60152
#322
10/01/2008 (12:05 pm)
I'll post this update as a resource after further testing. I think it could be optimized/reworked a little.
#323
Torque-MacCarb-Debug has exited due to signal 5 (SIGTRAP).
[Session started at 2008-10-28 21:01:36 -0700.]
dyld: Library not loaded: /usr/local/lib/libcppunit-1.10.2.dylib
Referenced from: /Users/charlie/Documents/workspace/Sephil Saga/example/EV4 Debug OSX.app/Contents/MacOS/EV4 Debug OSX
Reason: image not found
Any ideas what would be missing? I've gone through the Build settings with a fine-toothed comb.
10/28/2008 (9:11 pm)
I integrated this by hand into an existing project. I got it working so I could use the DTS Normal Mapping resource. It's working, pretty much fine (artists are reporting some bugs, we'll see). Anyway, it's working on MacOSX until I build it with the unit tests. It's compiling OK but libcppunit is causing it to crash out during the dynamic load process. I've included all the framework files, except one that doesn't exist in the 150 distribution directory- libcppunit.la. I get this error:Torque-MacCarb-Debug has exited due to signal 5 (SIGTRAP).
[Session started at 2008-10-28 21:01:36 -0700.]
dyld: Library not loaded: /usr/local/lib/libcppunit-1.10.2.dylib
Referenced from: /Users/charlie/Documents/workspace/Sephil Saga/example/EV4 Debug OSX.app/Contents/MacOS/EV4 Debug OSX
Reason: image not found
Any ideas what would be missing? I've gone through the Build settings with a fine-toothed comb.
#324
Any ideas? One, the subshader does exist- I only have one defined yet and it works in the game. argv[0] is being passed an empty string, so I understand it failing here, but why only in tree()?
10/30/2008 (8:56 am)
I scrapped the unit tests- too much frustration. However, I am getting a very strange problem regarding the tree() command and Materials- whenever I click on a Material it claims that the SubShader does not exist and crashes! It's failing an assert in mkMaterials line 93, in this code:ConsoleSetType(TypeSubShaderPtr)
{
if(argc == 1)
{
SimGroup *rootGroup = Sim::getRootGroup();
AssertFatal(rootGroup, "Why don't we have a root group?");
SubShader **shd = (SubShader **)dptr;
*shd = (SubShader*)rootGroup->findObject(argv[0]);
AssertFatal(*shd != NULL, avar("SubShader: requested sub shader (%s) does not exist.", argv[0]));
}
else
{
Con::printf("(TypeSubShaderPtr) Cannot set multiple args to a single SubShaderPtr");
}
}Any ideas? One, the subshader does exist- I only have one defined yet and it works in the game. argv[0] is being passed an empty string, so I understand it failing here, but why only in tree()?
#325
I have the binary compiled just fine, works on any project without shaders. If I try either demo or starter.fps, globalParameters.cs is not being executed. I have copied the 'Shaders' directory to my example folder but the script is not being exectued before autgenMatList.cs, which causes a crash. I see that it is supposed to be exec'd by common/canvas.cs, but it doesn't appear that anything in that script is exec'd before it gets to starter.fps, tries to do the autogen, and crashes...
Thanks
G
FYI stock TGE152, OSX 10.5.5 MacPro...
01/21/2009 (7:45 am)
Anyone watching this thread? I haven't been able to sift through the hundreads of VC compiler issues to find any info...I have the binary compiled just fine, works on any project without shaders. If I try either demo or starter.fps, globalParameters.cs is not being executed. I have copied the 'Shaders' directory to my example folder but the script is not being exectued before autgenMatList.cs, which causes a crash. I see that it is supposed to be exec'd by common/canvas.cs, but it doesn't appear that anything in that script is exec'd before it gets to starter.fps, tries to do the autogen, and crashes...
Thanks
G
FYI stock TGE152, OSX 10.5.5 MacPro...
#326
In common/client/canvas.cs, function initCanvas, after
In myGame/client/default.cs, add :
In myGame/data/init.cs, add after :
In myGame/main.cs, function onStart, after
You will have to tweak certain parameters (the last ones) to get your desired effect.
Nicolas Buquet
www.buquet-net.com/cv/
01/22/2009 (12:26 am)
Did you merge the MK scripts modifications ?In common/client/canvas.cs, function initCanvas, after
exec("~/ui/defaultProfiles.cs");add//------------------------------------------------------------------
// TGE Modernization Kit
//------------------------------------------------------------------
// Everyone needs shaders, yes?
// Shader stuff
exec("Shaders/globalParameters.cs");
exec("./materials.cs");
exec("~/ui/MKBugReporter.gui");
//------------------------------------------------------------------
// TGE Modernization Kit
//------------------------------------------------------------------In myGame/client/default.cs, add :
//------------------------------------------------------------------ // TGE Modernization Kit //------------------------------------------------------------------ $pref::DRL::enable = "1"; $pref::DRL::bloomQuality = "0"; $pref::Water::reflectionSize = "1024"; $pref::Water::Refract = "1"; $pref::Material::qualityLevel = "500"; //------------------------------------------------------------------ // TGE Modernization Kit //------------------------------------------------------------------
In myGame/data/init.cs, add after :
exec( "./terrains/propertyMap.cs" );
//------------------------------------------------------------------
// TGE Modernization Kit
//------------------------------------------------------------------
// Normal maps
exec("./interiors/lightingPack/autogenMatList.cs");
//------------------------------------------------------------------
// TGE Modernization Kit
//------------------------------------------------------------------In myGame/main.cs, function onStart, after
// Start up in either client, or dedicated server mode
if ($Server::Dedicated)
initDedicated();
else
initClient();add//------------------------------------------------------------------
// TGE Modernization Kit
//------------------------------------------------------------------
exec("./data/init.cs");
MaterialManager::setShaderQuality(500);
mkFluid::setReflectionSize(1024);
mkFluid::enableRefraction(1);
DRL::setBloomQuality(3);
DRL::setGoalIntensity(0.1);
DRL::setScaleLimits(1,4);
DRL::setBiasLimits(-0.07, -0.02);
DRL::setChangeRates( 10, 10 );
DRL::setBloomMultiplier( 1 );
DRL::setBloomQuality(3);
//------------------------------------------------------------------
// TGE Modernization Kit
//------------------------------------------------------------------You will have to tweak certain parameters (the last ones) to get your desired effect.
Nicolas Buquet
www.buquet-net.com/cv/
#327
I did the same operation that performed on my desktop.
I compiled TGE+MK with VC++ epress 2008 with no errors, then I launched the starter.fps with "lighting system feature demo" mission, it loads the mission correctly but when i try to perform any kind of action (like move or jump) the engine crashes.
this is a snippet of the console log:
I removed this line and now it works fine.
I tried with my notebook the "CG Dynamic Gamma & Water Upgrade" resource and it works perfectly.
Anyone know what the cause of this is?
Thanks in advance :)
01/27/2009 (5:41 am)
I tried this amazing kit, and it works very well with both my two desktop PCs (one equipped with nVidia 8600 GS and one with ATI RADEON X300SE), but I've some troubles with my notebook (equipped with ATI RADEON express 200M).I did the same operation that performed on my desktop.
I compiled TGE+MK with VC++ epress 2008 with no errors, then I launched the starter.fps with "lighting system feature demo" mission, it loads the mission correctly but when i try to perform any kind of action (like move or jump) the engine crashes.
this is a snippet of the console log:
... Render texture id is 247 Allocating 248960 bytes of data for 3890 verts (goal: 1190) in the interior VBO 185 texgen eqs and 839 lmtexgen eqs Could not load this GL function: glGenBuffersARB Could not load this GL function: glBindBufferARB Could not load this GL function: glBufferDataARB Could not load this GL function: glGenBuffersARB Could not load this GL function: glBindBufferARB Could not load this GL function: glBufferDataARB Could not load this GL function: glGenBuffersARB Could not load this GL function: glBindBufferARB Could not load this GL function: glBufferDataARB Could not load this GL function: glGenBuffersARB Could not load this GL function: glBindBufferARB Could not load this GL function: glBufferDataARB Could not load this GL function: glMapBufferARB Could not load this GL function: glUnmapBufferARB Could not load this GL function: glGenBuffersARB Could not load this GL function: glBindBufferARB Could not load this GL function: glBufferDataARB Could not load this GL function: glMapBufferARB Could not load this GL function: glUnmapBufferARB Could not load this GL function: glGenBuffersARB Could not load this GL function: glBindBufferARB Could not load this GL function: glBufferDataARB ...I've also got another error (in both my pcs) in interiorRender.cc file around line 1240: error "Aw, crap.4"
I removed this line and now it works fine.
I tried with my notebook the "CG Dynamic Gamma & Water Upgrade" resource and it works perfectly.
Anyone know what the cause of this is?
Thanks in advance :)
#328
www.garagegames.com/community/forums/viewthread/70910/2#comments
my graphic card does not works with MK... but it works with CG Dynamic gamma! how come?
so, here is another snippet of console log
EDIT: I updated my video card drivers with omegadrivers and now it works!!!
fantastic!!!! grat job guys!!! :)
01/27/2009 (6:22 am)
damn! i found the answer to my post... :(www.garagegames.com/community/forums/viewthread/70910/2#comments
my graphic card does not works with MK... but it works with CG Dynamic gamma! how come?
so, here is another snippet of console log
Video Init: Accelerated OpenGL display device detected. Accelerated D3D device detected. Voodoo 2 display device not detected. Activating the OpenGL display device... Activating the OpenGL display device... Setting screen mode to 800x600x32 (w)... Creating a new window... Acquiring a new device context... Pixel format set: 32 color bits, 24 depth bits, 8 stencil bits Creating a new rendering context... Making the new rendering context current... OpenGL driver information: Vendor: ATI Technologies Inc. Renderer: RADEON XPRESS 200M Series SW TCL x86/SSE2 Version: 1.4.5525 WinXP Release OpenGL Init: Enabled Extensions ARB_multitexture (Max Texture Units: 8) EXT_blend_color EXT_blend_minmax EXT_blend_subtract EXT_compiled_vertex_array EXT_texture_env_combine EXT_packed_pixels EXT_fog_coord ARB_texture_compression EXT_texture_compression_s3tc (ARB|EXT)_texture_env_add EXT_texture_filter_anisotropic (Max anisotropy: 16) WGL_EXT_swap_control ARB_texture_rectangle ARB_vertex_program ARB_fragment_program ARB_shader_objects ARB_shading_language (version: 1.10) ARB_vertex_shader ARB_fragment_shader EXT_framebuffer_object ARB_vertex_program information Max vertex program instructions: 65535 Max vertex program native instructions: 65535 Max vertex program temporaries: 65535 Max vertex program native temporaries: 65535 Max vertex program parameters: 256 Max vertex program native parameters: 256 Max vertex program attributes: 32 Max vertex program native attributes: 32 Max vertex program address registers: 1 Max vertex program native address registers: 1 Max vertex program local parameters: 256 Max vertex program env parameters: 256 Max vertex attributes: 32 Max vertex program matrices: 32 Max vertex program matrix stack depth: 16 ARB_vertex_shader information Max vertex shader texture units: 0 Max combined tex. image units: 16 Max tex. image units: 16 Max texture coords: 8 Max uniform vertex components: 4096 Max varying floats: 44 Max vertex attribs: 32 ARB_fragment_program information Max fragment program parameters: 32 Max fragment program local parameters: 32 Max fragment program env parameters: 32 Max fragment program ALU instructions: 128 Max fragment program native ALU instructions: 64 Max fragment program texture instructions: 32 Max fragment program native texture instructions: 32 Max fragment program texture indirections: 31 Max fragment program native texture indirections: 4 ARB_fragment_shader information Max fragment uniform components: 4096 OpenGL Init: Disabled Extensions EXT_paletted_texture NV_vertex_array_range 3DFX_texture_compression_FXT1 ATI_FSAA EXT_Cg_shader ATI_text_fragment_shader ARB_vertex_buffer_object
EDIT: I updated my video card drivers with omegadrivers and now it works!!!
fantastic!!!! grat job guys!!! :)
#329
01/29/2009 (10:00 am)
how i can make that this work with intel cards? whats i need?
#330
01/29/2009 (10:42 am)
Does this kit allow the use of transparency, or opacity maps? I have tried doing this with just an alpha channel without the kit, but I did not get good results.
#331
01/31/2009 (10:33 pm)
how i can activate bump maps for my models?
#332
@ Tom : the MK doesn't allow the use of transparency material. For this, you have to include DTS with transparency in your dif with constructor.
@ Javier : this resource permit bump or shader only on Interiors : DIF. Another resource adapted from the MK and that need the MK to work, enable shaders in TGE on DTS model : TGE shader pack : www.garagegames.com/community/resources/view/15662
Nicolas Buquet
www.buquet-net.com/cv/
02/02/2009 (12:11 am)
@ Javier : AFAIK, these resource doesn't work with integrated graphic card with what has to do with shaders. Lighting modification and bloom works well.@ Tom : the MK doesn't allow the use of transparency material. For this, you have to include DTS with transparency in your dif with constructor.
@ Javier : this resource permit bump or shader only on Interiors : DIF. Another resource adapted from the MK and that need the MK to work, enable shaders in TGE on DTS model : TGE shader pack : www.garagegames.com/community/resources/view/15662
Nicolas Buquet
www.buquet-net.com/cv/
#333
Hey...I know this thread is old (332 posts) but i was thinking...with such a massive update like this, could you or someone intergrate this into a fresh build of TGE 1.5.2 and then upload the complete source of working intergration onto the Unofficial Torque Public-File-System and/or the compiled binary of it to just drop into starter.fps as an example. Ofcourse the files would need to be paswrod protected, witht e password to such files in a private TGE post...but I think that would be great, and more people would be interested in using the TMK, coz intergrating massive things like ths can be time-consuming and then not work
from max :D
PS. unofficial Torque Public-File-System: http://www.garagegames.com/community/resources/view/16711
07/05/2009 (7:44 pm)
@ Armed GeekHey...I know this thread is old (332 posts) but i was thinking...with such a massive update like this, could you or someone intergrate this into a fresh build of TGE 1.5.2 and then upload the complete source of working intergration onto the Unofficial Torque Public-File-System and/or the compiled binary of it to just drop into starter.fps as an example. Ofcourse the files would need to be paswrod protected, witht e password to such files in a private TGE post...but I think that would be great, and more people would be interested in using the TMK, coz intergrating massive things like ths can be time-consuming and then not work
from max :D
PS. unofficial Torque Public-File-System: http://www.garagegames.com/community/resources/view/16711
#334
07/05/2009 (9:55 pm)
@MaximillianQuote:Download the 1.5.2 archive, drop it in, and recompile. It's really that simple... though I think there are a few minor gotchas that looking over this thread will fill you in on. I also saw you ask (in a blog that referenced the MK) for a source of normal maps -- the MK auto-generates them for you -- which is also discussed in this thread if you wish to disable this feature and make your own.
The Modernization Kit comes with all added and modified files. If you have not modified any of the files the Modernization Kit has you can simply replace the files in your installation of the Torque Game Engine with those from the Modernization Kit download.
Quote:Just like things are now -- although there are no Private TGE forums anymore.
Ofcourse the files would need to be paswrod protected, witht e password to such files in a private TGE post...
#335
I corrected it by modifying RenderTextureManager::destroy in mkRenderTexture.cpp file:
Nicolas Buquet
www.buquet-net.com/cv/
08/24/2009 (6:06 am)
I had in recurrent bug (hard lock) when exiting my application with the TMK active.I corrected it by modifying RenderTextureManager::destroy in mkRenderTexture.cpp file:
void _RenderTextureManager::destroy()
{
AssertFatal(RenderTextureManager, "No RenderTextureManager created");
delete RenderTextureManager;
#ifdef __NB__MK_CORRECTION
// if RenderTextureManager is not ste to NULL then
// in the process of shutting down the application
// _RenderTextureManager::destroy is first called by shutDownLibraries/MKDestroy
// and then _RendertextureManager::reset is called by shutDownLibraries/Platform::shutDown/Video::destroy/OpenGLDevice::shutDown/OpenGLDevice::cleanUpContextAndWindow/MKReset
// Then, _RendertextureManager::reset try to work on an destoyed object.
// It should be catch in MKReset by
// if(RenderTextureManager)
// RenderTextureManager->reset();
// but RenderTextureManager is not NULL after the call to _RenderTextureManager::destroy
//
// So, the presence of this fix :
RenderTextureManager = NULL;
#endif
}Nicolas Buquet
www.buquet-net.com/cv/
#336
I have tested this in the Stock TGE and it seems that it loads my interiors and shows them correctly(specular seems a little overpowering but no problem none the less), so its not my video card as I have an nVidia 9600GT.
I am using this with a custom modded MG Starter Kit so some of the script code was a little challenging, I have tried to read through the extremely long list of posts attached to this thread and have managed to get DRL (worked out of the box), Water(this was a pain for an hour or two) and it seems I cannot use any interiors...
Custom Console Log
StockConsole Log
BTW: This problem is a Script based problem on my end, I was wondering if anyone recognized the problem due to customizations aswell, because as I said before I am using the MG Starter Kit Scripts and its only because of the highly modified script methods being used that I'm having this problem.(pretty sure) :(
08/24/2009 (10:32 pm)
for some reason I can not relight any interior I place, and none of my missions with interiors will load, it seems every time I attempt to view an interior I get a Program Crash.I have tested this in the Stock TGE and it seems that it loads my interiors and shows them correctly(specular seems a little overpowering but no problem none the less), so its not my video card as I have an nVidia 9600GT.
I am using this with a custom modded MG Starter Kit so some of the script code was a little challenging, I have tried to read through the extremely long list of posts attached to this thread and have managed to get DRL (worked out of the box), Water(this was a pain for an hour or two) and it seems I cannot use any interiors...
Custom Console Log
StockConsole Log
BTW: This problem is a Script based problem on my end, I was wondering if anyone recognized the problem due to customizations aswell, because as I said before I am using the MG Starter Kit Scripts and its only because of the highly modified script methods being used that I'm having this problem.(pretty sure) :(
#337
This error is present in your "custom console" but not in your "stock console".
Try at first to get rid of it (perhaps a bad path).
Nicolas Buquet
www.buquet-net.com/cv/
08/25/2009 (4:08 am)
You've got an error on one DIF:Executing common/data/missions/barebones.mis. Unable to load interior: common/data/interiors/constructor/test.dif common/data/missions/barebones.mis (0): Register object failed for object (null) of class InteriorInstance.
This error is present in your "custom console" but not in your "stock console".
Try at first to get rid of it (perhaps a bad path).
Nicolas Buquet
www.buquet-net.com/cv/
#338
OK, that was just the Stock TGE Barebones Interior that I did not include into my Custom version.
Note: Upon comparing the very first Scene Lighting in the Custom and Stock versions, there is something very wrong that the Custom version is not doing to initially light the scene...
The initial Lighting is not crashing the game until an interior enters the FOV. (either at the end of mission loading or moving camera to view interior)
08/25/2009 (12:29 pm)
I REALLY appreciate the help Nic, I'm investigating that error right now...OK, that was just the Stock TGE Barebones Interior that I did not include into my Custom version.
Note: Upon comparing the very first Scene Lighting in the Custom and Stock versions, there is something very wrong that the Custom version is not doing to initially light the scene...
The initial Lighting is not crashing the game until an interior enters the FOV. (either at the end of mission loading or moving camera to view interior)
#339
I had enough things changed in my source and/or scripts to stop interiors from working correctly and was getting results similiar to ninjadaves screenshots (w/ wierd lines and colors)
I just got done removing as much of my custom mods from script and source to get this working...
I'll post more info when I figure out more about the problems I was being stalled with.
BTW: Must Have!!!
:)
Now my only complaint is a minor bug in the water reflection if your at a distance or high enough over the water(Post#227, Joseph Walters bug pic), either way... awesome mod!
08/30/2009 (3:28 am)
Success!!!I had enough things changed in my source and/or scripts to stop interiors from working correctly and was getting results similiar to ninjadaves screenshots (w/ wierd lines and colors)
I just got done removing as much of my custom mods from script and source to get this working...
I'll post more info when I figure out more about the problems I was being stalled with.
BTW: Must Have!!!
:)
Now my only complaint is a minor bug in the water reflection if your at a distance or high enough over the water(Post#227, Joseph Walters bug pic), either way... awesome mod!
#340
No info about the water bug : I almost use TMK for the HDR and Bloom, but bot the shaders on DIF, because I use it on Intel GMA950 chipsets (mac mini).
Nicolas Buquet
www.buquet-net.com/cv/
08/30/2009 (5:50 am)
Congratulation for your success in using TMK.No info about the water bug : I almost use TMK for the HDR and Bloom, but bot the shaders on DIF, because I use it on Intel GMA950 chipsets (mac mini).
Nicolas Buquet
www.buquet-net.com/cv/
Torque Owner Trenton Shaffer
===============
Here is a quick fix that will prevent your engine from auto-generating and overwriting your normal maps if they already exist. If you want them automatically generated again, simply go delete the PNG normal map(s) from the appropriate Interiors folder. Please note that there are many ways to do this, this one just worked for me.
Open mkInterior.cpp:
Find the following function at the bottom of mkInterior.cpp:
void mkInterior::generateMaterial(TextureHandle& handle, const char* name, const char* path, FileStream &pMapStream) { #ifdef MK_AUTOGEN_NORMALMAP ... ... ... #endif }Replace the entire function with the following code:
(or you could manually add the commented changes to your mkInterior::generateMaterial function)
void mkInterior::generateMaterial(TextureHandle& handle, const char* name, const char* path, FileStream &pMapStream) { // TS AUTOGEN_NORMALMAP FIX -- START char filechecker[256]; bool filecheckedexists; filecheckedexists = false; dSprintf(filechecker, sizeof(filechecker), "%s/%s_height_auto.png",path, name); if(ResourceManager->getPathOf(filechecker)) { Con::printf("FOUND: %s, skipping normal map generation", filechecker); filecheckedexists = true; } // TS AUTOGEN_NORMALMAP FIX -- END #ifdef MK_AUTOGEN_NORMALMAP U32 texWidth = handle.getWidth(); U32 texHeight = handle.getHeight(); // Ya, no nonexistant textures. if(texWidth == 0 || texHeight == 0) return; if(!filecheckedexists) // <--ADDED: TS AUTOGEN_NORMALMAP FIX Con::printf("Generating material for texture %s, width %i, height %i", name, texWidth, texHeight); RenderTextureFormat testFormat(RGBA8, Depth16, None, Stencil0, 4, true, false); RenderTextureFormat bestFit; RenderTextureManager->getClosestMatch(testFormat, bestFit); RenderTexture *heightmap = RenderTextureManager->createRenderTexture(texWidth, texHeight, bestFit); RenderTexture *nmap = RenderTextureManager->createRenderTexture(texWidth, texHeight, bestFit); Material* heightmapCreator = MaterialManager->findMaterialByName("heightmapCreator"); Material *nmapCreator = MaterialManager->findMaterialByName("nmapCreator"); // It'd be bad if we didn't have our materials if(!heightmapCreator || !nmapCreator || !heightmapCreator->getActiveShader() || !nmapCreator->getActiveShader()) return; // Generate the heightmap (blurred greyscale) RenderTextureManager->renderToTexture(heightmap); heightmapCreator->bind(); ShaderManager->setParameter("TextureSize", F32(texWidth), F32(texHeight)); glBindTexture(GL_TEXTURE_2D, handle.getGLName()); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2f(-1, -1); glTexCoord2f(0, 1); glVertex2f(-1, 1); glTexCoord2f(1, 1); glVertex2f(1, 1); glTexCoord2f(1, 0); glVertex2f(1, -1); glEnd(); // Generate the normal map from the blurred heightmap // Makes parallax mapping (and normal mapping) look // so much nicer. RenderTextureManager->renderToTexture(nmap); heightmap->bindToUse(0); nmapCreator->bind(); ShaderManager->setParameter("TextureSize", F32(texWidth), F32(texHeight)); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2f(-1, -1); glTexCoord2f(0, 1); glVertex2f(-1, 1); glTexCoord2f(1, 1); glVertex2f(1, 1); glTexCoord2f(1, 0); glVertex2f(1, -1); glEnd(); RenderTextureManager->renderToTexture(NULL); // I forgot this at first. Bad things happened. DON'T REMOVE IT!!! ShaderManager->unbindShader(); // TS AUTOGEN_NORMALMAP FIX -- START if(!filecheckedexists) {// TS AUTOGEN_NORMALMAP FIX -- END FileStream fStream; char texturePath[256]; // Download our fine work for saving. GBitmap *nmapTexture = nmap->download(); dSprintf(texturePath, sizeof(texturePath), "%s/%s_height_auto.png",path, name); // Life sucks if we can't save all of our work if(!fStream.open(texturePath, FileStream::Write)) { Con::printf("Failed to open file '%s'.", texturePath); return; } // Write a PNG nmapTexture->writePNG(fStream); fStream.close(); delete nmapTexture; }// <--ADDED: TS AUTOGEN_NORMALMAP FIX // Bah, we don't need anything anymore RenderTextureManager->deleteRenderTexture(nmap); RenderTextureManager->deleteRenderTexture(heightmap); // Save the script command to load this next time. char nMapPath[256]; char texPath[256]; dSprintf(nMapPath, sizeof(nMapPath), "%s/%s_height_auto",path, name); dSprintf(texPath, sizeof(texPath), "%s/%s",path, name); char scriptCommand[2048]; dSprintf(scriptCommand, sizeof(scriptCommand), "new Material()\n{\n mapTo = \"%s\";\n Shader20 = InteriorParallax20;\n textures[0] = \"Lightmap\";\n textures[1] = \"%s\";\n textures[2] = \"%s\";\n textures[3] = \"Fog\";\n\n samplers[0] = \"LightMap\";\n samplers[1] = \"BaseTexture\";\n samplers[2] = \"NormalMap\";\n samplers[3] = \"FogTexture\";\n};\n\n", texPath, texPath, nMapPath); pMapStream.write(dStrlen(scriptCommand), scriptCommand); Con::evaluate(scriptCommand); #elif defined(MK_AUTOGEN_MATERIALS) char texPath[256]; dSprintf(texPath, sizeof(texPath), "%s/%s",path, name); char scriptCommand[2048]; dSprintf(scriptCommand, sizeof(scriptCommand), "new Material()\n{\n mapTo = \"%s\";\n Shader20 = InteriorFF20;\n textures[0] = \"Lightmap\";\n textures[1] = \"%s\";\n textures[3] = \"Fog\";\n\n samplers[0] = \"LightMap\";\n samplers[1] = \"BaseTexture\";\n samplers[3] = \"FogTexture\";\n};\n\n", texPath, texPath); pMapStream.write(dStrlen(scriptCommand), scriptCommand); Con::evaluate(scriptCommand); #endif }