Hi,
I’d need to simulate the refraction that applies when looking through the eye’s cornea.
Here is a screenshot made with 3DSMax, the image above without the refraction shader the and the image below with the refraction shader of 3DS.
Now I’d need to do something similar in Unity.
I’ve tried the simple Refraction shader that is on the Wiki, but that gives weird results.
I am also new in the “shader’s world” so I am learning it at the same time, and since its a complex problem I don’t have an idea what to look for to correct this.
So here is the screenshot for what I’d like:
///EDIT///Sorry I had to take the image off///
And here is when I tried the refraction shader using the refraction function, because I know the refraction index of the cornea:
///EDIT///Sorry I had to take the image off///
This is with using the normals:
///EDIT///Sorry I had to take the image off///
Thanks a lot,
Greg
As you’ve discovered, the built-in refraction shader is not physically accurate, as it doesn’t cast rays. Unfortunately, you can’t really cast rays on graphics hardware. The best you can do is use a shader that uses another camera for a different perspective, but that only works in some very general cases.
Oh WOW, so this means that what I want to do is nearly impossible with Unity?
3DSMax’s shader does cast rays to be able to simulate that refraction?
Thanks for the reply
Greg
Physically accurate refraction isn’t possible without real-time raytracing. I don’t know of any game engines that do this.
No its nearly impossible with any realtime engine.
Render software can do that as it harshly put has “all time on earth to do its eye candy” not only <16ms
OK, thanks a lot everyone for having cleared that up!
Greg
Hey guys,
I have some more question about this.
So I understand that it won’t be possible to do anything physically correct, but is there a way to approximate or fake this?
For example to make the iris texture stretch when we have a frontal look at the eye to not to show the borders of the sclera. (only the left image of the first screenshot)
And also could someone explain what makes the built-in shader behave like its behaving on the screen shot? Why is the whole object mirrored on the texture behind the cornea?
Or is that shader was written only for refractions behind 2D surfaces?
Thanks a lot,
Greg
EDIT: Sorry I had to take the screenshots off, but I hope you will be able to respond my questions.
I recommend trying a purely transform-based approach if you can. That is, increase the size of the iris when the camera is looking directly at it.
If you need a screen shot host, try http://imageshack.us/
Thanks Daniel for this suggestion and this is what I will try to implement.
Since I am completely new to shaders I am at the moment reading the Cg Tutorial on the nvidia developer’s site.
Could you give me any kind of hint on how to get started with a shader that is scaling the texture behind it?
Thanks a lot
Greg
Oh, I meant a script-based scaling approach. Scaling objects behind what is being rendered using a shader is fairly advanced, and happens in screen space rather than world space. It will be difficult to do, and the results will be inaccurate.
I was thinking of actually changing the scale of the iris so that it obscures the sclera when viewed head-on, and scaling it back when viewed from the side.
Ah OK, I see what you meant. I don’t know if in this case it is a doable solution since the eye is a skinned model so scaling the iris might have an effect on other parts and also the designer said that the iris’ pivot might not be at its center.
In one of your previous answers you talked about making a shader that renders from a camera that is at a different perspective.
The designer tested that we could approach the effect in changing the camera’s focal point. Or rendering on the current cam through another cam that has a different focal point (or perspective as you said it earlier).
Would that be easier? If yes, are there any built in shaders that use this principle of rendering on current cam the vision of another cam? (So that I have something to start with)
Thanks a lot!
Greg
The reflective water shader in the island demo uses another camera in order to render reflections. I don’t have any experience with it, but that’s where I’d start.