good water shader... VERY VERY GOOD WATER SHADER

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
JPulham
Posts: 320
Joined: Sat Nov 19, 2005 12:06 pm

good water shader... VERY VERY GOOD WATER SHADER

Post by JPulham »

VERY good water shader here... DirectX but theres a PDF paper on it so maybe a GLSL version could be made...

http://graphics.cs.lth.se/theses/projects/projgrid/
pushpork
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

:shock: eye-poppingly good!
rogerborg was looking for a realistic ocean effect, think this one is good enough? :D
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
gfxstyler
Posts: 222
Joined: Tue Apr 18, 2006 11:47 pm

Post by gfxstyler »

hey i've seen that one a few months ago on gamedev.net! i think i even downloaded the demo and it ran pretty smooth on my gfx card (radeon 9600 mobility)


triple yay for this shader! someone please get this to work with teh irrlicht :P

see you!
Eternl Knight
Posts: 313
Joined: Tue Nov 01, 2005 5:01 am

Post by Eternl Knight »

I gave the paper a quick once over after downloading it. I'll look into it in more depth tonight when I get home, along with the code.

From the brief overview I read - this would not bee too difficult to implement in OpenGL as the paper mentions the implementation using HLSL (i.e. should be relatively easy to convert to GLSL).

On the other hand, it may not be so easy to implement an efficient version without some changes to Irrlicht's mesh handling. One of the advantages of the algorithm seems to be the use of a "semi-static" mesh, whereas Irrlicht pretty much recreates the mesh everytime it needs to be sent to the video card. Perhaps after merging some of the IrrSpintz GPU-side vertex buffer code this will be simple.

As I said, this is from a brief glance over the paper. It may be simple to do in current Irrlicht, or impossible without major changes. But at least I have determined that OpenGL is not an issue :)

--EK
Halan
Posts: 447
Joined: Tue Oct 04, 2005 8:17 pm
Location: Germany, Freak City
Contact:

Post by Halan »

porting something like that to irrlicht would be great :)
Eternl Knight
Posts: 313
Joined: Tue Nov 01, 2005 5:01 am

Post by Eternl Knight »

OK, having reada the paper in depth and looked at the code - it shouldn't be a MAJOR hassle to implement. However, there are a few things that I would need to change in Irrlicht for it to be "plug & play". And it has some limitations that may make it a little less appealing than it originally looks.

First of all, the algorithm relies on a second "camera" object that changes position based on the "real" camera, but with a variety of limitations imposed. This second camera is used to transform a grid of points so that they are space out equally in "screen space" (unlike the usual grid which is spaced out equally in "world/object space").

To make this simpler for the algorithm - there are a few limitations on the second camera that need to be considered if one is going to use the "shader" (which is more accurately a scene node & processing algorithm). Firstly, the camera cannot go "underwater". That is, when the camera goes below the waves (or the waves rise above the camera), the rendering is not so good (in fact - it's terrible). The reason for this mentioned in the paper is that the author did not want to worry about "triangle winding". A more "correct" implementation would be to check the camera's position in relation to the water object and reverse triangle winding/orientation if underneath the waves (and perhaps use an "underwater shader" to add fogging to limit visibility). There is also some stencil-mapping and/or scissor tests than need to be added if you want to limit the water to a small patch rather than an infinite plane (e.g. if you wanted to render a lake/shore rather than something in the middle of the ocean).

Also there is a lot of CPU-side calculations that need to be done. It uses a limited raster algorithm to interpolate across Perlin noise height-map textures (generated at runtime on the CPU) to position the vertices (also done on the CPU). This raster algorithm is also used to create normal maps on the fly to represent the high-level detail that cannot be captured in the geometry.

However, given these limitations, it is a good water renderer. The speed isn't top-notch (22-28 fps on my Radeon 9600), but this I think is more CPU-bound than GPU-bound (due to the software raster of the height & normal maps). I'm pretty sure you could send more the the GPU without large performance penalty. The issue is that your CPU allocation for AI, physics, etc is going to be adversely affected.

The HLSL is incredibly simple to implement in GLSL, so OpenGL implementation would not be a problem.

All in all, if I were making a game with a significant water component, I would add this to Irrlicht in a heartbeat. It would not likely make it into the "official" distribution though because it relies on the co-operation of a variety of components (a view camera, a "projection" camera, and a fast software rasterizer for positioning the vertices and creatinig the normal map). In other words, it doesn't really fit the "generic engine" concept as one would tailor it for any game it was used in. I estimate (for an intermediate programmer not directly copy & pasting) around two days effort to implement and test given the paper and code available.

--EK
JPulham
Posts: 320
Joined: Sat Nov 19, 2005 12:06 pm

Post by JPulham »

I was thinking of implementing this... but looks like theres lots of willing volunteers who would do a better job :D
pushpork
noreg
Posts: 158
Joined: Fri Jun 23, 2006 6:01 pm
Location: continental europe

Post by noreg »

Please "programmer gods" get your efforts coordinated, cause we humble mortals need the shader. :lol:
JPulham
Posts: 320
Joined: Sat Nov 19, 2005 12:06 pm

Post by JPulham »

HERE HERE. Looking at the concept its not really that hard... its more to do with motivation and time i think :?
pushpork
jAyTeA
Posts: 36
Joined: Wed Sep 06, 2006 7:50 am
Location: Hattorf am Harz, Germany

Post by jAyTeA »

I would die for having this water in my project!
This is so amazing!

Please someone implement this!
I haven't got time at the moment so i can't do it
JPulham
Posts: 320
Joined: Sat Nov 19, 2005 12:06 pm

Post by JPulham »

I have some comments: maybe a 'perpixel fog' could be applied where the camera is under water? if you go under ATM it just disappears. I dunno... I'll leave it to you. The simplest method (but most annoying) would be to turn fog on where the camera.pos.y < water.pos.y
pushpork
Eternl Knight
Posts: 313
Joined: Tue Nov 01, 2005 5:01 am

Post by Eternl Knight »

Well, as I mentioned - I do not have the need for the shader and hence, given my workload, am unable to implement it. I thought I would share my analysis for those that might be intimidated and/or think that Irrlicht could handle it "as is" (it cannot, there are a few features that need to be made specifically for the "shader" to work).

I apologise if anyone thought that I would be working on it. If it had already solved the (underwater issue), I might have done it for the hell of it. But as my needs do not include super cool looking waves - I cannot justify the time need to implement it and do something about the underwater issue. Especially given (due to the naturee of Irrlicht development & the changes required), the patch would need to be rejiggered everytime a new version of Irrlicht was released.

--EK
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

bitplane wrote::shock: eye-poppingly good!
rogerborg was looking for a realistic ocean effect, think this one is good enough? :D
That's actually too good for my purposes. It looks lovely though.
Post Reply