PDA

View Full Version : Modding InfoCenter - Lights and LGHT files - *UPD 30nov2005*


Numenor
15th Nov 2005, 12:38 AM
>>> Modding InfoCenter <<<

LIGHTS AND "LGHT" FILES
Some (uncomplete) working notes

:new: MAJOR UPDATED 30 NOV 2005: PLEASE READ AGAIN :new:
:alarm: All creators please read Paragraph 7! :alarm:



DISCLAIMER: The "Modding InfoCenter" threads are NOT tutorials: they are intended to help average-experienced object creators performing specific tasks, or to give users a deeper in-sight on specific modding-related subjects. So, don't expect to find step-by-step explanations, to be performed "blindly".

Please DO NOT REPOST the following info, or part of them, on other sites.
All the "Modding InfoCenter" threads are created and mantained by Numenor and JWoods. Everyone is welcome to post his own questions or additional information about the specific thread subject.


-------------------------------------------------------------------------------------

SUMMARY
This InfoCenter articles has the purpose to explain how the lights are managed by the game, and what is the meaning and function of the LGHT files.
First off, let me state clearly that these notes are far from being complete; the LGHT file format hasn't been decoded completely, yet and some information are still missing or unknown. Every contribute is more than welcome! :)

:deal: This tutorial is also provided in PDF format. To view it, we strongly suggest to download the Foxisoft PFD Viewer (http://www.foxitsoftware.com/pdf/rd_intro.php): it's free and small, less than 1Mb!

http://thumbs.modthesims2.com/getimage.php?file=163363 (http://thumbs.modthesims2.com/getimage.php?file=163363)




1 - INTRODUCTION

In the game there are two types of lights: direct light, that hits the objects and the sims around the light source, and diffusion light, that is the ambient light and is reflected by walls and floors, and bleeds through windows.
Every lamp in the game emits both types of light, and therefore people often don't realize that they are managed in a different way by the game.
Infact, every object can emit direct light, but only lamps (i.e. objects that use the LampGlobals) can emit diffusion light.
:new: CORRECTION: all the objects can cast any light; only, the LampGlobals are always needed in order to turn the light on and off: some BHAVs from the LampGlobals must be manually imported in non-lamp objects, and they need to be adjusted, too. My suggestion is to clone a lamp, whenever possible.

:new: The light is defined and created within the game by means of four different, connected elements: the Lighting.txt file (located in the gamedir), the LGHT file, the TextList 0x8E and the Resource Node.
We'll see more in detail the purpose of each of them later on; let's start with an overwiew about the relations between the 4 elements.
The Lighting.txt (or better, the custom .nlo file: see part 2) is where both the direct and the ambient lights are created and defined; the settings contained in it will override any other setting. If a light is not defined in the .nlo file, or the definition doesn't set all the needed parameters, the game falls back on the LGHT file contained in the package; but the LGHT file can only define a direct light, and therefore, a missing definition in the .nlo file always prevents the object from casting diffusion light.
The Resource Node is where the object is associated with its light definition; in the CRES there is a cLightRefBlock that holds the reference to the light name, as defined into the .nlo file; the cLightRefNode is also used to translate and rotate the light.
Lastly, there's the TextList 0x8E. I'm not sure what is its purpose: in my experiments, if an object has a working light, putting a wrong reference in STR# 0x8E doesn't prevent the light from working. Probably it's just another fall-back value, i.e. is used by the game when the primary references to the light can't be found.



2 - THE "LIGHTING.TXT" AND THE ".NLO" FILES

As explained above, the Lighting.txt file defines all the lights, in both their "direct" and "diffuse" components. It is located in [GameDir]\EA Games\The Sims 2\Res\Lights. NOTE: there is a "lighting.txt" file for each EP gamedir: all of them are read when the game starts.
The "lighting.txt" file can instruct the game to load other external text files. These external files, in turn, can load more files.
This is done by specifying in the lighting.txt (or in the external file called by the lighting.txt) an "include" instruction, that can have one of these forms:
include "filename" -> This includes a specific file (that can have any extension, as long as it is a text file).
wildInclude "*.nlo" -> This includes all the text file with .nlo extension (again, the extension is irrelevant: you can use *.txt if you like).
sinclude "filename" -> The leading "s" stands probably for "single" or "standard"; I couldn't find any difference with the normal "include" command: it loads a specific text file (with any extension).

:here: NOTE - The game takes the "Lights" folder as root folder; the additional files specified in the various "include" commands can be located in a subfolder nested into the Lights forder, but not outside the Lights folder. (I've run a test with the downloads folder: unfortunately, the "include" commands can't find a file located there...). Please note that the paths defined in the "include" commands use the normal slash ("/") as separator, and not the backslash ("\").

In order to create a custom light, we need to create a text file (conventionally, the additional light definitions have extension .nlo, "New Light Override"). In this file, we need to define our light, by assigning specific values to some attributes.
The basic syntax is: lightAttribOverride customLightName_light Attribute Value. The "customLightName" is whatever we decide to call the light; to avoid confusions, I suggest to use the CRES name. The "Attribute" and the "Value" are contained in the following table, that contains all the attributes used in the game light definitions, and the values that Maxis used for them.

Parameter Name Min Max
------------------------------------------------
intensity n 0 12
color (R,G,B) 0 1
falloffRate n 0 5
coneAngle n 0 150 (degrees)
conePenumbra n 0 55 (degrees)
range n 1000 1000
diffusionSourceIntensity n 0 3.5
diffusionSourceColor (R,G,B) 0 1
diffusionSourceFalloff n 0.5 15
diffusionSourceMin (x, y) -0.5 0.2
diffusionSourceMax (x, y) 0 2
diffusionSourceFloorIntensityScale n 0.5 1
diffusionSourceWallIntensityScale n 0.9 1.5
diffusionSourceIsDirectional n 0 1 (boolean)
diffusionSourceDirectionalFalloff n 0 1 (boolean)


As you can see, some attributes define direct light and some others define the diffusion light. The purpose of some attributes is still unknown to me: here is explained what I could understand.
Intensity / DiffusionSourceIntensity - Self-explanatory; usually this value ranges from 0 (= no light) to 1 (= normal light); in some rare cases is 5 or even 12.
Color / DiffusionSourceColor - Self-explanatory; these parameters are useful to tweak the intensity, too: a value of 0.5,0.5,0.5 will produce a white light, but less bright than 1,1,1.
FallOffRate / diffusionSourceFalloff - Define how quickly the light will stop being visible; normal value = 0.5; (0 = infinite: the light will hit even extremely distant objects; high values = the light will hit only close objects).
ConeAngle / ConePenumbra - These values (expressed in degrees) represent the ray of the light cone, and the ray of the additional penumbra cone that surrounds the light cone. The sum of the two rays must be less than, or equal to, 180°.
DiffusionSourceFloorIntensityScale / DiffusionSourceWallIntensityScale - These are multipliers that define how much walls and floors reflect the light; usually, their value is 1 (= normal reflectivity); values less than 1 attenuate the reflectivity.
(All the remaning attributes are unknown to me)



3 - THE "LGHT" FILE

First off, let's clear up is that there are four different "LGHT" filetypes in the game: Ambient Light and Directional Light (mostly used in CAS screen), Spot Light (used for doors and windows), and Point Light (used for lamps and other objects that lit up).
All the information provided in this article refer to the "Point Lights", though they probably apply to other LGHT types, too (untested).

As explained in the Introduction, the LGHT file defines the direct light, but is used only if there isn't a correct definition into the Lighting.txt.
The attributes set in the LGHT file are partly coincident with the LightAttributeOverrides that we have examined in the previous paragraph; as far as I could see, only some of the attributes related to the direct light are included in the LGHT file, not all. But again, there are some unknown values in the LGHT, too; so, I can't be sure if some attrivùbutes are really missing from the LGHT file...
Opening the LGHT in SimPE we can find (and edit) the following values:

Val1 = "Intensity": see explanation above; usually set to 1.
Val2 = (Unknown); normal value = 1; known range = 0.5 -- 1.0.
Val6 = "FallOffRate": see explanation above.
Val7 = (Unknown); normal value = 20; known range = 0 -- 20.
R, G, B = "Colour": see explanation above.


There are several name reference within the LGHT file; though some of them seem only explanatory (i.e. don't have to match the names in the Lighting.txt, or the CRES, or the STR# 0x8E), it's a good habit to follow a strict naming convention:
Filename - It's the scenegraphic name of the file: it should be in the form cresName_customLightName_light_lght (where "customLightName" is the name defined in the .nlo text file).
"cPointLight" tab, "Name" field - Put here the name of the light only, i.e. customLightName_light.
"cLightT" tab, "Name" field - Put here the full LGHT filename: cresName_customLightName_light_lght.
"cObjectGraphNode" tab, "Filename" field - You can leave this empty.



4 - THE TEXT LIST 0x8E
This file holds the reference to the light name, as defined in the .nlo file (i.e. customLightName_light). As said, I'm not sure about the purpose of this TextList: if the reference is wrong, the light will work anyway...



5 - THE RESOURCE NODE

In order for the LGHT file to be seen by the game, it must be linked to the Resource Node (CRES): a link to the LGHT file must be added to the CRES, "Reference" tab.
:here: NOTE: the Reference list within the CRES relies on the TGI of the various files linked: if you rename the LGHT file, you have to click "Fix TGI", and then change the reference in the CRES.
Then, a cLightRefNode block must be added to the CRES hierarchy, and attached it to an existing branch (see example in paragraph 6).
The name of the cLightRefNode has to be set in the "cObjectGraph" tab: it must match the light name defined in the .nlo file, i.e. customLightName_light. If multiple cLightRefNodes are added to the CRES, and all of them are related to the same light definition, then all of them must have the same name.

Once the LGHT file is properly linked to the CRES, it may be used by the object. You might need to adjust the light position, by editing the translation values into the "cTransformNode" tab of the cLightRefNode block.




6 - AN EXAMPLE: ADDING A DIRECT LIGHT TO AN OBJECT - ***UNFINISHED!***

1) First off, we need a LGHT (Point Light) file: you can extract it from any lamp, or directly from the Objects01.package, located in the GameDir.
You can choose any LGHT file, as long as it is a "Point Light": we'll adjust its parameters to match our needs.

2) Import the LGHT file into your package and rename it; the structure of the LGHT filename is the following: CRESname_DiffusionLightName_light_lght. You just have to replace the first part (before the first underscore) with the CRES name of your object. Do this either in the main "Filename" field and in the "Name" field under the "cLightT" tab. Then FIX TGI and commit.
http://thumbs.modthesims2.com/getimage.php?file=163362 (http://thumbs.modthesims2.com/getimage.php?file=163362)

3) Open the CRES, "Reference" tab, and add a reference to the LGHT file: use the Package Selector Form as shown in picture to drag-and-drop the reference into the list. Take note of the position of the added reference in the list; in this example, the Lighting is in position #2 (the positions start from zero).
http://thumbs.modthesims2.com/getimage.php?file=163371 (http://thumbs.modthesims2.com/getimage.php?file=163371)


