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.

DarkBASIC Professional Discussion / Dynamic cube map issue

Author
Message
Max Maker
19
Years of Service
User Offline
Joined: 17th May 2007
Location: 4
Posted: 18th Jun 2012 23:53 Edited at: 18th Jun 2012 23:54
Hi,
I'm trying to make dynamic cube map with plain (flat) object.
I mean reflection using cube map, But the reflection is not good.



i'm using environment bump effect.
if it's impossible using dynamic cube map way, Is there another way ???

and sorry for my language

4444444444444444444444
Max Maker
19
Years of Service
User Offline
Joined: 17th May 2007
Location: 4
Posted: 19th Jun 2012 19:17 Edited at: 19th Jun 2012 19:18
anyone ??

4444444444444444444444
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Jun 2012 14:43
Quote: "But the reflection is not good."


Looks OK to me.

What's the problem exactly? What do you think is wrong?
Max Maker
19
Years of Service
User Offline
Joined: 17th May 2007
Location: 4
Posted: 21st Jun 2012 22:27
thanks Green Gandalf
the problem not with Dynamic cube map codes, but with reflection position/place
works fine with other geometry shapes, but not with plain shape !

press 1,2,arrowkeys to control the sphere



4444444444444444444444
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jun 2012 15:20
I see what you mean now. I'll investigate.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jun 2012 16:01 Edited at: 22nd Jun 2012 16:10
I think the problem is with Evolved's use of the tangent space calculations in the shader. See if the attached shader is any better. It's an old one of mine and I'm not quite sure it's the latest version. Post back if you need help getting it working.

Edit Sorry! That shader isn't what you want. Serves me right for rushing before I stop for lunch.

Edit2 And it has the same problem. Weird. I'll investigate.

I'll post back later with a better version.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 22nd Jun 2012 16:18
Do they use a camera? It looks like a camera somewhere isn't high enough.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jun 2012 17:05 Edited at: 22nd Jun 2012 17:47
The main problem is indeed the camera. The dynamic cube map needs the cube map camera to be placed at the same position as the main camera, i.e. the following line in the dba code



needs to be changed to



That seems to improve things but there are still some problems with the reflection so something else needs to be fixed as well.

Edit The remaining problems are logic ones which can't be fixed easily. The shader assumes that the objects visible in the cube map are a great distance from the reflective surface as in a sky box or similar. This causes unavoidable problems when reflected objects are near the camera. Also, the shader assumes that a single cube map is sufficient. It isn't. If the surface were indeed flat then a single cube map would be correct - but the point of the normal map is that the surface isn't flat. In practice we have to pretend it is flat for the purposes of calculating a single cube map so the technique is necessarily an approximation to reality. That problem is only apparent if you study the reflections very carefully.

There was also a silly error in my earlier code "correction" . The cube map camera should be placed the same distance BELOW the reflective surface as the main camera is above it, so the correct line should probably be something like



[I say "probably" because I seem to be having trouble getting simple things right today.]
Max Maker
19
Years of Service
User Offline
Joined: 17th May 2007
Location: 4
Posted: 22nd Jun 2012 17:49 Edited at: 22nd Jun 2012 17:50
Thank you very muck green gandalf for your help
works great with your fx shader "bumpreflect",
but doesn't work with evolved's one, doesn't matter

i'll look for a solution later


thank you friend

4444444444444444444444
revenant chaos
DBPro Master
19
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 22nd Jun 2012 23:14 Edited at: 22nd Jun 2012 23:16
If you just want to apply reflections to a plain, I don't think using a dynamic cubemap is the best solution. A while back I posted a reflective floor demo which may help you, it doesn't use normal mapping but that could be easily added in the future.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Jun 2012 00:08
Quote: "but that could be easily added in the future. "


How?

Cube mapping is the simplest way when you have uneven surfaces such as those implied by normal mapping. One of the problems with several water shaders I've seen is that you get strange results when the reflection direction is outside the reflection camera's field of view. Dynamic cube mapping cures that painlessly.
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 23rd Jun 2012 10:39
Anybody knows how games such as gta4 performs reflections on uneven terrain with some hills?

«It's the Pony, pony me this, pony me that» — Bronies
«I sell apples and apple accessories» — Applejack
Derpy delivers: watch?v=g4Kgz4Us_RI
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 23rd Jun 2012 11:09 Edited at: 23rd Jun 2012 11:12
Quote: "Anybody knows how games such as gta4 performs reflections on uneven terrain with some hills?"


Bend a surface, and it bends the texture automatically. It's probably not accurate though. Raycasting is the accurate but slow way.

mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 25th Jun 2012 09:01
@Pincho Paxton
what about reflection itself?

«It's the Pony, pony me this, pony me that» — Bronies
«I sell apples and apple accessories» — Applejack
Derpy delivers: watch?v=g4Kgz4Us_RI
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 25th Jun 2012 12:52 Edited at: 25th Jun 2012 12:55
Reflection is a texture sent by a camera, and if you texture a shape it bends with the shape. It's the same as texturing a sphere, or a plain, you get the bending happening due to the curvature. That's why water shaders work so well.

mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 26th Jun 2012 08:51 Edited at: 26th Jun 2012 08:52
I just played in NFS hot pursuit, they did fake reflections - car has no wheels and not all rocks and small things are reflected. I think they just made upside-down LODs under the road somehow.

«It's the Pony, pony me this, pony me that» — Bronies
«I sell apples and apple accessories» — Applejack
Derpy delivers: watch?v=g4Kgz4Us_RI
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 26th Jun 2012 21:25
Quote: "I just played in NFS hot pursuit, they did fake reflections - car has no wheels and not all rocks and small things are reflected. I think they just made upside-down LODs under the road somehow."


Or the camera pass that renders the reflection uses LOD so that the pass doesn't cause as much of a performance hit.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th Jun 2012 23:05
That's a good point.
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 27th Jun 2012 17:03
But road is not plain! And their reflections are not distorted.

«It's the Pony, pony me this, pony me that» — Bronies
«I sell apples and apple accessories» — Applejack
Derpy delivers: watch?v=g4Kgz4Us_RI

Login to post a reply

Server time is: 2026-07-08 01:53:40
Your offset time is: 2026-07-08 01:53:40