Horde3D http://horde3d.org/forums/ |
|
Adding support for baked lighting http://horde3d.org/forums/viewtopic.php?f=1&t=924 |
Page 1 of 1 |
Author: | zoombapup [ 21.08.2009, 14:04 ] |
Post subject: | Adding support for baked lighting |
Hey all. Ok, another issue has come up. Specifically, how to get baked ambient occlusion into the engine. As far as I can tell, there is support for a second set of UV's? So its mainly a shader issue. Just adding another sampler for the lightmap, then making sure that the lightmap texture is multiplied with the diffuse properly. It seems reasonably simple, apart from a couple of issues. 1) The contexts are setup in the pipeline file right? Then it uses those contexts to define which VS/FS shaders are active for that geometry pass? 2) The ambient context would seem to be the most obvious place to add an ambient occlusion map. So my thinking is to add another flag (F06_Lightmap) and add another sampler there for the lightmap. Hmm, I see now how the contexts work with the pipeline files. Thats good. |
Author: | marciano [ 22.08.2009, 00:15 ] |
Post subject: | Re: Adding support for baked lighting |
The way you want to use the ambient occlusion maps sounds right. zoombapup wrote: 1) The contexts are setup in the pipeline file right? Then it uses those contexts to define which VS/FS shaders are active for that geometry pass? Yes, contexts are referenced in the pipeline files. They are declared and defined in the shader files. zoombapup wrote: 2) The ambient context would seem to be the most obvious place to add an ambient occlusion map. So my thinking is to add another flag (F06_Lightmap) and add another sampler there for the lightmap. Yep! |
Author: | zoombapup [ 22.08.2009, 09:15 ] |
Post subject: | Re: Adding support for baked lighting |
Ok, another question I'll need to add the second set of texcoords to pass in the VS. Is it safe to assume that two sets of UV's are always passed in the vertex stream? |
Author: | marciano [ 22.08.2009, 19:10 ] |
Post subject: | Re: Adding support for baked lighting |
At the moment it is safe to assume that. In the future we may want to save some memory and not have a second set of coordinates for all geometry. This will require some special care then, either on application or on engine side (e.g. having a default stream). |
Author: | zoombapup [ 22.08.2009, 21:20 ] |
Post subject: | Re: Adding support for baked lighting |
Ok, I've got the shader setup. But I'm getting some weird output, which I believe is the second set of UV coords. I've had a look in the collada file and there does seem to be a second set of UV coords as you would expect. But they are mapped onto channel 3. Code: <source id="Plane01-mesh-map-channel1"> <float_array id="Plane01-mesh-map-channel1-array" count="264"> blaaaah </float_array> <technique_common> <accessor source="#Plane01-mesh-map-channel1-array" count="88" stride="3"> <param name="S" type="float"/> <param name="T" type="float"/> <param name="P" type="float"/> </accessor> </technique_common> </source> <source id="Plane01-mesh-map-channel3"> <float_array id="Plane01-mesh-map-channel3-array" count="648"> blaaah </float_array> <technique_common> <accessor source="#Plane01-mesh-map-channel3-array" count="216" stride="3"> <param name="S" type="float"/> <param name="T" type="float"/> <param name="P" type="float"/> </accessor> </technique_common> </source> Obviously the blaaaah's are a long list of UV float coordinates. I'm just wondering, how does colladaconv assign UV coords? Will it just map the first two channels? I'll have a bit of time to look at the source tommorow. But if the easy fix is for me to just assign the lightmap texture to channel 2 in max rather than channel 3, I'll do that |
Author: | marciano [ 23.08.2009, 09:48 ] |
Post subject: | Re: Adding support for baked lighting |
Actually there is some logic in ColladaConv to handle exactly this. But of course it is possible that it got slightly broken over time. |
Author: | zoombapup [ 23.08.2009, 17:35 ] |
Post subject: | Re: Adding support for baked lighting |
Turns out it was the wrong UV channel in Max. I changed it to channel 2 and the second texcoords worked fine. Of course the lighting stuff is only as good as your lightmap generator. I'm going to be evaluating flatiron at some point, just to see how that goes. Now I guess I should have a look at adding a specularity mask texture. I really need some sample scenes with the various shader combinations my artists might want though. Hmm. |
Author: | PuG [ 13.10.2009, 14:45 ] |
Post subject: | Re: Adding support for baked lighting |
spec shader would be good in general, or contained in an alpha channel of the texture instead of transparency. |
Author: | zoombapup [ 13.10.2009, 21:04 ] |
Post subject: | Re: Adding support for baked lighting |
Problem is my game doesnt really need any of that stuff I'm going to be adding depth of field and ambient occlusion (directional AO) because my artists requested it. But I figured a spec-mask would be useful too. |
Author: | PuG [ 14.10.2009, 08:03 ] |
Post subject: | Re: Adding support for baked lighting |
understood your baked AO shader so far has been working as a lightmap pass (okay the model is still slightly shaded but enough to give a result) Would be good if a few extra shaders were included with H3d SDKs in general for those non-programmers. Talking of spec, what defines the amount per surface in horde? |
Author: | zoombapup [ 14.10.2009, 18:41 ] |
Post subject: | Re: Adding support for baked lighting |
If anyone has any specific shader requirements, I'm happy to take a look at them. I've got a "light from god" shader to write now so if any arty types want to list the kind of shaders they'd find useful, maybe we can get them written and put in the trunk? Phil. |
Author: | marciano [ 17.10.2009, 10:33 ] |
Post subject: | Re: Adding support for baked lighting |
zoombapup wrote: I've got a "light from god" shader to write now so if any arty types want to list the kind of shaders they'd find useful, maybe we can get them written and put in the trunk? Sounds great, we can definitely put them into the community branch. If you want to have write access to that svn repository, Volker can grant you the required user rights. |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |