Truevision3D

Projects => Showcase => Topic started by: Zaknafein on May 12, 2006, 11:35:26 AM



Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Zaknafein on May 12, 2006, 11:35:26 AM
New version as of July 7th 2007 :
- Much better interface, to see the different effects without touching the shader
- Self-contained Water class which would work alone in any TV3D project as-is (really!)
- Fixed fog support for all shader models and fog types (it never actually worked in SM3.0 before)
- Overall cleaner code
- Bloom!
- Lyon/Blinn specular reflections for long grazing specular highlights.

See the in-development thread (http://www.truevision3d.com/phpBB2/viewtopic.php?t=14268) for more information.

I will not update this sample anymore. That includes ports, enhancements, new features, fixes, optimizations, name it.

Also, I have seen someone on an XNA forum that used my code and textures to build his water shader and claimed it its own. I'd really like it if anyone that uses it would at least credit me (i.e. place my name somewhere, do not appropriate my work). Also I did mention below that the textures were made using trial software, and cannot be used in a commercial project!

New version as of August 1st 2006 :
- Better specular reflection;
- Fog support for both SM2.0 and SM3.0;
- Foam sprays can be disabled with a shader pre-processor (#define);
- Recompiled with newest TV6.5 DLL;
- Cleaned the codebase a little, easier to understand and to play with.

New shots :
(http://zaknafein.hjcrusaders.com/samples/Water/thumbs/blinnphong1.jpg) (http://zaknafein.hjcrusaders.com/samples/Water/blinnphong1.jpg)
(http://zaknafein.hjcrusaders.com/samples/Water/thumbs/bloomed2.jpg) (http://zaknafein.hjcrusaders.com/samples/Water/bloomed2.jpg)
(http://www.zaknafein.hjcrusaders.com/samples/Water/thumbs/Revamped2.jpg) (http://www.zaknafein.hjcrusaders.com/samples/Water/Revamped2.jpg)(http://www.zaknafein.hjcrusaders.com/samples/Water/thumbs/Revamped1.jpg) (http://www.zaknafein.hjcrusaders.com/samples/Water/Revamped1.jpg)

---

Finally, I've decided to make my shader open-source and free for everyone.

But I have one thing to ask you. Do not just take the shader and fit it in your app like a plug-in. There are TONS of customizations possible with the parameters, constants and compilation flags in the shader and in the code, play with them, adapt the shader to your tastes, or even better, learn HLSL and optimize it to your needs!!
The constants should not normally be changed, but you can play with them. The parameters are the things you want to play with in normal circumstances.
And of course if you have artists in your team or are one yourself, try to make other wave parallax maps to see how it'd look like... :)

The shader code is fully commented so it should be readable. I commented the TV3D code a bit too.
I optimized it as much as I could considering how versatile it is. The simplest configuration takes only 34 pixel shader arithmetic instructions, but the worst-case takes 50 (which makes it compatible SM2.0). I still think it's a very usable shader in a game environment.

Edit : The 3D parallax map (shown in the screenshots) was made using a trial version of CGSD's Bump Texture Tools (http://www.cgsd.com/bumptexture/), so I guess you wouldn't be allowed to use it in a commercial project. You'd need to pay for the app or make your own with another program. I've tried a couple of alternatives (Texture Maker (http://www.i-tex.de/news.php) generators, Photoshop clouds and noise) and this prorgam made the best seamless heightmaps.

You should know that this water is great when there's nothing that collides with it, since it's just a water plane (very little polygons) and there is no vertex displacement in the vertex shader. All "depth" effects are done via parallax mapping in the pixel shader. That means that a boat on the surface of a water plane like mine would never have slopes to climb or fall from.

--

And the download link : http://zaknafein.hjcrusaders.com/samples/Water/Water.rar (9 Mb)


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: newborn on May 12, 2006, 12:24:48 PM
:shock: tabern!


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: WEst on May 12, 2006, 12:35:44 PM
omg, i think I'm dreaming  :shock:


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: AriusMyst on May 12, 2006, 01:04:13 PM
Thanks Zak, I was hoping you were gonna release this. It will be very educational for me in my HLSL learning.  :)


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Migajek on May 12, 2006, 02:50:19 PM
Amazing, as always ;)


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Oxygen on May 12, 2006, 02:55:24 PM
I think it's time to add water to my engine. This water is top notch IMO. Thank you for your contribution.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: rootsage on May 12, 2006, 04:44:43 PM
YES!!! Thank you Zak, you are awesome! :D I'm so happy I have a awesome shader to play with now...

-Eric


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: phether on May 12, 2006, 08:15:55 PM
One Word.

Drool!

As always Zak. Nice Job!


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Raine on May 12, 2006, 08:45:15 PM
Thanks, and thanks, and thanks again! :D


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: darqSHADOW on May 12, 2006, 10:28:15 PM
Just tested on my system and I manage to hover right around 300fps with one video card, and over 450ftp average when in DualSLI mode.  :D  Good work, Zak, and an amazing sample for people!

DS


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Zaknafein on May 12, 2006, 10:30:46 PM
Excellent DS! :D I was a little worried about performance, that's good to hear.

And thanks alot everyone!! Do ask if you have questions about the sourcecode or implementation, etc...


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: darqSHADOW on May 13, 2006, 11:12:47 AM
This is not the thread to complain about 6.5 not being out.  So don't start.

DS


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Happy on May 14, 2006, 05:29:53 PM
:shock:  OMG Zak Awesome work!!!  I have only a geforce FX 5500 (need to upgade soon) :lol:, but i was exspecting like 7-10 fps... nope I hit around a good 29 looking down at the shader, and  40-45 moving across it  im very impressed man TV is extremely fast, ima look into shaders now thanks. :)


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Dan on May 15, 2006, 07:50:44 AM
Blimey Zak, Like it or not I think your going to be stuck with the King of shaders title! Thats a very impressive sample, Thank you for providing source code :)


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: oconnellseanm on May 15, 2006, 10:31:25 PM
Do you have to have Truevision3D 6.5 to run this?  I tried running it and it crashes.  I then debugged it in VS 2005 and it said it was missing Truevision functions.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: rootsage on May 15, 2006, 10:34:21 PM
Yep, check the title of the post "Zak's Ocean Shader Freely Downloadable [6.5]"

:D


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: tweakbox on May 15, 2006, 11:02:38 PM
Quote from: "Happy"
:shock:  OMG Zak Awesome work!!!  I have only a geforce FX 5500 (need to upgade soon) :lol:, but i was exspecting like 7-10 fps... nope I hit around a good 29 looking down at the shader, and  40-45 moving across it  im very impressed man TV is extremely fast, ima look into shaders now thanks. :)


Hrm, I've got a 4800+ dual core cpu, 2 gigs of very high-performance memory, and an ATI Radeon X1900XT 512 meg graphics card, complete with 48 pixel processing pipelines, and in both windowed and fullscreen I get around 35 FPS max, with 22 or so when I look right down at the water.  I'm fairly sure I've turned off all the happy settings in the graphics card drivers, but there's a bunch of happy settings in that thing, so I may have missed one.

Seems like I should be getting at least a few more FPS out of it though...


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: rootsage on May 15, 2006, 11:10:45 PM
I have a 4800+ Dual Core, 2 Gigs of Corsair XMS RAM, and 2 7800GTX running in SLI and I get 550 - 600fps. It has to be the config of your card tweakbox.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Oxygen on May 16, 2006, 01:14:10 AM
This is fantastic!

I'm not getting reflections though, haven't found any errors relating to it.

edit: nevermind, I wasn't trying hard enough. Looks great!


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Zaknafein on May 16, 2006, 06:25:44 AM
Quote from: "tweakbox"
Hrm, I've got a 4800+ dual core cpu, 2 gigs of very high-performance memory, and an ATI Radeon X1900XT 512 meg graphics card, complete with 48 pixel processing pipelines, and in both windowed and fullscreen I get around 35 FPS max, with 22 or so when I look right down at the water.

That's odd... Try enabling TV's profiler and check what's taking the most time to render. It'll probably be the waterMesh.render, but just to make sure.
And I don't know how well my shader reacts with anti-aliasing and very high anisotropic filtering on. Make sure you've got that turned off.
Or last resort, try disabling some compilation flags in the shader, like parallax-mapping and detail normal-mapping. Mostly those two.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: oconnellseanm on May 16, 2006, 08:22:38 AM
Quote from: "rootsage"
Yep, check the title of the post "Zak's Ocean Shader Freely Downloadable [6.5]"

:D


Well is there no way to distribute the TV 6.5 DLL files with the app?


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: tweakbox on May 16, 2006, 08:28:41 AM
That's against the current beta license agreement.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: darqSHADOW on May 16, 2006, 09:57:30 AM
Quote from: "tweakbox"
Quote from: "Happy"
:shock:  OMG Zak Awesome work!!!  I have only a geforce FX 5500 (need to upgade soon) :lol:, but i was exspecting like 7-10 fps... nope I hit around a good 29 looking down at the shader, and  40-45 moving across it  im very impressed man TV is extremely fast, ima look into shaders now thanks. :)


Hrm, I've got a 4800+ dual core cpu, 2 gigs of very high-performance memory, and an ATI Radeon X1900XT 512 meg graphics card, complete with 48 pixel processing pipelines, and in both windowed and fullscreen I get around 35 FPS max, with 22 or so when I look right down at the water.  I'm fairly sure I've turned off all the happy settings in the graphics card drivers, but there's a bunch of happy settings in that thing, so I may have missed one.

Seems like I should be getting at least a few more FPS out of it though...


Something is surely wrong on your end, Tweak.  Look at the previous page for how my system handled the demo, even with a single card I blew your FPS away, and my CPU is only a 3800+, but I have 4GB of RAM.

DS


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Oxygen on May 16, 2006, 12:35:05 PM
I'm running this Water (dual mode) with the HLSL Sky Zak created along with a landscape & 100 cylinders for tree placeholders, with shadows.

anisotropic & 16X AA. Looks fantastic 200+ FPS at 1280x1024 on a 7800GTX, 2gig ram, Athlon 64 3000+


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: tweakbox on May 16, 2006, 12:43:41 PM
Ok, so yea, I'm going to have to look into this or throw my video card against the wall.

I was going to have dual 7900 GT's, but the BFG ones I got kept comming with broken cap's.  I went through 3 RMA replacements with Newegg over that crap before I decided to just get the ATI card instead.

But seriously, I'm going to look into this tonight after work.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Zaknafein on May 16, 2006, 02:30:18 PM
Great to hear Oxygen :)
By the way, the dual-lookup texture I provided kinda stinks. It's way too harsh, and at high waveAmplitude settings it makes the fresnel look wierd.
Taking a single frame from the volume texture for dual-lookup makes it looks better IMO, if you wanna try that out.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: darqSHADOW on May 16, 2006, 02:53:50 PM
Quote from: "tweakbox"
Ok, so yea, I'm going to have to look into this or throw my video card against the wall.

