As promised, I revived BlindSide's old water shader, so here it is. However, I made quite a few changes and since I barely speak GLSL it's DX only for now.
- All terrain dependencies stripped, it's only the water surface but therefore universal
- Implemented as a SceneNode with some parameters, it takes 1 line of code to create it
- It's movable, scalable and works with parents
- Should work with most custom cameras
- Sinus waves and refraction are now switchable at runtime
- Minor changes in color and transparency
- It's extremely fast, even a little faster than before due to the cuts in terrain code (in the screenshot VSync is on, therefore capped at 75fps)
If shader materials are used on objects that intersect with the clip plane (the water surface) it's necessary to implement the clip plane inside those shaders as well in order to make reflections and refractions work correctly.
In HLSL a basic shader with a custom clip plane could look like this:
- Code: Select all
float4 Position : POSITION0;
float2 TexCoords : TEXCOORD0;
float3 Position3D : TEXCOORD1;
float4 Color : COLOR0;
VertexToPixel vertexMain ( float4 inPos : POSITION0,
float2 inTexCoords : TEXCOORD0 )
Output.Position = mul(inPos, xWorldViewProjection);
Output.TexCoords = inTexCoords;
Output.Position3D = mul(inPos, xWorld);
sampler2D diffuse : register(s0);
float seaLevel; // SceneNode Y position
PixelToFrame pixelMain(VertexToPixel PSIn)
clip(PSIn.Position3D.y - seaLevel); // clip if below seaLevel
float4 final = tex2D(diffuse, PSIn.TexCoords);
Output.Color = final;
In addition, I included my new blood effect. It's not 'perfect' yet since there's a lot of tweaking and fine tuning involved. Anyway, feel free to improve and/or extend it to your liking.
- Implemented as a SceneNode, it takes 1 line of code to create an effect
- It's self-controlled, so actually all you need to do is call new Effect(...) just where you need it. It destroys itself on animation end, so there's no need to store a pointer.
- simple texture animation shader
Key [ESC] : Exit
Mouse [LEFT] : Shoot (aim for Mr. Ball)
Key  : Show blood effect - mild
Key  : Show blood effect - medium
Key  : Show blood effect - brutal
Key  : Show blood effect - insane
Key  : Show massacre
Download package here.