Depth-Of-Field / Ambient Occlussion

Everything related to 3D programming
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 756
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: Depth-Of-Field / Ambient Occlussion

Post by Samuel »

Someone already asked about the Ambient Occlusion. SSAO uses a compositor and in PB 5.2 there is a bug when calling a compositor.
I already posted it in the bugs section. So, In time I'm sure it will be tracked down.

I'm not sure about the Depth of Field, but at first glance it looks like it uses a compositor too. If I have time later I might be able to take a quick look at it.
User avatar
Comtois
Addict
Addict
Posts: 1432
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: Depth-Of-Field / Ambient Occlussion

Post by Comtois »

Samuel wrote:SSAO uses a compositor and in PB 5.2 there is a bug when calling a compositor.
I already posted it in the bugs section. So, In time I'm sure it will be tracked down.
Compositor work fine here

Now CreateCompositorEffect () needs a cameraID() (in previous versions it was a camera's number).
Please correct my english
http://purebasic.developpez.com/
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 756
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: Depth-Of-Field / Ambient Occlussion

Post by Samuel »

Thanks for pointing that out Comtois. I switched them to CameraID() and my compositors run fine now.

Alexi, I'm going to work on the SSAO example later. I'll post it If I can get it running properly.
User avatar
AndyLy
Enthusiast
Enthusiast
Posts: 228
Joined: Tue Jan 04, 2011 11:50 am
Location: GRI

Re: Depth-Of-Field / Ambient Occlussion

Post by AndyLy »

In Ogre has effects such as Depth of Field and HDR. I tried to use them from the Ogre SDK, but they do not work .
I mean, I was unable to make them work .
Can anybody help with this ?
'Happiness for everybody, free, and no one will go away unsatisfied!'
SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
User avatar
Bananenfreak
Enthusiast
Enthusiast
Posts: 519
Joined: Mon Apr 15, 2013 12:22 pm

Re: Depth-Of-Field / Ambient Occlussion

Post by Bananenfreak »

You created a compositor; Here are good compositors:
https://www.gitorious.org/ogre3d/mainli ... compositor
Last edited by Bananenfreak on Fri Dec 26, 2014 9:33 am, edited 1 time in total.
Image
User avatar
AndyLy
Enthusiast
Enthusiast
Posts: 228
Joined: Tue Jan 04, 2011 11:50 am
Location: GRI

Re: Depth-Of-Field / Ambient Occlussion

Post by AndyLy »

This is script from the Ogre SDK . It only works part of the compositors .
Comtois posted above those which work . But I need the ones that don't work : Depth of Field and HDR .
They are in the list of the compositors (in Ogre SDK) but not working .

I want to blur the far background .
Image
'Happiness for everybody, free, and no one will go away unsatisfied!'
SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
User avatar
AndyLy
Enthusiast
Enthusiast
Posts: 228
Joined: Tue Jan 04, 2011 11:50 am
Location: GRI

Re: Depth-Of-Field / Ambient Occlussion

Post by AndyLy »

I have collected all the files that where reference to Bloom (surely a bunch of unnecessary files)
from the Ogre SDK and was able to get this effect to work )

Image
Image

P.S. Sorry, I forgot. Here scripts for Bloom :
https://www.dropbox.com/s/2l2x9p0xjjzxe ... r.rar?dl=0
'Happiness for everybody, free, and no one will go away unsatisfied!'
SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 756
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: Depth-Of-Field / Ambient Occlussion

Post by Samuel »

The HDR compositor is a little more complex compared to the other samples that come with OGRE.

If you look within the HDR compositor script near the top you'll find "compositor_logic HDR" which is a framework that allows complex compositors to receive callbacks with information for setting up the compositor.
Ogre's page on this is here.

This is also the same for a couple other compositors like heat vision and Gaussian blur.

As far as I can tell this means the compositors that use this framework will not run in Purebasic.
The compositors would each need to be rewritten to avoid this framework which might end up being a lot of work.

As for the Depth of field I managed to get it running, but it doesn't seem to work correctly.
In order to get it to run I had to uncomment the compositor script which makes me believe there may be something wrong with this compositor. They may have just commented it out until the problem is fixed.
If you want the example I got running I can post it for you later.
User avatar
AndyLy
Enthusiast
Enthusiast
Posts: 228
Joined: Tue Jan 04, 2011 11:50 am
Location: GRI

Re: Depth-Of-Field / Ambient Occlussion

Post by AndyLy »

Samuel
HDR I don't need now - Bloom is quite enough.
But the DOF would be useful. If you can make it work - it will be good.
'Happiness for everybody, free, and no one will go away unsatisfied!'
SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
User avatar
Bananenfreak
Enthusiast
Enthusiast
Posts: 519
Joined: Mon Apr 15, 2013 12:22 pm

Re: Depth-Of-Field / Ambient Occlussion

Post by Bananenfreak »

@AndyLy:
Thank you for sharing this. I tried to use those OGRE compositors, but not even one is loading correct -.-
Image
User avatar
AndyLy
Enthusiast
Enthusiast
Posts: 228
Joined: Tue Jan 04, 2011 11:50 am
Location: GRI

Re: Depth-Of-Field / Ambient Occlussion

Post by AndyLy »

Bananenfreak
You know that you need to have dll file from Nvidia to make it work?
'Happiness for everybody, free, and no one will go away unsatisfied!'
SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
User avatar
Bananenfreak
Enthusiast
Enthusiast
Posts: 519
Joined: Mon Apr 15, 2013 12:22 pm

Re: Depth-Of-Field / Ambient Occlussion

Post by Bananenfreak »

Yes, an installed CG-Kit

