Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Guide to new lighting features in 4.0RC1
Guide to new lighting features in 4.0RC1 [message #473749] Thu, 30 August 2012 02:47 Go to next message
jonwil is currently offline  jonwil
Messages: 3556
Registered: February 2003
Karma: 0
General (3 Stars)

This is the first of a series of posts I plan to make describing new features for modders in 4.0 and how to use them. In this post I will be describing the new lighting and vertex solve related features and changes in scripts 4.0RC1 (which is currently undergoing beta testing and will hopefully be released in the near future)

Firstly we have identified (and fixed) a bug in the vertex solve code related to meshes with bump mapping such as water. With this fix, you no longer need to hide water meshes before you run "compute vertex solve".

Secondly, we have identified (and fixed) a bug whereby meshes that have no vertex colors and have an opacity of less than 1 set in their material settings would be treated as though the opacity was set to 1. As of 4.0RC1 the vertex solve code will now use the correct opacity value.

The most well known example where the opacity bug can be seen is with the glass in the nod airstrip tower. With this fix, you will no longer need to hide any of the glass on the stock renegade buildings (including the air tower and the hand of nod) before you run "compute vertex solve".

Thirdly, we have added a feature to the vertex solve code that lets you completly disable vertex solve on a particular mesh. This is intended for meshes where the vertex solve still screws up even with the above 2 features as well as for vertexes that contain pre-calculated lighting baked into the w3d file (such as lightmap textures)

To use it, you select the mesh in 3DS MAX and open the "Properties" dialog. Then you click on the "User Defined" tab. (not sure where the relevant dialog box is for gmax users) In that box you type "Prelit=true" (without the quotes). This will cause the vertex solve code to completly ignore this mesh (i.e. its essentially same as hiding the mesh before you vertex solve)

Part 2 will be posted later and will cover the tools and LE features that let modders use the "alternate lighting" and "alternate materials" feature of the w3d engine building code (the same features Westwood used for the stock maps)


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Re: Guide to new lighting features in 4.0RC1 [message #473757 is a reply to message #473749] Thu, 30 August 2012 08:18 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3556
Registered: February 2003
Karma: 0
General (3 Stars)

And here is part 2.
Some things you will need to know: (some of which may be familiar to advanced modders but not everyone will know them)
1.Buildings have a prefix set in the building definition
2.Meshes that contain the building prefix followed by the ^ character are exterior meshes for that building
3.Meshes that contain the building preset followed by the # character are interior meshes for that building
4.Buildings can also have lights associated with them. Lights will match the building if the name of the light (which is taken from the .wlt file, see below) matches with the mesh prefix of the building.
5.Lights in renegade can come from 2 places, they can be directly placed into leveledit or they can be placed via a .wlt file
6.Every light in renegade has a "group ID" and a name.
7.A .wlt file is a file that is associated with a terrain .w3d file and contains one or more groups of lights.
8.When a .wlt file is loaded into leveledit, the lights are given names matching the .wlt filename.
9.The first group of lights in the .wlt file are given a "group ID" of 0, the second group is given a "group ID" of 1 and so on.
10.When a building is initialized, it creates 4 lists (actually 5 if you count the building aggregates but that doesn't matter for this discussion) and fills them with the appropriate data. The InteriorMeshes list contains all the interior meshes for the building. The ExteriorMeshes list contains all the exterior meshes for the building. The PowerOffLights list contains all the lights with a name that matches the building and a "Group ID" of 1. The PowerOnLights list contains all the lights with a name that matches the building and a "Group ID" of 0.
10.Meshes can have "Alternate materials" associated with them. This is basically a second set of material data stored in the .w3d file. (this second set of data may contain textures, shader settings, material settings, texture coordinates etc)
11.When a building is destroyed, the alternate materials on both the interior and exterior meshes are enabled. When a building goes low power, the alternate materials on the interior meshes are enabled.
14.When a building is destroyed or goes low power, all the lights in the PowerOnLights list are disabled and all the lights in the PowerOffLights list are enabled.

In part 3 I will post details of the wltmake tool and the altmat tool which will let you use the alternate light sets and the alternate materials. These 2 tools, an associated LE feature, the Prelit=true feature mentioned in part 1 and some method of generating the actual light map textures (I think 3D Studio Max can do it although I am not 100% sure) are all you need in order to produce meshes that function identically to the standard Renegade maps/buildings and use the same light mapping features including having the materials and lighting change when a building dies or goes low power.



Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Re: Guide to new lighting features in 4.0RC1 [message #473758 is a reply to message #473749] Thu, 30 August 2012 08:30 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3556
Registered: February 2003
Karma: 0
General (3 Stars)

One note, if you are using the Prelit=true feature on a mesh that is part of anything other than terrain, ALL the meshes in that w3d file need to be Prelit=true otherwise it will screw up when you run the vertex solve.


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Re: Guide to new lighting features in 4.0RC1 [message #473765 is a reply to message #473749] Thu, 30 August 2012 12:29 Go to previous messageGo to next message
Mauler
Messages: 448
Registered: May 2003
Location: Alberta, Canada
Karma: 0
Commander
Very awesome, can't wait to use these. Thanks! Thumbs Up

EDIT: Also 3DSmax can be used to create lightmaps and has the ability to export your lighting information to create wlt files, although gmax/renx cannot.
The "prelit" parameter can also be set in gmax, the same way it can be done in max

[Updated on: Thu, 30 August 2012 12:36]

Report message to a moderator

Re: Guide to new lighting features in 4.0RC1 [message #473767 is a reply to message #473749] Thu, 30 August 2012 18:54 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3556
Registered: February 2003
Karma: 0
General (3 Stars)

Here is part 3:
The alternate material feature will only work properly on terrain and will only work on meshes that are prelit (i.e. those that have "Prelit=true" set)
The alternate lighting feature will only work properly if the meshes being lit all have Prelit=true set. Meshes which do not have Prelit=true (and therefore get lighting from the vertex solve) will probably not look correct when the lights switch to the "power off/dead" set of lights.

To use the alternate lighting feature you do the following: (there may be other ways to generate .wlt files, I am only describing the way I know to do it)
1.Load leveledit and create a blank map
2.Place the building interior terrain for the building you want to add lights to at 0,0,0 (i.e. so that 0,0,0 in the building terrain is at 0,0,0 in the level)
3.Create any light presets you like and place them anywhere in the level (but presumably they will be inside the building). These will be the "normal" lights
4.Choose Lighting-Export... from the menu. Save the lights as e.g. normal.wlt (the name doesn't matter, I am using normal.wlt for this example)
5.You can (if you like) save this level with the placed lights in it for later further work if you like (you dont need to though)
6.Delete all your "normal" lights
7.Place your "dead" lights (which will also be used when there is low power)
8.Choose Lighting-Export... from the menu. Save the lights as e.g. dead.wlt (the name doesn't matter, I am using dead.wlt for this example)
9.You can (if you like) save this level with the placed lights in it for later further work if you like (you dont need to though)
10.Put wltmake.exe, memorymanager.dll, normal.wlt and dead.wlt in a folder. Open a command prompt and go to this folder.
11.Run wltmake out.wlt normal.wlt dead.wlt. Instead of out.wlt in that command, use the name of your building interior mesh but with a .wlt extension (so if the building is mabar_int.w3d, the wlt file would be mabar_int.wlt)
12.Copy the new output wlt file into your always.dat file or whatever (somewhere LE and the game can find it)
13.Edit the preset for your building interior terrain and set m_LightFilename to the name of your new .wlt file
14.Repeat steps #1 to #13 for all the buildings that need special lights
15.Once that is complete, open up each map that contains the newly-lit buildings.
16.Delete any instances of the building interior meshes (or of any terrain that proxies them in) and re-insert them into the level so that the lights get pulled in.
17.Save and re-export the map.
18.Enjoy your new lighting (hopefully)

To use the alternate materials feature you do the following:
1.Take your mesh in max or gmax and apply the "normal/alive" materials (including any light maps you may have created)
2.Export this to a w3d file (lets call it normal.w3d for this example)
3.Edit the mesh and apply the "dead" materials (including any light maps you may have created)
4.Export this to another w3d file (lets call it dead.w3d for this example)
5.Put both w3d files, memorymanager.dll, altmat.exe and w3dlib.dll in a folder. Open a command prompt and go to this folder.
6.Run altmat out.w3d normal.w3d dead.w3d replacing out.w3d with the name of the output mesh you want (i.e. the name that matches the building you are working with)
7.Place the new w3d file in a place that leveledit and the game will find it.
8.Export your maps as normal
9.Load the game and enjoy your new materials

The things you can change between normal and dead materials are:
Vertex colors
Texture coordinates
All the values on the Vertex Material tab
All the values on the Shader tab
All the values on the Texture tab EXCEPT for the "Stage 0 Texture" and "Stage 1 Texture" checkboxes

Changing anything else (including geometry or pass counts) will not work and may lead to crashes (in altmat or in the game).
Remember that you can't rename a w3d file so make sure you use the correct output filename.

Feel free to ask any questions you have about this stuff here and I will answer them.


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Re: Guide to new lighting features in 4.0RC1 [message #473795 is a reply to message #473767] Sat, 01 September 2012 04:20 Go to previous messageGo to next message
Mauler
Messages: 448
Registered: May 2003
Location: Alberta, Canada
Karma: 0
Commander
Trying out these tools now Thumbs Up

Could you clarify the command prompt part... i keep getting a error message when i try to convert my w3d's

[Updated on: Sat, 01 September 2012 04:39]

Report message to a moderator

Re: Guide to new lighting features in 4.0RC1 [message #473812 is a reply to message #473795] Sat, 01 September 2012 14:05 Go to previous messageGo to next message
saberhawk
Messages: 1068
Registered: January 2006
Location: ::1
Karma: 0
General (1 Star)
Mauler wrote on Sat, 01 September 2012 04:20

Trying out these tools now Thumbs Up

Could you clarify the command prompt part... i keep getting a error message when i try to convert my w3d's


What's the error message?
Re: Guide to new lighting features in 4.0RC1 [message #473844 is a reply to message #473749] Sat, 01 September 2012 20:55 Go to previous messageGo to next message
Mauler
Messages: 448
Registered: May 2003
Location: Alberta, Canada
Karma: 0
Commander
Well it seems to work, but the w3d file i get out is a empty w3d and altmat.exe crashes here is the error i get with altmat

Problem signature:
  Problem Event Name:	APPCRASH
  Application Name:	altmat.exe
  Application Version:	0.0.0.0
  Application Timestamp:	503de0c2
  Fault Module Name:	altmat.exe
  Fault Module Version:	0.0.0.0
  Fault Module Timestamp:	503de0c2
  Exception Code:	c0000005
  Exception Offset:	00002c30
  OS Version:	6.1.7600.2.0.0.768.3
  Locale ID:	4105
  Additional Information 1:	0a9e
  Additional Information 2:	0a9e372d3b4ad19135b953a78882e789
  Additional Information 3:	0a9e
  Additional Information 4:	0a9e372d3b4ad19135b953a78882e789
Re: Guide to new lighting features in 4.0RC1 [message #473866 is a reply to message #473749] Sun, 02 September 2012 09:52 Go to previous messageGo to next message
Mauler
Messages: 448
Registered: May 2003
Location: Alberta, Canada
Karma: 0
Commander
Well i really wish i could use these tools, I have prepared fixed up Renegade MP structures that would recreate the ones used on official WW maps.. the ones now don't properly change exterior materials when destroyed.. these ones would totally fix that on future custom maps

Here is a shot of the Hand of Nod
http://www.tiberiumcrystalwar.com/staff/Mauler/images/Renegade/HAND_Lightmapped.jpg
Re: Guide to new lighting features in 4.0RC1 [message #473889 is a reply to message #473749] Sun, 02 September 2012 15:27 Go to previous messageGo to next message
saberhawk
Messages: 1068
Registered: January 2006
Location: ::1
Karma: 0
General (1 Star)
Could you send me the pair of .w3d files that crashes altmat so I can reproduce the issue?
Re: Guide to new lighting features in 4.0RC1 [message #473894 is a reply to message #473749] Sun, 02 September 2012 19:23 Go to previous messageGo to next message
Mauler
Messages: 448
Registered: May 2003
Location: Alberta, Canada
Karma: 0
Commander
Here you go

[Updated on: Mon, 03 September 2012 04:32]

Report message to a moderator

Re: Guide to new lighting features in 4.0RC1 [message #473904 is a reply to message #473749] Mon, 03 September 2012 03:31 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3556
Registered: February 2003
Karma: 0
General (3 Stars)

I have investigated this and it seems like right now there is a limit in altmat.exe where it requires you to pass the full path to all 3 w3d files (e.g. c:\blah) for it to work. If the full path contains spaces (e.g. c:\program files\blah) then you need to enclose the full path in quotes.

I know the right fix but we (TT) need to figure out how best to get the fix out there.


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Re: Guide to new lighting features in 4.0RC1 [message #473906 is a reply to message #473904] Mon, 03 September 2012 04:11 Go to previous messageGo to next message
Mauler
Messages: 448
Registered: May 2003
Location: Alberta, Canada
Karma: 0
Commander
YES! success I got it to work, toggling materials now works in w3d Smile , And yes the 3 files require you to enter the full paths

video
ingame too Thumbs Up

[Updated on: Mon, 03 September 2012 07:09]

Report message to a moderator

Re: Guide to new lighting features in 4.0RC1 [message #473914 is a reply to message #473906] Mon, 03 September 2012 13:17 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3806
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
Once again, I say all you had to do to fix that "Bug" was use scale instead of add. Add worked exactly how it was supposed to, it added the texture right to the brightness of the other material.

Last thing I want to do is go through and move all the times I used a Detail Color Add Texture to a completely different pass with white emissive because people never figured out they what they really wanted to use was Detail Color Scale instead for anything that you wanted to add another layer onto.

Detail Color Add works great for things that you want to glow in the dark and be on one pass. For instance, the buttons on a control panel, instead of doing it with two passes you can do it with one by giving the detail color an add.

In the end people should have been using "Detail Color: Scale" all along for their water, as it allows the water to take on shadows and otherwise mimics the effect of hiding it during light gen.


Re: Guide to new lighting features in 4.0RC1 [message #473928 is a reply to message #473749] Mon, 03 September 2012 19:31 Go to previous messageGo to next message
Mauler
Messages: 448
Registered: May 2003
Location: Alberta, Canada
Karma: 0
Commander
After more testing of the tools, here are some issues i had run into while making a test map

- You need to export your map (terrain) and any exterior models that have alternate materials into 2 w3d files, one containing the "dead" materials and one containing the "normal" materials.. and use altmat.exe to output one w3d that contains the alternate materials and map terrain

- You cannot proxy alt material w3d's, causes things to go wacky, hence why you need to export map and buildings (exteriors) together..

my opinion on the process, it is rather extensive work just for the buildings to function properly.. but worth it.

Here is my test map video

You can try for yourself too! added a rar file containing the map. To test just host a lan and turn off base destruction to win

[Updated on: Mon, 03 September 2012 20:47]

Report message to a moderator

Re: Guide to new lighting features in 4.0RC1 [message #473930 is a reply to message #473749] Mon, 03 September 2012 22:57 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3556
Registered: February 2003
Karma: 0
General (3 Stars)

What happens if you try to proxy alt-material w3ds?
Get me some examples I can play with to see just whats up please.


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies

[Updated on: Mon, 03 September 2012 22:57]

Report message to a moderator

Re: Guide to new lighting features in 4.0RC1 [message #473931 is a reply to message #473930] Mon, 03 September 2012 23:09 Go to previous messageGo to next message
Mauler
Messages: 448
Registered: May 2003
Location: Alberta, Canada
Karma: 0
Commander
Well the first time around I wanted to separate the Hand exterior, to keep it separate from the actual terrain mesh. By doing this i had to proxy the (mnhand_ext.W3D) along with the original structure proxy's, but once i loaded it into the editor the alignment of the interior relation to the exterior mesh was off

Here is how it was setup the first time

-Exported Test_level.W3D (Contained just the terrain ground and Original Hand proxys and one that I created to call the new altmat W3D exterior

-Added the Test_level.W3D to terrain
-Added the mnhand_ext.W3D to the terrain as well

-Loaded map and the the z-axis rotation of the interior was off by 90 degrees

The problem was corrected when i exported the exterior along with the terrain mesh and created two new w3d files for altmat

[Updated on: Mon, 03 September 2012 23:10]

Report message to a moderator

Re: Guide to new lighting features in 4.0RC1 [message #473932 is a reply to message #473749] Mon, 03 September 2012 23:27 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3556
Registered: February 2003
Karma: 0
General (3 Stars)

Send me a set of w3d files so I can play with it please.


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Re: Guide to new lighting features in 4.0RC1 [message #473933 is a reply to message #473749] Mon, 03 September 2012 23:34 Go to previous messageGo to next message
Mauler
Messages: 448
Registered: May 2003
Location: Alberta, Canada
Karma: 0
Commander
Here EDIT: forgot some files..

Proxy folder contains the bugged version of the map and exterior

[Updated on: Tue, 04 September 2012 00:37]

Report message to a moderator

Re: Guide to new lighting features in 4.0RC1 [message #473934 is a reply to message #473749] Tue, 04 September 2012 00:30 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3556
Registered: February 2003
Karma: 0
General (3 Stars)

ok, it seems like there is a limitation in the game and leveledit where you cant have multiple layers of proxies (i.e. in your case lvl_test.w3d proxies in nbhon_ext.w3d which in turn proxies in other stuff)


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Re: Guide to new lighting features in 4.0RC1 [message #473936 is a reply to message #473749] Tue, 04 September 2012 00:36 Go to previous messageGo to next message
Mauler
Messages: 448
Registered: May 2003
Location: Alberta, Canada
Karma: 0
Commander
Was kinda thinking that was the case, but it was solved never the less.. just wondering if was a proper way to include the terrain and exteriors.. the official maps have the terrain and exteriors as one w3d..
Re: Guide to new lighting features in 4.0RC1 [message #475017 is a reply to message #473749] Sat, 22 September 2012 21:01 Go to previous messageGo to next message
Mauler
Messages: 448
Registered: May 2003
Location: Alberta, Canada
Karma: 0
Commander
Been experimenting with the lights in the editor. I cannot find a way to export my lights from LevelEditor... there is an option as you mentioned but it does nothing

EDIT: Ok after some aimless trial and error, i found that you cannot export a new wlt file from leveledit. I got my lights exported but I had to overwrite blank wlt files to get em working so i could merge them into one file with wltmake

[Updated on: Sat, 22 September 2012 21:28]

Report message to a moderator

Re: Guide to new lighting features in 4.0RC1 [message #476827 is a reply to message #473749] Sat, 10 November 2012 10:57 Go to previous messageGo to next message
roszek is currently offline  roszek
Messages: 296
Registered: June 2010
Karma: 0
Recruit
I can get the altmat to work fine but can't seem to get wltmake to work (lighting doesn't show up) not sure what I'm doing wrong?

Oh well, I guess something is better than nothing. Smile
Re: Guide to new lighting features in 4.0RC1 [message #477227 is a reply to message #473749] Wed, 21 November 2012 20:32 Go to previous messageGo to next message
Generalcamo is currently offline  Generalcamo
Messages: 522
Registered: October 2010
Karma: 0
Colonel
Could someone sticky this please? I would hate for this to be buried.
Re: Guide to new lighting features in 4.0RC1 [message #477229 is a reply to message #473749] Wed, 21 November 2012 21:40 Go to previous messageGo to previous message
jonwil is currently offline  jonwil
Messages: 3556
Registered: February 2003
Karma: 0
General (3 Stars)

Anyone having problems getting the wlt export feature in LE to work should make sure they are running the latest version of 4.0.


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Previous Topic: I need something :o
Next Topic: Applying Texture onto a map
Goto Forum:
  


Current Time: Sat Jul 27 00:46:00 MST 2024

Total time taken to generate the page: 0.01252 seconds