Doom3world

The world is yours! Doom 3 - Quake 4 - ET:QW - Prey - Rage
It is currently Sun May 26, 2013 12:02 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Seamless Looping Water Texture
PostPosted: Mon Apr 09, 2012 9:54 pm 
Offline
a gun & a nice word
User avatar

Joined: Sat Jan 11, 2003 9:30 pm
Posts: 8713
Location: Orlando, FL
So I've finally worked out a method to create a proper seamless looping image sequence for water. Here's the normal map...

Image

Obviously you can't use GIF in game so here's a PK4 with the TGA image sequence and a material shader to demonstrate how to cycle through the sequence...

http://temp-share.com/show/KdPf3ip3h

The sequence itself looks good but I'm not happy with the limitations of the current renderer so let's see what you guys can do with it.

This was done almost entirely with Blender and I'll elaborate on the process if there is interest.

_________________
Image Staff
Learn something today? Why not write an article about it on modwiki.net?


Top
 Profile  
 
 Post subject: Re: Seamless Looping Water Texture
PostPosted: Tue Apr 10, 2012 1:41 am 
Offline
is sad because his cool title went away
User avatar

Joined: Sun Aug 15, 2004 6:59 am
Posts: 748
Location: Some creature's lair
Very cool. This definitely looks like a fluid / liquid!

_________________
MBolus
Le mieux est l'ennemi du bien


Top
 Profile  
 
 Post subject: Re: Seamless Looping Water Texture
PostPosted: Tue Apr 10, 2012 5:43 am 
Offline
picked up 100 armour

Joined: Wed Dec 07, 2011 8:23 am
Posts: 129
Cool stuff Rich. I think The Dark Mod crew will appreciate this one too ;)


Top
 Profile E-mail  
 
 Post subject: Re: Seamless Looping Water Texture
PostPosted: Tue Apr 10, 2012 9:34 pm 
Offline
is sad because his cool title went away
User avatar

Joined: Wed Aug 06, 2003 3:53 pm
Posts: 680
Location: toilet
Antispam measure: What is larger? The Sun or the Galaxy?: BNA
Very nice, Rich! :D And there is indeed interest in your process elaboration... 8)


Top
 Profile E-mail  
 
 Post subject: Re: Seamless Looping Water Texture
PostPosted: Wed Apr 11, 2012 9:43 am 
Offline
a gun & a nice word
User avatar

Joined: Sat Jan 11, 2003 9:30 pm
Posts: 8713
Location: Orlando, FL
@LDAsh:

What you're looking at is basically Blender's ocean simulation. I found out recently that it is seamless and can bake a sequence of normal maps. I ran into some complications however.

The baked images are stored as OpenEXR files. It's easy enough to find a tool that will allow you to convert to Targa but I was hoping for batch conversion. Imagemagick will do the job but it doesn't support OpenEXR out of the box. To gain that functionality you're required to compile your own binary and being a Windows user and not much of a coder; I wasn't having that. In addition the normal maps didn't appear to be in tangent space. I was seeing lots of green and red but no blue.

The way I got around these problems was to bake a normal map the old fashioned way. Subdivide a plane a few times and apply the ocean simulation as a displacement. That yields a high polygon model. Create a second plane of equal size for the low polygon model, position it above the high polygon model, and bake. The only downside here was that I had to advance the timeline and bake each frame manually. I probably could have wrote a python script to automate this but it wasn't too much trouble.

This worked but there was a catch. The displacement is three dimensional meaning some parts of the high poly model were outside the projection area. The fix for this was to apply two array modifiers to the high polygon model to create a larger but repeating "ocean". I repositioned my low polygon object and baked.

Now to make the sequence loop. The trick here is simple and old school. It's basically a cross fade and since Blender has a built-in video editor you don't have to exit the program. You take the sequence and cut it in half. This middle point is now the beginning of one clip and the end of another. By overlaying the two clips and cross fading between them the jarring ends disappear.

The last problem was one I had encountered before in the past but it had slipped my mind. Blender's normal maps need to have the green channel inverted in order to work properly in Doom 3. Luckily Imagemagick can do that and I don't need to build a new executable for it.

@nbohr1more

Would you believe I tested this in TDM? It looks good if the water is opaque. But if the water is transparent it looks almost identical to the existing textures. You guys are welcome to it though.

_________________
Image Staff
Learn something today? Why not write an article about it on modwiki.net?


Top
 Profile  
 
 Post subject: Re: Seamless Looping Water Texture
PostPosted: Wed Apr 11, 2012 1:32 pm 
Offline
found a secret
User avatar

Joined: Fri Dec 12, 2003 9:49 am
Posts: 629
Location: teleporting, ETA=400ms
Quote:
It looks good if the water is opaque. But if the water is transparent it looks almost identical to the existing textures. You guys are welcome to it though.


