Popular Post Einheit-101 Posted June 8, 2020 Popular Post Share Posted June 8, 2020 (edited) 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 Edited September 13 by Einheit-101 Updated dead file download link 5 Link to comment
Hidin Posted June 8, 2020 Share Posted June 8, 2020 Thank you very much for sharing that information! 1 Link to comment
Moderators turret001 Posted June 8, 2020 Moderators Share Posted June 8, 2020 well done! Link to comment
Einheit-101 Posted June 8, 2020 Author Share Posted June 8, 2020 I recommend someone tries this out and reports bacc, maybe there is something unclear and i can improve the manual. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now