• 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.

Change the graphics again!?

Discussion in 'Racer Physics and Technical' started by Mr Whippy, Aug 8, 2012.

  1. Well I was having a think in the bath, where all my crazy ideas happen hehe.

    Right now Racer renders the sky dome to the live env map, but the problem is the live env map is car centric and so if the car is in the sunlight we get the sun spot on the car. Then if the car is in the shade we lose the sun spot.

    Since the envmap can be used in places where the car might not be, or even places on the car that are in shadow (bumper ducts, interiors etc) then it seems bad to burn the sun spot into the envmap.

    Since the sun spot is a really simple element, a blob, it can really easily be represented with a specular splodge.

    If we do that, then suddenly we can take our mip-mapped envmap, apply it to a chrome steering wheel feature, and when it goes into shadow the brightness disappears, and when it gets into the light we can have the specular effect represent the sun!

    I was a firm believer in letting the envmap sun spot do sharp specular, and then blur it to get soft reflections. Maybe render a few live maps for different materials etc.

    But in the end without moving the entire rendering/material system to something BRDF based with lookup cube maps scattered around (like CryEngine 3), which isn't going to happen soon, this approach seems to offer more realism and ability within the constraints of the current renderer.

    Technically all we are doing is removing the sun spot from the live env-map rendering.

    This means we can then mix in specular appropriate for the material and the environment.

    Ie, we can blend a mipmapped live envmap with a specular to get a chrome that works well on a car interior, so when the chrome is in the shadow it doesn't still have a bright spot on it.

    If you take a look at games like the new one from the Netkar team, they clearly are running a HDR envmap but it looks like they are running specular overlay for the sun spot.
    This is evident even in GT5 after playing more recently and watching the specular/sun behaviour on chromes/glass etc.
    It even looks like the sun in many of these rendering engines isn't really there, just a flare is drawn where it *should* be... ie, it's not present in the envmap to start with because it's not really ever rendered.

    So I'm not sure what people think to this approach.

    My only concern is that right now we use specular WITH the envmap sun spot on some car paints to give them a metallic feel. Ideally for car paints we could do with a system where we have multiple specular definitions etc...

    I'm gonna try alter the shaders to achieve this as in theory it's all shader based I think...

    Just wondering what other people think?

    Technically it's less right, but it offers us more ability to make nice materials within the constraints and limits of the system as it stands.

    Basically the envmap gets loads more powerful for any/all materials, if we define the fresnel with it we can apply it to the specular response too (so that looks correct!), AND we get shadows impacting the sun spot/specular splodge.


  2. You now know why I spent so much time writing a metallic shader. The specular in shadow has annoyed me all along, so I set my sky to specular=0 and all is well.

    This picture shows the car in sun....

    This shows it in the shade...

    I hope these show up, it's the first time to use this picture host.

    Alex Forbin
    • Like Like x 1
  3. Yep, works perfectly there.

    So what does setting the specular to 0 for the sky do?

    I think the sun spot in the rendering can be removed (shaders somewhere), so it's relatively easy to test this when I get the time.

    Just you need something to replace the sun, like a flare or bright spot or something... not sure, just as long it doesn't show up in the envmap rendering.

    That way we can have bits of cars that are in shadow but reflecting the sun light not doing so any more (ie, the Lambo side vents which always catch the sun spot despite them being in shadow and it ruins the look)

    Generally I still think we need to have HDR envmaps to reference too, live env-mapping is costly and not really needed for lots of materials, but we are STILL limited to just that one map (I won't mention the LDR envmaps as they have proven to not be much use if you start to crank the TOD around!)


  4. Sorry, it's in the special.ini/ env.clouds=1. Anything less than 1 lets the sun show on the skydome and will give a secondary sun. This allows you to use the actual suns specular for highlights which are much more accurate.
    It seems like we should be able to use the old solar flare for looking directly at the sun, no?

    Alex Forbin

    P.S. Just tested using the old flare and it works fine. Enable racer.ini/sun.flare=1
    • Like Like x 2
  5. Thanks, I did not know this.. don't think I have used env.clouds at all?
  6. Alexander Knoll

    Alexander Knoll

    ...you have, but you don't know it :D
    look in to the gfx i changed some days agoo...you know where^^
    • Like Like x 1
  7. Alexander Knoll

    Alexander Knoll

    WoW..works verry well!
    THX Alex!

  8. I'm still confused.

    Clouds just changes the amount of clouds. The sun spot is still rendered. If you have a solid white alpha channel in your cloud map then it'll block the sun spot, but then you also block the actual sky rendering too.

    You'll also lose the orange sunset effect etc etc...

    TOD won't work half as well.

    Doesn't seem like an elegant fix, better to do it in the shader properly somehow.

    The flare looks messed up, shows up through my car interior roof hehe. Also flares are not ideal for 'eye' views imo, my real eyes don't lens flare hehe.
    Great for track cameras though, but having multiple filters available for fs_filter doesn't seem to be something Ruud is bothered about despite games like GT3 (a decade old) having a selection of filters for different cameras :(

    The current sun is fine by all accounts, it just shouldn't be rendered in the env-map pass that is all really.
    As said, it's probably a 5 min fix in shaders.


  9. It's undoubtedly a kludge, but it beats having 2 specular spots and rendering the skydome spot as specular doesn't really work for HDRI since it is just a reflection of the sun and not the sun itself.
    As far as it being a 5 min fix, it probably would be for Ruud but I haven't found it yet. :D
    I've never been a real fan of the flare anyway, but it gives you a sun. You can edit its look to get rid of the lens reflections as well if you wish.

    Alex Forbin
  10. I don't really know how the sun works, I had the impression it was part of the mie/rayleigh sky calculations, rather than something that could be skipped in the envmap pass, though. Cause for example if you set the atmosphere appropriate to the moon, you get a single pixel sun due to complete lack of haze, refraction etc.

    As long as you use a live envmap, the sun gets obscured reasonably well just by virtue of being blocked out, it's just not perfect since the envmap comes from a single point.
  11. Indeed, it seems to be a part of the atmosphere.cg shader.
    Changing line #251 to be the following removes the sun "blob"
    However the zbuffer method for checking whether or not to render the lens flare (no longer?) work, so it's either always on or always off.

    Playing with this though, I'm getting some weird behaviour from the specular term on the murcielago. If I crank up the specular level it brightens the whole surface. I'm not sure exactly how to describe it.
  12. I usually use the following settings for a white solid color paint job...

    ambient=.2 .2 .2
    diffuse=.5 .5 .5
    specular=3 3 3 (gives a nice bright specular spot)
    shininess=6000 (tightens the specular spot so it's not a splotch)

    Keep in mind I've changed several things in the shaders and lighting.

    Here's an example...

    Here's another showing a metallic Rubio Rossa at Fiorano, Racers motion blur is looking pretty good now...

    Alex Forbin
  13. Cam, the specular intensifying the whole surface is the implement of ambient specular Ruud did, which isn't ideal.

    Check lighting.cg to swap back to the old one!

    // Ambient only
    // Ambient with specular ambience
    Ambient specular is a good thing, BUT, this implement is really not a good idea for lots of reasons.

    It works well on surfaces approaching lambert like tarmac/grass etc, but as soon as you get slightly glossy materials just glow (not good on car interiors :D )

    Alex, your values and images look good. I'm not sure about white being diffuse 0.5, real white in gamma space should be about 0.88 - 0.9 ish...

    The ambient is also not ideal.

    I know we discussed this before and your logic for using a lower ambient makes a lot of sense as materials get shinier then the ambient drops and we get sharper specular and less lambertian response.
    However, for most car paints we need layers, so the fresnel in the envmap takes care of the glossy properties and then the 'old' diffuse/ambient can be set to pure lambertian (ie equalised values or very close, possibly set with an appropriate specular setting)

    The way I see it is, set up the paint like we spray in real life.

    Base coat is laid down and is near matte, or slightly shiny (can do that with amb/diff/spec now), then we put lacquer over it which is the envmap + fresnel bit...

    The problem comes when we want to do metallic which you have done a different way which is possibly why you get those settings working nicely :)

    The HDRI spot works ok but a specular spot for the sun makes more sense (I think)... because right now the two suns (the one that powers 'specular' and the one in the envmap) are not of an equal starting power.

    Park two black cars next to each other, one running a shader with envmap for the sun spot.
    Park another car next to it without the envmap but with specular 1 1 1 and shininess 200 say...

    Now colour pick in kLux in Racer and the two spots are totally different values.

    It's just not ideal to have the two systems working together but being so wildly different. It makes good tuning across different TOD's and stuff really hard in my view.

    I believe that is why sims like GT5 and the new NetKar developers one use what appears to be a specular sunspot not envmap sunspot!

    Forza 4 probably even uses specular sunspot with it's IBL.

    Then there are other benefits we get having the sun appearance in ALL materials even envmapped ones in the deferred rendering, so areas in shadow will NEVER get a sun-spot shine in them, which suddenly makes interiors or shaded sides of cars look a lot more realistic without the odd face picking up the sun reflection despite it being in full shade!

    Hmmm, just all thoughts out loud :D

  14. I agree that we should not use the envmap sun for specular since it is simply a reflection of the light and not the light itself. That's why I use the actual sun for specular calculations in the metallic shader. The shader uses the bodycolor as the basecoat, then the metallic is applied as a noise map over that, then the clearcoat is what gives the nice specular. Just like real life. It's not really possible to do that with the envmap sun, from what I've found.

    As far as light levels go it's been very hard to get levels that match real life since there are a lot of adjustments throughout the render chain.

    The last thing that's driving me crazy is the persistent slight specular on objects in shadow, I haven't isolated it yet but I haven't given up either. (this is without ambient specular BTW)

    Alex Forbin
  15. Technically metallic is like a specular on the base coat, because the base coat has a sprinkling of shiny bits on it basically.
    Up close it'd need a control map for each flake, but as you get a few metres away (most purposes for real time use) it just looks like the base coat has a fairly strong specular of it's own.
    I like the effect of the shader you have given but it seems really costly to have a control map/new layer for what in essence soon becomes a specular splodge only (ie, should be really fast)

    All we really need to be able to do is define two speculars, one for the base coat, and then the one needed for the sun spot.

    Right now with the envmap sun spot we are technically more accurate (it's like lighting with a HDRi image)... BUT, we lose flexibility because our renderer doesn't raytrace etc, so we get the sun spot turning up where it's not wanted unlike the nicely calculated specular term :D

    I'm just playing with shaders, I'm sure lots of the default library are a bit buggy, the scale_detail_bump one especially seems like the bumps are not working right :D

    Probably some work to do in there generally any way, but it'd be nice to look at better shaders for car paints imo.
    Ie, something approaching BRDF, but like the old fresnel system. So define an rgba texture that has colour ramping vs angle, then in theory we can tint that in ambient using the ambient/diffuse entries in a car.shd...
    So we could have a red/purple shift with angle, and then push that red/purple shift to more blue/blue purple shift by adjusting ambient= 0.8 0.8 1 or something...

    Cheapy BRDF but it'd make car paints really pop much more.

    Then with a second specular splodge we could easily get a really realistic looking car paint with real depth, that in theory should be pretty fast (no slower than the current ones), and easy to author.

    I agree up close the metallic flakes look nice but in theory that shader isn't ideal for realtime use, it'd be better to have a custom shader for that where we can define flake size/spacing and map it to the object xyz rather than a texture/surface shader...