Author : disting


Reply
Reply
 
Thread Tools Display Modes
easterislandnick's Avatar
Old (#1)
I was looking at the UDK app Epic Citadel and it seems like they are baking their normal map shadow information to their light-maps, as the lighting is static in the scene they don't have to render normal maps at run time but still get lovely bumped effects baked in.

Is this possible with Unity? Has any one managed to get this up and running? I was looking at the advanced Beast settings but could not see any setting for taking normal map information into account when rendering light-maps. If I can bake normal map shadow information into light-maps and at runtime only calculate specularity I think I could achieve a very hi-end looking game on ipad2/3.
Offline , spline, 210 Posts, Join Date Dec 2005, Location UK  
   Reply With Quote

cupsster's Avatar
Old (#2)
Directional Lightmaps is way to go
Offline , triangle, 355 Posts, Join Date Jan 2010, Location Slovakia Send a message via Skype™ to cupsster  
   Reply With Quote

bugo's Avatar
Old (#3)
Exactly, but they only have this feature on Unity Pro. I wish I could know if this works on iOS, anyone?
Offline , dedicated polycounter, 1,463 Posts, Join Date Feb 2006, Location Redmond WA Send a message via MSN to bugo Send a message via Skype™ to bugo  
   Reply With Quote

Eric Chadwick's Avatar
Old (#4)
Dual Lightmapping is the Unity method for this.
http://unity3d.com/support/documenta...ngInDepth.html

I have Unity Pro here, but haven't tried it on iOS.
Offline , Polycount.com Editor, 6,674 Posts, Join Date Oct 2004, Location Boston USA  
   Reply With Quote

easterislandnick's Avatar
Old (#5)
Not really what I'm after as I don't want to use normal maps on my level at run time only during the bake process as it's too costly for ios devices.

My thinking is that a scene that has static lighting always has the same shadows generated by normal maps, so why not bake them into the light-maps and not generate them at run time?
Offline , spline, 210 Posts, Join Date Dec 2005, Location UK  
   Reply With Quote

Ged's Avatar
Old (#6)
Ive also been looking for a way to do this. I would like to bake in shadows and specular and normal map shadows in unity. Even if it means my object can never move and the specular doesnt change it would be a nice effect. I guess I will just have to bake it in my cinema4d and include it all in the diffuse.
Offline , veteran polycounter, 3,902 Posts, Join Date Feb 2007, Location UK cheltenham  
   Reply With Quote

bugo's Avatar
Old (#7)
Speculars can't be baked, or it would be color/albedo anyway, you will have to have at least one non-static light on your scene using dual lightmapping to get specularity.
Offline , dedicated polycounter, 1,463 Posts, Join Date Feb 2006, Location Redmond WA Send a message via MSN to bugo Send a message via Skype™ to bugo  
   Reply With Quote

Eric Chadwick's Avatar
Old (#8)
FWIW, from what our programmers tell me, directional lights are much more performance-friendly than either point or spot lights.
Offline , Polycount.com Editor, 6,674 Posts, Join Date Oct 2004, Location Boston USA  
   Reply With Quote

easterislandnick's Avatar
Old (#9)
Yeah, specular can't be baked but I could use a masked per vertex specular as they do on Shadow Gun which is pretty cheap, combine that with baked normal and it would look great on iOS. Any ideas if it's possible anyone???
Offline , spline, 210 Posts, Join Date Dec 2005, Location UK  
   Reply With Quote

Farfarer's Avatar
Old (#10)
I think you'd have to bake it in an external program, into a baked diffuse (or to your own lightmap textures).
Offline , dedicated polycounter, 1,404 Posts, Join Date Mar 2007, Location Leeds (UK) Send a message via MSN to Farfarer Send a message via Skype™ to Farfarer  
   Reply With Quote

Eric Chadwick's Avatar
Old (#11)
But baking normal maps into your lightmap will require the lightmap to be a fairly high resolution, right? And this means a significantly larger download (and memory cost).
Offline , Polycount.com Editor, 6,674 Posts, Join Date Oct 2004, Location Boston USA  
   Reply With Quote

bugo's Avatar
Old (#12)
@easterislandnick: I agree with Eric, it's not the goal to bake nmap light info. You should probably be able to use nmaps on iOS if you're not using an expensive shader, if you use specular + nmap it gets expensive for iOS. You will have to choose inbetween the two. I wouldn't go for that path, why do you need both?

Shadowgun uses a vertex specular + mask specular which creates a fake specular effect. I don't know if adding nmaps to it will decrease performance, probably.

They used nmaps + probes ONLY on their characters, so I imagine you can't (for an iOS game). I'm taking iPad3 out of consideration.
Offline , dedicated polycounter, 1,463 Posts, Join Date Feb 2006, Location Redmond WA Send a message via MSN to bugo Send a message via Skype™ to bugo  
   Reply With Quote

easterislandnick's Avatar
Old (#13)
A single lightmap is only 1.3 mb, a couple isn't going to be too much of a memory hog. I'm creating fairly enclosed environments so 3 1024s should give me fairly good lightmap resolution. Yeah, specular and normal maps per pixel is expensive on iPhone but I can make it really cheap if I bake the shadow information into the lightmaps. The only reason not to bake the normal shadow information into lightmaps is because it will increase download and runtime memory but people are willing to download large beautiful games (look at infinity blade) and the iPhone has a relatively large amount of memory so allocating about 4mb to lighting all of my environment with lovely looking shadows seems pretty great to me.

Every one is expecting the next few years of iOS games to look more like their console big brothers and sticking with diffuse and a bit of faked spec isn't going to cut it. I need to implement a decent set of shaders that can let me fake all types of believable materials.

In my mind the only reason not to do it is because no one knows how to do it! (including me!)
Offline , spline, 210 Posts, Join Date Dec 2005, Location UK  
   Reply With Quote

Elyaradine's Avatar
Old (#14)
Er... as far as I know, if you split it into 3x1024, you triple your draw calls. Have fun with that on mobile. :P

(Test it first maybe, but I seem to remember this being a problem for us.)
Generalist and TA at Luma Arcade
Houdini/Mixamo entry
Offline , triangle, 287 Posts, Join Date Apr 2009, Location South Africa  
   Reply With Quote

easterislandnick's Avatar
Old (#15)
Could be an issue with draw calls, I would have though that if you only have one lightmap per object you would be okay and static batching would be fine.
Offline , spline, 210 Posts, Join Date Dec 2005, Location UK  
   Reply With Quote

Elyaradine's Avatar
Old (#16)
Batching batches stuff that uses the same material. The "same" material is the same shader, with all of the same textures plugged in. If things use different lightmaps, they're effectively using different materials too, as far as I know.

(And batching works great for stuff that uses only one lightmap, but it also creates a new "batched" instance of the meshes in memory, so you're effectively using up twice as much memory for your meshes. Which... may or may not be an issue, depending on your game.)

Anyway. Baking your normals into your lightmap sounds cool. From my experience, I just don't think it's practical.
Generalist and TA at Luma Arcade
Houdini/Mixamo entry
Offline , triangle, 287 Posts, Join Date Apr 2009, Location South Africa  
   Reply With Quote

bugo's Avatar
Old (#17)
@easterislandnick: Dude, depends on the size of your scene, if your scene is big and to get the same pixel ratio of your normal maps, it can get quite of a big map. I'm not sure what you are looking for over here. I don't know how UDK does it, but it's probably a way of rendering static meshes that have nmaps, but I highly doubt they are the same pixel ratio as the textures theirselves.

Have you thought about baking this light information of your normal maps on the diffuse map? It's a matter of not rotating the textures. Might look cool!
Offline , dedicated polycounter, 1,463 Posts, Join Date Feb 2006, Location Redmond WA Send a message via MSN to bugo Send a message via Skype™ to bugo  
   Reply With Quote

easterislandnick's Avatar
Old (#18)
Yeah, they won't be at the same resolution as the diffuse. In UDK it's a one click solution, "If you enable "Use Normal Maps For Simple Light Maps" in the World Properties Lightmass Settings section, normals maps on a mesh will be merged into the simple lightmap. This will give improved lightmaps, but can cause slower lighting build times as it has to process the extra texture." They do it and it looks great on an iPhone 4. A lot of people here are acting like this is a crazy idea, but it's tried and tested on a multi million selling game!

If no one knows if it's possible in Unity then that's fair enough.
Offline , spline, 210 Posts, Join Date Dec 2005, Location UK  
   Reply With Quote

Farfarer's Avatar
Old (#19)
It's probably possible in Unity with scripting, if you roll your own lightmapping algorithm.

It's not in there as a default option, however.
Offline , dedicated polycounter, 1,404 Posts, Join Date Mar 2007, Location Leeds (UK) Send a message via MSN to Farfarer Send a message via Skype™ to Farfarer  
   Reply With Quote

bugo's Avatar
Old (#20)
@easterislandnick: I think you misunderstood what UDK does, it probably creates a fixed normal map light direction and converts that to pixel on realtime. It's not possible to bake that info into a map for the whole environment, memory wise it's not smart. It probably just fixes the normals to a light direction somehow. I will research a bit more about this and come back here, cause it's interesting.
Offline , dedicated polycounter, 1,463 Posts, Join Date Feb 2006, Location Redmond WA Send a message via MSN to bugo Send a message via Skype™ to bugo  
   Reply With Quote

easterislandnick's Avatar
Old (#21)


Uploaded with ImageShack.us

It does seem to be baking to the lightmap, there are some directional lightmaps in the project, I'm not sure they are used at runtime? It's clever stuff any way! The citadel demo has a huge amount of lightmaps, not sure how they fit it all in to memory at runtime!
Offline , spline, 210 Posts, Join Date Dec 2005, Location UK  
   Reply With Quote

bugo's Avatar
Old (#22)
oh, but that is not near close to the resolution of the diffuse, is it?
You know what's funny, I see some stains going on too, wow, im curious where those come from... thanks for showing.

Last edited by bugo; 05-04-2012 at 01:30 PM..
Offline , dedicated polycounter, 1,463 Posts, Join Date Feb 2006, Location Redmond WA Send a message via MSN to bugo Send a message via Skype™ to bugo  
   Reply With Quote

commander_keen's Avatar
Old (#23)
You should be able to do something like this in Unity by using Directional Lightmaps and doing a post process on the resulting lightmap files using the light normal map, along with the normal map of the individual normal maps from each lightmapped renderer. Its pretty complicated but possible. You would also want to define a custom lighting model for Directional Lightmaps and use that in all your shaders to disable the normal Directional Lightmap shading.

Directional Lightmapping is already pretty cheap, and if you still want specular then you still "need" to do normal map texture sample and transform into tangent space, so your really not optimizing much by just baking normal map shading into a lightmap.
Offline , polygon, 616 Posts, Join Date Jan 2005, Location Los Gatos, CA  
   Reply With Quote

bugo's Avatar
Old (#24)
Now I got what happens with directional lightmaps, it simply creates the world/object normals interpolated by light for the faces which enables a static nmap to be rendered cheaper (correct me if im wrong). Is that the same that UDK does? I wonder...
Offline , dedicated polycounter, 1,463 Posts, Join Date Feb 2006, Location Redmond WA Send a message via MSN to bugo Send a message via Skype™ to bugo  
   Reply With Quote

easterislandnick's Avatar
Old (#25)
HI, Unity 4 now does this out of the box! Having a play with it now! With single lightmaps normal information is now baked into lightmaps. Works great!
Offline , spline, 210 Posts, Join Date Dec 2005, Location UK  
   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Copyright 1998-2012 A. Risch