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

  Рет қаралды 55,839

AE Tuts

AE Tuts

Күн бұрын

Watch this tut for a better result • Screen Space Refractio...
This is a tutorial on creating a refractive shader by using the color scene node which gets the camera texture, this method is good for things like rivers because you don't need to put lots of reflection probes for it to work.
This material is part of the URP Material Pack Vol 2:
bit.ly/lwrp-ma...
Checkout my assets for more Tuts!
------------------------------------------------------------------------------------------
Popular Links
URP Material Pack Vol 1: bit.ly/lwrp-ma...
URP Material Pack Vol 2: bit.ly/lwrp-ma...
URP Material Pack Vol 3: bit.ly/lwrp-ma...
URP Material Pack Vol 4: bit.ly/lwrp-ma...
URP Floating Islands package: bit.ly/lwrp-fl...
Vector Field Maker Lite: bit.ly/vector-...
Vector Field Maker Pro: bit.ly/vector-...
Forest Pack 9 Types: bit.ly/forest-p...
------------------------------------------------------------------------------------------
Free Stuff
URP Volumetric Fog: aetuts.itch.io...
URP Outline Effect: aetuts.itch.io...
Procedural Spaceships, rock, snow and more via Blendity:
aetuts.itch.io...
------------------------------------------------------------------------------------------
Games and Demos
Bouncy Ball Demo: aetuts.itch.io...
Tear Pewdiepie in VR !: aetuts.itch.io...
Jello Tetris VR: aetuts.itch.io...
------------------------------------------------------------------------------------------
▶️ Subscribe ! bit.ly/AETutsSub
🐦 Follow me on : / ae_tuts
------------------------------------------------------------------------------------------

