Hello, everyone! Let’s again create a spatial shader for a 3D object. This tutorial is special because for the first time I will touch on a function that I have completely ignored so far. It is the function called light, and I will show how we can work with it.

  • insomniac_lemon@lemmy.cafe
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    41 minutes ago

    Youtube encoding doesn’t help, but I’m not sure about the “fire” effect here.

    It reminds me of when I turned Minecraft’s end skybox into a purple-ish Moiré pattern (no shader needed, just a checkerboard texture viewed at a distance+angle).



    Back to Godot, I made a toon-like light shader with the step function being the important bit*. It is probably good enough to use, though it’s a bit frustrating how I can’t seem to keep input colors accurate.

    I think that’s half something I don’t know enough to fix, and half an issue of how LIGHT / LIGHT_COLOR is pre-mixed. For instance, a larger issue is that ambient light mixes with an object’s differing hue here even though I expect/want 100% ambient due to the pure-black shadow. It mixes in the unshadowed part too, Godot seems to already lower the mix by light intensity but I’d also like to mix by saturation (white object gets most ambient mix) and/or perhaps with similar hues (dot product?).

    EDIT: Looking at it again, it might be that Godot is already doing this with hues, red ambient on a blue object giving significantly less influence than it does to a yellow object and there’s no hint of hue mixing. Although a purple shadow would be interesting.

    Using HSV is probably needed here, although to me it seems like an absolute mess without it being built-in.

    * unshaded+1 shadow w/ambient with diffuse = , 5(?) shades with diffuse += but it’s also too bright