I was going to have dual 7900 GT's, but the BFG ones I got kept comming with broken cap's.  I went through 3 RMA replacements with Newegg over that crap before I decided to just get the ATI card instead.

But seriously, I'm going to look into this tonight after work.


Wierd man.  I'm running dual BFG's myself and I've never had a problem.  This is the 6th and 7th BFG cards I've owned, prior to this I had some ATI cards, and then before that I went thru about 12 GF cards in one year (swearing I'd never go back to them)...  Until I found BFG...  ;)

DS


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: tweakbox on May 16, 2006, 03:04:16 PM
Quote from: "darqSHADOW"
Quote from: "tweakbox"
Ok, so yea, I'm going to have to look into this or throw my video card against the wall.

I was going to have dual 7900 GT's, but the BFG ones I got kept comming with broken cap's.  I went through 3 RMA replacements with Newegg over that crap before I decided to just get the ATI card instead.

But seriously, I'm going to look into this tonight after work.


Wierd man.  I'm running dual BFG's myself and I've never had a problem.  This is the 6th and 7th BFG cards I've owned, prior to this I had some ATI cards, and then before that I went thru about 12 GF cards in one year (swearing I'd never go back to them)...  Until I found BFG...  ;)

DS


Yea, I've had 10 or so BFG cards.  That was just some sort of issue they had with the early runs of that card I think, because other people had the same trouble.  I would have waited, but I had no video card at that time, so I was a little anxious ;)

But I'm seriously going to take a look into this in an hour or so and report back here what I find.  Is anyone else running this sample on an ATI card by chance?  It would be nice to know if there is a broader issue here.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: tweakbox on May 16, 2006, 04:34:51 PM
Ok, that doesn't make me feel so bad anymore.  I must have missed a setting, or done something odd.  I just turned off all of the special stuff in my graphics card drivers and now I get 700 FPS looking at the land, and about 500 looking right down at the water in fullscreen @ 1360x768.

Definately a great job on the shader though Zak.  I'm going to be messing around with this here to see what kind of nifty stuff I can come up with.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Mietze on May 22, 2006, 03:10:27 PM
Hi everyone, this is e!

Err.. I dunno where to start.. :)
I'm very impressed of Zak's shader.. its real eyecandy. Anyhow, i needed a good watershader for my game to simulate oceans and moving rivers, so i took it and modified it the last three days. It was a LOT of hard work and many hours of reading related theories, but the result is very impressive!

Quote from: "Zaknafein"
Do not just take the shader and fit it in your app like a plug-in. There are TONS of customizations possible with the parameters, constants and compilation flags in the shader and in the code, play with them, adapt the shader to your tastes, or even better, learn HLSL and optimize it to your needs!!
This is exactly what i did. I sure hope I didnt violated his copyright.

Quote from: "Zaknafein"
The 3D parallax map (shown in the screenshots) was made using a trial version of CGSD's Bump Texture Tools, so I guess you wouldn't be allowed to use it in a commercial project.
My game (Zara'ur) is non-commercial, so there wont be a problem.

So what did i modify? Its simple: I removed specular/foam, optimized the whole code, added an alphamapped diffusemap, optimized fresnel, added real refraction based on the alphamap and.. a lot of other things. The shader is optimized now, runs with 28 instructions and on my machine in this little testlevel at ~630FPS.

(http://www.e-studioz.de/files/water_final01.jpg)

(http://www.e-studioz.de/files/water_final02.jpg)

(http://www.e-studioz.de/files/water_final03.jpg)

(http://www.e-studioz.de/files/water_final04.jpg)


Comments are welcome  :wink:


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Oxygen on May 22, 2006, 03:31:35 PM
That is some sexy caribbean water you've got there. Very nice.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Zaknafein on May 22, 2006, 04:21:57 PM
Excellent!! :D

I'm glad someone made something totally different from what it originally looked like... the refraction looks great!
28 instructions? Wow, that rocks. Congratulations! :)

If it's not too much to ask, what do you mean by "real refraction based on the alphamap"? The alpha channel of the diffuse map you added?
Edit : If I am not mistaken, you removed the detail normal-map as well...?


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: potato on May 22, 2006, 04:55:22 PM
Very very nice Mietze :D You shader guys never cease to amaze.

I'm waiting for a shader that simulates the waves crashing against the shores *whip* get to work! :D


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Taneas on May 22, 2006, 09:51:09 PM
you shoud share :)


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Raine on May 22, 2006, 10:35:52 PM
It looks really, really cool Mietze. And I agree with Taneas about the sharing ^^.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Mietze on May 22, 2006, 11:47:08 PM
Thanks everyone, i hoped youd like it! :)

Quote from: "Zaknafein"
If it's not too much to ask, what do you mean by "real refraction based on the alphamap"? The alpha channel of the diffuse map you added?
Yup. The refraction is only there calculated, where the water is semi-transparent (near the coast).

Quote from: "Zaknafein"
Edit : If I am not mistaken, you removed the detail normal-map as well...?
Yes. The detail normalmap pimped the specular lighting a lot, but without the specular lighting there is no big need for it anymore :)


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Waterman on May 23, 2006, 01:48:08 AM
I have a question. Since you call these "ocean waves" i'd like to ask what you do to cover large areas with the water surface (since an ocean is rather large : -))? I take it this surface is a s quare? How big is the square, and what happens when the camera approaches the edge of the square?


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Rynus_Rein on May 23, 2006, 03:16:50 AM
I think the water then just stops continuing like you reach the end of a plane.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Mietze on May 23, 2006, 06:56:56 AM
Quote from: "Waterman"
I have a question. Since you call these "ocean waves" i'd like to ask what you do to cover large areas with the water surface (since an ocean is rather large : -))? I take it this surface is a s quare? How big is the square, and what happens when the camera approaches the edge of the square?
There cant be continous water, as you may know. But you can scale your waterplane as you want to. You just have to fit your UV-scale and tell it the shader. The diffusemap is clamped to the terrain so the water outside the terrain cant have special watercolors. The reflection- and refraction-maps are clamped to the projected view, so there are no limitations with the waterplane.  :wink:


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Zaknafein on May 23, 2006, 06:59:24 AM
Yea, I didn't make any plane size management...
An easy workaround : put ludicrously large values to the plane, and add "clip(IN.dist - 1000);" as the first pixel shader instruction, and add a "OUT.dist = dist(worldPos.xz, camPos.xz);" to the vertex shader or something similar. That would limit the viewable size of the plane yet have a "virtual plane" that's so large that it does not seem to end.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Waterman on May 23, 2006, 08:31:38 AM
Quote from: "Mietze"
There cant be continous water, as you may know.

Of course there can be. For rendering purposes, you could well constuct the relevant dynamic maps out of several landscape-bound static ones. Or page. You just decide when it's fake time.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Mietze on May 23, 2006, 09:17:51 AM
Quote from: "Waterman"
Quote from: "Mietze"
There cant be continous water, as you may know.

Of course there can be. For rendering purposes, you could well constuct the relevant dynamic maps out of several landscape-bound static ones. Or page. You just decide when it's fake time.
Indeed, you hit the point: fake. ;) 'Real' continous water with a high scaled plane isnt a good solution  :wink:


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Mietze on May 24, 2006, 08:19:55 AM
Sry for the doublepost, but i finally implemented it into my editor. You are now able to generate the diffusemap by specific colors and transparency per click - and the result is beautiful :)

