Depth of Field demo release

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
polygon9
Gnoblar
Posts: 10
Joined: Tue Nov 07, 2006 10:59 am

Re: Depth of Field demo release

Post by polygon9 »

I am using this effect in my Ogre1.6.4 project, and It works fine.
There are several changes in the source code.

I used Cg-shader for DirectX and GLSL-shader for OpenGL.
The effect is able to create/delete/re-create.

This source code needs modification, because it comes from my project.
my_dof.zip
(12.59 KiB) Downloaded 464 times
I hope it will help you.
luckpro
Gnoblar
Posts: 2
Joined: Tue Dec 01, 2009 7:57 pm

Re: Depth of Field demo release

Post by luckpro »

hi, i test the demo and works fine in opengl but not in direct3d. I use windows 7, lastest directx, ati radeon HD4870. The main viewport not move when change mode. I send you the screenshot and ogre log in direct3d. DoF is very important for games, nice work, thank you.

Code: Select all

20:16:56: Creating resource group General
20:16:56: Creating resource group Internal
20:16:56: Creating resource group Autodetect
20:16:56: Registering ResourceManager for type Material
20:16:56: Registering ResourceManager for type Mesh
20:16:56: Registering ResourceManager for type Skeleton
20:16:56: MovableObjectFactory for type 'ParticleSystem' registered.
20:16:56: Loading library OgrePlatform.dll
20:16:56: OverlayElementFactory for type Panel registered.
20:16:56: OverlayElementFactory for type BorderPanel registered.
20:16:56: OverlayElementFactory for type TextArea registered.
20:16:56: Registering ResourceManager for type Font
20:16:56: ArchiveFactory for archive type FileSystem registered.
20:16:56: ArchiveFactory for archive type Zip registered.
20:16:56: DevIL version: Developer's Image Library (DevIL) 1.6.7 Oct 28 2005
20:16:56: DevIL image formats: bmp dib cut dcx dds gif hdr ico cur jpg jpe jpeg lif mdl mng jng pcx pic pix png pbm pgm pnm ppm psd pdd psp pxr sgi bw rgb rgba tga vda icb vst tif tiff wal xpm raw 
20:16:56: Registering ResourceManager for type HighLevelGpuProgram
20:16:56: Registering ResourceManager for type Compositor
20:16:56: MovableObjectFactory for type 'Entity' registered.
20:16:56: MovableObjectFactory for type 'Light' registered.
20:16:56: MovableObjectFactory for type 'BillboardSet' registered.
20:16:56: MovableObjectFactory for type 'ManualObject' registered.
20:16:56: MovableObjectFactory for type 'BillboardChain' registered.
20:16:56: MovableObjectFactory for type 'RibbonTrail' registered.
20:16:56: Loading library .\RenderSystem_Direct3D9
20:16:56: D3D9 : Direct3D9 Rendering Subsystem created.
20:16:56: D3D9: Driver Detection Starts
20:16:56: D3D9: Driver Detection Ends
20:16:56: Loading library .\RenderSystem_GL
20:16:56: OpenGL Rendering Subsystem created.
20:16:57: *-*-* OGRE Initialising
20:16:57: *-*-* Version 1.2.1 (Dagon)
20:16:57: Creating resource group Bootstrap
20:16:57: Added resource location 'media/OgreCore.zip' of type 'Zip' to resource group 'Bootstrap'
20:16:57: Added resource location 'media' of type 'FileSystem' to resource group 'General'
20:16:57: D3D9 : RenderSystem Option: Allow NVPerfHUD = No
20:16:57: D3D9 : RenderSystem Option: Anti aliasing = None
20:16:57: D3D9 : RenderSystem Option: Floating-point mode = Fastest
20:16:57: D3D9 : RenderSystem Option: Full Screen = Yes
20:16:57: D3D9 : RenderSystem Option: Rendering Device = ATI Radeon HD 4800 Series
20:16:57: D3D9 : RenderSystem Option: VSync = No
20:16:57: D3D9 : RenderSystem Option: Video Mode = 800 x 600 @ 32-bit colour
20:16:58: D3D9 : Subsystem Initialising
20:16:58: D3D9RenderSystem::createRenderWindow "OGRE Render Window", 800x600 fullscreen  miscParams: FSAA=0 FSAAQuality=0 colourDepth=32 useNVPerfHUD=false vsync=false 
20:16:58: D3D9 : Created D3D9 Rendering Window 'OGRE Render Window' : 800x600, 32bpp
20:16:58: Registering ResourceManager for type Texture
20:16:58: Registering ResourceManager for type GpuProgram
20:16:58: Multiple render targets with independent bit depths supported
20:16:58: RenderSystem capabilities
20:16:58: -------------------------
20:16:58:  * Hardware generation of mipmaps: yes
20:16:58:  * Texture blending: yes
20:16:58:  * Anisotropic texture filtering: yes
20:16:58:  * Dot product texture operation: yes
20:16:58:  * Cube mapping: yes
20:16:58:  * Hardware stencil buffer: yes
20:16:58:    - Stencil depth: 8
20:16:58:    - Two sided stencil support: yes
20:16:58:    - Wrap stencil values: yes
20:16:58:  * Hardware vertex / index buffers: yes
20:16:58:  * Vertex programs: yes
20:16:58:    - Max vertex program version: vs_3_0
20:16:58:  * Fragment programs: yes
20:16:58:    - Max fragment program version: ps_3_0
20:16:58:  * Texture Compression: yes
20:16:58:    - DXT: yes
20:16:58:    - VTC: no
20:16:58:  * Scissor Rectangle: yes
20:16:58:  * Hardware Occlusion Query: yes
20:16:58:  * User clip planes: yes
20:16:58:  * VET_UBYTE4 vertex element type: yes
20:16:58:  * Infinite far plane projection: yes
20:16:58:  * Hardware render-to-texture: yes
20:16:58:  * Floating point textures: yes
20:16:58:  * Non-power-of-two textures: yes
20:16:58:  * Volume textures: yes
20:16:58:  * Multiple Render Targets: 4
20:16:58:  * Point Sprites: yes
20:16:58:  * Extended point parameters: yes
20:16:58:  * Max Point Size: 256
20:16:58: ***************************************
20:16:58: *** D3D9 : Subsystem Initialised OK ***
20:16:58: ***************************************
20:16:58: ResourceBackgroundQueue - threading disabled
20:16:58: Particle Renderer Type 'billboard' registered
20:16:58: Creating viewport on target 'OGRE Render Window', rendering from camera 'PlayerCam', relative dimensions L: 0.00 T: 0.00 W: 1.00 H: 1.00 ZOrder: 0
20:16:58: Viewport for camera 'PlayerCam', actual dimensions L: 0 T: 0 W: 800 H: 600
20:16:58: Parsing scripts for resource group Autodetect
20:16:58: Finished parsing scripts for resource group Autodetect
20:16:58: Parsing scripts for resource group Bootstrap
20:16:58: Parsing script OgreCore.material
20:16:58: Parsing script OgreProfiler.material
20:16:58: Parsing script Ogre.fontdef
20:16:58: Parsing script OgreDebugPanel.overlay
20:16:58: Texture: New_Ogre_Border_Center.png: Loading 1 faces(PF_A8B8G8R8,256x128x1) with  hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,256x128x1.
20:16:58: Texture: New_Ogre_Border.png: Loading 1 faces(PF_A8B8G8R8,256x256x1) with  hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,256x256x1.
20:16:58: Texture: New_Ogre_Border_Break.png: Loading 1 faces(PF_A8B8G8R8,32x32x1) with  hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,32x32x1.
20:16:58: Font TrebuchetMSBoldusing texture size 512x512
20:16:58: Info: Freetype returned null for character 160 in font TrebuchetMSBold
20:16:58: Texture: TrebuchetMSBoldTexture: Loading 1 faces(PF_BYTE_LA,512x512x1) with 0 generated mipmaps from Image. Internal format is PF_BYTE_LA,512x512x1.
20:16:59: Texture: ogretext.png: Loading 1 faces(PF_A8B8G8R8,256x128x1) with  hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,256x128x1.
20:16:59: Parsing script OgreLoadingPanel.overlay
20:16:59: Finished parsing scripts for resource group Bootstrap
20:16:59: Parsing scripts for resource group General
20:16:59: Parsing script DoF.program
20:16:59: Parsing script Tests.program
20:16:59: Parsing script DoF.material
20:16:59: Parsing script Example.material
20:16:59: Error in material Examples/Robot at line 617 of Example.material: Invalid vertex_program_ref entry - vertex program Ogre/HardwareSkinningOneWeight has not been defined.
20:16:59: Error in material Examples/Robot at line 629 of Example.material: Invalid shadow_caster_vertex_program_ref entry - vertex program Ogre/HardwareSkinningOneWeightShadowCaster has not been defined.
20:16:59: Error at line 677 of Example.material: Error in program Examples/GrassWaverVp parameter entry_point is not valid.
20:16:59: Error at line 677 of Example.material: Error in program Examples/GrassWaverVp parameter profiles is not valid.
20:16:59: Error in material Examples/HardwareMorphAnimation at line 764 of Example.material: Invalid vertex_program_ref entry - vertex program Ogre/HardwareMorphAnimation has not been defined.
20:16:59: Error in material Examples/HardwarePoseAnimation at line 799 of Example.material: Invalid vertex_program_ref entry - vertex program Ogre/HardwarePoseAnimation has not been defined.
20:16:59: Parsing script Ogre.material
20:16:59: Parsing script Tests.material
20:16:59: Parsing script DoF.overlay
20:16:59: Texture: focus.png: Loading 1 faces(PF_A8B8G8R8,128x128x1) with  hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,128x128x1.
20:16:59: Finished parsing scripts for resource group General
20:16:59: Parsing scripts for resource group Internal
20:16:59: Finished parsing scripts for resource group Internal
20:16:59: Texture: RustySteel.jpg: Loading 1 faces(PF_B8G8R8,256x256x1) with  hardware generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
20:16:59: Mesh: Loading ogrehead.mesh.
20:16:59: Texture: WeirdEye.png: Loading 1 faces(PF_B8G8R8,256x256x1) with  hardware generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
20:16:59: Texture: GreenSkin.jpg: Loading 1 faces(PF_B8G8R8,256x256x1) with  hardware generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
20:16:59: Texture: spheremap.png: Loading 1 faces(PF_B8G8R8,256x256x1) with  hardware generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
20:16:59: Texture: dirt01.jpg: Loading 1 faces(PF_B8G8R8,96x96x1) with 6 generated mipmaps from Image. Internal format is PF_X8R8G8B8,96x96x1.
20:16:59: Texture: Test_Plain.png: Loading 1 faces(PF_A8B8G8R8,512x512x1) with  hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,512x512x1.
20:16:59: Texture: Test_StaticVertexProgram.png: Loading 1 faces(PF_A8B8G8R8,512x512x1) with  hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,512x512x1.
20:16:59: Texture: Test_AnimatedVertexProgram.png: Loading 1 faces(PF_A8B8G8R8,512x512x1) with  hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,512x512x1.
20:16:59: Creating viewport on target 'rtt/169450848', rendering from camera 'PlayerCam', relative dimensions L: 0.00 T: 0.00 W: 1.00 H: 1.00 ZOrder: 0
20:16:59: Viewport for camera 'PlayerCam', actual dimensions L: 0 T: 0 W: 800 H: 600
20:16:59: WARNING: Texture instance 'DoF_Depth' was defined as manually loaded, but no manual loader was provided. This Resource will be lost if it has to be reloaded.
20:16:59: Win32Input8: DirectInput Activation Starts
20:16:59: Win32Input8: Establishing keyboard input.
20:16:59: Win32Input8: Keyboard input established.
20:16:59: Win32Input8: Initializing mouse input in immediate mode.
20:16:59: Win32Input8: Mouse input in immediate mode initialized.
20:16:59: Win32Input8: DirectInput OK.
20:16:59: Creating viewport on target 'rtt/169450976', rendering from camera 'PlayerCam', relative dimensions L: 0.00 T: 0.00 W: 1.00 H: 1.00 ZOrder: 0
20:16:59: Viewport for camera 'PlayerCam', actual dimensions L: 0 T: 0 W: 800 H: 600
20:16:59: Creating viewport on target 'rtt/169451040', rendering from camera 'PlayerCam', relative dimensions L: 0.00 T: 0.00 W: 1.00 H: 1.00 ZOrder: 0
20:16:59: Viewport for camera 'PlayerCam', actual dimensions L: 0 T: 0 W: 200 H: 150
20:16:59: WARNING: Texture instance 'CompositorInstanceTexture0' was defined as manually loaded, but no manual loader was provided. This Resource will be lost if it has to be reloaded.
20:16:59: WARNING: Texture instance 'CompositorInstanceTexture1' was defined as manually loaded, but no manual loader was provided. This Resource will be lost if it has to be reloaded.
20:17:01: Render Target 'rtt/169450976' Average FPS: 703.796 Best FPS: 774.226 Worst FPS: 633.367
20:17:01: Render Target 'rtt/169451040' Average FPS: 704.296 Best FPS: 775.225 Worst FPS: 633.367
20:17:03: Creating viewport on target 'rtt/169451040', rendering from camera 'PlayerCam', relative dimensions L: 0.00 T: 0.00 W: 1.00 H: 1.00 ZOrder: 0
20:17:03: Viewport for camera 'PlayerCam', actual dimensions L: 0 T: 0 W: 800 H: 600
20:17:03: Creating viewport on target 'rtt/169450976', rendering from camera 'PlayerCam', relative dimensions L: 0.00 T: 0.00 W: 1.00 H: 1.00 ZOrder: 0
20:17:03: Viewport for camera 'PlayerCam', actual dimensions L: 0 T: 0 W: 200 H: 150
20:17:03: WARNING: Texture instance 'CompositorInstanceTexture2' was defined as manually loaded, but no manual loader was provided. This Resource will be lost if it has to be reloaded.
20:17:03: WARNING: Texture instance 'CompositorInstanceTexture3' was defined as manually loaded, but no manual loader was provided. This Resource will be lost if it has to be reloaded.
20:17:05: Render Target 'rtt/169451040' Average FPS: 814.776 Best FPS: 819.361 Worst FPS: 810.19
20:17:05: Render Target 'rtt/169450976' Average FPS: 814.781 Best FPS: 820.18 Worst FPS: 809.381
20:17:07: Creating viewport on target 'rtt/169450976', rendering from camera 'PlayerCam', relative dimensions L: 0.00 T: 0.00 W: 1.00 H: 1.00 ZOrder: 0
20:17:07: Viewport for camera 'PlayerCam', actual dimensions L: 0 T: 0 W: 800 H: 600
20:17:07: Creating viewport on target 'rtt/169451040', rendering from camera 'PlayerCam', relative dimensions L: 0.00 T: 0.00 W: 1.00 H: 1.00 ZOrder: 0
20:17:07: Viewport for camera 'PlayerCam', actual dimensions L: 0 T: 0 W: 200 H: 150
20:17:07: WARNING: Texture instance 'CompositorInstanceTexture4' was defined as manually loaded, but no manual loader was provided. This Resource will be lost if it has to be reloaded.
20:17:07: WARNING: Texture instance 'CompositorInstanceTexture5' was defined as manually loaded, but no manual loader was provided. This Resource will be lost if it has to be reloaded.
20:17:08: Render Target 'rtt/169450976' Average FPS: 828.172 Best FPS: 828.172 Worst FPS: 828.172
20:17:08: Render Target 'rtt/169451040' Average FPS: 828.172 Best FPS: 828.172 Worst FPS: 828.172
20:17:08: Render Target 'rtt/169450848' Average FPS: 912.344 Best FPS: 1115.88 Worst FPS: 630.739
20:17:08: *-*-* OGRE Shutdown
20:17:08: Unregistering ResourceManager for type Compositor
20:17:08: Unregistering ResourceManager for type Font
20:17:08: Unregistering ResourceManager for type Skeleton
20:17:08: Unregistering ResourceManager for type Mesh
20:17:08: Unregistering ResourceManager for type HighLevelGpuProgram
20:17:08: *** Stopping Win32GL Subsystem ***
20:17:08: Unloading library .\RenderSystem_GL
20:17:08: Render Target 'OGRE Render Window' Average FPS: 912.064 Best FPS: 1115.88 Worst FPS: 630.37
20:17:08: D3D9 : Shutting down cleanly.
20:17:08: Unregistering ResourceManager for type Texture
20:17:08: Unregistering ResourceManager for type GpuProgram
20:17:08: D3D9 : Direct3D9 Rendering Subsystem destroyed.
20:17:08: Unloading library .\RenderSystem_Direct3D9
20:17:08: Unregistering ResourceManager for type Material
20:17:08: Unloading library OgrePlatform.dll
Attachments
screenshot_dof
screenshot_dof
screenshot_1.jpg (56.97 KiB) Viewed 6056 times
User avatar
Florin
Kobold
Posts: 33
Joined: Thu Mar 19, 2009 3:15 am

