Reflection
-
- Halfling
- Posts: 89
- Joined: Sun Oct 06, 2002 11:19 pm
Reflection
Hello Everybody,
I was thinking the other day about mirrored surfaces. To make a mirrored surface you have to setup and reflection matrix and renderer the world a again to a texture that is applied to a surface.
So what I was thinking is that it would be really nice to have a Reflection parameter in the material file.
texture floor.png
reflection 0.2
The number would be how reflective the surface is. 1 being fully reflective so the texture about would not be seen at all. That would give the artist control over how reflective they think the surface should be.
Does this sound like a good idea. Has it already been done. I read the part about reflections in the docs but it was cubmapping and enviromental mapping. I nice feature but not a true reflection.
Thanks, Ben
I was thinking the other day about mirrored surfaces. To make a mirrored surface you have to setup and reflection matrix and renderer the world a again to a texture that is applied to a surface.
So what I was thinking is that it would be really nice to have a Reflection parameter in the material file.
texture floor.png
reflection 0.2
The number would be how reflective the surface is. 1 being fully reflective so the texture about would not be seen at all. That would give the artist control over how reflective they think the surface should be.
Does this sound like a good idea. Has it already been done. I read the part about reflections in the docs but it was cubmapping and enviromental mapping. I nice feature but not a true reflection.
Thanks, Ben
Dating a women is like driving in a foreign country. You don't know what side of the road your on, you can't understand the signs and you certainly don't want to ask for directions but it usually worth the ride.
- Kencho
- OGRE Retired Moderator
- Posts: 4011
- Joined: Fri Sep 19, 2003 6:28 pm
- Location: Burgos, Spain
- x 2
- Contact:
There are some features supported for this purpose in Ogre (take a look at the Camera class, and its methods for "reflected camera" and so on...)
The problem is that you can't use a material as a "reflector/mirror", as the geometry can be extremely complex, and you have to render the scene for each reflection plane. For a plane, this is render twice. But for a cube, this means render 4 times (for a perfect cube, and not rendering the occluded faces....). This is why it's usually selected a plane as the mirror for the whole scene, and use stencilling to reflect just some parts...
The problem is that you can't use a material as a "reflector/mirror", as the geometry can be extremely complex, and you have to render the scene for each reflection plane. For a plane, this is render twice. But for a cube, this means render 4 times (for a perfect cube, and not rendering the occluded faces....). This is why it's usually selected a plane as the mirror for the whole scene, and use stencilling to reflect just some parts...
- japito
- Halfling
- Posts: 77
- Joined: Mon Apr 26, 2004 11:01 pm
- Location: In your MBR ... (sometimes in spain)
You can explain it a little more?Kencho wrote:There are some features supported for this purpose in Ogre (take a look at the Camera class, and its methods for "reflected camera" and so on...)
The problem is that you can't use a material as a "reflector/mirror", as the geometry can be extremely complex, and you have to render the scene for each reflection plane. For a plane, this is render twice. But for a cube, this means render 4 times (for a perfect cube, and not rendering the occluded faces....). This is why it's usually selected a plane as the mirror for the whole scene, and use stencilling to reflect just some parts...
ummmm emmmm estoooo.....
- Kencho
- OGRE Retired Moderator
- Posts: 4011
- Joined: Fri Sep 19, 2003 6:28 pm
- Location: Burgos, Spain
- x 2
- Contact:
Yep. Reflections (in the context he is talking) are quite "expensive" as you must perform them manually. For instance, think you have a marble floor and want to reflect the geometry on it. You have to make two render passes: One for the above and one for the reflection, plus the floor "transparency" and some scaling and stencil operations. There are many papers about this around internet. What he was talking about was adding this feature in the material scripts, so you just say the amount of "scene reflection" and OGRE would do everything else.
This can be done, so that OGRE would detect the plane that would perform the reflection, and it will automatically modify the render algorithm so that it reflects it. The problem is that if the mesh that will reflect is not a perfect plane, then it must add a render pass per face (guess the performance rendering a 100K polygon scene per frame?). If you have a plane, you render the scene twice. If you have a cube, you render it 4 times (the original and one per face you actually see). If you have a 45K geosphere... well... 22501 times... is... wow.
Do you know what I'm talking about? Of course there are "approaches" A LOT less expensive, like cube-mapping reflections, with the cost of less accuracy in the reflections. But even with this is not practical to add a parameter in the material script for this, but doing it manually.
This can be done, so that OGRE would detect the plane that would perform the reflection, and it will automatically modify the render algorithm so that it reflects it. The problem is that if the mesh that will reflect is not a perfect plane, then it must add a render pass per face (guess the performance rendering a 100K polygon scene per frame?). If you have a plane, you render the scene twice. If you have a cube, you render it 4 times (the original and one per face you actually see). If you have a 45K geosphere... well... 22501 times... is... wow.
Do you know what I'm talking about? Of course there are "approaches" A LOT less expensive, like cube-mapping reflections, with the cost of less accuracy in the reflections. But even with this is not practical to add a parameter in the material script for this, but doing it manually.
- :wumpus:
- OGRE Retired Team Member
- Posts: 3067
- Joined: Tue Feb 10, 2004 12:53 pm
- Location: The Netherlands
- x 1
- Kencho
- OGRE Retired Moderator
- Posts: 4011
- Joined: Fri Sep 19, 2003 6:28 pm
- Location: Burgos, Spain
- x 2
- Contact:
That's what I was talking about at the end of the post.
Anyways, I still ask myself why you have to render the scene 6 times for the cubemap reflection, while you just see reflected 3 at most
From top down:
As you can see, you don't see more than 3 faces never, so I think you just need to use (or at least update) 3 faces each frame, instead of 6, right?
Anyways, I still ask myself why you have to render the scene 6 times for the cubemap reflection, while you just see reflected 3 at most
From top down:
Code: Select all
+------+ \
| cube | \ <- View frustum
| map | \
+------+ \
\
----------------* Camera
- DWORD
- OGRE Retired Moderator
- Posts: 1365
- Joined: Tue Sep 07, 2004 12:43 pm
- Location: Aalborg, Denmark
- Contact:
- :wumpus:
- OGRE Retired Team Member
- Posts: 3067
- Joined: Tue Feb 10, 2004 12:53 pm
- Location: The Netherlands
- x 1
- DWORD
- OGRE Retired Moderator
- Posts: 1365
- Joined: Tue Sep 07, 2004 12:43 pm
- Location: Aalborg, Denmark
- Contact:
- SuprChikn
- Bugbear
- Posts: 863
- Joined: Tue Apr 19, 2005 6:10 am
- Location: Melbourne, Aus
- Contact:
- Kencho
- OGRE Retired Moderator
- Posts: 4011
- Joined: Fri Sep 19, 2003 6:28 pm
- Location: Burgos, Spain
- x 2
- Contact:
Yes, you're right. 5 faces may be needed. Anyways, you can avoid a pass for the unseen face, right?
BTW: I think I have a method to avoid drawing the 6th face always. If the reflection cameras take the same orientation from the camera, the 6th face (back) won't be needed, isn't it?
Performance tuning to the end!!
BTW: I think I have a method to avoid drawing the 6th face always. If the reflection cameras take the same orientation from the camera, the 6th face (back) won't be needed, isn't it?
Performance tuning to the end!!
- DWORD
- OGRE Retired Moderator
- Posts: 1365
- Joined: Tue Sep 07, 2004 12:43 pm
- Location: Aalborg, Denmark
- Contact: