Glass/Water Refractive Shader in Unity using Shader Graph (Camera Texture Method)

Поділитися
Вставка
  • Опубліковано 2 жов 2024

КОМЕНТАРІ • 83

  • @noobcoodoocoo
    @noobcoodoocoo 2 роки тому +1

    useful tutorial, very cool, used it for a camera warp effect

  • @JonathanGilmer
    @JonathanGilmer 2 роки тому +10

    If it's not working for you, make sure you have opaque texture set to on in the camera settings! Also, you'll need to set the IOR value to anything other than 0 to see a difference.

    • @JonathanGilmer
      @JonathanGilmer 2 роки тому

      @@WolffRahm_ Awesome, I'm glad I was able to help out!!

    • @kristianthaler6525
      @kristianthaler6525 Рік тому +1

      Got stuck for a few minutes and almost gave up, got it working thanks to this comment. Thank you.

    • @JonathanGilmer
      @JonathanGilmer Рік тому

      @@kristianthaler6525 awesome!! I'm glad I was able to help!

    • @JonathanGilmer
      @JonathanGilmer Рік тому

      Lol apparently I had the same reply for someone else, too. 😅

  • @hyunwookim8029
    @hyunwookim8029 4 роки тому +2

    Thank you for the awesome tutorial!

  • @vaepuer2290
    @vaepuer2290 3 роки тому +4

    Interesting tutorial, I've tried this in 2020 with URP and does it still get plugged into Emission? Because all that happens is the object goes bright white.

    • @RickusDomesticus
      @RickusDomesticus 3 роки тому

      I tried this on 2021 urp, and didn't work on Emission,, but still this is a great tutorial

  • @nanami-dl7eh
    @nanami-dl7eh 4 роки тому +1

    I look trough this material everything is ok,, except some Transparent materail , I't mean i can't see the Glass ball by another glass ball.

  • @mfedorov
    @mfedorov 4 роки тому +2

    did't work at unity 2019.4.9f1 with URP, make just a white transparent sphere =(

    • @rafwins2000
      @rafwins2000 3 роки тому +1

      Look at the first solution here
      answers.unity.com/questions/1692270/scene-color-node-not-working-in-shader-graph.html

    • @JonathanGilmer
      @JonathanGilmer 2 роки тому

      @@rafwins2000 That worked for me. Thanks!!!

  • @macksnotcool
    @macksnotcool Рік тому +1

    Thanks! I even figured out how to use this with a normal map to distort the glass even more in a realistic way!

  • @HunterD006
    @HunterD006 2 роки тому +1

    Any way to fill it with color?

  • @dertobbe1176
    @dertobbe1176 5 місяців тому

    Doesnt work for me 😕

  • @zig8925
    @zig8925 3 роки тому +1

    This is great, but I found a few problems. I'm using this for windows with a wavy normal map. But since it's using the screen space render texture, then you can see objects that are in front of your glass through the glass. It could be pretty cool, but not what I'm looking for. This gets even worse when you introduce a normal map, cause then things from the far left or right side of the screen get mixed into the refraction. I'm going to try and use a stencil cut out to fix this

    • @AETutsVids
      @AETutsVids  3 роки тому +1

      yes true, it might be possible to use the depth texture to check if an object is in front then don't do any refraction

    • @zig8925
      @zig8925 3 роки тому +1

      @@AETutsVids Yeah I saw some videos using that method, but it makes visibility through the glass bad. And it has some side effects

  • @adajiang3801
    @adajiang3801 4 роки тому +2

    Hey I followed your tutorial, my glass texture is showing up in my editor and game mode but not in my Oculus Quest, it just shows up as grey transparent sphere. Do you happen to know the problem ?

    • @AETutsVids
      @AETutsVids  4 роки тому +1

      Not exactly sure, thou usually in VR there are two cameras for each eye, so this might be why

    • @thomasrafty4375
      @thomasrafty4375 4 роки тому

      Heywassup

    • @TinyTiniaMan
      @TinyTiniaMan 3 роки тому

      As there been any fix found for this ? I have the exact same problem with Oculus Quest and Unity 2019.4.14f1 (pain in the ass to debug as it only occurs when using the headset)

  • @andresca1985
    @andresca1985 2 роки тому

    i did in unity version 2021 and no works, some help?

  • @ConkerKing
    @ConkerKing 4 роки тому

    I tried this, but for some reason the refraction (IOR = positive number) rotates clockwise as i zoom out... (anti clockwise IOR =negative number) ? Any thoughts ? ta :)

  • @ssojyeti2
    @ssojyeti2 4 роки тому +1

    How do you prevent objects in front of the shader-textured object from showing up in its refraction? I only want objects behind the object to get refracted. Is this possible with this technique? Or is it possible to set certain layers to not show up in the refraction? That would also work for me...

    • @AETutsVids
      @AETutsVids  4 роки тому

      Good question, as far as I know as long as the object is being rendered before rendering the transparent objects, then it will show up in the Color Texture node (which means in the refraction), so I am not sure if there is a way to dynamically show and hide objects based on if they are in front or at the back of the refractive object, however you can make objects not show either way by playing with their render queue, which might not look right unless you make them transparent (by that I only mean in the drop down, they can still have alpha=1)

  • @SirRelith
    @SirRelith 4 роки тому +1

    Doesn't work for me.
    It renders a cube as light gray. I change the pbr master node Surface to Transparent. If I change the blend from Alpha to Additive I get a half transparent white color.

    • @AETutsVids
      @AETutsVids  4 роки тому +1

      Did you enable opaque texture from the LWRP settings?

  • @arsizhifenerprozhod
    @arsizhifenerprozhod 2 роки тому

    i can't believe i went from unity 2018 to 2019 so that hardly any glass shader works for me or they are techniques who uses reflection probes

  • @impheris
    @impheris 3 роки тому

    i'm trying this shader again and my scene is shaking like crazy, why is that? any fix?

  • @AustinPinheiro_uniquetexthere
    @AustinPinheiro_uniquetexthere 3 роки тому

    idk how i messed up at the first step but my scene color to albedo aint working like yours and other peoples. and i checked a lot of settings to see if they were similar so idk

  • @stefanleo6575
    @stefanleo6575 4 роки тому +1

    Its giving me an error in the code for the custom function on the word: refract()

    • @RivenbladeS
      @RivenbladeS 4 роки тому

      me too

    • @RivenbladeS
      @RivenbladeS 4 роки тому +1

      Fixed it. Create a shader->PBR Graph->open the graph->in the PBR Master select the settings icon->set Surface to Transparent like in the video at 1:29

  • @david3atista
    @david3atista 2 роки тому

    mine is pink brah

  • @RivenbladeS
    @RivenbladeS 4 роки тому +1

    For the ones that have the error "undeclared identifier refract" for unity 2019.3
    Create a shader->PBR Graph->open the graph->in the PBR Master select the settings icon->set Surface to Transparent like in the video at 1:29

    • @mfedorov
      @mfedorov 4 роки тому

      just clear console, its temporary error

    • @aaronspencermusic
      @aaronspencermusic 3 роки тому

      Also they're normal brackets ( ) not curly { } i made that mistake , maybe someone else did toooo

  • @albertcallejoamat7837
    @albertcallejoamat7837 2 роки тому

    ... What about URP?

  • @ulu9311
    @ulu9311 2 роки тому

    What type of shad are you creating?

  • @megumin4625
    @megumin4625 4 роки тому +1

    I adapted this into Amplify Shader Editor :)

    • @andresca1985
      @andresca1985 2 роки тому

      how you did? show me all nodes, please

  • @devashishpacholiya6794
    @devashishpacholiya6794 2 роки тому

    Can I use it in 2d

  • @dylanisaac1017
    @dylanisaac1017 4 роки тому

    OMG THE CUSTOM FUNCTION DIDN'T GIVE ME THAT BUG, AYYYYYY

  • @PascalAchermann
    @PascalAchermann 4 роки тому

    Awesome thank you!

  • @playedugame
    @playedugame 4 роки тому

    Nice

  • @gametwistdeveloper6610
    @gametwistdeveloper6610 3 роки тому

    Is there a way to make this material not cast shadows?

    • @AETutsVids
      @AETutsVids  3 роки тому

      Casting shadows can be turned off from mesh renderer component

    • @gametwistdeveloper6610
      @gametwistdeveloper6610 3 роки тому +1

      ​@@AETutsVids​I'd need to do this on the shader side since I have a big combined mesh (think window frame with glass). It seems to be really easy with most shaders, but for some reason shader graph seems to be lacking this function. But thank you!

  • @Krafter37
    @Krafter37 4 роки тому

    I followed your tutorial and I can't get it to work. I have a very weird result on one side and other side of the cube is just white :/

    • @AETutsVids
      @AETutsVids  4 роки тому

      Make sure the master node is set to transparent

    • @Krafter37
      @Krafter37 4 роки тому

      @@AETutsVids yeah I did. Np just gonna use a transparent material

    • @AETutsVids
      @AETutsVids  4 роки тому +1

      Also make sure the quality settings you have opaque texture enabled, otherwise I donno what is wrong, have a nice one

  • @sivang86
    @sivang86 4 роки тому

    How do you add the settings to the project?

    • @AETutsVids
      @AETutsVids  4 роки тому

      if you open Edit > Project Settings and click on the Quality tab

  • @jackblack2567
    @jackblack2567 4 роки тому

    did same not working

  • @zacksnyder5861
    @zacksnyder5861 4 роки тому +4

    I had an issue with the Custom function, so here is what it should be: Out = refract(View, Normal, IOR);

    • @oxovira8408
      @oxovira8408 4 роки тому +1

      Your function is a same of the video, but I could be wrong.

    • @zacksnyder5861
      @zacksnyder5861 4 роки тому +2

      Alban TIPREZ I just found the function to be hard to read at the videos resolution. I decided to put it here so it could be copied

    • @oxovira8408
      @oxovira8408 4 роки тому +1

      ​@@zacksnyder5861 AAH Sorry, I had a problem with my shader, so I misunderstood your comment.

  • @李尊-l9f
    @李尊-l9f 4 роки тому +1

    Thank you very much! I'm creating a AR Project.Your last tutorial about using probe is not perfectly suitable,but this is!

    • @AETutsVids
      @AETutsVids  4 роки тому

      Yes, this method is also much better for all types of water objects

  • @yori4434
    @yori4434 4 роки тому

    Works wierd in 2019.3

    • @AETutsVids
      @AETutsVids  4 роки тому +1

      Define wierd

    • @AETutsVids
      @AETutsVids  4 роки тому

      I am not even able to open a URP project in 2019.3

    • @yori4434
      @yori4434 4 роки тому

      @@AETutsVids ua-cam.com/video/t5fUDhuqsnQ/v-deo.html
      IOR is "changing" depending on camera distance
      Wierd distortion (on top of cube for example)

      As for the latter, I'm not sure, maybe it should be so :D

    • @AETutsVids
      @AETutsVids  4 роки тому

      @@yori4434 sorry I missed your comment, make sure to normalize the view direction node

    • @yori4434
      @yori4434 4 роки тому

      @@AETutsVids But it is normalized :D

  • @StavrosDidakis
    @StavrosDidakis 4 роки тому +1

    I got your materials from the asset store, but I can't find this glass shader example. Also, I have tried to build the same shader you have have but mine looks completely different (terrible quality). Pretty sure I have all settings mentioned here. Any help is appreciated

    • @AETutsVids
      @AETutsVids  4 роки тому

      Hey lets talk in emails or on Facebook, anasainea@gmail.com

    • @zig8925
      @zig8925 3 роки тому

      He has a second video, where he does the same kind of effect with reflection probes, instead of the render texture. He explains some more things there, since he made that vid first