Recently @Tut and I were experimenting about lightmapping with a light map and a shader (Very different from vertex lighting) and i want to share our experience with that.
Initially we only wanted to make the 2nd UV channel work with objects but then i remembered about @Ren_712 lightmapped "Dust" map from counter strike and i wanted to re-create that effect.
I thought his instructions were a bit unclear, so i write it down here again. If an Admin reads this, please move this topic to User Guides, i think thats better than this scripting tutorial section.
This is the original resource of Ren:
https://community.multitheftauto.com/index.php?p=resources&s=details&id=12151
In 3ds max, first you need an object that you want to assign the 2nd UV map to. Doesnt matter what object.
-Create the "unwrap uvw" modifier
-Select "2" as Map Channel in the modifier
-In the following Dialog, "Move" or "Abandon" the UV coordinates of Channel 1 to the new Channel 2, you will most likely need to use "Flatten mapping" anyway
-Do whatever you need with the new UVs (Flatten mapping makes everything fit on 1 texture = no more "tiling")
-Create the lightmap with whatever tool (Radiosity?) that can render the light onto a grayscale lightmap image. This image will later produce light with our 2nd flattened UV map.
-Right click on the object and "Convert to -> Editable mesh", this collapses everything nicely and saves your changes.
-Finish your object and then export it with rwio or Kams max scripts.
This is the lightmap shader created by Ren, its nothing special and i simplified the code a little bit and i added some comments:
https://www.dropbox.com/scl/fi/mlcev0quowyccpcl3vnrr/light.fx?rlkey=um6t3lzwz5xwjm4i5bqbepah5&dl=0
Now all you need to do is assign the lightmap shader to your object with the following simple code:
local lshader = dxCreateShader("light.fx")
if lshader then
local lightTexture = dxCreateTexture("your_lightmap.png", "argb")
if lightTexture then
dxSetShaderValue(lshader, "lightTexture", lightTexture)
engineApplyShaderToWorldTexture(lshader, "*", THE_TARGET_OBJECT_THAT_NEEDS_LIGHT)
end
end