4) Add one "cObjectGraphNode (cLightRefNode)" block into the CRES ("Edit Blocks" tab). Take note of the number of the added block.
http://thumbs.modthesims2.com/getimage.php?file=163372 (http://thumbs.modthesims2.com/getimage.php?file=163372)


5) Include the newly added block in the CRES Hierarchy, by adding a "Child Node" into one of the existing branches (usually, main Shape, like in picture).
Note: while adding the Child Node, the "Unknown 1" value is always "1", and the "Child Index" is the number of the added block, that you have written down in previous step 4.
Optionally, adjust the translation (i.e. the relative position of the light compared to the Shape). COMMIT, then CLOSE and RE-OPEN the CRES (so to update the Hierarchy).
http://thumbs.modthesims2.com/getimage.php?file=163409 (http://thumbs.modthesims2.com/getimage.php?file=163409)


6) Select again the CRES Hierarchy and select the (now shown) new light block. Open the "Unknown2" block and set the values as shown in picture (I don't know the meaning of all these values, but they seems identical in all the cLightRefNodes...). In particular, the value [7] must be set to the position numeber of the LGHT file in the CRES Reference list (the one that you have noted down in step 3).
http://thumbs.modthesims2.com/getimage.php?file=163416 (http://thumbs.modthesims2.com/getimage.php?file=163416)


6b) (Added thanks to the info provided by Calidan)
In the same tab, just above the "Unknown1" value, there is a "String[] Array" (the name may change according to the localized version of your .NET environment): open it by clicking on the little grey button with the three dots and write Practical in the text field. We are not sure why this is necessary, but probably the "Practical" value is needed to define the type of the block, and to instruct the game on how to manage it.
http://thumbs.modthesims2.com/getimage.php?file=174626 (http://thumbs.modthesims2.com/getimage.php?file=174626)