Re: Depth of Field demo release

Post by Florin »

Hi. I am still stack at this assertion
Expression: physicalIndex + count <= mFloatConstants.size()
which is poped up by this assertion:

Code: Select all

	//-----------------------------------------------------------------------------
	void GpuProgramParameters::_writeRawConstants(size_t physicalIndex, const float* val, size_t count)
	{
		assert(physicalIndex + count <= mFloatConstants.size());
		memcpy(&mFloatConstants[physicalIndex], val, sizeof(float) * count);
	}
physicalIndex = 0
val = -82.280144
count = 16
mFloatConstants.size() = 4

So here seems to be the problem. The question is how this problem can be solved ?

Thanks for help.
User avatar
Florin
Kobold
Posts: 33
Joined: Thu Mar 19, 2009 3:15 am

Re: Depth of Field demo release

Post by Florin »

I solved the assertion like this:

Code: Select all

fragParams->setNamedConstant("dofParams", dofParams,
		sizeof(dofParams)/sizeof(dofParams[0]), 1.0f);

in DepthOfFieldEffect::preViewportUpdate
User avatar
Florin
Kobold
Posts: 33
Joined: Thu Mar 19, 2009 3:15 am

Re: Depth of Field demo release

Post by Florin »

Finally I made it :)

Code: Select all

