April 27, 2013

UDK Ocean WIP (2) + shader source

Few days ago I've created ocean shader for UDK based on nVidia Island11 demo. You can find it here:


Not a ready solution - it shouldn't be used for production, but it's a good point to start. I think it's a good idea to share my work with you :)

Download UDK Ocean shader (packages saved with February 2013 UDK).






Brief description
  • Designed for DirectX11 tesselation (flat version for DX9);
  • Opacity with dynamic shadows on ocean surface (can be used with dynamic lighting and has bug-free DOF);
  • Subsurface scattering (SSS) simulation;
  • All the data is generated from one 256x256x32b normal map.

Should be added/fixed for production (shader):
  • Height displacement and normal disturbance fading near the shore;
  • Render targets square resolution support (independent from screen resolution);
  • Z-displacement for reflections is wrong when camera is close to surface;
  • Wind vector/speed dependence (if you need);
  • Skyline tiling issues fix (ripple);
  • Performance optimization, quality switches, etc.

Other improvements to do:
  • Ocean mesh/LOD system;
  • SceneCapture actors and player's FOV should be dynamically related;
  • Disable capture actors when refraction feature isn't used;

It's just a common directions of development, there are a lot ot them more. First of all you should understand what you want to get from ocean. F.e. today I'm using simplified shader to get optimal performance and organic view exactly for my game.

HowTo

You'll find three files in archive above:
  1. SC_PlayerController.uc - contains Unreal Script code for fake opacity control. You should integrate it into your PC class (you can use my class for tests also);
  2. SC_OceanTest.upk - shader resources, materials, etc.;
  3. SC_Island11.udk - test mapl
There are four key actors on map:

1. Ocean surface mesh. You must set two options for it:
  • Object tag is "MyBelovedOcean";
  • "Only owner can see" is on;
2-3. Render targets for scene depth ("DepthTrickster" tag) and scene color ("ColorTrickster" tag) capturing. FOV must be the same as used for player.

4. Reflection capture actor. Simple one, but important. No special tags required.

Main idea of "opaque material with opacity" is to use scene capture actors to get scene depth and color behind surface from scene "without ocean". 

We've made ocean mesh visible only for owner, and capture actors don't see it. Position and rotation of these actors are synced with player controller's position and rotation, FOV is the same, so we can easily make projection of render targets to screen space. Profit :)


Of course, this trick has its limitations and bottlenecks, but it's useful for my game, and I'm happy about it. If you needn't dynamic lighting for your water surface you can always modify material to be truly traslucent.

to FFT or not to FFT?

I know that one of the frequent requests is "how to make FFT Ocean", f.e. like this one. It's really possible to do it with UDK (you should use ScriptedTextures), but:
  1. it'll work only with DirectX11 - tesselation displacement is only one solution for heightmap from texture, even generated on the flow;
  2. FFT passes work relatively slow, 'cause you have to use script buffers, not a solid shader;
  3. You can try to make it faster using sets of pre-calculated FFT data (like in Assasin Creed 3), but you have to use float textures. Their support (.float) in UDK is something from Hell.
I want to say that FFT algorythm is not useful for in-game ocean with UDK. It's better to use Gerstner-based solutions. But for portfolio demos it would be a great thing. It looks pretty cool.

P.S.

There are a lot of different approaches for ocean simulation in games. This shader is just only one of them. Hope you'll find it useful, and you're free to use it as you want.

April 22, 2013

SeaCraft possible service interruption

We have servers maintenance work not envisaged in the plan. SeaCraft website and forum service can be interrupted for April 23-24th. Sorry for inconvenience.

Edit: the date was changed to 25-26th Apritl

April 19, 2013

Deep, let me go

I'm working in my dreams too now. Ocean owns me :) I woke up broken, but it's interesting to feel youself a virtual diver.

Anyway, the second milestone is here. We have a deepness now.


No special things required to make a material with transparency, but my ocean is not usual UE3 transluent material shader. Transluent materials and dynamic lighting system are not a friends. For example, sun reflection isn't blocked by dynamic actors, the ship hasn't a shadow, and there are no light'n'shadow effects from explosions, especially at night levels.

I'm a trickster, and my ocean is opaque material. It has self-shadowing, dynamic shadows, light effect, etc., and it's really cool for my game.


Of course, my trick has it's limitations. But they are irrelevant for gameplay I have.

April 15, 2013

UDK Ocean WIP

I's not a good idea to prototype shaders with in raw DirectX, 'cause you can meet some "fun" stuff in porting the code into engine. Different systems of axes, forced gamma correction, mipmap generation.. it's just a beginning of the Samurai's path.

Heh, there was a hell for three days :) But first version of new, updated ocean for SeaCraft game is here. Not a final one, but definitely milestone.


There are few issues, but my first goal is to create basic material for diffuse/specual/normals/heightmap. It's ok, and now I'm going to add refraction, foam and huge waves for stormy weather.

Static screenshot:


I'm thinking about low-end PCs also, and there is a special version for them. It works very fast and looks for today:


It's just a WIP. I'll write a detailed article about different approaches in ocean real-time rendering once it will be done in "first release version". While working on SeaCraft I've got a lot of notes, thoughts and practical tricks to share.

April 4, 2013

Dead tanks souls

Our warships are chops. That means they are dead tanks souls.


Game physics is one big fake cause of realtime demands - the ships are not swimming, they are flying. We're using statistical ocean model (functional model was used before), and vehicles react on pre-calculated math waves to be on the right height and toss. In this way, the engine knows the ships as choppers "with pompons". If you've played UT3 before you should know that Cicada is sister of any ship from SeaCraft :)

Last week we've worked on explosions. It's very important for SeaCraft to create model when each fire burst shows something about ship state. Blowing should be bright, precise, clear. Not realisic, but playable.


The result is that we're using standard for many games explosion model, you can see in on screen above. Just for today. It will be changed and improved a lot in future - we want to gather reviews for our burning model on alpha-tests first. The system have to be balanced - the main target is to make it really clear and helpful for player.

A couple of words about the plot. Just an intro:
  • Ruby had no reasons to shoot Oswald;
  • Green Zone was around Saigon, in 1964;
  • Hanoi said "Hello, stalker!" in summer 1969.