Page 6 of 6
Re: Depth of Field demo release
Posted: Mon Sep 26, 2011 1:37 pm
by andrea147
Yes it would be nice if smn do this....

Re: Depth of Field demo release
Posted: Wed Dec 14, 2011 11:19 am
by lordsme
While writing code to support DoF with multiple cameras, I'm experiencing a problem when I resize my application main viewport with DoF enabled:
cameras lose their correct aspect ratio.
Here's the code line that makes this happen:
Code: Select all
m_pDepthViewport->setCamera(new_camera);
Anyone ever experienced anything like this?
Re: Depth of Field demo release
Posted: Wed Dec 14, 2011 11:26 am
by lordsme
It seems that adding this line of code when resizing the main viewport solves the problem:
Code: Select all
m_pDepthViewport->setDimensions(
m_pViewer->getViewport()->getActualLeft()
, m_pViewer->getViewport()->getActualTop()
, m_pViewer->getViewport()->getActualWidth()
, m_pViewer->getViewport()->getActualHeight()
);
Re: Depth of Field demo release
Posted: Sat Dec 24, 2011 6:48 pm
by Tubulii
I tried to run the shader but I always get
Code: Select all
19:29:09: Attempted to load Cg program 'DoF_DepthVP_cg', but no suported profile was found.
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
}
}
But
19:32:40: * Supported Shader Profiles: hlsl ps_1_1 ps_1_2 ps_1_3 ps_1_4 ps_2_0 ps_2_a ps_2_b ps_2_x ps_3_0 vs_1_1 vs_2_0 vs_2_a vs_2_x
vs_3_0 (Ati radeon 5770)
And
Code: Select all
19:29:09: OGRE EXCEPTION(2:InvalidParametersException): Parameter called worldViewProj does not exist. in GpuProgramParameters::_findNamedConstantDefinition at ..\src\OgreGpuProgram.cpp (line 1097)
19:29:09: Compiler error: invalid parameters in DoF.material(9): setting of constant failed
for all parameters. It doesn't matter which CG dof version in this thread i use. It's always the same.
I have read something that parameters are "kicked out" if they seem not to be used. How ever I have no idea how to fix this.
Has anybody an idea? Thanks!
Re: Depth of Field demo release
Posted: Sat Dec 24, 2011 10:22 pm
by Mind Calamity
This works for me, it's a different material, but still contains the world view projection matrix parameter, try it like this:
Code: Select all
vertex_program_ref outline_vs_cg
{
param_named_auto worldViewProjMatrix worldviewproj_matrix
param_named size_value float 0.2
}
Just remove the default_params.
Re: Depth of Field demo release
Posted: Sun Dec 25, 2011 12:35 pm
by Tubulii
Mm, interesting, removing default_params worked but I am still geting this:
Code: Select all
Attempted to load Cg program 'DoF_DepthOfFieldFP_cg', but no suported profile was found.
I think this means that,
profile vs_3_0 is not supported by my graphics card but why the log says:
Code: Select all
Supported Shader Profiles: hlsl (...) ps_3_0 (...) vs_3_0
Does this mean only hlsl shader vs_3_0 is supported by my ati 5770? The manual says "Cg (3.1.5 Cg programs) (an API- and card-independent, high-level language which lets you write programs for both OpenGL and DirectX for lots of cards)"
Now i am confused...
Edit: I did a fresh restart and with version 1.7.3 it seems to run fine, out of the box. I will now compare the working example with my other project. I hope it is only a typo or a missing file... nevertheless thank you!
Re: Depth of Field demo release
Posted: Sun Dec 25, 2011 6:16 pm
by Mind Calamity
Check your plugins.cfg file, see if it contains this line: Plugin=Plugin_CgProgramManager, I think that's what fixed it for me last time...
Re: Depth of Field demo release
Posted: Sun Dec 25, 2011 6:28 pm
by Tubulii
Mind Calamity wrote:Check your plugins.cfg file, see if it contains this line: Plugin=Plugin_CgProgramManager, I think that's what fixed it for me last time...
And if cg.dll is copied into the right folder: i think that was my mistake. Thanks again.
Re: Depth of Field demo release
Posted: Sun Dec 25, 2011 8:23 pm
by Mind Calamity
Yupp, cg.dll has to be in the same folder as the Cg plugin.
Re: Depth of Field demo release
Posted: Sun Jan 15, 2012 6:19 pm
by Beauty
I just want to mention that Mr. Tubulii created a C# port of this code for usage with Mogre and .NET.
Details are here:
http://www.ogre3d.org/addonforums/viewt ... =8&t=15042
Thanks to all people who helped to develop and improve the DepthOfField code.

Re: Depth of Field demo release
Posted: Tue Jan 17, 2012 1:28 am
by Beauty
On yesterday I motivated Tubulii to create a wiki page for the Mogre port.
Today he created a sweet page for Mogre DOF.
Thanks !!
Look here:
http://www.ogre3d.org/tikiwiki/Dof+shader+in+Mogre
Re: Depth of Field demo release
Posted: Sat Jan 21, 2012 4:03 pm
by rybka007
Hi,
I have a problem with implementing DOF to my project. I have added correct Lens and DepthOfFieldEffect classes to the project and additionally created a class that is called Realistic Camera. From there i try to create an instance of both DepthOfFieldEffect and Lens, but I get:
C:\Users\Ryba\Documents\QtOgre-build\..\QtOgre\source\RealisticCamera.cpp:41: błąd:C2259: 'DepthOfFieldEffect' : cannot instantiate abstract class
due to following members:
'bool Ogre::RenderQueue::RenderableListener::renderableQueued(Ogre::Renderable *,Ogre::uint8,Ogre::ushort,Ogre::Technique **,Ogre::RenderQueue *)' : is abstract
This is akward, because every project I have seen uses this class like that. What can be the problem?
Re: Depth of Field demo release
Posted: Sat Jan 21, 2012 6:58 pm
by Rambus
C:\Users\Ryba\Documents\QtOgre-build\..\QtOgre\source\RealisticCamera.cpp:41: błąd:C2259: 'DepthOfFieldEffect' : cannot instantiate abstract class
due to following members:
'bool Ogre::RenderQueue::RenderableListener::renderableQueued(Ogre::Renderable *,Ogre::uint8,Ogre::ushort,Ogre::Technique **,Ogre::RenderQueue *)' : is abstract
This is a common programming error unrelated to the DoF release. In plain English the error means the class called DepthOfFieldEffect has not been fully defined.
This class inherits from RenderableListener and the RenderableListener class defines a set of pure virtual methods (they start with the keyword virtual and end with '= 0;' ). When ever you inherit from a class with pure virtual members you _must_ provide a definition for them- or you get this error.
I suggest reading up on C++ object oriented programming, it will make your programming life much easier
Edit:
To fix:
In DepthOfField.h
Code: Select all
virtual bool renderableQueued(Renderable* rend, Ogre::uint8 groupID, Ogre::ushort priority, Technique** ppTech, RenderQueue* pQueue);
In DepthOfField.cpp
Code: Select all
bool DepthOfFieldEffect::renderableQueued(Renderable* rend, Ogre::uint8 groupID, Ogre::ushort priority, Technique** ppTech, RenderQueue* pQueue)
{
// Replace the technique of all renderables
*ppTech = mDepthTechnique;
return true;
}
I think the error was just a change to the renderableQueued definition between ogre versions but I can't really remember.
Re: Depth of Field demo release
Posted: Thu Feb 09, 2012 4:35 pm
by rybka007
I knew what were virtual functions, I just didn't realise that the actual implemention of it changed. Thanks a lot
Now I have another akward problem. The whole script runs, I can succesfully modify the lenses parameters. However no matter what I choose, the image with DOF effect is always blurred. It is visible in the image below:
In the log displayed on the right it is visible, that initial focus distance was 300 and it was modified using a ray cast to set it properly (all valuesa are in millimeters). However even after recalculation of dofParams, the effect stays the same.
What could cause the problem?
Re: Depth of Field demo release
Posted: Tue Jan 22, 2013 10:58 am
by MarkieMoo
Hi all,
Im a noobie. Trying to get this to work on a dual screen system and all seems to work up until the point it calls the previewport function after I create a new DepthOfFieldEffect class.
D3D9RenderWindow* D3D9Device::getPrimaryWindow()
{
RenderWindowToResorucesIterator it = mMapRenderWindowToResoruces.begin();
while (it != mMapRenderWindowToResoruces.end() && it->second->presentParametersIndex != 0)
++it;
assert(it != mMapRenderWindowToResoruces.end());
return it->first;
}
It basically hits the assert() in the function. Can anyone help please?
Thanks
Re: Depth of Field demo release
Posted: Wed Jan 23, 2013 9:48 am
by MarkieMoo
Is there not simple plugin that works with 1.7.4+ for GL/DX C++? I don't know that's why I'm asking; If I'm being too presumptious please let me know. I just don't know if one exists.
Many Thanks in advance.