How do I convert light into an alpha value in Strumpy?

Discussion in 'ShaderLab' started by TomBrien, Apr 29, 2012.

  1. TomBrien

    TomBrien

    New Member

    Joined:
    Apr 28, 2012
    Messages:
    79
    Hey! I'm completely new to manipulating shaders.
    I've used 3DSMax for a long time, so I have a knowledge of how diffuse and bumps maps work, and what Fresnel and Self-illumination is and so on, but I'm not GREAT at it.

    Anyway- How can I get an Emission map to have an alpha based on how much light is hitting an object? Here's me in 3DStudio:
    [​IMG]
    (I'm finding out this software deserves a lot of credit for how easy to use it is)

    And here's me in the Strumpy Shader Editor:
    [​IMG]
    (Strumpy is also fairly intuitive, considering I've not had to learn any coding)

    I think it's using the Luminance Constant, but I don't know how to covert that into a 0 to 1 value.
    ...And then I THINK I can bend the gradient from light to dark using Clamp- but hey one step at a time right.
  2. Jesus

    Jesus

    Member

    Joined:
    Jul 12, 2010
    Messages:
    60
    In the strumpy examples you should find one called 'Ramp Lighting' or similar.

    This grabs the luminosity at a pixel, and maps it to the U channel of the Ramp Texture.


    Take some time to understand the buts of that shader, how and why everything works, and it shouldn't be hard to rebuild a similar one that uses luminosity to affect the Alpha channel.
  3. TomBrien

    TomBrien

    New Member

    Joined:
    Apr 28, 2012
    Messages:
    79
    Thanks Jesus, I figured out what ramp shaders were by downloading a Skin Shader and deconstructring it (also found out more about rim lighting).

    I couldn't figure out how to do it in Strumpy, but LUCKILY I found an old thread where someone literally pasted a graph.

    It's still not great though: because the colour is a mix of the diffuse map and the light ramp, it always comes out as really desaturated on either the red or the blue:


    I can't really even tell if the ramp is recognising the RGB of the colours, or just measuring how bright they are.

    Here's what I had in 3DS, applied to the Self-Illuminating (Emission) map:
    [​IMG]

    But I can't apply any light-based nodes to Emission here.
    Last edited: May 3, 2012
  4. TomBrien

    TomBrien

    New Member

    Joined:
    Apr 28, 2012
    Messages:
    79
    Alright well... I got the shadows to go from being white-to-black to being a warm hue to a cool hue (red to blue in this case)
    [​IMG]

    Which was really the MAIN THING I wanted... I guess this is the closest I'm gonna get. I tried applying a ramp texture to the lighting, but the light seems to cut off at like 80% darkness. I don't know what's up with it:

    [​IMG]

    No matter what kind of ramp texture I put in, it always switches to pure red where it should be dark blue. It even does it with the Strumpy example. Someone else had this problem but I don't get how he fixed it.

    WELL whatever, I'll just do it without the toon shader step-down.
    Last edited: Apr 30, 2012