http://www.e-studioz.de/index.php?page=project&subpage=media&action=show&id=30
(Click on the image to expand its size)


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: J on May 25, 2006, 06:40:21 AM
hi there,

first of all, this is really cool stuff! respect to Zaknafein, truly suitable to show what tv can do! i'd like to convert this demo to c++ but have some troubles with overloaded operators:

(all snippets are part of the 'updateWater' function from the file 'Water.cs')


QUESTION 1

variable types (in c++):

Code:
cTV_3DMATRIX reflView = gTVCam->GetRotationMatrix();
cTV_3DMATRIX* m_reflectMat;


the c# source says:
Code:
reflView *= m_reflectMat;


does the following line do the same?

Code:
gTVMathLib->TVMatrixMultiply(&reflView, &reflView, m_reflectMat);


(i tried to multiply two non-pointer cTV_3DMATRIX variables but the overloaded * operator does not work)




QUESTION 2

c# source:
Code:
TV_4DVECTOR clipPlane = new TV_4DVECTOR();
...
TV_4DVECTOR q;
...
TV_4DVECTOR scaledPlaneVector = clipPlane * (1.0f / (clipPlane * q));



my c++ converting attempt due to the lack of overloaded operators (or due to my lack of knowledge how to use these..):


Code:
cTV_4DVECTOR clipPlane;
cTV_4DVECTOR q;
cTV_4DVECTOR scaledPlaneVector;

