Labels

October 23, 2012

//status update 04 & RGP day 8

Lots of good stuff has happened recently. I am waiting for my new custom laptop to get shipped from US, so finally I will be able to normally screencast the process of the development of my racing game ..and to actually play my game. As a real tech geek I will also write a short review of it :)
Not much has happened to RGP since the last post and I believe the real process will start whenever I will be on my new rig.

Here is the list of stuff regarding RGP:

- So for the outdoors lighting in the game I will be using a procedural sky model originally presented in 2002 GDC by Naty Hoffman and Arcot J. Preetham. Implementation by Simon Wallner seemed to be the best one I could find and I have already got it working in BGE (see it HERE). I thought I was quite satisfied with the results, but just few days ago some guy asked for an assistance regarding the sky shader as he is implementing it in UDK4 engine. It turns out I had seen his works numerous times and visited his portfolio earlier, be sure to check it out HERE <- awesome stuff! Anyways he also pointed out that it lacks the distinct sunrise feel to it so I took another look at the shader. After few modifications I came up with a nice sunset/sunrise effects.
- I also added a Uncharted2 filmic tone mapping operator from John Hable's GDC presentation and implementation of it from HERE. I really Hope I can add a real HDR support in BGE someday.
- Another feature I have been trying to replicate in BGE is generation of cubemap environment maps in real-time. I did it by simply rendering textures from 6 cameras and then combining them in a shader. It is slow but works! A simplified and optimized version of it I might use for reflection in the game.
- And the last but not least - a pseudo lens flare by John Chapman (implementation from HERE)

blends:

both files also feature point light scattering by Miles Macklin.

realtime cubemap:
https://dl.dropbox.com/u/11542084/realtime_cubemap.blend

lens flares:
https://dl.dropbox.com/u/11542084/flare_playground_3.blend

screenshots:

the upgraded sky model



real time cube environment mapping





lens flares





Battlefield3 style dusty lens



light directly into lens



