Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Reflection Shader

Author
Message
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 19th Nov 2013 22:37
Does anyone know if it's possible to use a reflection shader in AGK. And if so, does anyone have an example on how to do it?

My scene is very simple, I need to reflect one object on a shiny wooden floor so performance shouldn't be an issue.

This is my first venture into shaders, so be gentle

Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 20th Nov 2013 23:48 Edited at: 20th Nov 2013 23:48
Reflection usually involves rendering to an image from a different camera view point, then texturing the reflective surface with that image.

So you will probably need to wait for AGK2.

You could make the surface transparent and draw everything twice, once above and once below, inverted. I have no idea how this would look but it may work for really limited situations. I have done similar with 2D sprites to create sprite reflections.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 22nd Nov 2013 20:39
There is a problem with drawing everything inverted. Imagine a car reflected on a shiny showroom floor. The reflection doesn't show the underneath of the car, whereas drawing everything inverted would. You would somehow need to invert only the parts you can see.

Our good friend and shader expert Green Gandalf has said he might get chance to take a look.

Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 22nd Nov 2013 21:42 Edited at: 22nd Nov 2013 21:43
Quote: "There is a problem with drawing everything inverted. Imagine a car reflected on a shiny showroom floor. The reflection doesn't show the underneath of the car, whereas drawing everything inverted would. You would somehow need to invert only the parts you can see."


You may be right here but in my imagination I can't see the problem. A reflection would show the underneath of the car wouldn't it? Obviously from head height the real(original) car would get in the way in real life and in the simulation, this is why you don't see under the car?

You have me interested in this now, I may try putting a little demo together to see how it looks, could be interesting

Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 22nd Nov 2013 23:51 Edited at: 22nd Nov 2013 23:58
Yeah, I'm pretty sure the inverted geometry technique is the same perspective as a reflection. As Matty says you wouldn't see the underneath of the car with this technique either, since the normal geometry would obscure the underneath car in the reflected geometry. The exception here being a low view height where you would see the underneath of the car in the reflected geometry, but you would in a true reflect as well. The main issue is lighting really, as with a light source above, the top of the car would be bright and the underneath dark, but the reverse would be true on the inverted geometry.

If you draw yourself a little picture with a shape above a line and a shape below it and a spot for the observer, you can demonstrate this to yourself. Draw a line to the surface and through to the inverted geometry, plus a reflected line back up to the geometry. Assuming you have a steady hand and have drawn your scene accurately, the line will touch the same place on the geometry of the normal and inverted object. You'll also see the underneath of the inverted geometry is obscured by the normal geometry when you try and draw lines from the observer to it.

Edit: this is only true for 3d scenes btw, not for 2d

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Nov 2013 12:45
Quote: "There is a problem with drawing everything inverted. Imagine a car reflected on a shiny showroom floor. The reflection doesn't show the underneath of the car, whereas drawing everything inverted would. You would somehow need to invert only the parts you can see."


I don't think I understood that.

All you have to do is stand in front of a mirror and hold the palm of your hand facing the mirror. You should be able to see the palm of your hand in the reflection and only the back of the real hand.

Why should a car on a showroom floor be any different?



Powered by Free Banners
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 23rd Nov 2013 18:19
You see why I can't even begin to get my head around this!

I am thinking of a bad reflection I saw in a photoshopped picture. The problem was that you couldn't see the underneath, not that you could. My bad

The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 23rd Nov 2013 21:56
But would that be an issue if you mirror the scene underneath with a transparent object on top. I think some FPS creator projects have used it and got some awesome results.

Say ONE stupid thing and it ends up as a forum signature forever. - Neuro Fuzzy

Login to post a reply

Server time is: 2024-05-03 07:27:16
Your offset time is: 2024-05-03 07:27:16