fragParams->setNamedConstant("pixelSizeScene", pixelSizeScene,
		sizeof(pixelSizeScene)/sizeof(pixelSizeScene[0]), 1.0f);
fragParams->setNamedConstant("pixelSizeBlur", pixelSizeBlur,
		sizeof(pixelSizeBlur)/sizeof(pixelSizeBlur[0]), 1.0f);
fragParams->setNamedConstant("dofParams", dofParams,
		sizeof(dofParams)/sizeof(dofParams[0]), 1.0f);
fragParams->setNamedConstant("pixelSize", pixelSize,
		sizeof(pixelSize)/sizeof(pixelSize[0]), 1.0f);
... adding the last parameter 1.0, which is the multiplicity factor of count, which by default was 4 and the cause of the assertion
Robloch
Gnoblar
Posts: 5
Joined: Tue Oct 20, 2009 10:14 am

Re: Depth of Field demo release

Post by Robloch »

with the dof file I upload, you wouldn't had this problem i think :/
User avatar
Florin
Kobold
Posts: 33
Joined: Thu Mar 19, 2009 3:15 am

Re: Depth of Field demo release

Post by Florin »

Yes, you are write. I works also with the last two parameters as ....1, 3);
User avatar
boyamer
Orc
Posts: 459
Joined: Sat Jan 24, 2009 11:16 am
Location: Italy
x 6

