Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Tutorials on Baking Lighting for AGK game levels?

Author
Message
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 8th Mar 2018 19:40
I'd like to employ baked lighting into an AppGameKit level. How do I go about doing so.

AGK shadows are currently only supported for the global lighting, not point lights. And there is so much more that goes into lighting than just a shadow, things like bounced light and ambient glow which you can achieve in Maya fairly easily but would be a nightmare to code a shader for in AppGameKit (At least for my level). So How do you go about Baking the lighting and using it in AppGameKit levels?
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 8th Mar 2018 20:33
Hi
Cant you Use maya to create the baking image ?

I create my baking textutre in blender, and i can add light, shadow, gi, ao... all that the renderer can do.
AGK2 tier1 - http://www.dracaena-studio.com
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 8th Mar 2018 20:57 Edited at: 8th Mar 2018 21:30
There are dedicated tools I think as well. I think I remember seeing or at least hearing there were anyway. Maybe google light texture baker.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 8th Mar 2018 21:06 Edited at: 8th Mar 2018 21:18
Quote: "Hi
Cant you Use maya to create the baking image ?

I create my baking textutre in blender, and i can add light, shadow, gi, ao... all that the renderer can do."


You absolutely can. There are plenty of tutorials available on YT for Maya. I've never personally done it, never had an opportunity to explore it aside from right now.

The question really is, how do I go about applying the light map to the object? Maya (using Maya Software Render) seems to bake the lighting directly in to the texture file. In that case, this means that every single object will need to have a separate texture file with it's own custom light baked into it? I mean, I figured using one texture file across multiple instances of an object is a way to cut down on resource size. If I have 40 statues, each one will now have it's own texture with it's own unique lighting map baked right into the diffuse texture. I figured that you'd normally bake the lighting onto a separate texture file and apply that on top of the model.

There's a function called SetObjectLightMap( objID, imageID ).
I assume this is where you'd supply that light texture that would lay on top of the diffuse texture?
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 8th Mar 2018 21:37 Edited at: 8th Mar 2018 21:41
I cant comment on Maya. I use blender and sometime 3DS max to make lightmaps. App game kit has no way of creating the lightmap for you (not without ALOT of programming at least)

If your scene doesnt wrap textures or reuse them in multiple places within the scene then you can bake your lightmap directly into the texture as this is the simplest and quickest way to create realistic smooth shadows, ambient occlusion and lighting effects etc. The lighting level can be baked directly into the colour saved in the texture if its not used on other models or elsewhere in the scene.

However, a lot of scenes reuse textures in multiple places and dont have unique UV's at all points within the scene...So a separate lightmap texture is needed. Blender and 3DS max and various other software will allow you to place many lights in a scene and then render the overall lighting to a completely separate texture. (This is called "baking"). The model for the scene also needs a separate set of UV textures so that the lightmap can be applied correctly and its easy enough to make these too. You unwrap the model to a texture then use the built in renderer to make the lightmap texture for you.

Once this second texture has been made you simply load this image in AppGameKit and use the SetObjectLightMap function (or even the mesh version) and your scene goes from looking very simple and very flat coloured to looking much more realistic and lit up almost like a raytraced image! (well without reflections of any sort!) As the overall lighting effect is much less detailed then the colour texture, it can be of a much lower resolution typically so you dont end up using twice as much memory by using two textures. Typically its a lot less!

The lighting effects added by doing this are static though. you cant move your lights around the scene as they are permenantly baked into it. you would need to rerender the lighting texture to do that or swap in another image.

There are plenty of online tutorials for creating the lightmaps in blender. You then simply load your model into app game kit and apply diffuse/colour textures like you normally would. The only additional step is loading the lightmap textures (using LoadImage) and using the extra function SetObjectLightMap() and you have a scene with better lighting but without needing a lot of GPU power. Your right that it does just lay over the diffuse texture and modulate the lighting level accross it.
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 8th Mar 2018 21:44
Can you only apply ONE light map using SetObjectLightMap( objID, imageID ). function?

What if I have ambient occlusion AND a light map? I Guess I could bake both into the diffuse texture as one solution. Can you by any chance apply multiple light maps?
Thanks.
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 8th Mar 2018 21:50 Edited at: 8th Mar 2018 21:58
Yes, only one lightmap with the built in function. The point is that the effect of many lights and reflections of light and ambient occlusion/GI can be baked into one lightmap. You would just combine the lightmaps into one texture. Well, the renderer in the 3d modelling software would. It doesnt just use the input from one light, it can use the combined affect of many.

The idea of the lightmap is that it bakes in the effect of multiple point lights, parrallel lighs and the shadows created by other objects in the scene as well as AO into one file. Multiple lightmaps doent really make sense unless you want to dynamically change your lighting and if thats the case you are possibly better off adding a dynamic light and using real time shadows. It is possible to have multiple lightmaps being applied but you will need a shader to do this. Then you can have lightmap texture with 4 dynamic lights in it (R.G.B.A) and very the intensity of each light dynamically but not actually move the position of the light.

EDITED: To correct my poor spelling
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 9th Mar 2018 04:20 Edited at: 9th Mar 2018 05:24
Is a lightmap black and white or purely black one with an alpha channel of varying transparencies making up the different values of darkness?

Also does a normal map of a 3D object in AppGameKit respond to all the dynamic lights? Or just the directional light?
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 9th Mar 2018 08:50
Hi

There are several types for lightmapping :
- lightmap : light + shadow (+ao, gi...) -> blendmode "overlay" ?
- shadowmap : only "shadow" (+ao) -> blendmode multiply (or color burn sometimes).

Another one could be (but not very interesting ^^) :
- "OnlyLightMap" : only lighting (+Gi, radiosity, light bounce...) -> blendmode "add" or "screen".


A lightmap is in color (RGB), it's not necessary to have an alpha channel, if you use the function of AppGameKit : SetObjectLightMap()
I think, the blendmode for this image is near the "overlay" photoshop blendmode.
All colors < rgb(127,127,127) will be used as shadow (multiply or perhap's burncolor mode)
All colors >= rgb(128,128,128) will be used as light (add mode)

So in multiply (or add) blendmode, you can have colors, not only white & black.

Here is a 3D multiply shader example :

Multiply.ps :


Multiply.vs :


And a screenshot with comparison
Left : shader multiply / Right : AppGameKit lightmap
No sun / no shadow, just SetAmbientColor(120,120,120) for this test



I hope this can help

AGK2 tier1 - http://www.dracaena-studio.com
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 10th Mar 2018 00:59
Thanks Blendman. I'm actually going to bake AO and Lights / shadows right into one map.
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net

Login to post a reply

Server time is: 2024-11-27 14:43:01
Your offset time is: 2024-11-27 14:43:01