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!
User avatar
DWORD
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 1365
Joined: Tue Sep 07, 2004 12:43 pm
Location: Aalborg, Denmark

Post by DWORD »

Hm, it worked for me moments ago. I can e-mail it to you if you want.

I'm working to integrate yours and raflegan's changes. I can confirm that your changes also work on nVidia. I start hating compilers that silently compile errorneus code, it would be a lot easier to spot bugs if it would just 'not work' on errors.
raflegan
Gnoblar
Posts: 16
Joined: Thu May 25, 2006 3:32 pm
Location: Vienna, Austria

Post by raflegan »

Here is another site with the file, but it should work on the first one, too.
User avatar
DWORD
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 1365
Joined: Tue Sep 07, 2004 12:43 pm
Location: Aalborg, Denmark

Post by DWORD »

I integrated your changes and added the missing test programs for D3D. Now it runs exactly the same on D3D and GL. Thanks for compatibility testing and fixing. :) Please let me know if it runs on ATI now, too.

Binary Windows demo: dof-0.1.3-bin-win32.zip
Source for Linux and Windows (VS.NET 7.1): dof-0.1.3-src.tar.bz2

Edit: Btw, on performance, in Windows D3D runs twice as fast as GL on my machine, however running GL in Linux is just as fast D3D is in Windows. :?
User avatar
SuprChikn
Bugbear
Posts: 863
Joined: Tue Apr 19, 2005 6:10 am
Location: Melbourne, Aus

Post by SuprChikn »

Binary version: "The dynamic link library d3dx9_30.dll could not be found ..." ;)
User avatar
DWORD
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 1365
Joined: Tue Sep 07, 2004 12:43 pm
Location: Aalborg, Denmark

Post by DWORD »

Ah, don't you have the newest DX SDK? ;)

http://www.dll-files.com/dllindex/dll-f ... l?d3dx9_30
User avatar
SuprChikn
Bugbear
Posts: 863
Joined: Tue Apr 19, 2005 6:10 am
Location: Melbourne, Aus

Post by SuprChikn »

Afraid not. I'm using Win2K, so...

[edit]
Hmm, that's odd. I do notice that DX9 runs at a higher frame rate than OpenGL on my computer, but the DX9 version also seems to be blurrier.

The following two screenshots were taken on consecutive runs of the program, one using DX, the other OpenGL. The camera was not moved and no other settings were changed:

DX9:
Image

OpenGL:
Image

Seems a bit strange.
[/edit]
User avatar
DWORD
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 1365
Joined: Tue Sep 07, 2004 12:43 pm
Location: Aalborg, Denmark

Post by DWORD »

Hm, the GL version is the right one. It looks like the DX version ignores the depth completely and just blurs everything. :? On my 6800 it looks identical on GL and DX, so I don't know what could be wrong. Updated drivers?
raflegan
Gnoblar
Posts: 16
Joined: Thu May 25, 2006 3:32 pm
Location: Vienna, Austria

Post by raflegan »

Do you get any exceptions in Ogre.log concerning the vertex or fragment shaders?
The DoF_DepthOfField_hlsl.frag shader has to be compiled to ps_3_0 in DirectX, does your card support pixel shader 3.0?
Alternatively, the shader could be compiled to ps_2_a, too, but I don't know if Ogre supports that shader model.
User avatar
ahmedismaiel
OGRE Contributor
OGRE Contributor
Posts: 217
Joined: Wed Jan 25, 2006 11:16 pm
Location: Redmond,WA

Post by ahmedismaiel »

the directx version made the demo crashes ,on my ATI X700 ,any ideas?
i'll debug the application and see
User avatar
SuprChikn
Bugbear
Posts: 863
Joined: Tue Apr 19, 2005 6:10 am
Location: Melbourne, Aus

Post by SuprChikn »

DWORD wrote:Hm, the GL version is the right one. It looks like the DX version ignores the depth completely and just blurs everything. :? On my 6800 it looks identical on GL and DX, so I don't know what could be wrong. Updated drivers?
I just updated my drivers, and there's no change.
raflegan wrote:Do you get any exceptions in Ogre.log concerning the vertex or fragment shaders?
No exceptions in the Ogre.log, though there are a few errors reported, though I think they're "normal":

Code: Select all

22:29:03: Error in material Examples/Robot at line 617 of Example.material: Invalid vertex_program_ref entry - vertex program Ogre/HardwareSkinningOneWeight has not been defined.
22:29:03: 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.
22:29:03: Error at line 677 of Example.material: Error in program Examples/GrassWaverVp parameter entry_point is not valid.
22:29:03: Error at line 677 of Example.material: Error in program Examples/GrassWaverVp parameter profiles is not valid.
22:29:03: Error in material Examples/HardwareMorphAnimation at line 764 of Example.material: Invalid vertex_program_ref entry - vertex program Ogre/HardwareMorphAnimation has not been defined.
22:29:03: Error in material Examples/HardwarePoseAnimation at line 799 of Example.material: Invalid vertex_program_ref entry - vertex program Ogre/HardwarePoseAnimation has not been defined.
raflegan wrote:The DoF_DepthOfField_hlsl.frag shader has to be compiled to ps_3_0 in DirectX, does your card support pixel shader 3.0?
My card is a 6200, so yes, it supports ps3.0

