[REQ] Light Refraction shader

Discussion in 'Mod Discussions' started by killerkiwijuice, May 27, 2015.

  1. killerkiwijuice

    killerkiwijuice Post Master General

    Messages:
    3,879
    Likes Received:
    3,597
    Just came accross my mind when making an effect, I would be pretty awesome if a shader could bend light like a black hole/lens!:
    [​IMG]

    @bgolus, would this be potentially hard to code into the engine, orrrrrrr :p

    PS. Gonna post a video soon of the effect I want to use it on.
    xankar likes this.
  2. crizmess

    crizmess Well-Known Member

    Messages:
    434
    Likes Received:
    317
    AKAIK extreme light bending - like the black hole effect shown in your picture - isn't possible in the setup Uber uses.
    It's only possible within really narrow use cases, like doing it only against the sky box, or when an environment cube map already exist for this view point and the distortion doesn’t magnify a lot.
    Last edited: May 27, 2015
  3. killerkiwijuice

    killerkiwijuice Post Master General

    Messages:
    3,879
    Likes Received:
    3,597
    Well, couldn't it be made artificial instead of a very complicated ray tracing simulation? A 2D effect.
  4. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    I believe doing it to the entire screen as a 2D camera lens effect would just be a matter figuring out the math. But I'm doubtful you could do a post effect based on a unit location - not that I've looked into the shaders in any detail.
  5. exterminans

    exterminans Post Master General

    Messages:
    1,881
    Likes Received:
    986
    In theory, you could. The vision radius shader for example does precisely that, it gets fed a list of all units on screen and there respective vision radius, iterates over that, and executes a fragment shader which samples every single location of the screen.

    The same way, it would be possible to add a distortion during the sampling phase of that shader.

    Unfortunately, it isn't possible to configure any other unit attribute except for vision radius as an input to that shader.
  6. dom314

    dom314 Post Master General

    Messages:
    896
    Likes Received:
    1,196
    I suppose you could still use that, but then only do the effect for specific infeasible vision radii, like -1.0 or -2.0.

Share This Page