Hey guys I'm back, it's been a while.
So I'm trying to make a glass shader. Basically I'm making a GUI with OpenGL, so the camera is always going to be pointing the same direction, with a background. I want to make some glass-like buttons etc, and I think it's a bit overkill to use an cube sampler when I only have to refract what's underneath (no reflection).
I tried this: http://www.gamasutra...pping_part_.php but it didn't work very well for me - my object always looked the same no matter what was underneath. I'm going to try again, but if anyone has something else I could do I'd appreciate it.
Cheap glass shader without cube sampler
Started by vdf22, Jun 15 2012 03:42 PM
6 replies to this topic
#2
Posted 15 June 2012 - 05:54 PM
If your object is too close to what's behind it, the refraction will be amplified too much, like a magnifier. I assume that because it's a button, rounded?!
Also, is your button's normal facing the right way, outwards?
Also, is your button's normal facing the right way, outwards?
#3
Posted 15 June 2012 - 06:18 PM
It's not common, but I'm putting youtube video link here - - (I appologize for not marking it as link, but I just cant open dialog for adding hyperlink, though I think the bug is on my side in not updated opera).
Basically you render scene behind your menu to texture - distort coordinates (with some normal map to look good) and map them projectively from camera on GUI. You can also add reflection this way, etc.
Note that it really needs fine-tuning to look good
- but it's worth it.
Basically you render scene behind your menu to texture - distort coordinates (with some normal map to look good) and map them projectively from camera on GUI. You can also add reflection this way, etc.
Note that it really needs fine-tuning to look good
My blog about game development (and not just game development) - http://gameprogramme...y.blogspot.com/
If you don't know how to speed up application, go "roarrrrrr!", hit the compiler with the club and use -O3 :D
If you don't know how to speed up application, go "roarrrrrr!", hit the compiler with the club and use -O3 :D
#4
Posted 15 June 2012 - 06:33 PM
Looks like you have some dispersion going on in there...
reedbeta.com - developer blog, OpenGL demos, and other projects
#5
Posted 15 June 2012 - 06:33 PM
Alienizer, on 15 June 2012 - 05:54 PM, said:
If your object is too close to what's behind it, the refraction will be amplified too much, like a magnifier. I assume that because it's a button, rounded?!
Also, is your button's normal facing the right way, outwards?
Also, is your button's normal facing the right way, outwards?
It's a flat sphere, so it shouldn't refract too much (right). Since the article I linked to didn't use a shader, I made one up with his formulas. But it didn't give me the results I wanted - in fact moving it the button didn't even change at all and it just showed the same color no matter where it was. The normals are fine, I'm using a specular shader with it right now.
Vilem Otte, on 15 June 2012 - 06:18 PM, said:
It's not common, but I'm putting youtube video link here - - (I appologize for not marking it as link, but I just cant open dialog for adding hyperlink, though I think the bug is on my side in not updated opera).
Basically you render scene behind your menu to texture - distort coordinates (with some normal map to look good) and map them projectively from camera on GUI. You can also add reflection this way, etc.
Note that it really needs fine-tuning to look good
- but it's worth it.
Basically you render scene behind your menu to texture - distort coordinates (with some normal map to look good) and map them projectively from camera on GUI. You can also add reflection this way, etc.
Note that it really needs fine-tuning to look good
Actually I saw that video, which is where I got the idea.
I had a heck of a time finding any documentation, but eventually I found that article that uses the same formula, and I'm assuming that's where he got it from.
#6
Posted 16 June 2012 - 04:31 PM
Reedbeta, on 15 June 2012 - 06:33 PM, said:
Looks like you have some dispersion going on in there... 
I found the shaders I did for effect like this, so here they are (it's a bit older - I mean like 2 years or so):
http://pastebin.com/XMP0s2GF - Vertex shader
http://pastebin.com/8e3v03Rq - Fragment shader
Look at the bunny - he's got this shader on him

EDIT: My appologize for comments a bit out in those sources - I use Kate and GEdit as text editors for code (no IDE
My blog about game development (and not just game development) - http://gameprogramme...y.blogspot.com/
If you don't know how to speed up application, go "roarrrrrr!", hit the compiler with the club and use -O3 :D
If you don't know how to speed up application, go "roarrrrrr!", hit the compiler with the club and use -O3 :D
#7
Posted 17 June 2012 - 04:43 AM
Thanks, I'll try that when I have time. I figured out part of my problem (it was stupid. Really) but my shader still isn't working quite right. I'll give yours a go
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