q.x = sign(clipPlane.x) / culledProj.m11;
q.y = sign(clipPlane.y) / culledProj.m22;
q.z = 1.0f;
q.w = (1.0f - culledProj.m33) / culledProj.m43;

scaledPlaneVector.x = clipPlane.x * (1.0f / (clipPlane.x * q.x));
scaledPlaneVector.y = clipPlane.y * (1.0f / (clipPlane.y * q.y));
scaledPlaneVector.z = clipPlane.z * (1.0f / (clipPlane.z * q.z));
scaledPlaneVector.w = clipPlane.w * (1.0f / (clipPlane.w * q.w));



does this c++ code do the same as the c# source? or is the * operator an alias for cross or dot product?


thanks in advance for shedding any light on this
cheers
j


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Zaknafein on May 27, 2006, 10:58:31 PM
@J :
I don't know if the operators are overloaded in C++, since I haven't used TV3D with C++ and I don't really know C++ anyway :P

But as far as I can tell...
The first code part (using TVMatrixMultiply) looks good.
And there is no overloaded operator that replaces dot nor cross product. Still have to pass through TVMathLib for that. So the second code part looks quite right as well.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: J on May 28, 2006, 05:31:33 AM
@zaknafein:

thanks for the info! unfortunately, i still get only a dark blue plane: no reflections, no waves, no nothing.. i guess i have to learn how to use render surfaces / shader stuff because this ocean shader really rocks!!

where are the c++ people? i converted the c# code line per line to c++ but it does not work. textures / shaders are all loaded correctly..

thanks again,
cheers
j


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Solar on July 12, 2006, 09:32:25 AM
like we say in dutch at The Hague: Tering, das vet!!!
Translation: *curse* , this looks awesome!!!


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Dragoon on July 13, 2006, 05:45:23 AM
or at the veluwe (also in the Netherlands): dat is godse vet!!
wich is translated to something like: that's godlike!!


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Zaknafein on July 31, 2006, 11:24:44 PM
Small updates, bugfixes and added features. See first post for details.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: pizzayoyo on July 31, 2006, 11:48:55 PM
Hmm... While running the executeable I am getting a System.MissingMethodException. Maybe I need to download C# to see whats wrong.

Btw, i have MTV3D65.dll and DXD9X.dll in the folder.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Zaknafein on August 01, 2006, 10:06:58 AM
I don't know man, I just tested it at work on a clean machine, with the latest MTV3D65 and D3DX9_29 in the executable directory. No problem...  :?


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: sigi on August 01, 2006, 10:11:44 AM
Works without Probs here.
Thank You, great work.   :)


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: nikko on August 24, 2006, 05:38:18 AM
Do you want to host your files on a speed server? Because your link is damn slow currently!
I host them on my decicated server.


Nikko


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Zaknafein on August 24, 2006, 08:17:49 AM
I would like that yes... because the current host is my home machine on a humble ADSL. If you want to host, I'll place the link on the front page.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: nikko on August 24, 2006, 09:24:14 AM
It is maybe a stupid question but when I run water.exe from the release directory I get a "file not found" exception.
Where this exe should be copied?


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Rynus_Rein on August 24, 2006, 09:38:39 AM
do you've got 6.5?


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: nikko on August 24, 2006, 09:52:09 AM
yes!

Today. But I can't run any examples. I always have this kind of exceptions. I've copied the DLLs in the system directory, but no way.

Nikko


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: nikko on August 24, 2006, 10:08:39 AM
Ok it works now... was just a matter of tweaking things.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Shadowsong on November 07, 2006, 09:23:47 AM
Hm I tried to translate this to Vb .NET but it just renders a dark green-blue plane. The landscape renders fine. But the water is just an empty plane. no reflections, no shading, no movement.