7) The object is now ready to work. We only need to adjust the parameters in the LGHT file: as explained, you have to set the RGB values for the light colour, the VAL1 for the intensity and the VAL7 for the Attenuation.


NOTE - As explained, the object of this example will not cast any "diffusion" light, because we only have added a LGHT file (a "direct" light).
In order for the object to cast a diffusion light, we have to import in the package a Text List 0x8E, extracted from a lamp that casts a light that we'd like for our object, too. But the Diffusion light will work only if your object uses the LampGlobals (i.e. it was cloned from a lamp); on the contrary, the Direct light works in every type of object.


:alarm: 7 - CREATORS GUIDELINE FOR A UNIFORM MODDING TECNIQUE :alarm

When creating a custom object that is intended to emit light, first off you should consider the following:
1) Does the object really need a diffusion light? If you are creating a candle, or a small, "intimate" lamp table, you don't need a diffusion light at all, and therefore a suitable LGHT file contained into the package is more than enough to create the direct light alone.
2) Does your object need a custom diffusion light? The game already contains definitions for a lot of nice diffusion lights: high lights, low lights, coloured lights... You can re-use one of the already defined lights: just clone a lamp that has a light that you like, read the value from the Text List 0x8E and paste it in your package (use that reference also as name for the cLightRefNodes in the CRES!).
3) OK, your object really needs a custom diffusion light. In this case you need to do the following:
install the CEP v.3.3 or newer: it enables support for custom light in the game, by adding a "wildInclude" command to the Lighting.txt; also, the CEP3.3 creates a folder called "CEP3_CustomLights" within the main Lights folder: all the custom .nlo files should be installed there, if you want the game to read them;
create a blank text file, rename it like the .package that contains your object and change the extension to .nlo;
edit the .nlo file, defining all the light attributes, as explained in paragraph 2;
put both the .package and .nlo in the same ZIP and upload it;
warn the users that - in order to use your object - they have to install the CEP 3.3, and then put the .nlo file in the folder: [gamedir]\EA Games\The Sims 2\TSData\Res\Lights\CEP3_CustomLights[/B].


:here: NOTE - Some older posts and threads, as well some older coloured light posted here on MTS2 used a different approach, that I strongly discourage: modifying the light definition of an existing (Maxis) light. I discourage it because this way you'll modify the behaviour of all the Maxis lamps that use that light definition. For example, if I create a red wall lamp, and modify the "lightingwallvalue_light", giving it a red tint, every Maxis cheap wall lamp in the game will emit a red light!




-------------------------------------------------------------------------------------

OTHER USEFUL RESOURCES

Modding Infocenter Index (http://www.modthesims2.com/search.php?titleonly=1&showposts=0&do=process&query=InfoCenter) - Comprehensive list of all the InfoCenter threads
Object Creation Workshop and Repair Center (http://www.modthesims2.com/showthread.php?t=82084) - If your object doesn't work, no matter what you try
The CRES File (http://www.modthesims2.com/showthread.php?t=84487) - To better understand the structure of the Resource Node.




-------------------------------------------------------------------------------------

XTS
18th Nov 2005, 01:35 AM
Is this guy a genius or what!?! :D
Thank you Numenor! And all along I thought you were putting the potion code in your files!! lol
Thanks for sharing with us..
xts

Calidan
28th Nov 2005, 02:55 PM
Well, I followed the basic tutorial of Numenors' Modding InfoCenter - Lights and LGHT files (http://www.modthesims2.com/showthread.php?t=103817) but my object still does not want to light up. The object was not cloned from a light initially, but from reading that thread (and others) it seems that this is only 'really' required if I want diffusion light, and in this case I just want it to generate A light (so spot works for my needs).

My object now loads into the game without crashing or generating object errors, sceneograph shows it all there and available, just no light.

Do I have to mess with BHAV's to turn it on (tried but that generates errors because I'm most likely doing it wrong anyway), or should it be ON by default? Will I have to import the light semi globals to make it work?

Any pointers or suggestions at this stage would be welcome as it's been annoying me for the last couple of days :)

I've even recloned the original item and started from scratch twice still to no avail.

Oh. Its a cloned sculpture item that I want to generate a perm. low level light.

Thanks for any help/suggestions etc in advance - and while I would prefer to not upload the package (simply because I'm not ready to let others see it as it's something I have not yet seen done, and am protective of 'what' it does) I will IF its the only way to get some closure to this annoying light problem. (is it possible to just upload/email it to someone privately? if needed?)

And Numenor, the last image in the tutorial is linked to the wrong attachment :) just thought I'd mention it.

--
Calidan

Numenor
28th Nov 2005, 07:02 PM
Calidan, first off, thanks for the heads up about the wrong image.

So, your objects was not cloned from a lamp... It shouldn't be a problem, but I need to double check my notes and my experimental packages. I will let you know.

If I need to look at your packages, I'll give you directions for a "private" delivery :)

Calidan
28th Nov 2005, 11:08 PM
Calidan, first off, thanks for the heads up about the wrong image.

So, your objects was not cloned from a lamp... It shouldn't be a problem, but I need to double check my notes and my experimental packages. I will let you know.

If I need to look at your packages, I'll give you directions for a "private" delivery :)

The help is much appreciated - thanks

Also just another clarification. LGHT(LightRef) is associated with ShapeRef, and as such the textures used on an object should have no affect on lights?
ie. The game engine would not have a problem with objects with animated textures?

If is does, would I be better using 2 Shape entries and only associating Lights with the non-animated one?

(The above questions are irrelevant, but left in as were part of the initial post)

EDIT: **UPDATE** Problem Solved
It seems I was overlooking 1 (apparently) important setting.. Before the light can actually be emitted by the ShapeRef it is linked to, you must let the game know WHAT that ShapeRef is.

Now in Numenors' tutorial at the beginning of this thread, he points out that you must set the Unknown2 Value [7] to the position number of the LGHT Ref. From my testing and experimentation it seems you must ALSO add a reference to the ShapeRef (the one set as 'Practical') into the Strings Array. You do not reference the Shape by its name, but rather simply a pointer to the 'Practical' ShapeRef.
http://216.32.95.38/images6/MTS2_174626_Calidan_LightSetting.png

Simply adding this Array item has now allowed my item to emit light (and yes lights are on by default) which I am SO pleased about.

Hope this helps :) and perhaps this could also be mentioned in the tutorial/outline you started the thread with Numenor.

--
Calidan

Numenor
29th Nov 2005, 01:56 AM
Thanks Calidan, this is an important clarification!

In my test packages (and actually in all the Maxis LGHT that I've examined), the first element of that String Array is always set to "Practical"; sometimes, a second string, set to "Sims", is added to the array.

To tell the truth, I don't know what "Practical" means. I only know that the cLightRefNode has the same structure than the cShapeRefNode, which is labeled as "Practical", too.

BTW: what about that "Unknown1" set to zero that I see in the screenshot? In all the LGHT files that I've seen it is always set to 1...

Calidan
29th Nov 2005, 10:26 AM
Thanks Calidan, this is an important clarification!

In my test packages (and actually in all the Maxis LGHT that I've examined), the first element of that String Array is always set to "Practical"; sometimes, a second string, set to "Sims", is added to the array.

To tell the truth, I don't know what "Practical" means. I only know that the cLightRefNode has the same structure than the cShapeRefNode, which is labeled as "Practical", too.

BTW: what about that "Unknown1" set to zero that I see in the screenshot? In all the LGHT files that I've seen it is always set to 1...

Yes I have noticed that also and initially thought that both were needed. But when I tested this I found that the light would generate illumination regardless of Unknown1 being Zero or One, so at this stage I have not determined what this setting actually relates to. In this case as I was adding a LightRef to a non-light item, Unknown1 and 2 were all set to Zero by default and as such I left it Zero when I added the string 'Practical' to test.

If someone else could shed some LGHT (heh) on what this Unknown1 refers to, and if leaving it Zero will cause any 'instability' in a light object please. (Don't want buggy objects now do we)

--
Calidan

chrissy6930
29th Nov 2005, 11:23 AM
After reading your thread about LGHTs I have yet another question: as the cSpotLight refers to a system file not to a file in the package did I understand u correctly in believing I can replace the 'windowcolonialtallarch' or the 'windowtwotilewideloft' with any of those listed in the blocks starting with 'create' in the windows.txt?
using the windowArtNouveauRound for a round window is very tempting...

if I did get u right there does not seem to be any case sensitivity - cSpotLight vs text file...
would I need to do anything about the settings in cSpotLight as well ?
and how can I figure what the diff between the files listed is?

Numenor
29th Nov 2005, 03:05 PM
Chrissy, as far as I coud see, the label that you can read in the "Name" field (into the LGHT file, "cSpotLight" tab) is only descriptive.
The values in the other 9 fields (Val1 to Val9, including the RGB ones) are the actual values that define the light.

Mind that, unlike you might think, doors and windows don't cast any "diffusion" light: they only cast "direct" light, which is defined inside the package, in the LGHT files.

If you have created a small, rounded window by cloning a large rectangular one, then probably the LGHT files in your package define too a strong light for such a small window; *and* the position of the source of the light (which is defined in the CRES) is probably out-of-center, compared to the new window.

In order to fix these problems (that should be barely visible, anyway), you should:
Extract both LGHT files ("north" and "south") from a Maxis window that is similar to yours.
Replace the LGHT files in your package with the extracted ones.
While replacing, be sure not to confuse the "north" and the "south" files; and be sure to restore the original filenames that your LGHT files had before the replacement (this is very important, because a different name generates a different TGI, and the TGI is already set in the CRES reference table: if the TGI changes, the LGHT will lose its link to the CRES, and the window will not cast direct light any more).

As for editing the translation of the cLightRefNodes into the CRES, I think that you know how to do it, right?

Bottom line: remember that all these info are mostly untested; if the directions given above are inaccurate, let me know and we'll discuss them more deeply.

Numenor
29th Nov 2005, 03:24 PM
Calidan, I've added the info you provided in the article. But I have another explanation (well, sort-of) for that "Practical": it is not a reference to the cShape; simply, both the cShape and the cLight are "Practical" blocks, whatever it may mean.

There are a lot of similarities between the cShape and the cLight (for instance, both refer to the "reference list" set in the CRES, which is a thing that no other block do, except for the cViewer); so, this parameter may simply define the "type" of block.

Calidan
29th Nov 2005, 04:23 PM
Calidan, I've added the info you provided in the article. But I have another explanation (well, sort-of) for that "Practical": it is not a reference to the cShape; simply, both the cShape and the cLight are "Practical" blocks, whatever it may mean.

There are a lot of similarities between the cShape and the cLight (for instance, both refer to the "reference list" set in the CRES, which is a thing that no other block do, except for the cViewer); so, this parameter may simply define the "type" of block.

You could be right on the mark there. Trust Maxis to 'reuse' a definition :) But that then poses the question, how does the 'Sim' entry found in some strings arrays relate to a light and since the LightRef seems to be the only block (well not that I've looked too deep) that uses arrays in this form, is it refering to how the light is emitted, or where the light is emitted from. It was this latter thought that made me add it, since the ShapeRef is also considered 'practical' (which I guessed meant the 'actual or usable' shape ingame)

Ah well :) lots of guesswork at this stage, little 'information' :)

Re: The LGHT article. I'm glad my little contribution could be of help. Thanks

--
Calidan

Numenor
29th Nov 2005, 07:06 PM
Yes, I wondered about the meaning of the "Sims" entry. I want to look into the "SimsXX.package" to see if the cShapes are qualified as "Sims" there... You know, I'm only expert with objects and the "ObjectsXX.package".

Moreover, I'm not expert in hex editing, so I can't confirm this; but the fact that SimPE represents in a different way the cShape and the cLight doen't mean that the blocks have a different structure. Beside the graphical representation, I find the two blocks very similar, i.e. they contain the same data, more or less.

But I agree that there is a lot of guessing work yet to do on this subject :)

Kristos_Kazare
30th Nov 2005, 05:40 AM
I have just been playing around with this all day. At least I know what I over looked and where. Alright, I made an object, and it will light up, but not cast any defused light on the wall. I created the nlo file, typed it in the lighting.txt file, but still no defused light. I know I'm doing something wrong somewhere, could you possible break down the nlo and lighting.txt file a little more? Oh, it was cloned off a light. I used the neon strips from NL.