My card is a bit of a weird one in some respects though. For one, it has 256MB, which seems a fair bit for a 6200. Also, I'd read in a few places (including in a couple of threads on the ogre forums) that there is little difference between the 6200 and the 6600, and you can effectively turn your 6200 into a 6600 by using some software and re-enabling some pixel pipelines. So, I decided to give that a go, and found that according to the software (RivaTuner), those said pixel pipelines are already enabled. Don't know what's going on there.
raflegan
Gnoblar
Posts: 16
Joined: Thu May 25, 2006 3:32 pm
Location: Vienna, Austria

Post by raflegan »

Hmm, tomorrow I'll probabely have a chance to test the DoF Effect on an ATI card.
Maybe I will be able to identity the error then.
User avatar
Grom
Hobgoblin
Posts: 523
Joined: Fri Jan 06, 2006 6:35 pm

Post by Grom »

when I try to do this (in direct3d9)

Code: Select all

DepthOfFieldEffect *DOFE = new DepthOfFieldEffect(viewPort);
it causes a crash that doesn't log an error. If someone can offer me advice on debuggin this i'd be glad to try and find the source of the error, but when I compile the debug version and do debug->start it has an exception that breaks to a bunch of assembly.
raflegan
Gnoblar
Posts: 16
Joined: Thu May 25, 2006 3:32 pm
Location: Vienna, Austria

Post by raflegan »

I have tried the DoF Effect on computer with an ATI card today and it worked there.
To get correct debug information, you would probabely need the ogre library debug information (in VisualStudio the OgreMain.pdb or OgreMain_d.pdb file) to get a more exact location of the error.

You could also try to test very simple shaders, to see if something is wrong with the hlsl shaders, e.g. rewrite the DoF_DepthOfFiel_hlsl.frag shader to:

Code: Select all

uniform float2 pixelSizeScene;      // pixel size of full resolution image
uniform float2 pixelSizeBlur;       // pixel size of downsampled and blurred image

float4 main(float2 tex : TEXCOORD0) : COLOR0
{
  return float4(1.0,pixelSizeScene.r,pixelSizeBlur.r,1.0);
}
(You have to use pixelSizeScene and pixelSizeBlur in the output, otherwise the compiler would optimize them away)
If you get a red screen, then this shader is causing the problems, otherwise it is probabely not this shader causing the problem (or at least not only this shader).

You could also locate the error more exactly by writing outputs the Ogre.log yourself, e.g. with:

Code: Select all

#include <OgreLogManager.h>

LogManager::getSingleton().logMessage("text");
Here is a modified DepthOfFieldEffect.cpp file that outputs text in every step of the depth of field effect construction.
User avatar
SuprChikn
Bugbear
Posts: 863
Joined: Tue Apr 19, 2005 6:10 am
Location: Melbourne, Aus

Post by SuprChikn »

raflegan wrote:You could also try to test very simple shaders, to see if something is wrong with the hlsl shaders, e.g. rewrite the DoF_DepthOfFiel_hlsl.frag shader to:

Code: Select all

uniform float2 pixelSizeScene;      // pixel size of full resolution image
uniform float2 pixelSizeBlur;       // pixel size of downsampled and blurred image

float4 main(float2 tex : TEXCOORD0) : COLOR0
{
  return float4(1.0,pixelSizeScene.r,pixelSizeBlur.r,1.0);
}
(You have to use pixelSizeScene and pixelSizeBlur in the output, otherwise the compiler would optimize them away)
If you get a red screen, then this shader is causing the problems, otherwise it is probabely not this shader causing the problem (or at least not only this shader).
I changed the .frag file as you said, and do indeed get a red screen.
raflegan
Gnoblar
Posts: 16
Joined: Thu May 25, 2006 3:32 pm
Location: Vienna, Austria

Post by raflegan »

