Oct 02 2006

Non-Reflective Water

Published by Renaud Bédard at 11:48 under C#, HLSL, Samples, TV3D 6.5

Downloads

NonReflectiveWater.rar [7.9Mb] – C# 2.0 (VS.NET 2005)

Description

I had a request from a MMORPG developer to make a lightweight water shader that doesn’t need a reflection rendersurface, yet looks acceptable.
It looks nowhere as shiny as the reflective water shader or even TV’s built-in water, but it runs a zillion times faster because it doesn’t do any parallaxing, nor specular bumpmapping, nor perspective projection… Its implementation is alot simpler as well.

Features

  • Two test environments : sunset and day skies
  • Uses a L8 (8-bit grayscale luminance) texture for alphablending, which allows semi-transparent shores
  • Two lookups of the same normal-map, scrolling in opposite directions, is used to simulate wave animation
  • Diffuse bump-mapping is made using the composite normal-map
  • A specular/gloss-map defines the specular spots; it’s also bumped by the normal-map
  • Two parameterized colors define the darkest and lightest parts of the water
  • Supports vertex fog in both SM2.0 and SM3.0 paths (this version does not yet map to TV3D semantics… will be updated soon)

Screenshots

11 responses so far

11 Responses to “Non-Reflective Water”

  1. [...] I had a request from the same MMORPG developer which asked me for Non-Reflective Water to make a simpler version of my old “HLSL Sky Demo”, which I haven’t put on my blog yet because I’m not all that proud of the code. [...]

  2. tomon 17 Dec 2008 at 20:35

    Amazing!!!

    VB.NET version,please.

  3. roto23on 14 Apr 2009 at 12:45

    Renaud.

    I cannot get this project to run when I unzip it. I get this message..
    error PRJ0019: A tool returned an error code from “Preforming Custom Build Step”.

    Also, there is a file column and “Shaders” is listed under that column. Any idea? This tutorial is exactly what I was looking for too. A light weight water system so as to not kill my frame rate.

    I have been surfing this web site and your skills are amazing. Also, this is a total shot in the dark but I have to ask… Did you ever play DAOC?, I frequently ran up against a plaer named Zaknafein.

  4. roto23on 14 Apr 2009 at 13:00

    I got past that error by just removing the shader from the project. However, I now get a memory access violation error. I suspect its cause I’m using a new version of the MTV3D65.dll then you did cause I see licsense input boxes. I’ll try and track down an older dll and reference that

  5. Renaud Bédardon 14 Apr 2009 at 13:03

    Yes, the shader project was referencing a tool that is in the DirectX SDK and it’s an old version, so the usage probably changed… deleting the shader project solves this, and it’s not necessary.

    For the other problem, try making it work with the newest TV3D DLLs. There are breaking changes that occured in TV3D since then, like you have to do Scene.CreateLandscape instead of “= new TVLandscape()”, probably other ones… but yeah, running with an old DLL won’t help much.
    You should remove everything about beta keys too.

  6. Renaud Bédardon 14 Apr 2009 at 14:56

    Oh also, Zaknafein is a pretty popular alias, and I’ve never played DOAC. :P

  7. roto23on 15 Apr 2009 at 18:02

    I got most of your tutorial working by making the changes you suggested, thanks. The landscape does not render, but that’s ok since I’m focusing on the water.

    Now here is the unfortunate part for me….When I add your water code (not landscape) to my project I don’t get anything and there are no errors in the debug file. I don’t even see the blank mesh I usually get when something only partially works. Any ideas? it should appear at the coordinates I set in the AddFloorGrid() method, correct?
    I did not add your water class directly, I just copied the code from it and put it in the “code behind” file of my main form.

  8. Renaud Bédardon 16 Apr 2009 at 15:40

    Hard to tell what’s the problem here… Check the TV debug file, maybe you’re missing resources like shaders or textures.
    One thing to keep in mind, this shader uses an alpha (transparency) map that defines the shores and that lets the terrain be visible in those areas.

  9. jpon 15 Oct 2009 at 20:32

    Finally, someone can make it run??
    I can only see the landscape but no the water.
    I’m removing the shader from the project, and removing the “Engine.SetBetaKey(settings but nothing…)” part. but nothing
    I changed this part “Scene.CreateLandscape instead of “= new TVLandscape()” whit the same result.
    any ideas??

  10. Renaud Bédardon 15 Oct 2009 at 21:09

    Hi jp, I just tested it and there seems to be a problem with the SM3 technique of the shader.
    It’s really wierd because it compiles in most compilers (SFxE and XNA) but when I build the effect in TV3D it rejects it.
    Workaround : Remove the SM3 technique and leave only the SM2 one, then it works.

  11. jpon 15 Oct 2009 at 21:38

    Nop, I can not make to run properly, I only can se de landscape but nothing about nonreflect water. Can you explain me more specificly what is the problem? what I need to do? I can not understand the meaning of SM2 and SM3 and how to fix the problem.
    Thanks for your time.

Trackback URI | Comments RSS

Leave a Reply