What about translating this into VB.NET Zak? Your other demos were written in VB. too.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Raul on November 07, 2006, 11:05:51 AM
I will like to test it but I do not have 6.5 :( and it does not work ... :( I like the shots :D


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Rynus_Rein on November 07, 2006, 01:29:45 PM
Quote from: "nikko"
yes!

Today. But I can't run any examples. I always have this kind of exceptions. I've copied the DLLs in the system directory, but no way.

Nikko

I heard a rumour that installing Adobe Reader fixes some kind of problems :/


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Zaknafein on November 07, 2006, 03:03:52 PM
I don't have the time right now to translate it, but I definitely will some time.
Like I said on my blog/webpage, most samples (including this one) will need some updating because of the new features of the latest TV3D build. I'll tell you once it's done...


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Gamecode on November 20, 2006, 11:28:22 AM
pls.
how to make this GREAT efect in VB 6 + tv6.5?


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Zaknafein on November 20, 2006, 12:44:39 PM
No problem, just port the C# code to VB6 and it should work well. :)


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: TMichael on January 26, 2007, 01:09:01 PM
Just so this topic doesn't get buried, I have to say... wow! Beautiful work with the shader Zak. I recently chose TV3D for my project (I will upgrade to 6.5/license soon), and those water shader pics were one of the many selling points. I can't wait to begin experimenting with them myself.

Cheers,
Tim


Title: hey
Post by: sciophyte on February 08, 2007, 01:55:11 AM
finally at the point to get some of the graphics done and i've kept tabs on this for future reference, i'm trying to port it into vb6 but i'm not quite sure what to do with this...

Code:

q.x = Math.Sign(clipPlane.x) / culledProj.m11;
q.y = Math.Sign(clipPlane.y) / culledProj.m22;
q.z = 1.0f;
q.w = (1.0f - culledProj.m33) / culledProj.m43;
TV_4DVECTOR scaledPlaneVector = clipPlane * (1.0f / (clipPlane * q));


anyone have experience in both languages that can give me a hand?

thanks


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: BlindSide on February 08, 2007, 10:14:05 AM
I'm not sure what's so difficult about porting that - the VB6 code should be practically identical. Let's see what the problem is maybe?


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Zaknafein on February 08, 2007, 11:22:50 AM
This is the new update code for my water shader, which will be in the new version... It's much simpler thanks to new tv3d functions :

Code:
       public void Update()
        {
            TVCamera viewportCamera = Core.Viewport.GetCamera();
            TV_3DMATRIX reflView = viewportCamera.GetRotationMatrix();
            TV_3DVECTOR camPos = viewportCamera.GetPosition();

            // View matrix reflection 1
            reflView.m41 = camPos.x;
            reflView.m42 = camPos.y;
            reflView.m43 = camPos.z;
            maths.TVMatrixReflect(ref reflectMat, waterPlane);
            reflView *= reflectMat;

            // View matrix reflection 2
            // Using two reflections allows not to reverse the culling mode on reflected geometry
            // Thanks for the tip, Sylvain :)
            TV_PLANE comb = new TV_PLANE();
            TV_3DVECTOR vec = reflView.RowVec3(3);
            TV_3DVECTOR vec2 = vec + reflView.RowVec3(2);
            TV_3DVECTOR vec3 = vec + reflView.RowVec3(1);
            maths.TVPlaneFromPoints(ref comb, vec, vec2, vec3);
            maths.TVMatrixReflect(ref reflectMat, comb);
            reflView *= reflectMat;

            waterCamera.SetMatrix(reflView);

            reflectRS.StartRender();
            waterCamera.SetProjectionClipPlane(false, waterPlane);
            renderDistant.Invoke();
            waterCamera.SetProjectionClipPlane(true, waterPlane);
            renderClose.Invoke();
            reflectRS.EndRender();
        }


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Waterman on February 08, 2007, 01:33:35 PM
What is all that code? :-)

I use:

At creation:
Code:
camReflex.SetCustomProjection #.TV.Camera.GetProjectionMatrix
plane=#.TV_PLANE.New 0 1 0 -0.5
camReflex.SetProjectionClipPlane 1 plane


In the loop:
Code:
camReflex.SetPosition #.CAM.WORLDPOS * 1 -1 1
camReflex.SetLookAt (#.TV.Camera.GetLookAt).(x y z) * 1 -1 1
{}surfReflex.StartRender 0
(render stuff)
{}surfReflex.EndRender


I guess i'm just so lazy ...


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Zaknafein on February 08, 2007, 02:05:11 PM
Well I do clipping at runtime because I don't want to clip the skybox, which makes nasty artifacts when the water is very wavy.
The SetLookat alternative is very interesting, it's simpler and probably faster than my matrix stuff :P


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Gamecode on February 13, 2007, 04:09:02 AM
pls pls '!! how to make this water (and shaders generally) in VB 6 ...
can anybody translate or show any any tutorial for shaders + vb6 ? :(


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Gamecode on February 13, 2007, 04:22:06 AM
Quote from: "BlindSide"
I'm not sure what's so difficult about porting that - the VB6 code should be practically identical. Let's see what the problem is maybe?


i dont have (.net ? or what language)


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Lil`Buh on February 13, 2007, 04:43:40 AM
Quote from: "Gamecode"
i dont have (.net ? or what language)


download it for free on microsoft's website... google "Visual Basic 2005 express"


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Gamecode on February 13, 2007, 04:47:08 AM
Quote from: "Lil`Buh"
Quote from: "Gamecode"
i dont have (.net ? or what language)


download it for free on microsoft's website... google "Visual Basic 2005 express"


thanks i download it now ...


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Gamecode on February 13, 2007, 05:35:17 AM
i downlooad , install ... and when opening Water.sln then VB type error : the aplication for project  water.cpoj is not installed , make sure  the aplication  for the project type .csproj  is instaled and same for shaders for vcproj


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Hypnotron on February 13, 2007, 05:45:39 AM
i dont know about all that, but i do know you need the managed dll version of tv3d 6.5 referenced in those projects.  you can find mtv3d65.dll on the beta page.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Gamecode on February 13, 2007, 05:47:26 AM
no change :(


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Lil`Buh on February 13, 2007, 05:54:42 AM
you installed Visual Basic ... and the shader is a C# project...


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Gamecode on February 13, 2007, 05:56:27 AM
oh ... ok,i get istall c#


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Gamecode on February 13, 2007, 12:29:52 PM
ok in c# all run ... bud FPS :(
only 50 on 1024*768 ,,,, clasics water run 160 - 170 Fps .... when this use in game, its be too slow :(


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Zaknafein on February 13, 2007, 12:35:31 PM
From the original post :
Quote
But I have one thing to ask you. Do not just take the shader and fit it in your app like a plug-in. There are TONS of customizations possible with the parameters, constants and compilation flags in the shader and in the code, play with them, adapt the shader to your tastes, or even better, learn HLSL and optimize it to your needs!!

The FPS difference with TV's water is very normal. This water does a lot of things TV's water doesn't do. You can customize it to improve the speed, but you'll never reach the same.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Gamecode on February 13, 2007, 12:43:56 PM
thanks for info zak.
i.a. water look GREAT !


and  my question : is possible how to set in TV6.5 clasics water  smaller reflection (default is like giant mirror) :(


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Zaknafein on February 13, 2007, 12:49:22 PM
Sure, check out AGT's third person demo for an example of properly used TV water. It can look pretty good.
http://www.truevision3d.com/phpBB2/viewtopic.php?t=13697


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Gamecode on February 13, 2007, 01:10:08 PM
thanks... great.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Gamecode on February 13, 2007, 05:16:54 PM
AGT' s water is good, bud not can set water collor , less reflections etc.

i simplify you watershader in C#  (run) and then retype to VB6 .. shader is create (in log), bud nothing showing .. nothing :(

 
your  program.cs
Code:

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using MTV3D65;

namespace Water {
    static class Program {
        static Viewport _viewport;
   
        static TVCamera _camera;
        static Settings _settings;

     
        static readonly string PATH_BASE = Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf(@"\bin\"));
        static readonly string PATH_MEDIA = PATH_BASE + @"\Textures\";
        public static readonly string PATH_SHADERS = PATH_BASE + @"\Shaders\";

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main() {
            Initialize();
            Mainloop();
        }

        static void Initialize() {
            // Show an information getter
         
         
     

            // Fetch the infos
       

            // Do we want to continue?
            if (infoGetter.HasQuit) return;

            // Kill it
            infoGetter = null;

            // Init engine and viewport
            _viewport = new Viewport();
            Core.Initialize(_viewport, _settings);

            Core.Engine.SetSearchDirectory(PATH_MEDIA);

            // Init environment and water
            _camera = new TVCamera();
            Core.Engine.SetCamera(_camera);
            _camera.SetPosition(0, 60, 0);

            Water.InitWater();
        }

        static void InitEnvironment() {
         

        }

        static void Mainloop() {
            bool keepLooping = true;

            while (keepLooping) {
                Application.DoEvents();
                keepLooping = !Core.Inputs.IsKeyPressed(CONST_TV_KEY.TV_KEY_ESCAPE);

                Core.Engine.Clear();
                Water.RenderWater();
                Core.Engine.RenderToScreen();

            }
        }
    }
}




and  water.cs (i need only this two "source codes ????"

Code:


using System;
using System.Collections.Generic;
using System.Text;
using MTV3D65;

namespace Water {
    class Water {
        // Height of the water plane
     
        // Fix for reflection glitches where water hits the land
     

        static TVShader _waterShader;
        static TVRenderSurface _reflectRS;
        static TVMesh _water;


        public static void InitWater() {
            // Load related textures
            // Comment/uncomment the right texture depending on the method you use
            Core.TexFact.LoadVolumeTexture(@"Water\VolumeNormalMap.dds", "WaterVolume", CONST_TV_COLORKEY.TV_COLORKEY_USE_ALPHA_CHANNEL, true);
            //Core.TexFact.LoadTexture(@"Water\\NormalMap_DXT5NM.dds", "WaterDual");

            // Rendersurfaces init
            _reflectRS = Core.Scene.CreateRenderSurface(384, 384, true, CONST_TV_RENDERSURFACEFORMAT.TV_TEXTUREFORMAT_X8R8G8B8);
         
            // Water init
            _water = Core.Scene.CreateMeshBuilder("Water");
            // The texture tiling of the grid defines how tiled the waves will be
            _water.AddFloorGrid(1, -5000, -5000, 5000, 5000, 32, 32, 50, 50, 50);
            _water.SetTextureEx(0, _reflectRS.GetTexture());

            // Comment/uncomment the right texture depending on the method you use
            _water.SetTextureEx(1, Core.Globals.GetTex("WaterVolume"));
            //_water.SetTextureEx(1, Core.Globals.GetTex("WaterDual"));

         

            _waterShader = Core.Scene.CreateShader("WaterShader");
            _waterShader.CreateFromEffectFile(Program.PATH_SHADERS + "WaterShader.fx");

            // Set the shader parameters
            _water.SetShader(_waterShader);

        }

     

        public static void RenderWater() {
            _water.Render();
        }
    }
}







and i retype this code to VB6


create water and shader
Code:


Private Sub init_water()
 
TextureFactory.LoadVolumeTexture "c:\VolumeNormalMap.dds", "watertex", TV_COLORKEY_USE_ALPHA_CHANNEL, True
Set RenderSurf1 = Scene.CreateRenderSurface(384, 384, True, TV_TEXTUREFORMAT_X8R8G8B8)
Set WaterMesh = Scene.CreateMeshBuilder
WaterMesh.AddFloorGrid 1, -5000, -5000, 5000, 5000, 32, 32, 50, 100, 50

WaterMesh.SetTextureEx 0, RenderSurf1.GetTexture()
WaterMesh.SetTextureEx 1, GetTex("watertex")

Set shader = Scene.CreateShader("shader")
shader.CreateFromEffectFile "c:\WaterShader.fx"
WaterMesh.SetShader GetShader("shader")
End Sub




main loop

Code:

Private Sub Main_Loop()
    Do
        DoEvents
       
        Check_Movement
       
        TV3D.Clear
     

     
         WaterMesh.Render

        TV3D.RenderToScreen
   
    Loop Until DoLoop = False
   
    ' We ask to quit.
    Main_Quit

End Sub




bud when run : nothing showing .... only black :(

i can post here my source code if it helps.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Zaknafein on February 13, 2007, 05:52:04 PM
First, yes you can set the water color with TV's built-in water with TVGraphicEffect.SetWaterReflectionColor.
Second, your code oversimplifies everything. And I'm not going to port it to VB6 at the moment, and neither will I help you doing it step by step, which it looks like you want me doing... So check your debug file, and good luck.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Gamecode on February 14, 2007, 02:04:20 AM
thanks for tip.

ad our water.
yes,i kick out ALL , bud water in C# run , the same i VB not ..... and debug file : your c# and my vb6 is Identical ..... shader created, no error , bud not :(


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: sybixsus on February 14, 2007, 08:56:21 AM
If there's no error in the shader and you don't see anything, chances are that one of more of the textures is not being applied correctly.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Gamecode on February 14, 2007, 09:06:54 AM
maybe .. bud all is only copied and converter to VB ....
i search error later.
now : can i set smaller water reflection (like 50% reflect , no 100%) in TV6.5 default water ? :-D


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Hypnotron on March 04, 2007, 10:21:24 PM
Make sure

1) you have the directional light in the scene
2) the texture paths within the FX file are properly pointing to the right locations.  

First time i tried getting this working i forgot to do this and i wasted half a day.  

Same thing happened to me just now as I incorped it into my new framework. Only this time i remembered after half an hour wasted  :D


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: likedonuts on March 23, 2007, 04:46:01 AM
Looks amazing, thanks or sharing!

Anyone has this poject in VC# 2003?  

/Mike


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Gamecode on July 07, 2007, 02:40:34 PM
reupload od port to vb6 ?


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Zaknafein on July 07, 2007, 03:03:40 PM
Nope, no port for VB6. But I just updated the download link, and put up a new version of the sample too, it should be easier to convert now because the code is much cleaner.


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Gamecode on July 07, 2007, 03:07:13 PM
Quote from: "Zaknafein"
Nope, no port for VB6. But I just updated the download link, and put up a new version of the sample too, it should be easier to convert now because the code is much cleaner.


thanks


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Gamecode on July 17, 2007, 12:09:45 PM
hi,
if i download, install visual c# and try run get this error :


first :  the application for  project "c:\water\media\shaders\shaders.vcproj" is not installed
Warning   78   The referenced component 'MTV3D65' could not be found.    

any ideas ?


Title: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Zaknafein on July 17, 2007, 12:14:06 PM
The vcproj error is nothing important, it's only because I compile the shaders from the Visual C++ IDE but it's not needed for the project to run; you can just remove the VC++ project from the solution.

The MTV3D65 error is because you need to re-reference the TV3D 6.5 DLL in the C# project. Delete the problematic reference and re-add it. Of course you need to be in the beta program...


Title: Re: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: JukkaKevät on August 16, 2007, 03:39:59 AM
Hey I was just playing around with this shader and the vsleepy's underwater one. I noticed the evil issue when getting really close to the water plane (beneath the -5 fix) that the reflections disappear. The fix is there because the rendersurface "can't see inside the land" and thus renders the sky.

I fixed this by making landscape doublesided (disabled backface culling) for the duration of the reflection rendering. It didn't impact performance much and gives me the opportunity to get rid off the fix value. Now I have seamless transition to underwater.

Haven't tested on larger landscapes or more precise landscapes what the performance hit is. Just letting people know if they are struggling with the same issue.

... have to check how to apply the alpha map to get transparent shores...


Title: Re: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: vsleepy on August 16, 2007, 04:39:17 AM
can you see the water plane when you are under water? got a screen shot?


Title: Re: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: JukkaKevät on August 16, 2007, 05:09:40 AM
The water plane is currently very bad if seen from underwater since it reflects the ocean bottom and doesn't catch any specular lighting, all the zaknafein's shader effects are calculated for nothing, so I'm creating another plane which is seen only from underwater and rotate couple of caustic textures on it.

I'll get you screenshots very soon if it works fine, I'll post them on your thread (these two could be merged into one Definitive Water Effects - thread  ;D

edit: I posted the shots on your shader thread


Title: turn to vb.net
Post by: nomadsoul on August 25, 2007, 10:36:26 AM
hi, i try to turn zak hlsl code into vb.net, it hard work because i can't understand c language, but i have already done this :
(http://img208.imageshack.us/img208/1216/clipboard01eo7.jpg)
For the moment the water doesn't look like zak water but i think i'am on the right way, i must change the reflection, and the water animation !

Thanks to you zak i begin to understand c language !  ;D


Title: Re: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: rpiller on August 27, 2007, 05:11:22 PM
There is only one problem with this entire thing. The water looks so amazing it makes the landscape look bad :) When I start working on a game that needs water, I will for sure be looking into this little puppy. Create work indeed.


Title: Re: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: ZaPPZion on September 07, 2007, 09:38:49 AM
Hi,

I've got a couple questions now 6.5 is free to use (so i have it finally (no offence intended)). I'd like to use this water because it's awesome looking, but i've never worked with c++ or c#, but i can understand the language. If i'm not mistaken, only thing i need to port to VB6 is the water.cs file? And then i can make an instance of the class in vb, and use the methods that are inside?. (if zak agrees, and i succeed in porting it to vb6, i can probably post it on the wiki). Do you mind if i try to port it Zak?  ;)

thx in advantage.


Title: Re: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Zaknafein on September 07, 2007, 10:09:15 AM
Of course I don't mind! :)
It's open source, do what you want with it. But good luck porting that to VB6, I used some .NET-specific features like delegates, that may be harder to port. If you have questions/problems you can post them here... it'll help others that are trying to port.


Title: Re: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: ZaPPZion on September 07, 2007, 11:11:37 AM
oh yea, i see, didnt notice that stuff before ;) i'll try and find out if there's actually something like that in VB, or that it's just impossible to do this in VB (might be true, if so, i'll probably learn another language  ::))
so it's just the water.cs right?
btw thx for the quick reply


Title: Re: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Zaknafein on September 07, 2007, 11:39:12 AM
Yep it should contain everything that's needed.


Title: Re: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: DarthSmiley on December 18, 2007, 01:22:32 PM
I started trying to convert this over to the latest 6.5 release, but i've run into a wall..

        Dim vec As TV3D65.TV_3DVECTOR
        Dim vec2 As TV3D65.TV_3DVECTOR
        Dim vec3 As TV3D65.TV_3DVECTOR

        vec = reflview.RowVec3(3)
        vec2 = vec + reflview.RowVec3(2)
        vec3 = vec + reflview.RowVec3(1)
        maths.TVPlaneFromPoints(comb, vec, vec2, vec3)
        maths.TVMatrixReflect(endreflect, comb)
        reflview = endreflect
It would seem that the RowVec3 class is no longer implemented.. What is one to do >_>


Title: Re: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Hypnotron on December 18, 2007, 01:39:33 PM
perhaps something like...

Code:
public TV_3DVECTOR RowVec3(int rowID, TV_3DMATRIX mat)
{
if (rowID < 1  || rowID > 4) throw new ArgumentOutofRangeException();

TV_3DVECTOR row;
switch (rowID)
{
case 1:
row.x = mat.m11;
row.y = mat.m12;
row.z = mat.m13;
break;
case 2:
row.x = mat.m21;
row.y = mat.m22;
row.z = mat.m23;
break;
case 3:
row.x = mat.m31;
row.y = mat.m32;
row.z = mat.m33;
break;
case 4:
row.x = mat.m41;
row.y = mat.m42;
row.z = mat.m43;
break;
}

return row;
}


Title: Re: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Zaknafein on December 18, 2007, 02:23:10 PM
Uh, it's not a class and it's working right here.
It's a method under TV_3DMATRIX :
Code:
public TV_3DVECTOR RowVec3(int iIndex)


Title: Re: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Hypnotron on December 18, 2007, 02:39:00 PM
always forget about these myself.


Title: Re: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: pvel on January 28, 2008, 10:52:14 PM
I'm having trouble getting this to work in my project...
I actually had decent looking water before, but this looks way better :-)
First, thx to Zak for opensourcing this.. Indie gamedev needs this kinda stuff to get things done :-P

I'm using C# for my project, and copied the Water class to my project.. I copied the initWater() method from your source, getting no errors in my debuglog.txt
but I'm not seeing any water. I also call water.render(); of course in my world.render() method.. My skybox works just fine, so it's not a central setting that's wrong.. I just don't see any water.. any suggestions would be more than welcome :-)
There is a lot of code in your example, and I'm having a bit of a hard time figuring out which I need. Seems you also have code for a landscape in it, which is no longer used?

Edit: hmm.. in your screenshots I do see the landscape. when I run your project, I don't see it.. Is that just me, or are the screenshots from an older version?


Title: Re: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: JohnB on January 28, 2008, 11:07:44 PM
Are you sure you got all the shaders, textures, etc. copied to the right places?

Just an idea.

John B.


Title: Re: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: pvel on January 28, 2008, 11:14:41 PM
yep, edited all paths.. double checked them.
Also, errors like that should show up in debug output right?


Title: Re: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: pvel on January 29, 2008, 12:50:22 AM
Here's the source that matters I think, my World class:
Code:
using System;
using System.Collections.Generic;
using System.Text;
using MTV3D65;
using System.Windows.Forms;

namespace game_v1
{
    internal class World
    {
        private Core core;

        private TVTextureFactory textureFactory;
        private TVLightEngine lights;
        private TVAtmosphere atmosphere;

        private Water water;

        public static readonly string PATH_SKYBOX = Core.PATH_MEDIA + @"Skybox\";

        public World(Core core)
        {
            this.core = core;

            textureFactory = new TVTextureFactory();
            lights = new TVLightEngine();
            atmosphere = new TVAtmosphere();
        }

        public void init()
        {
            initSkyBox();

            initWater();
        }

        private void initSkyBox()
        {
            int front, back, right, left, up, down;
            back = textureFactory.LoadTexture(PATH_SKYBOX + "Clouds_NegX.dds");
            down = textureFactory.LoadTexture(PATH_SKYBOX + "Clouds_NegY.dds");
            left = textureFactory.LoadTexture(PATH_SKYBOX + "Clouds_NegZ.dds");
            front = textureFactory.LoadTexture(PATH_SKYBOX + "Clouds_PosX.dds");
            up = textureFactory.LoadTexture(PATH_SKYBOX + "Clouds_PosY.dds");
            right = textureFactory.LoadTexture(PATH_SKYBOX + "Clouds_PosZ.dds");


            atmosphere.SkyBox_Enable(true);
            atmosphere.SkyBox_SetTexture(front, back, left, right, up, down);
            atmosphere.SkyBox_SetScale(5, 5, 5);
        }

        private void initWater()
        {
            #region SETTINGS

            TV_2DVECTOR NormalMapTiling = new TV_2DVECTOR(32, 32);
            int ReflectionSurfaceSquareSize = 384;
            Water.NormalMapMode NormalMapMode = Water.NormalMapMode.VolumeMap;
            String VolumeNormalMapTexturePath = "VolumeNormalMap.512.dds";
            String NormalMapTexturePath = "DualLookupNormalMap.512.VolumeSlice.dds";
            bool ParallaxMapping = true;
            bool DetailNormalMapping = true;
            bool TroubledWaterEnhancements = true;
            bool FoamSprays = true;
            bool LyonBlinnSpecularReflection = false;
            TV_COLOR skyAverageColor = new TV_COLOR(0.5f, 0.62f, 0.77f, 1);

            #endregion


            water = new Water(core, new TV_3DVECTOR(0, 40, 0), new TV_3DVECTOR(4096, 0, 4096), NormalMapTiling, ReflectionSurfaceSquareSize);

            int normalMapTexId;
            if(NormalMapMode == Water.NormalMapMode.VolumeMap)
                normalMapTexId = textureFactory.LoadVolumeTexture(Water.PATH_WATER + VolumeNormalMapTexturePath, "WaterNormalMap", CONST_TV_COLORKEY.TV_COLORKEY_USE_ALPHA_CHANNEL, true);
            else
                normalMapTexId = textureFactory.LoadTexture(Water.PATH_WATER + NormalMapTexturePath, "WaterNormalMap");


            water.Initialize(NormalMapMode, normalMapTexId, ParallaxMapping,
                DetailNormalMapping,TroubledWaterEnhancements,
                FoamSprays, LyonBlinnSpecularReflection);

            if(TroubledWaterEnhancements)
                water.SkyAverageColor = skyAverageColor;

            water.DistantRenderingMethod = RenderDistant;
            water.CloseRenderingMethod = RenderClose;
        }

        public void update()
        {
            water.update();
        }

        public void render()
        {
            RenderClose();
            RenderDistant();
            atmosphere.Atmosphere_Render();
            water.render();
        }

        public void postRender()
        {

        }

        public void RenderDistant()
        {
            atmosphere.Atmosphere_Render();
        }

        public void RenderClose()
        {
        }
    }
}

From what I can see, I'm doing exactly the same as the example source.. The skybox shows fine.. but no water to be found. Am I overlooking something obvious? :-/


Title: Re: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Mietze on October 31, 2008, 02:31:48 PM
I’m translate Zaknafein's example on VB 6. But reflection doesn’t work. Somebody help…  ::)
"Does not work" can be anything... more details! Or would you like to get an error description a la "It won't work, because.. no dice!"


Title: Re: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: ZaPPZion on November 01, 2008, 04:43:22 AM
Does it give an error? does it reflect the wrong stuff? Does it display black? Does anything show up?


Title: Re: Zak's Ocean Shader Freely Downloadable [6.5]
Post by: Gamecode on November 02, 2008, 08:17:17 AM
Reflections are absent.  ???

Screenshots:
http://sergeyxp.narod.ru/screenshots.htm

hi,pls i have big problem make funcionaly watershader in VB6.
can u send me "tutorial" how to create zaks watershader funcionaly in vb6 ? pls !!