Boe6's vehicles: Add lights
Lights are still somewhat of a mystery to me. That said, there are a couple routes to take for lights, depending on how you would like them to look.
Last updated
Lights are still somewhat of a mystery to me. That said, there are a couple routes to take for lights, depending on how you would like them to look.
Last updated
Lights are using emissive (glowing) and glass materials. For more documentation about that, you can check Material properties.
Many lights, such as the headlights on the porsche, are reflective lights, with headlight lenses. These lenses require lots of lighting settings, such as IOR
, RefractionDepth
, FresnelBias
, and more.
Example:
The other common option, is to use solid lights, as many modded cars do. These lights avoid using the complex light options, and instead opt to use block-style lights. These are done by creating a custom mesh, setting it as a light material, and covering it with blank normal map lenses or glass. (IOR=1.0 & RefractionDepth<0.2) Example:
Here is an explanation of some light options, based on my own experience. Note that these values are not fully understood currently. If you learn something about these values, please share!
IOR
: “Index of Refraction”. This seems to be an on/off switch for enabling refraction. Values greater than 1 enable refraction.
RefractionDepth
FresnelBias
: Unknown. (does nothing?)
NormalStrength
: Strength of normal map on the mesh
NormalMapAffectsSpecular
: Strength of normal map on reflected light
Normal
: Path to normal map
GlassRoughnessBias
: n/a
BlurRadius
: n/a
For the emitted light beam, there are “vehicleLightComponent
”s in the .app
file components list. The localTransform
can be edited by the position xyz
bit values. Orientation will control which direction the light is aimed.
Example LightComponent
localTransform values:
To create a new light in a mesh that doesn’t have one already, you can duplicate the material in the mesh settings. Make sure to update the localMaterialBuffer
or preloadLocalMaterialInstances
, materialEntries
, and appearance chunkMaterials
.
See:
Once the vehicle_lights material is linked in the mesh, it also need to be linked to a vehicleLightComponent
in the .app
file. You can use an existing lightComponent
or duplicate a new one. The component has a parentTransform
entry, and a bindName
value which is used to set what mesh it is a part of.
Example:
For lights like brakes, headlights, or reverse lights - you need to edit the vertex paint in Blender. Select the light emitting object in blender and switch to "Vertex Paint" mode. Example:
Set the color to one that enables the brake behavior, for brakes this is red in hex:
You must use these specific hex colors for lights to be activated properly:
Headlights: #7C0101
Taillights: #e7010
Reverse lights: #cb0000
Use the Draw tool in Vertex Paint mode to draw on the color to the entire part. Example:
Lights should now be fully working.
Headlight colors are controlled in your vehicle's tweak file. You need to add this entry to your main Vehicle
record:
The values are RGBA respectively so the above changes the headlight color to blue
Adjusting the tweak file from the previous section, here's how it should all look like: