SHADER window/glass material

Discussion in 'Tracks' started by luchian, Oct 23, 2014.

  1. luchian

    luchian Administrator Staff Member

    Joined:
    Jun 3, 2014
    Messages:
    2,402
    Likes Received:
    1,005
    AC member TTM (< thank you) found a way to do some decent looking window/glass material, should you need one for your tracks. Here is his method:

    "Step1:
    Window texture alpha channel controls window transparency. Texture must be saved 8.8.8.8 argb 32 bpp - unsigned

    Step2: ksEditor
    Select window object and apply ksPerPixelAT material and then apply ksPerPixelReflection material. :) ..Without applying ..PixelAT material first window is not transparent.

    Step3:
    Material settings. ksSpecularEXP value controls reflection sharpness. (There is no need 0,5 to KsAlphaRef, i left value accidentally..) isAdditeve needs to be 1. FresnelMaxLevel is window's brightness, maybe not right word describe, but change value and you see. :)

    btw, there is also ksPerPixelSimpleRefl material with same values to material window only relfects blue color."


    window_1.jpg
    window_2.jpg
     
    Willy Wale, MacArnu and ihlades like this.
  2. Dave Bulow-Osborne

    Dave Bulow-Osborne New Member

    Joined:
    Apr 7, 2019
    Messages:
    3
    Likes Received:
    1
    Hi Luchian,

    Firstly, thanks for taking the time to make these instructions. I've already used them several times and it generally works great! The tip about switching to alphatest shader first for transparency worked perfectly. Thanks.

    I did have 1 little question about the level of transparency, though.

    Basically I'm trying to create heavily black tinted glass for a trackside building, which in daylight is heavily tinted and looks almost opaque, but at night is lit up from the inside. It's based on a real life building where this happens.

    I've tested and tested, but can't quite get it to appear correctly. It may just be a glitch my end, but I've noticed that while the alpha channel of the image definitely does control transparency, it seems to only allow 3 options: fully opaque, 50% transparent, or 100% transparent. It seems to 'snap' to one of these settings depending on which is the closest option to the actual alpha channel transparency. Hope that makes sense.

    e.g. if I set the alpha channel to something near 50% grey, the window will be 50% transparent, but if I try to increase the opacity closer to about 80% (a lighter grey on the alpha), it appears fully opaque, since this was the closest option.

    The only reason I can think why it's doing this is because the shader might be using 'alpha test' mode rather than 'alpha blend' mode.

    In the material properties in ksEditor there's the option to change it to alpha blend, which then gives the impression of working perfectly when viewed in ksEditor, but in game it still appears fully opaque if the alpha channel colour is too light.

    Just wondering if you (or anyone else here) has any suggestions on this from your experience? Sorry for the long post! Thanks!
     
    luchian likes this.
  3. luchian

    luchian Administrator Staff Member

    Joined:
    Jun 3, 2014
    Messages:
    2,402
    Likes Received:
    1,005
    First of all this is the perfect way of asking for help. You have clearly explained what the issue it, so kudos on that.

    Unfortunately, I did not experiment more than this with the shader, so I'm afraid I cannot contribute. Hopefully, some of the "elders" know something more (..or at the least, know if this is the limit).
     
  4. Dave Bulow-Osborne

    Dave Bulow-Osborne New Member

    Joined:
    Apr 7, 2019
    Messages:
    3
    Likes Received:
    1
    Thank you Luchian for your super quick reply. Really appreciate your reply even if on this occasion you couldn't help. Hopefully someone else can chime in :)
     
  5. Johnr777

    Johnr777 Active Member

    Joined:
    Jul 26, 2017
    Messages:
    293
    Likes Received:
    206
    Hopefully I can help...

    Nowadays with CSP and SOL, the game is looking great, with new features and what not... but ksEditor is still the same old one, made to resemble things before CSP. So often you are going to get different results in both scenarios.

    Best is to pay attention to what the game outputs, and not the editor.

    Here is what I've been using for window settings. have a look at ambient and diffuse settings, all zeros.

    windowsAC.jpg

    The texture itself:

    RoadAM_building_windows.jpg
     
    Nericksenna, Prototype and luchian like this.
  6. Dave Bulow-Osborne

    Dave Bulow-Osborne New Member

    Joined:
    Apr 7, 2019
    Messages:
    3
    Likes Received:
    1
    Thank you, Johnr777. I will try this. Really appreciate your help.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice