Problem with Melv's Water code
by Rodney (OldRod) Burns · in Torque Game Engine · 01/31/2003 (4:27 am) · 9 replies
Actually the problem's not with his code, but my understanding of it I'm sure :)
I added Melv May's improved fluid rendering code from the HEAD release into my project and it works, but I'm getting a display problem I don't know how to fix.
Here's a screenshot:
members.cox.net/rodburns/waterscreenshot.jpg
The lighter ring around the edge is what I'm looking at. I have used the same texture on the water surface and for the water edge both. Why is the edge area so much lighter?
Also, does anyone have a link to some good free water and lava textures that will work with Torque?
I added Melv May's improved fluid rendering code from the HEAD release into my project and it works, but I'm getting a display problem I don't know how to fix.
Here's a screenshot:
members.cox.net/rodburns/waterscreenshot.jpg
The lighter ring around the edge is what I'm looking at. I have used the same texture on the water surface and for the water edge both. Why is the edge area so much lighter?
Also, does anyone have a link to some good free water and lava textures that will work with Torque?
#2
01/31/2003 (7:23 am)
Yeah, that is how its supposed to work. I think if you tweak some of the depth values (I forget what they are called, but I think there are values that set the depth for the shallow color, and the deeper color) you might be able to get right of it, if thats what you want.
#3
Perhaps Melv or someone else can help?
Also, you might see if you can reproduce the appearance on another system/video card. It could be a weird interaction....
01/31/2003 (7:41 pm)
I'm not sure that that's quite right, as I've never noticed bright rings around my water (I use Melv's code, too, recent HEAD checkout).Perhaps Melv or someone else can help?
Also, you might see if you can reproduce the appearance on another system/video card. It could be a weird interaction....
#4
01/31/2003 (7:57 pm)
Oooooooo, nice code to get that kind of water.....I think I'll download it and ATTEMPT to get it working.
#5
It might help if I explain how the fluid surface is calculated/rendered, I will call it water for this discussion.
The algorithm is quite simple, I cast rays down to the terrain at discreet points across the water surface. This value is obviously the depth at that point and I use this to calculate the colourisation across the surface.
I provide a script parameter 'ShoreDepth' that allows you to specify a level of depth at which the water object will make the transition between what it will use as shoreline or deep water. It was requested by quite a few community folk that we have the ability to have different textures with different tessellation values for shoreline and deep water.
The problem I had with this was that there was a sharp edge on the transition and so I changed the code to blend the two by overlapping the texturing process slightly. This solved the problem but it can become easy to produce this kind of ring effect where shore meets deep water.
I really hate the effect and I can think of half a dozen ways of solving it. In the near future when I've finished up on Strategem I intend on getting back to making some groovy additions to the engine and this includes doing the water properly this time.
For speed and compatibility I modified the existing fluid code which I don't normally like doing but next time it'll be from scratch.
Sorry if it doesn't give you the effect you require, I was never happy with it myself but I know for others it was just so much better than the standard fluid effect. ;)
- Melv.
02/01/2003 (2:31 am)
Hi guys,It might help if I explain how the fluid surface is calculated/rendered, I will call it water for this discussion.
The algorithm is quite simple, I cast rays down to the terrain at discreet points across the water surface. This value is obviously the depth at that point and I use this to calculate the colourisation across the surface.
I provide a script parameter 'ShoreDepth' that allows you to specify a level of depth at which the water object will make the transition between what it will use as shoreline or deep water. It was requested by quite a few community folk that we have the ability to have different textures with different tessellation values for shoreline and deep water.
The problem I had with this was that there was a sharp edge on the transition and so I changed the code to blend the two by overlapping the texturing process slightly. This solved the problem but it can become easy to produce this kind of ring effect where shore meets deep water.
I really hate the effect and I can think of half a dozen ways of solving it. In the near future when I've finished up on Strategem I intend on getting back to making some groovy additions to the engine and this includes doing the water properly this time.
For speed and compatibility I modified the existing fluid code which I don't normally like doing but next time it'll be from scratch.
Sorry if it doesn't give you the effect you require, I was never happy with it myself but I know for others it was just so much better than the standard fluid effect. ;)
- Melv.
#6
I love the code, it's a great improvement over the hard-edged shoreline we had before :)
BTW, in your resource you mention two water textures you used in your example, but the link to them seems down. Are these still available?
02/01/2003 (2:51 am)
Thanks for the explanation Melv. I do have a change in depth not far from the shoreline, so that's probably the culprit. I'll smoothe out the depth changes and see if that helps.I love the code, it's a great improvement over the hard-edged shoreline we had before :)
BTW, in your resource you mention two water textures you used in your example, but the link to them seems down. Are these still available?
#7
I've removed the "Object Heaven" site where the data was stored but I've put all my GarageGames stuff onto another server so that people can still get at it.
If you use ...
http://www.melv.may.btinternet.co.uk/garagegames/
... you'll find all the files in there.
I've not had time to change my resources appropriately but I'll do it today. :)
- Melv.
02/01/2003 (5:14 am)
Rodney,I've removed the "Object Heaven" site where the data was stored but I've put all my GarageGames stuff onto another server so that people can still get at it.
If you use ...
http://www.melv.may.btinternet.co.uk/garagegames/
... you'll find all the files in there.
I've not had time to change my resources appropriately but I'll do it today. :)
- Melv.
#8
02/01/2003 (7:22 am)
Thanks :)
#9
02/01/2003 (7:54 am)
Aww I always loved that ring and purposely make a little dropoff in any larger bodies of water in my levels so it shows up.
Torque Owner Ace