Page 1 of 2

Re: Depth-Of-Field / Ambient Occlussion

Posted: Thu Sep 19, 2013 6:19 pm
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.

Re: Depth-Of-Field / Ambient Occlussion

Posted: Thu Sep 19, 2013 7:31 pm
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).

Re: Depth-Of-Field / Ambient Occlussion

Posted: Thu Sep 19, 2013 7:48 pm
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.

Re: Depth-Of-Field / Ambient Occlussion

Posted: Wed Dec 24, 2014 9:53 pm
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 ?

Re: Depth-Of-Field / Ambient Occlussion

Posted: Thu Dec 25, 2014 9:54 am
by Bananenfreak
You created a compositor; Here are good compositors:
https://www.gitorious.org/ogre3d/mainli ... compositor

Re: Depth-Of-Field / Ambient Occlussion

Posted: Thu Dec 25, 2014 12:07 pm
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

Re: Depth-Of-Field / Ambient Occlussion

Posted: Fri Dec 26, 2014 5:48 am
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

Re: Depth-Of-Field / Ambient Occlussion

Posted: Fri Dec 26, 2014 6:22 pm
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.

Re: Depth-Of-Field / Ambient Occlussion

Posted: Fri Dec 26, 2014 8:13 pm
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.

Re: Depth-Of-Field / Ambient Occlussion

Posted: Sat Dec 27, 2014 11:52 am
by Bananenfreak
@AndyLy:
Thank you for sharing this. I tried to use those OGRE compositors, but not even one is loading correct -.-

Re: Depth-Of-Field / Ambient Occlussion

Posted: Sat Dec 27, 2014 1:54 pm
by AndyLy
Bananenfreak
You know that you need to have dll file from Nvidia to make it work?

Re: Depth-Of-Field / Ambient Occlussion

Posted: Sun Dec 28, 2014 10:11 am
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

Re: Depth-Of-Field / Ambient Occlussion

Posted: Sun Dec 28, 2014 12:34 pm
by AndyLy
What PB-Version do you use?
PB 5.31

Re: Depth-Of-Field / Ambient Occlussion

Posted: Sun Dec 28, 2014 3:40 pm
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

Re: Depth-Of-Field / Ambient Occlussion

Posted: Sun Dec 28, 2014 6:28 pm
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