25 comments:

  1. Nice update. I've actually implemented a similar lens flare using compute shaders and ftt. It was pretty buggy. But the idea came from matt patineo suggestion in Jason thread on gameDev. Really nice though.

    ReplyDelete
    Replies
    1. thanks, that is actually based on the same technique Matt Pettineo (MJP) published in 2009.

      Delete
  2. Woooow, this is gonna rock UDK and Cryengine sooo bad, I really hope you keep giving us all this stuff (and I hope you find some way of earning money to), I want to learn how to do what you do, so do not stop, the world needs your genius!!!!

    ReplyDelete
  3. Hell yeah! I wish I could capture cubes like that in unreal :D
    And the lens flares... I feel wet xD

    ReplyDelete
    Replies
    1. :) Thanks David,
      I will actually make a blog post about the cube mapping right away, as it is actually quite simple and unique.

      Delete
    2. I made 6 captures with orthographic view cameras (fov 90º) in unity. Dunno if you did the same here. Anyway, extremely expensive for a real use! :)

      Delete
    3. yea, thats exactly how I done it. It is very expensive indeed, I am looking for a more effective technique right now.

      Delete
  4. I have a little question.

    What's going on with the strange volumetric light glow in the cube map screenshots?
    Is it a separate shader, or just some halo-plane around the lamp?

    -Thomas.

    ReplyDelete
    Replies
    1. Hi Thomas,
      that is a nice light scattering simulation by Miles Macklin. Got it from here:
      http://blog.mmacklin.com/2010/05/29/in-scattering-demo/

      I modified it a bit to work in light space.

      float Scatter(vec3 vPos, vec3 lPos)
      {
      float d = length(vPos);
      vPos /= d;

      vec3 q = -lPos;

      float b = dot(vPos, q);
      float c = dot(q, q);

      float s = 1.0/sqrt(c-b*b);

      float l = s*(atan((d+b)*s)-atan(b*s));

      return l;
      }

      where
      vPos = gl_ModelViewMatrix * gl_Vertex;
      lPos = gl_LightSource[i].position.xyz;

      you add this when you are doing the light calculation. multiply with light color and voila!

      Delete
    2. If you need a hand in implementation, just give a shout :)

      Delete
  5. Looking great, really. Please continue development - this is looking pretty awesome.

    ReplyDelete
  6. Could you share blend files with these goodies? ;P

    ReplyDelete
    Replies
    1. hmm good idea :)
      give me a moment, I will upload them and add the links in the post.

      Delete
    2. Nice! Thank you very much, your work is a goldmine learning python for BGE! :)

      Btw, I see bug in the Realtime cubemap, the front and back (or left and right) tiles are black, I will try figure out why, but at the moment I have no idea. Same result in 2.64 and BGE Candy for me.

      And I am very curious about the upgraded sky model, you think you could share that one to? ;)

      Delete
  7. Hello,

    very nice result in the video!
    As I'm trying to implement this myself in our open source engine (http://minko.io), I have two questions :

    - How do you get the blue-ish "flare" on the point light spheres? it looks like it appears only in the screen-space lens flare screenshots, yet I dont' understand how this technique gives such results.

    - About the lights "glow" visible in the cube map screenshots, how does that glow work? I've read your answer on scattering but I'm not sure I understand how to use this. Is this done at rendering or in post-process? My understanding is that there is no actual spheres but just sprites rendered using this scattering technique in the pixel shader. Is that correct?

    That's actually a lot more than 2 questions :)
    Thank you for your help !

    ReplyDelete
    Replies
    1. Hello Jean-Marc,

      by the blue-ish flare you mean that horizontal blueish flare? I was trying to simulate an anamorphic lens flare effect. It works by blurring image horizontal n times and applying a blue tint to it.

      in the cube-map screenshots there are no post-process effects. The effect is a volumetric light scattering and is all calcuated per-material. I parented a light source to each sphere and calculated a lambert shading and Scatter() thingy. And you are right, I could actually hide the real spheres (which are also used for physics) and use the pixel shader to do the work.

      Cheers

      Delete
    2. Thanks Martin for the quick response!

      About the anamorphic shader, that's what I thought. But I'm surprise by the quality of the result since mine doesn't give such widespread flares without a) taking a lot of blur passes or b) losing a lot of quality because of image tearing. Any suggestions?

      Regarding the glowing spheres, I'm still puzzled because I don't understand what geometry causes this. To me, the Phong/Lambert stuff will run on the fragment shader of each pixel lit by the source. Yet, this looks very much like a screenspace effect. But the Scattering() relies on some vertex position... It looks like I'm missing something here :)

      Delete
    3. indeed there are quite a lot of horizontal blur samples. I guess 16 or even 32 in each direction. the trick is to use 1/4th or even 1/8th of the original texture size (512px or 256px), this will make the blur look smoother and you can use less blur samples.

      the glow (or volumetric light scattering) is actually calculated exactly the same way as you calculate lighting such as lambert diffuse shading and phong specular reflection. It is just an extra function you can add after you calculate all the lighting. There is no special geometry for the glow. For it to look correct you have to run the Scatter() for every material in the scene.

      Delete
    4. Thank about the hint on the anamorphic lens flare!

      About the glow, I'm still having a hard time figuring out how that glow is even visible when the sphere is not close to any actual geometry if it doesn't have a geometry of it's own... We'll give it a try and come back with actual questions.

      Thanks for the help anyway!

      Delete
    5. no problem Jean-Marc,

      the glow is sort of projected from the view to the geometry behind the light source (either a distant wall, object, player, etc.). But there has to be geometry otherwise it will break the illusion of the glow.

      here is a screenshot where i added a hole in geometry so there is nothing to run the glow shader on.
      https://dl.dropboxusercontent.com/u/11542084/glowbreak.jpg


      yeah try it yourself, I think it should be quite easy to implement it and that way you will understand how it works.

      cheers

      Delete
  8. Hello Matirns Congratulations for you work!
    I have a little question with the Lensflare. I want the lensflare reflected only in an object not all. I change the line -> "mesh = own.meshes[0]" for -> "mesh = sun.meshes[0]" the sun is a sphere shadder but not work! how could I do? I need you help :(

    ReplyDelete
  9. Glad to chat your blog, I seem to be forward to more reliable articles and I think we all wish to thank so many good articles, blog to share with us. Feel free to visit my website; 카지노사이트링크

    ReplyDelete
  10. Well I truly enjoyed studying it. This article offered by you is very useful for proper planning.
    메이저사이트
    경마

    ReplyDelete
  11. Thank you for sharing excellent informations. Your website is very cool. I’m impressed by the details that you have on this site. It reveals how nicely you perceive this subject.
    바카라사이트
    사설토토

    ReplyDelete