+21
Under review

Real time reflection

vincent 10 years ago updated by Skaarah 9 years ago 16
Hi, I'm trying to forge a water shader. So far everything works fine the only problem is the realtime reflection. You said in an other post that there was already an request for this. But I couldn't find the request so I thought I ask it this way;
Is it already implemented? 
Is this also possible with a render texture? And what would the node setup be to make that work? 
thx 
Currently it's not possible, as you can't pass matrices into SF shaders. This is something that will probably make it into a future version, probably after 1.0 is out.
+1
Couldn't you use a render texture with a 2nd camera that has an inverted matrix in c#? Then use that texture as your reflection. Like unity's water shaders.
+1
Tested this and it works great. You can get post of the code you need in the Unity Pro Standard Asset Water Shader Script that came with Unity. You just pass the reflection in as a Texture. The script makes the camera, renders it, and sets the texture right into Shader Forge.
Oh, I thought you had to use matrices in order for that to work? Could you show a screenshot?
+3
It is possible. I have shared it with people in forum but for people come to this place for an answer it is quite simple :

I did the same thing as Baris, I used the Code from Unity's water c# script that feeds the texture to the shader. It creates the camera reflection matrix.
Awesome, glad it worked out :)
Brad:
Could you explain me with some more details, what you exactly did to get the reflections into Shaderforge?
You picked the "Water.cs" from the folder Water(Pro Only) / Sources / Scripts?
You used the script as it is or changed it (I get a lot of errors because all the called properties are not present in my shader)? 
...
Thanks very much!
You have to make the parameters with shader forge for it to fill in. 
Sounds great! Could you please describe in detail how to make the parameters with shader forge? I dont get it how the "water.cs" feeds the texture into the shader forge shader?! The water.cs script keeps as it is, correct? Maybe you can post a small expample? Thanks in advance!!
+2
found Baris post:
Http://forum.unity3d.com/threads/shader-forge-a-vi...
Rendering the reflections alright but they don't line up :(
I did try this again with the mirrorscript and it works. I also works with the new reflection script from Unity 5
Really? How did you make it? Could you share with us?Thank you!
PBL with Unity5 and a reflection probe works quite well for me.