Post Processing Example

  1. last year

    I'm trying to do some post process shading and I can't seem to figure it out. Could anyone give some pointers on setting it up (assuming I have the shader itself figured out)? Even explaining how to get the Bloom filter, thats in the HDR pack would help a lot. Thanks a bunch!

  2. Ivan

    27 Jul 2015 Administrator
    camera-> setPostFilterByName("HDRProcessBloom");

    You'll need to add the hdr pack and add the "hdr" dir resource before hand.

  3. 7 months ago

    I know this thread is old but... would you be able to elaborate on the latter part?
    I have added the Resource dir to the ResourceManager like so:
    Services.ResourceManager:addDirResource("Resources", false)
    and added the HDR filter to my camera, but it still isn't working?
    scene:getDefaultCamera():setPostFilterByName("HDRProcessBloom");

    What else do I need to do?

  4. fodinabor

    14 Jul 2016 Administrator

    Well what you have to do is:

    Services.Resources:addArchive("hdr.pak")
    Services.Resources:addDirResource("hdr")

    To make this work you have to copy the hdr.pak from the Assets in the Polycode source tree to your Resources.. Although I think that is done automatically when using lua..

  5. Edited 7 months ago by CandyFace

    Hmm that doesn't seem to work either... but yes it's true that the resources folder is added automatically when using lua.

    I added the code like you said but no effect is being applied, nor am I getting any errors.

    Services.ResourceManager:addArchive("hdr.pak")
    Services.ResourceManager:addDirResource("hdr", false)
    scene:getDefaultCamera():setPostFilterByName("HDRProcessBloom");

    in case you want to see my code in context, although with the above not commited yet..
    https://github.com/CandyFace/AsteroidsLua/blob/master/Scripts/Main.lua

    The code block has been inserted between my level scene instance and setting the video mode.

    edit: After a bunch of trial and error... as well as looking at some of the old c++ template code. I've gotten to this so far:

    Services.ResourceManager:addArchive("default.pak")
    Services.ResourceManager:addDirResource("default", true)
    Services.ResourceManager:addArchive("hdr.pak")
    Services.ResourceManager:addDirResource("hdr", true)
    scene:getActiveCamera():setPostFilterByName("HDRProcessBloom");

    If I use the print(scene:getActiveCamera():hasFilterShader())
    then it returns true.. but I still can't see the effect being applied.. at least it's not visible at all. I'm developing on OSX btw.

  6. fodinabor

    14 Jul 2016 Administrator

    did you add hdr.pak manually to the Resources folder? (and loaded it via "Resources/hdr.pak" ?)

  7. Yes I've added the hdr.pak manually although it's not inside a Resources folder. It just lies in my main folder currently, but that shouldn't make any difference, as long as I make sure it's the right path right?

  8. fodinabor

    14 Jul 2016 Administrator

    Yes.. if it can load that file it should be alright.. can you make Services.Logger:setLogToFile(true) before adding the hdr.pak (actually don't know, whether that works in lua..) that should create a logfile .. can you post what is in there?

  9. Edited 7 months ago by CandyFace

    it doesn't seem like there are any lua bindings anymore for PolyLogger.. The only function I have access to is CoreServices.GetLogger() which returns Logger but that's it.

    I figured it out.. after understanding how to set the parameters inside the shader, it all seemed to work.

    So in the end, this was all I needed to do:

    Services.ResourceManager:addArchive("hdr.pak")
    Services.ResourceManager:addDirResource("hdr", true)
    scene:getDefaultCamera():setPostFilterByName("HDRProcessBloom")
    
    scene:getDefaultCamera():getLocalShaderOptions()[1]:addParam(ProgramParam.PARAM_NUMBER, "brightThreshold"):setNumber(0.1)
    scene:getDefaultCamera():getLocalShaderOptions()[2]:addParam(ProgramParam.PARAM_NUMBER, "blurSize"):setNumber(0.003)
    scene:getDefaultCamera():getLocalShaderOptions()[3]:addParam(ProgramParam.PARAM_NUMBER, "blurSize"):setNumber(0.003)
    scene:getDefaultCamera():getLocalShaderOptions()[4]:addParam(ProgramParam.PARAM_NUMBER, "bloomFactor"):setNumber(1.5)
    scene:getDefaultCamera():getLocalShaderOptions()[4]:addParam(ProgramParam.PARAM_NUMBER, "exposure"):setNumber(0.4)
 

or Sign Up to reply!