Re: Depth of Field demo release

Post by boyamer »

I was following this topic,is there a stable working version of depth of field?

Thanks
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Depth of Field demo release

Post by jacmoe »

A stable, working version of something which the original author has abandoned a long time ago?
Yes. :)
Robloch wrote:with the dof file I upload, you wouldn't had this problem i think :/
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Robloch
Gnoblar
Posts: 5
Joined: Tue Oct 20, 2009 10:14 am

Re: Depth of Field demo release

Post by Robloch »

I don't really know if my version is stable, but I didn't have any problem yet. You'll find the files at the bottom of page 4.
User avatar
Florin
Kobold
Posts: 33
Joined: Thu Mar 19, 2009 3:15 am

Re: Depth of Field demo release

Post by Florin »

I am trying to add this DoF effect to a stereoscopy app. I have two windows, of which viewports are displaced with the interocular distance. The problem is that the effect on the SECOND window seems to take into account the geometry of the FIRST window :(


I added the effect to viewports before AND after the displacement of the camera by the interocular offset, but I get the same result.
I guess the main principle would be to add the effect to each viewport separatelly. Any ideas about this aspect ?

thanks!
User avatar
Olganix
Halfling
Posts: 41
Joined: Thu Nov 06, 2008 4:18 pm

Re: Depth of Field demo release

Post by Olganix »

I'm not an expert on that but may be both use the same texture.
Try to use two textures and add two compositor target on diferents viewports of yours windows.


note:
I have try to approch the Ogre's CompositorDemo by set a DofListener class which create my texture, and use a DofLens class for automatic update of the focus.
May be you should do the same to manage yours cameras/Textures ( may be not for yours lens, could be very hard for your eyes :) )).



(sorry for my english ...)
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2
Contact:

Re: Depth of Field demo release

Post by Thieum »

Florin, are you using the stereo plugin ?
It currently does not handle correctly the compositors. It can be tricky to handle it automatically but I think it is possible
User avatar
boyamer
Orc
Posts: 459
Joined: Sat Jan 24, 2009 11:16 am
Location: Italy
x 6

Re: Depth of Field demo release

Post by boyamer »

Is it possible to adapt this to run on shader model 2 instead of 3?
User avatar
Olganix
Halfling
Posts: 41
Joined: Thu Nov 06, 2008 4:18 pm

Re: Depth of Field demo release

Post by Olganix »

just change the declaration of the vertex shader and the pixel shader.

example in :

Code: Select all


vertex_program DoF_DepthVP_cg cg			
{
    source DoF.cg
    entry_point DoF_DepthVP_cg
    profiles vs_3_0					
    
    default_params					
    {
        param_named_auto worldViewProj worldviewproj_matrix		
    }
}


fragment_program DoF_DepthFP_cg cg
{
	source DoF.cg
	entry_point DoF_DepthFP_cg
	profiles ps_3_0
}

you can try vs_2_0 instead of vs_3_0 and ps_2_0 instead of ps_3_0. (note: it's the same with the original Dof.program which use HLSL)

http://developer.nvidia.com/object/cg_profiles.html

I just read again the code of Dof's shaders, I don't see anything which could be a problem (there are little differences between synthaxes of shader's version (shader 4 could use integer for example) ).

hope it's what you need.
User avatar
Florin
Kobold
Posts: 33
Joined: Thu Mar 19, 2009 3:15 am

Re: Depth of Field demo release

Post by Florin »

Thieum, I use a slightly modified StereoManager class, and I define my own custom projection matrix for the frustums of the left and right cameras, displaced with an offset.

Code: Select all

Ogre::Matrix4 mOffAxis;
mOffAxis = (...);
mCamera->setCustomProjectionMatrix(true, mOffAxis);	
If I set the offset between the frustums to zero, then it works because the position of the cameras and the projection matrixes are all the same, but then there is no stereoscopy any more.

Code: Select all

Real offset = mStereoMgr->getEyesSpacing()/2;

if(mIsLeftEye)
{
	offset = -offset;
}

//offset = 0;  //cancels the stereoscopy

mOldOffset = mCamera->getFrustumOffset();

if(!mStereoMgr->mFocalLengthInfinite)
	mCamera->setFrustumOffset(mOldOffset - Vector2(offset,0));
Still, it seems that the DoF effect works well but only for the left viewport. I think the trick could be somewhere around the custom projection matrix.

Lens takes mCamera->getFOVy() as parameter, but with my custom projection matrix the angles of the FOV are not symmetrical for the top-down, respectively left-right edges of the frustum. So the calculation for the Lens mFocalLength and mFieldOfView fields should be adjusted in order to take into consideration custom projection matrixes.

Code: Select all

mLens = new Lens(stereoMgr->mCamera->getFOVy(), 1.5);

Unfortunatelly I don't really know much about shaders or compositors. Could you give me a hint to adjust the stereo plugin to work with the DoF effect ?
This is an important feature for the stereoscopic vision, as it mimics the focus of the eye lenses.

thanks!
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2
Contact:

Re: Depth of Field demo release

Post by Thieum »

hi,
I looked your problem more in detail.
you can use a depth of field effect with the dual output stereo mode, it is pretty easy.
You just have to create twe instances of the DOF effet, like this :

Code: Select all

	mStereoManager.init(gLeftViewport, gRightViewport, StereoManager::SM_DUALOUTPUT);
	mStereoManager.setEyesSpacing(EYES_SPACING);
	mStereoManager.setFocalLength(SCREEN_DIST);
	mStereoManager.saveConfig("stereo.cfg");
	//mStereoManager.useScreenWidth(SCREEN_WIDTH);
	mStereoManager.createDebugPlane(mSceneMgr);
	mStereoManager.enableDebugPlane(false);

	mDOFEffectLeft = new DepthOfFieldEffect(gLeftViewport);
	mDOFEffectLeft->setFocalDepths(10, mStereoManager.getFocalLength(), 190); // use the default near and far depths, just change the focal depth

	mDOFEffectRight = new DepthOfFieldEffect(gRightViewport);
	mDOFEffectRight->setFocalDepths(10, mStereoManager.getFocalLength(), 190);
There is just a small bug : if you display the stereo manager's debug plane, the DOF effect will not be applied to what is behind the plane, but if you hide it there is no problem

I tried to use the effect with the anaglyph mode but it is much more complicated and it did not worked.

I don't know if it can be useful for you, but the stereo manager can be used with a camera with a frustum offset (used in off-axis projection)
just set the offset with mCamera->setFrustumOffset(offset); and the eye separation offset will be added to the current offset
User avatar
Quorthon3D
Greenskin
Posts: 100
Joined: Fri Aug 08, 2008 8:06 pm
Location: Belo Horizonte - Brazil

Re: Depth of Field demo release

Post by Quorthon3D »

@DWORD nice job, very good effects.
Sorry for my fail english, I'm studing, I swear! =]
TuxBobble
Gnoblar
Posts: 11
Joined: Wed Feb 17, 2010 4:05 pm

Re: Depth of Field demo release

Post by TuxBobble »

I'm wondering if anyone is still supporting this DoF release at this point...("supporting" maybe) I'm trying to get it to work for a project, but I keep running into errors.

The latest error comes at:

Code: Select all

	mDepthMaterial = MaterialManager::getSingleton().getByName("DoF_Depth");
	mDepthMaterial->load(); // needs to be loaded manually
	mDepthTechnique = mDepthMaterial->getBestTechnique();
I can debug up to the load() call, but during the call to load() and before the assignment of mDepthTechnique, I get an assertion error:

Code: Select all

Assertion failed!

Program: ...
File: f:\codingextra\ogre\shoggoth_vc9\...\ogresharedptr.h
Line: 152

Expression: pRep
I've been trying to figure this out, but I'm not sure why I'm getting this error right now. I have all the materials packaged with the demo (dof.material contains DoF_Depth) and I believe they're all in the right location (I added a line for them in resources.cfg though I suppose it's possible that I did that incorrectly)

If anyone has any ideas, I'd really love to hear them.

UPDATE:
So, I believe, based on debugging, that the issue really lies with the function call BEFORE the call to load(). It seems as though the call to getByName("DoF_Depth") returns a null value, rather than the proper mDepthMaterial result. I'm trying to figure out what I'm doing wrong in this load step--it makes me think there is an issue with the external files, but I copied them directly from the compressed folders, and did not edit them at all. I THINK they're in the right place...but now I'm questioning that, too...
TuxBobble
Gnoblar
Posts: 11
Joined: Wed Feb 17, 2010 4:05 pm

Re: Depth of Field demo release

Post by TuxBobble »

So, I've established that the real issue is, in fact, with the

Code: Select all

 mDepthMaterial = MaterialManager::getSingleton().getByName("DoF_Depth");
line. It seems that for whatever reason, the DoF_Depth material simply will not load correctly. I am not sure what I'm doing wrong, but I took the materials directly from the source. When I try to call load(), the assertion fails because mDepthMaterial is not a sound value. Does anyone have any suggestions on why the getByName("name") function won't "get by name"?
User avatar
gmfreaky
Halfling
Posts: 56
Joined: Tue Feb 02, 2010 6:49 pm

Re: Depth of Field demo release

Post by gmfreaky »

Works perfect here, around constant 80 FPS on my nVidea Geforce 8600GT (256 MB)
andrewxie
Gnoblar
Posts: 17
Joined: Fri Jun 04, 2010 11:46 am

Re: Depth of Field demo release

Post by andrewxie »

How the Lens works ?
Doc_QuicknDirty
Gnoblar
Posts: 16
Joined: Mon Aug 30, 2010 4:48 pm
x 1

Re: Depth of Field demo release

Post by Doc_QuicknDirty »

Hallo,

Today I tried to add the Depth of Field demo code to my app. It works fine for objects but is blurring all terrain, no matter what distance.
I am using the newest unstable Ogre 1.8.x version and the new terrain component.

Any hints?
screenshot02242011_182335032.jpg
Best wishes

Ralf
User avatar
Xplodwild
Goblin
Posts: 231
Joined: Thu Feb 12, 2009 3:49 pm
Location: France
x 13
Contact:

Re: Depth of Field demo release

Post by Xplodwild »

Bumping this, I have the same problem as Doc_QuicknDirty.
Isn't the terrain in another renderqueue?

I also noticed in other compositors (like Glow) that terrain doesn't do his occlusion role (you can see glowing objects through the terrain). Any reason why compositor scene input doesn't seem to contain terrain while doing occlusion ?


Edit: Found the solution. You need to disable Vertex Compression in TerrainGlobalOptions. Definately this doesn't work well with all kinds of shaders, and decals.
maesla
Gnoblar
Posts: 24
Joined: Thu Dec 02, 2010 7:33 pm

Re: Depth of Field demo release

Post by maesla »

Someone could upload a entire VS solution of DOF working in Ogre 1.7.x, please?
Post Reply