Did you try using the generated normalmaps for refraction ?

Something like that :

Code:
{
program heatHaze.vfp
vertexParm 1 1.5 // magnitude of the distortion
fragmentMap 0 _currentRender
fragmentMap 1 textures/water/water_local.tga // the normal map for distortion
}

_________________
I got six little friends and they all run faster than you ;)

Check our multiplayer mods out at
moddb or the SPS Homepage


Top
 Profile  
 
 Post subject: Re: Seamless Looping Water Texture
PostPosted: Wed Apr 11, 2012 1:53 pm 
Offline
a gun & a nice word
User avatar

Joined: Sat Jan 11, 2003 9:30 pm
Posts: 8713
Location: Orlando, FL
Yes. I tried it with heathaze. It looks almost identical to a scrolling texture so you don't really gain anything there.

_________________
Image Staff
Learn something today? Why not write an article about it on modwiki.net?


Top
 Profile  
 
 Post subject: Re: Seamless Looping Water Texture
PostPosted: Thu Apr 12, 2012 5:13 pm 
Offline
picked up 200 ammo

Joined: Mon May 04, 2009 5:56 am
Posts: 235
Would this be good for pools of blood?


Top
 Profile E-mail  
 
 Post subject: Re: Seamless Looping Water Texture
PostPosted: Thu Apr 12, 2012 6:24 pm 
Offline
picked up 200 ammo

Joined: Tue Aug 31, 2004 7:31 pm
Posts: 280
Location: Ireland
Nice work rich,
It looks like it would be ideal for lava pools, so I'll give that a try.

I tried a similar approach for creating ripples around the player's legs in water (animated expanding circle as a specular map), but it didn't work out in practice because overlapping ripples became overbright. I must revisit that problem...

_________________
"Leave me alone, I know what I'm doing..." Kimi Raikkonen


Top
 Profile  
 
 Post subject: Re: Seamless Looping Water Texture
PostPosted: Fri Apr 13, 2012 11:50 pm 
Offline
picked up 75 health

Joined: Sun Mar 21, 2010 3:49 pm
Posts: 85
I played around with this stuff last year, to make better stream textures. While I cant seem to remember what I did with the textures/script/material, I remember that when using the animated normalmap + refraction, it only looked any good with quite a lot of specular on it to bring out the details.

I was generating the strip texture from script, as animating with multiple files can cause trouble, as well as being slightly cheaper. Just using a scale with instant jump worked quite well to move along the strip.

Edit : Oh, found the material and two textures
Code:
textures/darkmod/serp/animatedtest
{
   water
   {
      blend bumpmap
      map textures/temp/wavelong
      scroll table32[ time*0.9 ] * 0.03125, 0
   }
   {   
      vertexProgram heatHazeWithMask.vfp
      vertexParm 0 table32[ time*0.9 ] * 0.03125, 0
      vertexParm 1 1.3
      fragmentProgram heatHazeWithMask.vfp
      fragmentMap 0 _currentRender
      fragmentMap 1 textures/temp/wavelong
      fragmentMap 2 textures/water_source/vp_water
   }
   {
      if (global5 == 2)
      blend add
      program ambientEnvironment.vfp
      vertexParm      0      1, 1, 1, 1   // UV Scales for Diffuse and Bump
      vertexParm      1      1, 1, 1, 1   // (X,Y) UV Scale for specular
      vertexParm      2      global2, global3, global4, 1

      fragmentMap      0      cubeMap env/gen1
      fragmentMap      1      _flat         // Bump
      fragmentMap      2      textures/water_source/water_green // Diffuse
      fragmentMap      3      _black         // Specular
   }
}


Top
 Profile E-mail  
 
 Post subject: Re: Seamless Looping Water Texture
PostPosted: Wed Apr 18, 2012 10:01 am 
Offline
a gun & a nice word
User avatar

Joined: Sat Jan 11, 2003 9:30 pm
Posts: 8713
Location: Orlando, FL
How do you handle tiling or does that just naturally work out since each frame is nearly identical to the next?

_________________
Image Staff
Learn something today? Why not write an article about it on modwiki.net?


Top
 Profile  
 
 Post subject: Re: Seamless Looping Water Texture
PostPosted: Wed Apr 18, 2012 11:06 am 
Offline
picked up 75 health

Joined: Sun Mar 21, 2010 3:49 pm
Posts: 85
Heh, I cant remember at all - I don't see why it wouldn't work, the ambient stage is uniform, I think that's about the only thing that might not tile if it included a real normalmap.

I never really worked out how to generate nice tiles which had current and minor ripples, to look like a stream; then I got sidetracked by something else.


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group