D3D10 water rendering
#21
Posted 22 September 2008 - 08:26 PM
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
#22
Posted 22 September 2008 - 08:36 PM
What do you mean for shift? The dictionary does not help me! Can you explain it better?
And what about the first problem?
#23
Posted 22 September 2008 - 08:40 PM
ViewTexC += normalMap.rg * .0001;
scale the .0001 as you need.
As for the first problem, I cant say anything but there isn't one. It's functioning as it should. Can you tell me what you're trying to get it to do?
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
#24
Posted 22 September 2008 - 08:46 PM
starstutter said:
Oh yes, you're right. To have a complete spot of water i must create a decent geometry, like a cube. I'm really going crazy, i should make a break :D
I will try your new code, (now i understand what do you mean for shift, damn dictionary...you meaned like the byteshift in C language :) ), but i've not understand why have i to make this...the concept behind it!
#25
Posted 22 September 2008 - 08:53 PM
XVincentX said:
Quote
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
#26
Posted 22 September 2008 - 09:01 PM
Now, if you want, i would talk about your 2 images, and next steps for water effect
Images questions:
a) D3D9 or D3D10? (d3d9, i suppose)
b) Are you using antialiasing? Anisotropic texture filter?
c) How many polygons there are in that scene?
f) Max and normal framerate?
Water questions:
I read a little bit the physics that manages the water and how all works, so
a) Refraction: how to simulate it? I thought to make a component to add, using the different refraction index in some ways....(1.0003 for air, 1.3333 for water)
Reflection: Via cubemap? i will study it
What do you say about?
#27
Posted 22 September 2008 - 09:03 PM
XVincentX said:
Rather than a cube you should just create a flat water surface that extends all the way to where the water meets the ground.
Quote
The idea is that instead of looking at the geometry under the water at the same point where it would be if the water wasn't there, you look at the geometry at a slightly different point. You move the point by a distance that depends on the water's normal. It produces a distorted image of what's under the water. It's not really refraction but can still look rather good.
#28
Posted 22 September 2008 - 09:06 PM
Reedbeta said:
And if i would go underwater?
#29
Posted 22 September 2008 - 09:38 PM
Although you can use this same technique to render the water surface as seen from below, distorting the view of objects above the water.
#30
Posted 22 September 2008 - 09:42 PM
#31
Posted 22 September 2008 - 11:36 PM
XVincentX said:
Quote
Anisotropic, yes. Why wouldn't you? It makes surfaces look a lot better and it's a one word command in the shader declarations :)
Quote
Quote
The right image was using a higher polycount and an HDR environment so that drained it some. I think it was somewhere around 125-140 fps
Keep in mind however these framerates were recorded in windowed mode, which is substancially slower than fullscreen (in certain cases I see %25 speed increases).
Quote
I read a little bit the physics that manages the water and how all works, so
a) Refraction: how to simulate it? I thought to make a component to add, using the different refraction index in some ways....(1.0003 for air, 1.3333 for water)
Quote
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
#32
Posted 23 September 2008 - 06:29 AM

This images uses this code
float4 ps_plane(PS_INPUT input) : SV_TARGET
{
float2 ViewTexC = 0.5 * input.WorldPos.xy / input.WorldPos.w + float2( 0.5, 0.5 );
ViewTexC.y = 1.0f - ViewTexC.y;
ViewTexC += NormalMap.Sample(SamplText,input.Tex).xy * 0.9f;
return CurrentBackbuffer.Sample(SamplText,ViewTexC + EyePosition.xy);
}
Even if the water movement makes the texture move everytime in a single direction. So i modify the code to move toward a range with little oscillations.
Anyway, the water seems too rich of miniwaves. I've tryied to play with the .0001 value, but no results makes me satisfied. Mabye it's a normal map problem?
EDIT:
This code seems to work very better
float4 ps_plane(PS_INPUT input) : SV_TARGET
{
float2 ViewTexC = 0.5 * input.WorldPos.xy / input.WorldPos.w + float2( 0.5, 0.5 );
ViewTexC.y = 1.0f - ViewTexC.y;
ViewTexC += NormalMap.Sample(SamplText,ViewTexC).xy * 0.06f;
return CurrentBackbuffer.Sample(SamplText,ViewTexC + EyePosition.xy);
}
#33
Posted 23 September 2008 - 02:20 PM
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
#34
Posted 23 September 2008 - 02:47 PM
Let's wait a while, else i will upload it again.
#35
Posted 23 September 2008 - 05:06 PM
Make sure you're only modifying the image using the r and g channels of the texture.
EDIT:
actually on second thought, try and image bias:
ViewTexC += (NormalMap.Sample(SamplText,ViewTexC).xy * 0.06f) - bias;
I can't tell you the specific value of the bias, because that depends totally on your code. I would start at 0.1 and work your way either up or down (depending on which gets it closer) and just guess untill the image is aligned properly. Note that it's possible that the coordinates may not be the same scale. That means the x and y shifts could react differently to different values. So make bias a float2( +-0.1, +-0.1) and see if positive or nagitve numbers for either give you the right outcome. You may not have to do this at all though. Start with just positive and see if that does the trick.
EDIT AGAIN:
Wait, what's with the "+ eyePosition.xy" thing. That's probably what's messing the shift up. You should remove that as this is not yet a view dependant calculation.
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
#36
Posted 23 September 2008 - 06:41 PM
I was forced to used it becouse D3D10 has an orrible shader system:
float4x4 ViewMatrix; float4x4 WorldMatrix; float4x4 ProjMatrix; float4 LightDirection; float4 MaterialColor; float3 EyePosition; texture2D Texture; texture2D CurrentBackbuffer; texture2D NormalMap;
Ok it works. If only i add a float, in this way
float4x4 ViewMatrix; float4x4 WorldMatrix; float4x4 ProjMatrix; float4 LightDirection; float4 MaterialColor; float3 EyePosition; texture2D Texture; texture2D CurrentBackbuffer; texture2D NormalMap; float value;
D3D10 gives me Warnings becouse there are unbinded resources...so to make it work i'm forced to change variables position looking for the right order, and this is so bad.
D3D10 effect system, anyway has GetParameterByIndex and ByName, by ByName NEVER works.....and that's it.
I will try with bias value soon.
#37
Posted 23 September 2008 - 11:36 PM
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
#38
Posted 24 September 2008 - 06:17 AM
Anyway, i tried to use the bias value in this way
float4 ps_plane(PS_INPUT input) : SV_TARGET
{
float2 ViewTexC = 0.5 * input.WorldPos.xy / input.WorldPos.w + float2( 0.5, 0.5 );
ViewTexC.y = 1.0f - ViewTexC.y;
ViewTexC += ((NormalMap.Sample(SamplText,ViewTexC).xy + EyePosition.xy) * 0.06f) - float2(-0.1,-0,1);
return CurrentBackbuffer.Sample(SamplText,ViewTexC);
}
And what i can see it's only a texture movement on the surface. I tried some combinations: ++,+-,-+,-- also using higher values: with 0.5 the texture disappears and the surface becomes blue (that it's the Clear color in RenderTarget)
#39
Posted 24 September 2008 - 06:19 AM
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
#40
Posted 24 September 2008 - 06:27 AM
Without Bias:

With
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