Numenor
30th Nov 2005, 03:48 PM
My guess is that your custom .nlo file isn't read by the game, because it is "included" in the main lighting.txt.

The lighting.txt file, as said, can instruct the game to load other external text files. These external files, in turn, can load more files.
This is done by specifying in the lighting.txt (or in the external file called by the lighting.txt) an "include" instruction, that can have one of these forms:
include "filename" -> This includes a specific file (that can have any extension, as long as it is a text file). This command is available for all the games (TS2, UNI, NL).
wildInclude "*.nlo -> This includes all the text file with .nlo extension (again, the extension is irrelevant: you can use *.txt if you like). Available for UNI and NL; probably it works in TS2, too (untested).
sinclude "filename" -> The leading "s" stands probably for "single" or "standard"; I couldn't find any difference with the normal "include" command: it loads a specific text file (with any extension). Available for TS2/UNI/NL.

:here: NOTE - The game takes the "Lights" folder as root folder; the additional files specified in the various "include" commands can be located in a subfolder nested into the Lights forder, but not outside the Lights folder. (I've run a test with the downloads folder: unfortunately, the "include" commands can't find a file located there...).
:here: NOTE - The values specified in the text files (the lighting.txt and all the one "included" in it) will override the settings in the LGHT files contained in the packages.

