Ambient Occlusion Demo

Post your questions, suggestions and experiences regarding to Image manipulation, 3d modeling and level editing for the Irrlicht engine here.
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

and this is his version of ambient occlusion.

Image
Image
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

by lightmap i mean ambient occlusion ;)
Image Image Image
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

yep, nothing grand so far.

though, i'm trying to project a post-western age, when western civilization is all but a memory. a new civilization replaced it and that's what i'm trying to create here.
Image
xskinyx
Posts: 25
Joined: Fri Dec 29, 2006 3:28 am

Post by xskinyx »

JP wrote:Notice that the lightmap is incorrect when you rotate the model? The lighting appears the same for all the tombstones (or whatever they are), regardless of their rotation.
Yes, that is the nature of ambient occlusion. I wouldn't call this "incorrect" though.

dlangdev: The "final" scene you posted doesn't apear to have any ambient occlusion. Those shadows look real-time to me.
oldskoolPunk
Posts: 199
Joined: Wed Nov 29, 2006 4:07 am

Post by oldskoolPunk »

shadows != AO

Static AO is an outdoor light-bouncing type effect. Blender has had it for years now. If done correctly, its hardly even noticable, except that everything just looks "more real".

The downside is that anything that moves in the AO scene is going to look horribly out of place. Unless you use an AO shader on the moving objects (nice one Blindside!)

dlangdev, speed up Blender's AO by changing it to approximate. It wont look quite as good, but its ALOT faster, (because you dont need raytrace turned on)and it will blend with a realtime AO'd objects better :)

Image
Image
Image
Signature? I ain't signin nuthin!
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

Nice.

By the way, thanks for the tip.

I'll work on it as soon as I get my kicks back.

I'm just too bored to move my butt.
Image
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »


The "final" scene you posted doesn't apear to have any ambient occlusion. Those shadows look real-time to me.
AO doesn't need a light source, it uses disks or a depth map to figure out shades of grey.

They were made in 3DS Max. I only use blender. I would imagine 3DS Max has better shadows/AO.

It would be nice to have SSAO, but Blindside is keeping it a secret.

Well, it's not going to be a secret soon, once I get my butt going and playing around with RenderMonkey. Multi-sampling is definitely going to be hard, though.
Image
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

SSAO isn't that much of a secret. In fact, jinquan has implemented it into his engine, shown the demos, and I believe he even gave the code for. At any rate, it's all over GameDev as well.

And yes, AO is meant as a simulation of shadows. It is supposed to catch the little soft shadows that can't be done well with shadowing techniques. Basically, set a sofa, or something smaller, closer and closer against the wall. Notice the soft shadow that begins to form as it gets closer and closer. AO simulates what happens when objects are close to each other like that for shadowing. Usually by analyzing the depth map, as dlangdev said, and taking into account, in a variation of ways, the angle between the objects.
TheQuestion = 2B || !2B
oldskoolPunk
Posts: 199
Joined: Wed Nov 29, 2006 4:07 am

Post by oldskoolPunk »

Shadows are a blockage of direct light, while AO is a simulation of the occlusion of indirect lighting (bounced). Two totally different things :)

http://en.wikipedia.org/wiki/Ambient_occlusion
Signature? I ain't signin nuthin!
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

It would be nice to have SSAO, but Blindside is keeping it a secret.
It's not a secret, look here: http://www.gamedev.net/community/forums ... hichPage=2

Theres alot of source code that'll plug more or less directly into XEffects (Using it's depth map rendering features). You can also search for jinquan's SSAO topic where he posted the source code (And his version is pretty identical to mine).

Cheers
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Post by Mel »

Wow! after seeing those screens i feel ashamed of my own! XD none the less, i'll keep improving! :)
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

Blindside, need your help.

Can you help me figure out the Ambient Occlusion code posted on the link you provided. I made a sample demo program and I'm stuck generating the DepthMap RTT.

Should I simply get the Z-value and stuff it to gl_FragColor? I want to interface the Z-value to the AO demo, tho.

Shader Code:

Code: Select all


uniform sampler2D myTexture;
uniform sampler2D depthMap;

void main (void)
{
    //vec3 col = gl_TexCoord[0].z;
    vec3 col = gl_Position.z;
    //vec3 col = gl_Position.z/gl_Position.w;
	gl_FragColor = vec4(col,1.0) *2.0;
}

Render Loop:

Code: Select all

	while(device->run())
	if (device->isWindowActive())
	{
		driver->beginScene(true, true, 0);

		driver->setRenderTarget(depthMap, true, true, video::SColor(0,0,0,255));  
		for ( int i=0; i<17; i++) {
			room->getMaterial(i).MaterialType = (video::E_MATERIAL_TYPE)newMaterialType2;
		}
		smgr->drawAll(); 
		driver->setRenderTarget(0, true, true, 0);  



		for ( int i=0; i<17; i++) {
			room->getMaterial(i).MaterialType = (video::E_MATERIAL_TYPE)newMaterialType1;
		}
		smgr->drawAll();
		env->drawAll();

		driver->endScene();

		int fps = driver->getFPS();

		if (lastFPS != fps)
		{
			core::stringw str = L"Per pixel lighting example - Irrlicht Engine [";
			str += driver->getName();
			str += "] FPS:";
			str += fps;

			device->setWindowCaption(str.c_str());
			lastFPS = fps;
		}
	}
Here is the screenshot.

Texture shows the content of the depthMap. It looks like the Z-value is getting in there. Is that OK? do I need to divide it by w?

Image
Image
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

Here's the latest screenshot.

I'm still trying to translate the depthmap to match the screen.

The cube at the center is the test render of the depthmap, i'm still wondering why the columns are white.

Image
Image
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

OK, I think I have an idea how to put the two texture maps into the final render. It looks like I need a screen quad for rendering the depth and color maps, tho.

Is there a simple way of setting-up the screen quad, I mean the simplest least-amount of code? I can setup the render to have three passes.
Image
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

Image
Post Reply