• This Website Is Not For Sale
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Ambient occlusion, is it possible?

Discussion in 'Racer Physics and Technical' started by Mr Whippy, Feb 19, 2010.

  1. I'd love to see ambient occlusion in Racer for loads of reasons... and good old self-shadowing for car interiors.

    Is this a CG/shader thing to refine and get working, or is there hard coding behind the scenes that Ruud needs to complete to allow these things to happen?!

  2. I'm afraid, currently in Racer, neither cannot be done by just implementing the shaders.

    I assume, you're talking about Screen Space Ambient Occlusion? Afaik, it is not just making the shaders, but the algorithm for rendering a frame needs to be (hard) coded as well. There are quite a lot of material on GameDev.net, have a look.

    As for shadows (shadow mapping is the way to go IMHO), a shadow map needs to be rendered for each light (in the simplest case - only for the sun) and then fed to all shaders that are affected by shadows.

    I really don't want to have stenciled shadows, where you cannot cut the specular light in the shadowed area etc..
  3. Yeah, shadow maps seems the way forward.

    I'm just playing PGR2 here (Xbox1) with interior shadowing, and also GT5P on the PS3, and it has it too... Xbox1 and PGR1 is old, and GT5P is getting on now.

    We have CG graphics yet this whole hardcoded old shadow system and lighting system seems to be hindering Racers visuals.

    OK, for the old shaders and the really old gfx system that is fine, but holding on to it all for CG stuff seems to be limiting us moving forward :(

    Really looking forward to these additions, since almost all current and last-gen games had these features and now with Racer still not having them (when in the past Racer kinda kept pace with what was out there, or better than), makes Racer look a bit limited.

  4. Funny this subject pops up. Cascaded shadow maps is almost up and running for Racer ! I'm gonna finish up the shaders and the ini settings next week. And ambient occlusion would be nice too, i will try to put taht high on the "to-do" list.
  5. Pretty interesting, can't wait for the next release! Any teaser screens? :p
  6. Back when we were on RSC I posted a link to a website that had info about cg generated shadows. I tried to use them but my very limited knowledge of cg's rendered them unuseable. I'll look to see if I still have the info and post it tomorrow night.

    I found the info the 7z file has a .mht file that will open in your browser.

    Attached Files:

  7. Actually mitch, we need fullscreen normals...any idea how to get them without butchering the motion blur code?
  8. fullscreen normals are optional if you look at the sample code.. So it should be possible
  9. Ah, indeed.

    Ok, giving it a go.
  10. i stopped with this:


    the problem was this function:

    float3 fetch_eye_pos(float2 uv)
        float z = tLinDepth.SampleLevel(samNearest, float3(uv, 0), 0);
        return uv_to_eye(uv, z);
    I'm not an expert in HLSL so don't really know what "SampleLevel" does, it has something to do with mipmapping or something.
    also, the depth map seems to be linear, so the racer depth map needs to be converted.
    It would be nice to see what you come up with without looking at my code first.
    I suggest you also use the horizon based AO since that is the best one.

    I see two possible problems with my shader:
    - The constants might be wrong
    - the samplelevel thing

    If i was able to run the sample code i could pinpoint the problem ...
  11. Hmmm
    Is there a way to load a texture for FS shaders?
    We need a randomiser texture apparently...
  12. that's not really necessary, you can just replace that by 0.0.

    i'm almost there by the way, i'm getting some ambient occlusion in one half of my screen ... really bizar bug. :) almost there
  13. Excellent, because mine just collapsed in a heap. haha

    Be sure to post the code, if you can't/don't want to post it PM me ;)
  14. untitled..JPG
    almost there ! :)
  15. I've gotta tell ya, i'm blown away by this SSAO stuff, it's absolutly amazing.

    here is the fullscreen shader:

    It needs a lot of tweaking in the constant section (in ssoa.cg). Post the best settings you can find here. I'm gonna implement this as a feature as soon as possible.



    If you want to use the shader, "ssao.cg" as fs_filter1 (extract the shader files in the fullscreen shader folder)

    adjust the variable "f" in the shader with fx.visibility defined in racer.ini

    you can find it here in ssoa_conv.cg:
    float3 fetch_eye_pos(float2 uv, sampler2D depthMap)
        // tLinDepth.SampleLevel(samNearest, float3(uv, 0), 0);
        //float4 depth = tex2D(depthMap,uv);
        float f=750.0f; // adjust this to match fx.visibility from racer.ini
        float n = 0.1f;
        float z = (2 * n) / (f + n - tex2D( depthMap, float2(uv) ).z * (f - n));
        return uv_to_eye(uv, z);

    in ssao.cg change the rand value to 1.0f/reswidth for the best result

    float3 rand=1.0f/1024.0f;
    we are probably gonna need a normal texture to make it look real good, but this really shows off how good i could be
  16. Fantastic work :D

    The level of realism added just with this is astonishing.

    No more 2d shadow maps for the ambient occlusion under the car needed then :D

    Saves baking vertex lighting into tracks too!

    Tyres that are under the car will appear dark, but as they steer out into the light, or the suspension extends, they will light up a bit. All these lovely little visual details will now be evident and not need faking or being evident as wrong :)

    Can't wait to try it...!

  17. While you are working on this, can you please look into making the naming convention of the fs shaders a bit more logical, and layered?

    Ie, I don't like vignetting, but do like HDR and motion blur.

    Is there any way you can make the fs shaders have good names and/or be commented well enough so we can just turn off some lines in the fs shader files to turn features on/off.

    Ie, bloom_hdr_vign_blur_ssao.cg would be the name for the file with all the features on, but also there is one with the same name but no _vign, which has all the same stuff, but no vignetting?

    Or perhaps just make it clear in one general fs_shader with comments which bits to comment out to turn effects on/off etc?!


  18. Could you perhaps upload it to mediafire or something? That crapidshare is overloaded again... sigh.