:here: SUGGESTION to creators and modders - The "Lighting.txt" file is too an important game file to fiddle with it. In the effort of providing a uniform behaviour to all modders, I suggest to do the following:
1) Create a backup copy of the lighting.txt file, located in the base-game dir ([gamedir]\EA Games\The Sims 2\TSData\Res\Lights).
2) Append to the Lighting.txt the following line: wildInclude CustomLights/*.nlo.
3) Create a folder named "CustomLights" nested into the folder [gamedir]\EA Games\The Sims 2\TSData\Res\Lights.
4) Put your custom light definition (that must be a text file with .nlo extension) into the CustomLights folder.

The steps 1 to 3 are to be performed only once, and it will enable the custom lights.
This way, the game will read and create, when starting, all the custom lights defined into the CustomLights folder.
When uploading an object with custom lights, we can then ask the users to put the object in the the Downloads, the .nlo file in the CustomLights and (if they didn't already done it) append that single line to the lighting.txt.


I'm still experimenting: more info will be added later on

Kristos_Kazare
30th Nov 2005, 06:16 PM
Hmmm, I followed the steps to the tea, but the ambient light is still not showing. I was wondering if it had something to do with the editted mesh, so I made a test and didn't change the mesh for the plutonium rods in NL. Changed everything so it wouldn't over-right anything and added the light. I made all the needed changes to the lighting text file, custom nlo file, and it still wouldn't show. I'm gonna try again today because I'd really like to make some custom neon signs, but need to get the ambient light working.

Numenor
30th Nov 2005, 08:30 PM
Either the nlo file wasn't written correctly, or there is something wron in the internal references of the package.

My experiments show that in the CRES, the cLightRefNod must have a name that match the one of the light defined in the nlo (e.g. if the light name is "MyCustomLight_light", all the cLightRefNode(s) must have, in the cObjectGraphNode, "MyCustomLight_light").

I'm still testing, but if you want to be sure, put the same name ("MyCustomLight_light") in the STR# 0x8E, without adding any prefix: no ##0x1c050000! here; and lastly put "MyCustomLight_light" in the LGHT file ("cPointLight" tab").
Also, the LGHT name should be: cresName_MyCustomLight_light_lght.

Numenor
30th Nov 2005, 10:15 PM
I'm sorry, I'm not the right person to ask about Milkshape: I'm more "amateur" then you at meshing :)

Kristos_Kazare
1st Dec 2005, 01:38 AM
Well, I worked on it, and worked on it some more. Deteled the clone and made a new one, and it's just not getting any ambient light. I followed everything to the letter and still nothing. The item was cloned from the plutonium rods from NL and already has it's own ambient light, but even with nothing changed (text list, lighting.txt, etc) it still won't show with the ambient light.

Numenor
1st Dec 2005, 02:40 AM
I've been reworking this article for the whole day (it's 3:30 AM, here, and I'm still working... :)).

Since you are so interested, I'm going to post the new, unfinished version: it is complete with regards to the info provided, but the Example / tutorial is still to be reworked, so don't rely on that.
Concentrate on the names: dont's confuse the light name (customLightName_light) with the LGHT filename (cresName_customLightName_light_lght). Pay attention to the crossed references, as explained in the article.

Kristos_Kazare
1st Dec 2005, 03:04 PM
I guess I am doing something completely wrong somewhere. Lets say you clone a light, wouldn't the clone have ambient light if you didn't change anything? Because even if I just clone a light, it's still not pulling any of the ambient light at all. It will turn on and off and give off the direct light, but no ambient.

Numenor
2nd Dec 2005, 02:42 AM
A cloned lamp should cast diffusion light... I've cloned hundreds of lamps and they all do...
Perhaps you changed something in the TextList 0x8E or in the CRES (the names od the cLight blocks)?

darylmarkloc
28th Feb 2006, 08:37 PM
What the hell is "TEXT LIST 0x8E" in English? Using Hex for descriptors is annoying...

Numenor
28th Feb 2006, 08:54 PM
SimPE uses hex to represent the Text List numbers...
The "Text List 0x8E" is the Text List with instance number 0x00008E

I could use the textual name (in this case, "Light Names"), but that name is purely decorative, and is often different from object to object, while the instance number (0x8E) is always the same.

darylmarkloc
3rd Mar 2006, 04:09 AM
I'm sorry- I was getting frustrated after an evening spent trying to find meaningful information in conversations carried on almost entiredly in hex..it's like showing off by old time programmers who talk about what they had for lunch in OpCodes. SimPE and learning to modify would be a lot less of pain if it substituted function and variable names for fixed known hex identifiers in the first place..it'd certainly be easier to follow what is going on or at the very least there was a published list of codes and their meanings (if there is I haven't seen it) - the words 'user friendly' come to mind

jaxad0127
3rd Mar 2006, 04:52 AM
SimPE and learning to modify would be a lot less of pain if it substituted function and variable names for fixed known hex identifiers in the first place..it'd certainly be easier to follow what is going on or at the very least there was a published list of codes and their meanings (if there is I haven't seen it) - the words 'user friendly' come to mindTry the PJSE plugin, standard in all SimPE releases for a while.

tunaisafish
3rd Mar 2006, 06:28 AM
darylmarkloc,

See the PJSE forums at http://simlogical.com/SMF/

Specifically, the PJSE Includes forum. This is an attempt to document to global constants, and common function parameters. One step closer to converting ts2 hex codes to english.

jaxad0127
3rd Mar 2006, 06:33 AM
The PJSE bhav plugin includes those and more. Just get the latest SimPE.

tunaisafish
3rd Mar 2006, 08:04 AM
jaxad, No it doesn't. I would know as I moderate that forum :)

It was discussed about adding these to PJSE part of SimPE, but it would needlessly increase the download size for those not interested in BHAV hacking. That would be the vast majority of SimPE users.

Numenor
3rd Mar 2006, 08:43 AM
darylmarkloc - I perfectly understand your point, since I'm not a programmer and hex editors always made my head spin :)
But I'm not, e.g., describing in hex a BHAV line: I'd never describe a code line as "0x0002 - 04000000000500070000000000000000", but I'd use the user-friendly translation provided by the PSJE plugins "Expression (My attribute 0x0004 "Exit?" := Literal 0x0000)".
If - every now and then - we have to use a single hex number just to name an element of the package, it's not "talking in hex" :)

darylmarkloc
3rd Mar 2006, 09:45 AM
Back to lights..and sorry for causing this off the track series of posts. I made a 2 storey light for indoors..it wasn't anything particularly original, simply being a transplant of a light I knew reached two floors from outside use to inside. Although it works well enough and lights a 2 floor space just fine, it needs tweaking, I think, because the effect of the light (reflection off walls and floor etc) is different if the space is not a true room, if it is a basement and if it is a true room (eg; no wall gaps). It may be this is just the way the game will display light over those spaces regardless. Anyway, I've thrown it open to anyone who wants to improve it. I've played with an *.nlo file per this thread and frankly, nothing I do seems to make that much difference to changing the spread, reflection or luminosity.

Numenor
4th Mar 2006, 12:34 AM
The way the game handles the light effects is complex, and sometimes (for instance, in your case, where the light is put into a non-standard space), editing the .nlo file isn't just enough.

Reading the thread about the Radiance Lighting Mod (and examining the mod itself), I've understood how many variables are taken in account by the game when a light is displayed. Basement, for instance, are known to be a "defective" area, where light is not displayed correctly.

Karybdis
12th Apr 2006, 09:26 PM
btw, incase this hasnt been noticed,

I put the description of the light values on the wiki a few months ago. http://wiki.modthesims2.com/C9C81BAD
for the less complex lights, just cut values off the end of the floats.

MissWendy
14th Apr 2006, 03:51 AM
Thank you, Thank you.. This is exactly what I have been looking for! You are truely the best!!

Numenor
14th Apr 2006, 10:24 AM
btw, incase this hasnt been noticed,

I put the description of the light values on the wiki a few months ago. http://wiki.modthesims2.com/C9C81BAD
for the less complex lights, just cut values off the end of the floats.

Hi Karybdis! How nice to see you around!
Oh!, I didn't notice that you had recently updated that wiki page... Thanks for the heads up (I knew the older version, with no explanations, but just the "float1", "float2"... values).

Finally I see the complete connections between the parameters in the text files (.nlo) and the LGHT file in the package... I was missing the inner and outer angle in the LGHT...

shannanisims
3rd Jul 2006, 06:47 PM
Sorry I'm trying to follow all this but it might as well be written in Chinese
(or any other language besides English... because I can't understand a thing!)

Here is my issue... I cloned the wall light from the base game with the flame animations.
I want to make a floor lamp and post lamp with the same flame effect.
So I cloned it, changed their placement (which works perfectly)
but they don't reflect light like a regular floor or post light. They still
reflect (diffuse... is that the proper term?) light like the wall light does.

So what exactly would I need to change to get them to have the
same diffused light as other floor and post lamps? I'm not really creating
a custom light file... I just need to change these so they light up the
areas around them properly.

Numenor
3rd Jul 2006, 09:47 PM
If you changed the placement of the lamp, the origin of the light is likely to be located in a different place/height than the original position. In simple words, in the original wall lamp, the bulb is in a high position, near the wall; while in a floor lamp it is in a lower position and far from the wall.

Moving the mesh in the GMDC isn't enough, because the position of the light is defined in the CRES: if you look in the CRES Hierarchy, you'll see a cLightRefNode (it's the one with a little "bulb" icon next to it). Click on it, and the node will open up; go to the cTransform tab and look on the left, at the "Translation" box. In this box, you see the coordinates of the original bulb: you have add/subtract some values so to "move" the bulb in the correct position.

Remember that:
- Increasing the X moves the bulb on the left
- Increasing the Y moves the bulb towards you
- Increasing the Z moves the bulb upwards.

Remember also that the unit of measure is the tile: i.e., if you add 1 to the X, the bulb will move 1 tile to the left.
You don't have to be extremely precise; mind that the "bulb" we are talking about isn't actually visible in the game: it's only the (invisible) point that the light originates from.

shannanisims
5th Jul 2006, 04:16 PM
Thanks Numenor... that did the trick! I just copied the placement info
from similar existing objects (cuts down on trial and error. What can I say
I have limited patience. LOL!) and now the glow around the lights is perfect.

I don't know how you can open up those packages and look at
all those random digits and figure this stuff out. Its pretty darn amazing!

Numenor
5th Jul 2006, 09:08 PM
Good job, Shannanisims :) Copying from existing objects is always the best thing to do in most cases.

georgia_blakeley85
6th Jul 2006, 04:06 AM
Hi! first of all I have to say that youre a genius Numenor! Im very new here and id like to start to learn about modding, so please bare with me if I sound dumb ;D
I was wondering if it's possible to change a single object's (lamp) light colour, for exmaple: a ceiling lamp that originally radiates bluish light would be changed to radiate yellowish light. hope you can understand ;)

Numenor
7th Jul 2006, 12:09 AM
Yes, Georgia, what you ask can definitely be done.
As explained in the first post, the light sources emit two types of light:
direct light (also technically called "Practical" light), that hits the surrounding objects and sims;
diffusion light, that hits walls and floors.

In order to fully change the colour of the light of a lamp, you have to change both types of light.

The direct light can be easily defined within the LGHT file that is automatically included in the package when you clone the lamp. The instruction on how to edit the LGHT file can be found in part 3 of the article above.

The diffusion light can be defined into a separate .NLO file, built using the info provided in Part 2 (NOTE: read also the installation instructions for installing the NLO file into your game; and remember that you need the latest CEP in order to use custom diffusion light in your game).

One last thing that I feel it's important to repeat, though already explained in the article, is that, in order for all these lights to work, the name of the light itself must be unique in the game, and identical in all the light references contained in the package and in the NLO file.
The "light name" I'm talking about is the "customLightName_light" that is named several times in the article: it must be written in the LGHT file, in the TextList 0x8E, in the CRES and in the NLO file, as explained in the several parts of the article.

But before doing anything, please read carefully Part 7, point 2: in your case, probably the easiest thing to do is to assign to your lamp the blue light used by Maxis for the bulb-shaped table lamp.

georgia_blakeley85
7th Jul 2006, 03:27 AM
Wow, thanks for answering Numenor! Ill certainly just read the article first before I ask any more questions ;)

Max3D
22nd Jul 2006, 03:55 PM
maybe i've lost something... but inside the array "unknown 1" you can't write "PRACTICAL" c'ause it takes only number..
i've tryed with 0x03 'cause it my practical.. but the light didn't work :(

Numenor
22nd Jul 2006, 04:36 PM
I said:
In the same tab, just above the "Unknown1" value, there is a "String[] Array..."
You have to edit the string array, not the Unknown1 value.

Max3D
22nd Jul 2006, 04:42 PM
I said:

You have to edit the string array, not the Unknown1 value.

oh... lol :lol:

thnx :giggler:

nectere
28th Jul 2006, 01:37 AM
I have no idea where to look for this answer so I am going ask here and hope for one. I cloned a light did my thing and it works perfectly...except I can not recolor it - sorta. I can recolor the original from which I cloned mine - so I know I SHOULD be able to recolor it. However mine will hold the recolors, they appear there but the object does not update with the new color selected in design mode - what should I be looking for?

IgnorantBliss
28th Jul 2006, 04:50 AM
nectere, did you update MMATs with the main GUID? Open the MMATs and see what the value for the line objectGUID is. Is it the original Maxis GUID or yours?

nectere
3rd Aug 2006, 05:25 PM
Yes I did, there was actually only one GUID, so it was the main. And yes all 4 of the mmats have the custom GUID not the original.

I cloned the spike light. I have checked this package forwards and backwards, rebuilt it, recreated it over a dozen times. Currently I am having someone else look at it because nothing I have done or someone I had look at it has done has been able to solve the problem. Perhaps its unique to the spike light I am not sure...its been released into the wild as not recolorable but I sure would like to get it working for my own benefit since I know the spike light is in fact recolorable because I recolored it, just not my clone of it. *sniff*

Thank you Ignorant Bliss for writing back and trying to help.

Numenor
3rd Aug 2006, 10:19 PM
The Spike Light is slave of the "City Dweller Dims" garden light (as stated in the CEP documentation); therefore, it is not autonomously recolourable.
With Maxis items, SimPe is quite smart, and when you try to recolour the Spike Light, it actually creates a recolour for the City Dweller. But the clone of the Spike light might cause problems to SimPE. I suggest you to clone the City Dweller Dims, or - as an alternative - clone the Spike Light with the "Make stand-alone object" option active; but I warn you: especially with muilti-state objects, like a lamp, the "Make stand-alone" option might give unexpected results.

nectere
4th Aug 2006, 05:17 AM
Actually I did use make stand alone (along with uncheck remove useless files) and it still doesnt take the colors. I can make a recolor of the object I have cloned, it shows up in design mode in the catalog and lets me select it in design mode, but when I select it, nothing happens. I have tried cloning it in various ways, checking and rechecking everything, (and I have a learned a lot more than I set out to with all the tutorials I have read lol) so I guess I will need to clone the other light as you have suggested. Thanks for the input Numenor, its much appreciated.

KevinsHope
11th Dec 2006, 03:45 AM
Thanks for this tutorial. It is awsome.

maybesomethingdunno
26th Mar 2007, 02:15 AM
This is very useful and interesting, thanks! This may not be the right place to ask this, but I think it is related. If an object already has light files but you do not want it to give off light (the opposite intention of this thread, I guess :lol: ), is there any risk in simply deleting them from the package?

I ask because I do not think I have found and changed every light-related BHAV in an object that has many BHAVs. I tried setting Val1 to "0" in both light files found in the package, thinking "0 = no light", but it was only after I deleted the light files that I could get it to stop giving off light. So far, I have not seen any errors (other than an unrelated one that I am trying to fix now ;) ) but I just wanted to get an expert opinion. I know BHAVs can control lights; but, without the light files in the package, could there be any problems I just have not come across yet?

(I am sorry if this is the wrong place to ask this. I just thought it was the best place since this thread deals with how the lights are managed by the game.)

Ben♣
17th May 2007, 06:44 PM
Hello everyone,

I'm making a lamp. I cloned a 1-tile lamp and followed Echo's tutorial to add a second tile. It works fine. The problem is that there seems to be light on 1 tile only (the original one obviously).

I know I can translate the light in the CRES (cTransformNode tab after selecting a line in the CRES Hierarchie) but what I want to do is to duplicate the existing light and move it so that each tile has its own.

I noticed I wasn't able to clone the line in the Hierarchie so I thought I had to clone the whole CRES line (in the Resource list), to make the modification (i.e. change the X value) and to change the Instance number to make it 1 higher. I tested my object and it doesn't work.

I don't know what I'm doing wrong. I mean, for example, each OBJD needs its own OBJf. Is there something similar for CRES ? Or am I wrong when I clone the CRES ?

Sorry for my English, I hope it's "understandable".

Thanks for the information Numenor, by the way !

Thanks in advance for any help :)

Numenor
17th May 2007, 10:05 PM
Hello everyone,

I'm making a lamp. I cloned a 1-tile lamp and followed Echo's tutorial to add a second tile. It works fine. The problem is that there seems to be light on 1 tile only (the original one obviously).

I know I can translate the light in the CRES (cTransformNode tab after selecting a line in the CRES Hierarchie) but what I want to do is to duplicate the existing light and move it so that each tile has its own.

I noticed I wasn't able to clone the line in the Hierarchie so I thought I had to clone the whole CRES line (in the Resource list), to make the modification (i.e. change the X value) and to change the Instance number to make it 1 higher. I tested my object and it doesn't work.

I don't know what I'm doing wrong. I mean, for example, each OBJD needs its own OBJf. Is there something similar for CRES ? Or am I wrong when I clone the CRES ?

Sorry for my English, I hope it's "understandable".

Thanks for the information Numenor, by the way !

Thanks in advance for any help :)

Actually, the best option is to simulate a double light, while keeping a single light point. In fact, duplicating a light is not easy at all, and the result would be quite disappointing anyway (apart from a brighter light, you wouldn't see any difference...).

You'd better create a doubled light map on the ground (a sort of ground shadow that is usually contained in the lamp meshes) and optionally create/modify a "lightpattern", i.e. a special mesh that simulates the light cone coming from some lamps, usually contained in the wall-mounted lamps and in some floor lamps.

This way, the lamp will look as if it has two lights, but you have spared yourself the troubles of creating an actual second light.
I only suggest to translate the only existing light to the centre of the mesh.

Ben♣
20th May 2007, 03:59 PM
Thank you, now I also think that translating the existing light to the center was the best to do... :)

I'm making a wall lamp so I have a "lightpattern" subset. It's useful but I want to increase the light of my object (I'm playing with transparency you see). Then I think I'm talking about the "diffusion light". I tried setting the Val1 (= Intensity) to a higher value (5, 12...) but I'm not sure it works.

for now, I've only set the R, G, B to 1,1,1. What should I do ? Lamps are quite tricky huh...

sim0727
4th Aug 2008, 01:33 PM
Is this only possible for objects or would you be able to make a sim's eyes glow, like the werewolf for example?

simsartthat
18th Oct 2008, 01:17 PM
I've read through all the information I can find about light modding, but I notice some scroll-down options in Simpe's TXMT files for lights, and I'd like to understand what they do.

In the Generic Rcol Editor plugin view, in the categorizes properties tab, can someone kindly explain the following:

Default environment map:

*stdMatEnvCubeCoef - by changing the color using the scrolldown color menu, how does this affect the light?

Default textures:

*stdMatDiffCoef - same question
*stdMatEmissiveCoef - same question
*stdMatSpecCoef - same question

I've had some success playing with these settings to produce different colored lights in custom game objects, by changing the color of the parts of lighting packages that have no corresponding texture files. But I would really like to understand the function and effect of all these scroll down options that are included in Simpe.

The most basic thing I'd like to understand is...how do I change just the color of a lightbulb? lol..I had success with some cloned files, but not with others....

Thanks in advance for all help, or a link to something that explains these options in detail!

EDIT: Since I obviously phail at googling the right and proper phrase in order to find something that explains all the Material Definitions, and how the settings can be changed, and what each setting represents, could someone kindly provide a link to same? I really have been googling for hours trying to find this info...thanks all!

Numenor
18th Oct 2008, 02:14 PM
The TXMT properties you mention are not only related to lights; they apply to all objects, and any kind of material. Modifying them you can't modify the colour of the light: at most, you can modify the appearance of the lamp (glass, metal frame, etc).

- stdMatDiffCoef = the general "diffusion" colour; if the object uses a texture, you should leave it to the default value [0.8,0.8,0.8], but you can modify the values to add a tint to the texture; for example with [1.0,0.7,0.7] you will add some general red all over the texture. Remember that the three values separated by commas are RGB values: the first is for Red, the second for Green, the third for Blue. Each value range from 0 to 1 (decimals are allowed). [1,1,1]=full white, [0,0,0]=black etc.

- stdMatEmissiveCoef = the "Emissive" value of the material; higher values make the material look "lit". Playing with the RGB values you can give a tinted "lit" look to the object, but again this parameter doesn't change in any way the light cast by the object.

- stdMatEnvCubeCoef = the "Environment Cube" = how the material reflects the surrounding environment. Please note that it's a "fake" environment: except from mirrors, objects don't reflect the actual surroundings, but a fake image, referenced in the TXMT itself.

- stdMatSpecCoef = "Specularity" = how the surface is hit by the external light; play with the RGB values to make your object show tinted reflections when hit by the light.

simsartthat
18th Oct 2008, 02:33 PM
Numenor, thanks so much for the response, that does make a great deal of sense. Since I'm asking in the lighting thread, yes, I was interested in how these files affect lighting, specifically. I did have success changing the actual color of the light with your information in the first post, but I still seem to totally phail at changing the color of the bulb itself in some (and only some) packages where there is no texture image for the lightbulb.

Is it safe to presume I can just add a mipmap with a texture image for a bulb I import into my gmdc? As I said, changing the material definitions work with all the parts of SOME lamps but doesn't seem to work with others.

I'm almost understanding all this...I think, lol

Thanks again Numenor!

Numenor
18th Oct 2008, 07:57 PM
If the bulb has no texture it's even simpler :)
The colour of the bulb can be changed within the TXMT, modifying the parameters discussed earlier, and in particular the Diffusion and the Emissive ones.
No need to add a texture or modifying the GMDC.

Reyn
28th Jan 2009, 09:08 PM
Okay, I've got a problem. I'm trying to make a neutral version of all the good witch furnishings - the lamps and throne. The throne is obviously not a problem for here [and not a problem anyway :)] but I'm having a problem with the light. The light itself is a nice golden light, natural/warm, but the glowing ball, 'the bulb' as it were, refuses to change colour. I don't know if its a LGHT property or if its generated like aqaurium fish or the like. If its a LGHT property, what am I missing? If its not, then I guess I'll post it under repair, or try and figure out which tutorial I -will- need. But right now, I'm confused as to what I'm missing.

Numenor
29th Jan 2009, 10:10 PM
I see from the CEP documentation that 3 witch lamp out of 4 had a problem, fixed with a CEP Extra: "Lit/Unlit textures now correctly switch". Do you have the latest CEP installed? If so, please post (here or in the Repair Service) a faulty recolour.

Reyn
29th Jan 2009, 10:20 PM
I'll get the new CEP. I thinkg its been a bit since I updated it - like a few months. And if it doesn't fix it, then I'll post it.

And thanks!