• 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.
Discuss and enjoy the 2017 Formula One Australian Grand Prix (Live Blog) Click here.

Alpha map emission shader

Discussion in 'Racer Physics and Technical' started by Stereo, Aug 27, 2010.

  1. I've been working on the RX-7 to get it up to the recent versions, one of the things I've been fiddling with is interior lighting. The majority of this stuff (eg. the gauges) is texture mapped, and only certain elements should have emissions - if it's more general it looks like it's got a small lamp on it, rather than the icons actually glowing. With the Kilolux levels and real shadowing it's a lot darker in the cockpit so the instrument panel is really needing this kind of thing.

    So, to arrange this, I copied standard_f.cg to standard_glow_f.cg, with one minor change:
    baseCol*(ambient + Ke)
    This is in the ambient lighting line -
    Changed to
    baseCol*(ambient + Ke*baseCol.a)
    In combination with a shader specifying emission amounts, this means that a 1.0 on the alpha channel will emit, while a 0.0 is completely lit by normal ambient light. After that it's just a matter of fixing up the interior maps with appropriate emissions.

    I guess my question is whether this functionality is duplicated in another shader, or if this would be a useful addition to the set of shaders.
  2. That sounds like a good move. Most people currently use an alpha map to outline their emission materials.

    I think the most important part will be how the alpha is used. The nice smooth 'blend' blendfunc is preferable to the bitty looking alpha_to_coverage variety of transparrency.

    I guess then we can do some really nice dashboard illuminations with the areas around the dials picking up some of the light too (less alpha on the transparrency map_, which at dusk might not be visible but as it gets darker would become more obvious. Ah the joys of a large dynamic range :D
  3. That's something I was thinking about as well, burning static lighting into a texture and setting it as emissive. If it's handled as emissive by Racer then it won't show up in bright light, only the appropriate low light levels.

    The shader I'm using above is more for 'backlit' stuff - the colour's already there and it just needs some fixed emission level. To stick a real dashboard light in and burn its lighting into the texture might want its own color channel.

    Putting it into the actual material instead of as an overlay means less messing with transparency, just mix it inside the shader and you get exactly the result you want instead of the least-bad blendfunc.
  4. Yep, works well.

    Need to adjust the map now is all.

    You made a mistake though, it should be
    baseCol*(ambient + Ke*baseCol.a)
    to work with the rest of the shader.
  5. Sorry, wrote it from memory.

    Still needs the 3d gauge elements to look right but it's better.
  6. Haha, yeah, I've done that a few times - written something from memory only to have it fail :D

    Looking really good :D
    As you said, just need to be able to define shaders for needles and stuff.

    Can I suggest we change the line to incorporate the "night" variable? In daylight it's a little too overexposed.

    float3 ambientColor=baseCol*(ambient + Ke * baseCol.a*night);
    IMO that exposes better during the day, having the emission there + the sun diffuse makes it a little too bright IMHO.
    My emission is currently set to 3.