Пікірлер: 83
@JonathanGilmer
@JonathanGilmer 2 жыл бұрын
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 Жыл бұрын
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. 😅
@macksnotcool
@macksnotcool Жыл бұрын
Thanks! I even figured out how to use this with a normal map to distort the glass even more in a realistic way!
@noobcoodoocoo
@noobcoodoocoo 2 жыл бұрын
useful tutorial, very cool, used it for a camera warp effect
@vaepuer2290
@vaepuer2290 3 жыл бұрын
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
@hyunwookim8029
@hyunwookim8029 4 жыл бұрын
Thank you for the awesome tutorial!
@AETutsVids
@AETutsVids 4 жыл бұрын
You're very welcome!
@RivenbladeS
@RivenbladeS 4 жыл бұрын
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
@nanami-dl7eh
@nanami-dl7eh 4 жыл бұрын
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.
@impheris
@impheris 3 жыл бұрын
i'm trying this shader again and my scene is shaking like crazy, why is that? any fix?
@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 :)
@andresca1985
@andresca1985 2 жыл бұрын
i did in unity version 2021 and no works, some help?
@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
@SirRelith
@SirRelith 4 жыл бұрын
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 жыл бұрын
Did you enable opaque texture from the LWRP settings?
@HunterD006
@HunterD006 2 жыл бұрын
Any way to fill it with color?
@mfedorov
@mfedorov 4 жыл бұрын
did't work at unity 2019.4.9f1 with URP, make just a white transparent sphere =(
@rafwins2000
@rafwins2000 3 жыл бұрын
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!!!
@zig8925
@zig8925 3 жыл бұрын
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 жыл бұрын
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 жыл бұрын
@@AETutsVids Yeah I saw some videos using that method, but it makes visibility through the glass bad. And it has some side effects
@ssojyeti2
@ssojyeti2 4 жыл бұрын
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)
@ulu9311
@ulu9311 3 жыл бұрын
What type of shad are you creating?
@adajiang3801
@adajiang3801 4 жыл бұрын
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 жыл бұрын
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)
@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
@stefanleo6575
@stefanleo6575 4 жыл бұрын
Its giving me an error in the code for the custom function on the word: refract()
@RivenbladeS
@RivenbladeS 4 жыл бұрын
me too
@RivenbladeS
@RivenbladeS 4 жыл бұрын
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
@devashishpacholiya6794
@devashishpacholiya6794 2 жыл бұрын
Can I use it in 2d
@megumin4625
@megumin4625 4 жыл бұрын
I adapted this into Amplify Shader Editor :)
@andresca1985
@andresca1985 2 жыл бұрын
how you did? show me all nodes, please
@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 жыл бұрын
Also make sure the quality settings you have opaque texture enabled, otherwise I donno what is wrong, have a nice one
@albertcallejoamat7837
@albertcallejoamat7837 2 жыл бұрын
... What about URP?
@PascalAchermann
@PascalAchermann 4 жыл бұрын
Awesome thank you!
@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 жыл бұрын
​@@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!
@dertobbe1176
@dertobbe1176 5 ай бұрын
Doesnt work for me 😕
@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
@李尊-l9f
@李尊-l9f 4 жыл бұрын
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
@playedugame
@playedugame 4 жыл бұрын
Nice
@jackblack2567
@jackblack2567 4 жыл бұрын
did same not working
@AETutsVids
@AETutsVids 4 жыл бұрын
What is the result?
@dylanisaac1017
@dylanisaac1017 4 жыл бұрын
OMG THE CUSTOM FUNCTION DIDN'T GIVE ME THAT BUG, AYYYYYY
@zacksnyder5861
@zacksnyder5861 4 жыл бұрын
I had an issue with the Custom function, so here is what it should be: Out = refract(View, Normal, IOR);
@oxovira8408
@oxovira8408 4 жыл бұрын
Your function is a same of the video, but I could be wrong.
@zacksnyder5861
@zacksnyder5861 4 жыл бұрын
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 жыл бұрын
​@@zacksnyder5861 AAH Sorry, I had a problem with my shader, so I misunderstood your comment.
@david3atista
@david3atista 2 жыл бұрын
mine is pink brah
@yori4434
@yori4434 4 жыл бұрын
Works wierd in 2019.3
@AETutsVids
@AETutsVids 4 жыл бұрын
Define wierd
@AETutsVids
@AETutsVids 4 жыл бұрын
I am not even able to open a URP project in 2019.3
@yori4434
@yori4434 4 жыл бұрын
@@AETutsVids kzbin.info/www/bejne/qmbJhneeqtampLM 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 жыл бұрын
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
Oceans with Unity Shader Graph.
27:00
PolyToots
Рет қаралды 73 М.
Unity Shadergraph Tutorial - Cracked Ice
12:15
Binary Impact
Рет қаралды 53 М.
버블티로 부자 구별하는법4
00:11
진영민yeongmin
Рет қаралды 18 МЛН
ТИПИЧНОЕ ПОВЕДЕНИЕ МАМЫ
00:21
SIDELNIKOVVV
Рет қаралды 1,5 МЛН
Бенчик, пора купаться! 🛁 #бенчик #арти #симбочка
00:34
Симбочка Пимпочка
Рет қаралды 3 МЛН
Я сделала самое маленькое в мире мороженое!
00:43
Кушать Хочу
Рет қаралды 4,3 МЛН
Fractured Portal Effect in Unity using Shader Graph
9:10
AE Tuts
Рет қаралды 12 М.
How To Create Water Effects in Unity - Water Bending Tutorial
16:36
A Bit Of Game Dev
Рет қаралды 108 М.
Unity Shadergraph: Rain Drop Ripples!
21:58
PolyToots
Рет қаралды 55 М.
Unity Shader Graph - Fire Flames Shader Tutorial
13:46
Gabriel Aguiar Prod.
Рет қаралды 179 М.
GRASS SWAY in Unity - SHADER GRAPH
16:56
Brackeys
Рет қаралды 731 М.
Magical Plasma Orb Part 1 Shader Graph Unity Tutorial.
14:59
Binary Lunar
Рет қаралды 36 М.
버블티로 부자 구별하는법4
00:11
진영민yeongmin
Рет қаралды 18 МЛН