Jump to content
  • Advertisement
Sign in to follow this  
rumpfi88

OpenGL Radiosity c++ tutorial

This topic is 2557 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

For my graphic engine (not real time) I want to use Radiosity. My program only uses C++, but to create a window and draw pixels it uses OpenGL. My first Versions only works with raytracing algorithm and local illumination.

Do you know any practical tutorials where they explain Radiosity in C++?

lg rumpfi88

Share this post


Link to post
Share on other sites
Advertisement
while not c++, it has still some pseudo code and is quite good explained and easy to understand:

http://freespace.virgin.net/hugo.elias/radiosity/radiosity.htm




Share this post


Link to post
Share on other sites
well just look for general radiosity tutorials, language doesn't matter, the theory is whats important and once you understand theory behind radiosity you'll be able to write your own radiosity engine in any language you understand.
The general approach for real-time is light propagation volumes which is very roughly a 3D grid which spreads lighting from the first bounce. I suppose the same thing could be done for not real-time quality if you do this on a much larger magnification.
That or if you want pure accuracy you could do a series of ray traces essentially
Light throws out A rays
A rays act as lights to colliding surfaces which then throw out B rays
B rays act as dim lights to colliding surfaces which then throw out C rays
C rays act as dimmer lights to colliding surfaces which then...
etc. etc. depending on how long you don't mind them bouncing around for (longer can = more accurate but also < efficient)

The way krypt0n linked to is a compromise of both sort of.
It splits surfaces into (just quoting the documentation I read on it) micro-facets which will act like the rays I mentioned above. though instead of infinitely multiplying each surface already has them and instead of creating more, information is passed and blended with each of the other micro-facets.

Share this post


Link to post
Share on other sites
The procedures behind rendering the hemicubes and approximating the light inputs and outputs is easy to understand for me, but how are we supposed to break up each surface into patches? And how could this be applied to a deferred renderer? I have no experience with baking any sort of textures onto objects, and this problem seems like it would have to use baked textures.

Share this post


Link to post
Share on other sites
You can bake per vertex, which makes things pretty simple. For textures you have to generate some sort of unique parameterization (UV mapping) of all meshes in the scene. Your sample points are then located at the center of each texel in the texture that you map to the scene. The DX9 D3DX library has a class that can generate the parametrization for you, although it's a little hard to use since the documentation sucks.

Why do you ask about a deferred rendering? If you pre-bake lighting, it's almost totally unrelated to how you handle your runtime lighting.

Share this post


Link to post
Share on other sites
Don't know if it is related, but I've implemented algorithm from Hugo Elias website some 7 years ago (unwrapping static meshes to light maps is evil!!!) through render-to-texture and even in that time an average ray tracer could beat it in speed, or was it that using GPU for the actual implementation is that slow?

Ah... that was a long time ago, I bet that most modern games doesn't use light maps (mostly) - I personally would think twice before implementing them (of course if it is not for learning purpose - then go for it), as you can do dynamic lighting on most PCs today (on some even dynamic GI, ... eh... good dynamic GI, not that SSAO trick that everyone overdo and then it looks very very bad :wink: ... not that it couldn't be nice, but well most people overdo SSAO a lot).

Share this post


Link to post
Share on other sites
I find the industrial standard method to develop radiosity is a complete jarring solution, id rather invent my own gi method any day, its actually not that complicated, multiple bouncing...

Share this post


Link to post
Share on other sites

Ah... that was a long time ago, I bet that most modern games doesn't use light maps (mostly) - I personally would think twice before implementing them (of course if it is not for learning purpose - then go for it), as you can do dynamic lighting on most PCs today


Lightmaps with prebaked GI are very popular. Off the top of my head you have...

  1. All Call of Duty games
  2. The Uncharted series
  3. The God of War series
  4. Killzone 2/3
  5. Halo series
  6. Pretty much every Unreal Engine 3 game
  7. Battlefield 3 (they use Enlighten which is a realtime GI solution, but I'm pretty sure that they keep the GI static at runtime)

Typically it is only games with dynamic time of day that don't do it (GTA, Elder Scrolls, Assassin's Creed), although there is a few cases of games just going with all dynamic deferred lighting. I would definitely, definitely, definitely not recommend going without any kind of GI solution for a modern game. It makes an enormous difference on your overall lighting quality, and can actually make it easier for artists to a light a scene (since GI is intuitive to them, and they can use less lights). Runtime GI solutions are cool, but still very much in their infancy. Licensing or developing one means you will add non-trivial runtime costs, and will likely end up with lower-quality GI than you would have if you just pre-baked it.

Either way this is pretty off-topic since the OP already said that his engine is not real-time, so I apologize for that.

Share this post


Link to post
Share on other sites
I've implemented a similar tech like the one I linked to when the Geforce1 (256) came out, as there is a big advantage using the GPU. It's because all the setup artist do, be it multi layer texture, decals, glossy texture, env maps etc. doesn't have to implemented again, it's just the usual rendering when you make the initial shooting.

that's even more of an advantage nowadays then it was back then, you can have tons of shaders and effects combined nowadays, some fog volumes, fully reflective walls, water/pools, and you dont want to maintain it (as artist won't use that every day, they'll use it every now and then when they do another light pass).

and it's damn simple to implement, by rendering the scene and downscaling it to a pixel.

as for UVs, I'd suggest to not implement a special algorithm, but with what artist setup in their editors. they have auto unwrapper, they can always hand-tweak UVs and optimize/fix visual artifacts. it can be very time consuming to debug and fix your own UV mapper, it might be sometimes not even a bug, but some extreme case of the expected behavior and you might investigate for few days to come to this conclusion and it won't fix this bug.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!