Sorry for the late answer.
I have found an error in the DoF_DepthOfField_hlsl.frag shader. Apparently, the global variables have to be initialized inside a function (there is no error if you initialize them somewhere else, but then they just don't get a value, or the value zero).
Here is an updated version of the shader, just replace the old one.

Please tell me if this fixed some of the errors.
User avatar
SuprChikn
Bugbear
Posts: 863
Joined: Tue Apr 19, 2005 6:10 am
Location: Melbourne, Aus

Post by SuprChikn »

Yep, that's better. GL and DX seem to be behaving the same now.
User avatar
ahmedismaiel
OGRE Contributor
OGRE Contributor
Posts: 217
Joined: Wed Jan 25, 2006 11:16 pm
Location: Redmond,WA

Post by ahmedismaiel »

the problem i have is not resolved yet

the problem is in this code

Code: Select all

void DepthOfFieldEffect::addCompositor()
{
	// Add the compositor to the viewport
	mCompositor = CompositorManager::getSingleton().addCompositor(
		mViewport, "DoF_Compositor");

	// Register 'this' as a listener
	mCompositor->addListener(this);
}
 
mCompositor is null after calling addCompositor but i don't know yet why ,any idea??

i think there is files missing
User avatar
DWORD
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 1365
Joined: Tue Sep 07, 2004 12:43 pm
Location: Aalborg, Denmark

Post by DWORD »

@raflegan, SuprChikn: Thanks, I'll add the new file.

@ahmedismaiel: addCompositor() does indeed return 0 on error, but as I don't get that problem, would it be possible that you could step into the Ogre code and see where it goes wrong, maybe find out which file is missing if that is the case?

Thinking about it, do you run Linux? Because then the problem might be case of the filenames, if you have copied them in manually. Make sure the case matches, or try the new release I'll post in a moment from scratch...
User avatar
DWORD
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 1365
Joined: Tue Sep 07, 2004 12:43 pm
Location: Aalborg, Denmark

Post by DWORD »

User avatar
ahmedismaiel
OGRE Contributor
OGRE Contributor
Posts: 217
Joined: Wed Jan 25, 2006 11:16 pm
Location: Redmond,WA

Post by ahmedismaiel »

my problem that make addCompositor() return 0 is because the D3D shader requires ps_3_0 which my ATI x800 doesn't support

is that hlsl program cannot be done is ps2.0 ,is there a feature that really require ps 3.0 ?
User avatar
ahmedismaiel
OGRE Contributor
OGRE Contributor
Posts: 217
Joined: Wed Jan 25, 2006 11:16 pm
Location: Redmond,WA

Post by ahmedismaiel »

found it
the minimum version that compiles the fragment_program DoF_DepthOfFieldFP_HLSL is ps_2_b

so in the DOF.program file the declaration should be

Code: Select all

fragment_program DoF_DepthOfFieldFP_HLSL hlsl
{
  source DoF_DepthOfField_HLSL.frag
  entry_point main
  target ps_2_b
}
now it works fine on ATI x700,thanks DWORD ,thanks OGRE :)
Oogst
OGRE Expert User
OGRE Expert User
Posts: 1067
Joined: Mon Mar 29, 2004 8:49 pm
Location: the Netherlands
x 43

Post by Oogst »

You are doing some manual things to get to the depth-buffer, but the GPU has one anyway. Is there not some way to get a copy of the depth buffer as it is from the GPU?
My dev blog
Awesomenauts: platforming MOBA (PC/Mac/Linux/XBox360/X1/PS3/PS4)
Blightbound: coop online dungeon crawler (PC)
Swords & Soldiers: side-scrolling RTS (Switch/PS3/Wii/PC/Mac/Linux/iPhone/iPad/Android)
Proun: abstract racing game (PC)
Cello Fortress: mixing game and live cello performance
The Ageless Gate: cello album
Skorpio
Kobold
Posts: 37
Joined: Sun Sep 24, 2006 9:32 am

Help

Post by Skorpio »

Hello

I just downloaded the DOF project. Both the windows exe and the compiled version crash.

It seems the mDepthMaterial comes back null

mDepthMaterial = MaterialManager::getSingleton().getByName("DoF_Depth");

because when I step through the code

mDepthMaterial->load()
shows me

- Ogre::SharedPtr<Ogre::Material> {pRep=0x00000000 {mTechniques={first=??? last=???} mSupportedTechniques={first=??? last=???} mBestTechniquesBySchemeList={size=???} ...} pUseCount=0x00000000 } Ogre::SharedPtr<Ogre::Material>

I would appreciate any kind of help.

I have the OGRE SDK 1.2.2, DOF 0.1.4 and NET7.1

Thanks

Best Regards
User avatar
DWORD
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 1365
Joined: Tue Sep 07, 2004 12:43 pm
Location: Aalborg, Denmark

Post by DWORD »

What does the log say? Does your video card support the shaders? Does it find the media files? Did you try ahmedismaiel's tip above about changing the shader target to ps_2_b?
User avatar
yuriythebest
Orc
Posts: 468
Joined: Sun Jul 10, 2005 11:44 am
Location: Kiev, Ukraine

Post by yuriythebest »

awsome awsome awsome! now ogre does have everything :D On my p4 3.06ghz, 1gb ram, nvidia 6600 runs at:

34fps= 800*600*16
13fps=1280*1024*16

in direct3d with no antialising, no vsync