SHADER window/glass material

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

  1. luchian

    luchian Administrator Staff Member Pilot RLR

    Joined:
    Jun 3, 2014
    Messages:
    2,899
    Likes Received:
    1,391
    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. MGMetroDave

    MGMetroDave Active Member

    Joined:
    Apr 7, 2019
    Messages:
    141
    Likes Received:
    155
    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 Pilot RLR

    Joined:
    Jun 3, 2014
    Messages:
    2,899
    Likes Received:
    1,391
    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. MGMetroDave

    MGMetroDave Active Member

    Joined:
    Apr 7, 2019
    Messages:
    141
    Likes Received:
    155
    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 Moderator

    Joined:
    Jul 26, 2017
    Messages:
    576
    Likes Received:
    402
    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
     
    EKO Sim-Racing, Prototype and luchian like this.
  6. MGMetroDave

    MGMetroDave Active Member

    Joined:
    Apr 7, 2019
    Messages:
    141
    Likes Received:
    155
    Thank you, Johnr777. I will try this. Really appreciate your help.
     
  7. Kornepheros

    Kornepheros New Member

    Joined:
    Dec 12, 2018
    Messages:
    3
    Likes Received:
    0
    I've been working on a track that has a stream running nearby. I've created a rocky-textured creek bottom with a plane of "glass" plane sitting 10 cm above it. I used a custom DDS image that has a wave pattern to try to give some texture to the water surface. I then used the ksPerPixelReflection shader with the settings used by Johnr777 and it looks really great in the ksEditor... but in the game (using Content Manager) it's opaque purple! (Actually, the water looks good when looking through it at the car tires, but is opaque when looking through it to the stream bed. Also, I adjusted the ambient and diffuse settings to show the water texture better, but the results were the same when I tested with these set to zero.) Reading through this entire discussion, there are a couple of things that were not clear to me that may be the culprit:

    1. luchian mentioned the need to apply the ksPerPixelAT shader first... but I'm not sure what this means... Do I simply set the object's shader to ksPerPixelAT (do the settings matter?), then switch to ksPerPixelReflection? Or is there some way to apply two shaders at the same time that I haven't figured out yet? What does this need to look like in the .fbx.ini file?

    2. MGMetraDave thanked luchian for the tip on switching to alphatest shader first... is this referring to the ksPerPixelAT shader? eAlphatest is a blend mode within a shader, not a shader itself, and I don't recall luchian saying anything about using eAlphaTest in this discussion instead of eAlphaBlend...

    3. luchian also mentioned the need to use an argb 8.8.8.8 texture... Might this different from other DDS images that I have used successfully on my track? I am no expert on DDS files or how GIMP saves them, but my 2048x2048 image saved uncompressed is 16 MB in size, which is exactly what I would expect... Might my ignorance about this file format be the problem? Here is what my image looks like, texture on the left, alpha channel on the right:

    AnimatedStreamTexture.jpg

    After trying to get the ksPerPixelReflection shader to work, I later found and installed the stFlow shader. Now my water is animated and looks amazing in ksEditor:

    AnimatedStream.jpg
    But the animated water is still purple in the game! It looks like some sort of toxic sludge instead of water:

    AnimatedStream2.jpg

    Oddly, I've discovered that playing using my Oculus Rift results in the purple color... if I play on a monitor it looks opaque grey:

    AnimatedStream3.jpg

    Does anyone have an idea what I am doing wrong?
     
  8. garyjpaterson

    garyjpaterson Member

    Joined:
    Jun 28, 2017
    Messages:
    94
    Likes Received:
    97
    Probably something to do with the fact you are not using a normal map in the normal map slots:
    upload_2019-12-28_11-26-36.png

    I'd use a flat normal map (something like 128 red, 128 green, 255 blue) in those slots to see what happens, though obviously to get the best effect you will want to make an actual normal map.
     
  9. quetillo

    quetillo Member

    Joined:
    Mar 20, 2020
    Messages:
    53
    Likes Received:
    4
    Location:
    España
    What kseditor do you use for the water, I put the stFlow and it does not start in the kseditor V6, thanks
     
  10. Johnr777

    Johnr777 Moderator

    Joined:
    Jul 26, 2017
    Messages:
    576
    Likes Received:
    402
    The kseditor from the SDK.

    Where did you put the stflow shader?
     
    quetillo likes this.
  11. quetillo

    quetillo Member

    Joined:
    Mar 20, 2020
    Messages:
    53
    Likes Received:
    4
    Location:
    España
    Thanks for answering, I have the kseditor that comes inside the assetto game and I downloaded the new kseditorV6, but it won't let me open it, it only works with the kseditor that comes in assetto.
     
  12. Johnr777

    Johnr777 Moderator

    Joined:
    Jul 26, 2017
    Messages:
    576
    Likes Received:
    402
    The modded editor is outdated. You should use the one in the SDK
     
  13. quetillo

    quetillo Member

    Joined:
    Mar 20, 2020
    Messages:
    53
    Likes Received:
    4
    Location:
    España
    If I have it in the original sdk, the one that comes in the game, there is if it works for me, but in the sdk page the new one does not work, thanks I will continue with this
     
  14. fughettaboutit

    fughettaboutit aka leBluem

    Joined:
    Jul 21, 2014
    Messages:
    400
    Likes Received:
    155
    if you want to use stFlow shader in SDK editor you have to copy it in its folder too, its like an AC-install on its own, it does NOT know about stuff you installed to the AC folder itself, i think this is described on stFlow download page too on RD
    upload_2021-1-21_23-49-0.png
     
  15. fughettaboutit

    fughettaboutit aka leBluem

    Joined:
    Jul 21, 2014
    Messages:
    400
    Likes Received:
    155
    Ooh sorry, stFlow install has its own SDK folder, so forget what i wrote above, it should work just like this.

    But dont just unpack, open archive, go into "stFlow" folder, and put both folders from image below into ac-folder. This does not apply when you install per MOD folder with jsgme and have unpacked the archive "stFlow_1.0.7z" into MOD folder.

    If you moved your editor folder somewhere else, this might be a reason too.

    upload_2021-1-21_23-55-43.png
     
    Last edited: Jan 22, 2021
    quetillo likes this.
  16. fughettaboutit

    fughettaboutit aka leBluem

    Joined:
    Jul 21, 2014
    Messages:
    400
    Likes Received:
    155
    and yes, unfortunately kseditorV6 does not work with stFlow shader, i did encounter that too
     
    quetillo likes this.
  17. quetillo

    quetillo Member

    Joined:
    Mar 20, 2020
    Messages:
    53
    Likes Received:
    4
    Location:
    España
    Thanks, it's already solved, I have to use the stream's ksd
     
  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