EDIT: What PB-Version do you use? I use PB 5.30 and it can´t load:

Code: Select all

StdQuad_vp.program
Image
User avatar
AndyLy
Enthusiast
Enthusiast
Posts: 228
Joined: Tue Jan 04, 2011 11:50 am
Location: GRI

Re: Depth-Of-Field / Ambient Occlussion

Post by AndyLy »

What PB-Version do you use?
PB 5.31
'Happiness for everybody, free, and no one will go away unsatisfied!'
SMsF town: http://www.youtube.com/watch?v=g6RRKYf_Pd0
SMf locations module (Ogre). Game video: http://www.youtube.com/watch?v=ZlhBgPJhAxI
User avatar
Bananenfreak
Enthusiast
Enthusiast
Posts: 519
Joined: Mon Apr 15, 2013 12:22 pm

Re: Depth-Of-Field / Ambient Occlussion

Post by Bananenfreak »

I don´t understand it. Where´s the Problem?
Also, even without real existing compositordata, PB creates an compositor --> IMA on End or FreeEffect()!

Code: Select all

EnableExplicit


Define.f KeyX, KeyY, MouseX, MouseY
Define nx.f, nz.f, Boost.f = 1.5, Yaw.f, Pitch.f
Define.i Quit, boden, effect
#kam_0 = 0
#window = 0
#plane = 0
#planent = 0

If InitEngine3D(#PB_Engine3D_DebugLog | #PB_Engine3D_EnableCG)
  
  Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
  Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Scripts", #PB_3DArchive_FileSystem)
  Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Models", #PB_3DArchive_FileSystem)
  Add3DArchive("Bloom", #PB_3DArchive_FileSystem)
  Add3DArchive("/", #PB_3DArchive_FileSystem)
  Parse3DScripts()
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  OpenWindow(#window, 0, 0, 1800, 1000, "Compositortest", #PB_Window_ScreenCentered)
  OpenWindowedScreen(WindowID(#window), 10, 10, 2000, 2000, 0, 10, 10, #PB_Screen_SmartSynchronization)
  
  WorldShadows(#PB_Shadow_TextureAdditive, 200, RGB(255 * 0.2, 255 * 0.2, 255 * 0.2), 4096)
  
  AmbientColor(RGB(255 * 0.2, 255 * 0.2, 255 * 0.2))
  LightDirection(CreateLight(#PB_Any, RGB(250, 250, 250), 0, 0, 0, #PB_Light_Directional), -0.5, -0.4, -0.6)
  WorldShadows(#PB_Shadow_Additive, 500, RGB(255 * 0.2, 255 * 0.2, 255 * 0.2), 4096)
  
  ScaleEntity(CreateEntity(#PB_Any, MeshID(LoadMesh(#PB_Any, "tudorhouse.mesh")), #PB_Material_None, 0, 27.5, 0), 0.05, 0.05, 0.05, #PB_Relative)
  ScaleEntity(CreateEntity(#PB_Any, MeshID(LoadMesh(#PB_Any, "ninja.mesh")), #PB_Material_None, 30, 0, 30), 0.05, 0.05, 0.05, #PB_Relative)
  
  CreatePlane(#plane, 100, 100, 100, 100, 100, 100)
  boden = GetScriptMaterial(#PB_Any, "Scene/GroundBlend")
  CreateEntity(#planent, MeshID(#plane), MaterialID(boden), 0, 0, 0)
  EntityRenderMode(#planent, 0)
  
  ;-Camera
  CreateCamera(#kam_0, 0, 0, 100, 100)
  MoveCamera(#kam_0, 20, 20, 20, #PB_Absolute)
  CameraLookAt(#kam_0, 20, 20, 20)
  CameraRange (#kam_0, 2, 5000)
  CameraFOV   (#kam_0, 90)
  CameraBackColor(#kam_0, RGB(50, 40, 200))
  
  ;-Effect
  effect = CreateCompositorEffect(#PB_Any, CameraID(#kam_0), "Bloom")
  Debug effect
  
  Repeat
    Repeat
    Until WindowEvent() = 0
    
    If ExamineMouse()
      Yaw   = -MouseDeltaX() * 0.05
      Pitch = -MouseDeltaY() * 0.05
    EndIf
    
    If ExamineKeyboard()
      
      If KeyboardPushed(#PB_Key_Up)    
        MoveCamera(0,  0, 0, -1 * Boost)
      ElseIf KeyboardPushed(#PB_Key_Down)
        MoveCamera(0,  0, 0,  1 * Boost)
      EndIf 
      
      If KeyboardPushed(#PB_Key_Left)  
        MoveCamera(0, -1 * Boost, 0, 0) 
      ElseIf KeyboardPushed(#PB_Key_Right)
        MoveCamera(0,  1 * Boost, 0, 0)
      EndIf 
      
    EndIf
    
    RotateCamera(0, Pitch, Yaw, 0, #PB_Relative)
    
    RenderWorld()
    FlipBuffers()
  Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  
Else
  MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf

FreeEffect(#PB_All)
End
Image
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 756
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: Depth-Of-Field / Ambient Occlussion

Post by Samuel »

Bananenfreak wrote: I use PB 5.30 and it can´t load:

Code: Select all

StdQuad_vp.program
The error is from Ogre not Purebasic. It's just reporting that it can't find one of the vertex programs that's called from within the material script.
You need to make sure all the required files for the compositor are available otherwise you will get this kind of error.

Here are all the required files and the cg.dll which is needed to run them.
This compositor can be easily converted to HLSL if you want to exclude the dll, but that will remove opengl compatibility.
Bloom.zip
Post Reply