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 / Shadows on Water Shader Keep moving instead of being stationary

Author
Message
JackDawson
14
Years of Service
User Offline
Joined: 12th Jul 2011
Location:
Posted: 13th Sep 2011 23:14
Hello guys. Well I finally got the water colors to a point I like and it dawned on me that the shadows were throwing me off in the first place. What is happening is when you go up near the water and look out it looks great. Well sort of. If you move the camera left or right or up or down the shadows move too. Meaning instead of the mountain being here and the Shadow being here, the mountain is here but the shadow ends up over there. That kind of scenario. They should be stationary with the mountain to look the part. But I just cannot seem to get the math right on this.

Anyone who understands how the shader works, could you please check my source code I have attached and look in the WATER.DBA where CAMERA 1 and CAMERA 2 are at. Both of those are used for the water shader to make the water look good. But the reflections move because of the camera angle and I need to get it to where it will not move. The rotation and / or the position are out of alignment when you move the camera. But cameras or one, I do not know. But something is mis-aligned.

Any ideas would be great. Thank you.

"Life is like a box of chocolates.. eat it before it melts."
JackDawson
14
Years of Service
User Offline
Joined: 12th Jul 2011
Location:
Posted: 13th Sep 2011 23:21 Edited at: 13th Sep 2011 23:26
In case you need a picture for a reference of what the heck I'm talking about. If I keep turning the camera left, it really goes out of alignment.. if I turn toward the right it start to align up and then if I keep turning right, it comes out of alignment the other direction. SAME thing happens when I ANGLE the mouse up and down as well.

The camera 0 uses xPos#, yPos# and zPos# for position. And for angle it uses xAng# and yAng#.

But the shader camera's 1 and 2 do not use those. It just pulls from the camera at the moment and then renders it out. So there must be a way around this problem. Like finding a number to keep the shadows in one spot no matter what angle the Camera 0 is at.

Again, this is about the Angle of the camera(s), not the position.



"Life is like a box of chocolates.. eat it before it melts."
Mugen Wizardry
User Banned
Posted: 13th Sep 2011 23:42
@Jack Dawson, can u release this source so we can see how u did that?

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Sep 2011 23:49
Quote: "it dawned on me that the shadows were throwing me off"


I think you mean reflections.
JackDawson
14
Years of Service
User Offline
Joined: 12th Jul 2011
Location:
Posted: 13th Sep 2011 23:57 Edited at: 13th Sep 2011 23:57
Quote: "@Jack Dawson, can u release this source so we can see how u did that?"


If you read the whole thread and looked at the first post where the downloads usually are.. you would have noticed I had already put it there.

Quote: "I think you mean reflections."


Yea, the reflections OF the shadows I guess is what I mean.

"Life is like a box of chocolates.. eat it before it melts."
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Sep 2011 00:57
I haven't time to look into this now but I'd check your camera positioning/camera syncing code. If I recall correctly you are using three cameras, 0, 1 and 2. If they are not being moved together you might get that problem. Check that each is moved before the relevant camera sync or, better still, adjust the cameras in the same bit of code so you don't accidentally move one before rather than after it;s sync (or vice versa).

I'm assuming that the reflection moves to its correct position fairly quickly. Does it? If not then it's a coding or maths error of some sort.
JackDawson
14
Years of Service
User Offline
Joined: 12th Jul 2011
Location:
Posted: 14th Sep 2011 01:02 Edited at: 14th Sep 2011 01:05
Its hard to explain unless you see it for yourself. Its not that it is too quick. However the syncing might be the problem. I am using 1 Sync command and 2 sync mask's and 1 fastsync.

The problem is I do not know which order they are supposed to be in.



The UpDateWater() function is called once per SYNC command. The Sync command comes AFTER this is called. The other two functions you see here are called from within the UpDateWater() function.

"Life is like a box of chocolates.. eat it before it melts."
Mugen Wizardry
User Banned
Posted: 14th Sep 2011 01:08
My mistake

CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !
JackDawson
14
Years of Service
User Offline
Joined: 12th Jul 2011
Location:
Posted: 14th Sep 2011 01:11
No problem.

"Life is like a box of chocolates.. eat it before it melts."
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Sep 2011 01:16
Just looked at your demo from the other thread. I think the problem was in that demo too and I believe I've just fixed it by making sure that all three cameras have the same field of view.

Here's the relevant code from your example "g":

JackDawson
14
Years of Service
User Offline
Joined: 12th Jul 2011
Location:
Posted: 14th Sep 2011 01:25 Edited at: 14th Sep 2011 01:26
Hahahaha, although that code is still in there, I had changed my original camera 0 to FOV of 50. Once I set it to 70 like the other two, it synced right up.. You sir are a genious. I had been toiling with this all day.. LMAO

I'll post the updated code back on my original thread. Thanks again GG.

http://forum.thegamecreators.com/?m=forum_view&t=188775&b=1



"Life is like a box of chocolates.. eat it before it melts."

Login to post a reply

Server time is: 2025-08-09 02:25:16
Your offset time is: 2025-08-09 02:25:16