• Create Account

## Water effects

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

2 replies to this topic

### #1xlope01  Members

215
Like
0Likes
Like

Posted 18 June 2013 - 12:09 PM

Hey,

Any suggestion on how to make the water area that do not have specular to look like the spot that i have mark with the red circle(to create small white specs)


SamplerState SampleType;
Texture2D normalTexture : register(t0);

cbuffer WaterBuffer
{
float4 refractionTint;
float3 lightDirection;
float waterTranslation;
float reflectRefractScale;
float specularShininess;
};

struct PixelInputType
{
float4 position : SV_POSITION;
float4 reflectionPosition : TEXCOORD0;
float4 refractionPosition : TEXCOORD1;
float3 viewDirection : TEXCOORD2;
float2 tex1 : TEXCOORD3;
float2 tex2 : TEXCOORD4;
};

{
float4 normalMap1;
float4 normalMap2;
float3 normal1;
float3 normal2;
float3 normal;
float4 color;
float3 reflection;
float specular;

// Move the position the water normal is sampled from to simulate moving water.
input.tex1.y += waterTranslation;
input.tex2.y += waterTranslation;

// Sample the normal from the normal map texture using the two different tiled and translated coordinates.
normalMap1 = normalTexture.Sample(SampleType, input.tex1);
normalMap2 = normalTexture.Sample(SampleType, input.tex2);

// Expand the range of the normal from (0,1) to (-1,+1).
normal1 = (normalMap1.rgb * 2.0f) - 1.0f;
normal2 = (normalMap2.rgb * 2.0f) - 1.0f;
normal = normalize(normal1 + normal2);

color = float4(0,0,1,0);

// Calculate the reflection vector using the normal and the direction of the light.
reflection = -reflect(normalize(lightDirection), normal);

// Calculate the specular light based on the reflection and the camera position.
specular = dot(normalize(reflection), normalize(input.viewDirection));

// Check to make sure the specular was positive so we aren't adding black spots to the water.
if(specular > 0.0f)
{
specular = pow(specular, specularShininess);

color = saturate(color + specular);
}

reflection = -reflect(normalize(float3(-1.0f, -2.0f, 3.2f)), normal);

color = saturate(color + normalize(float4(reflection.x,reflection.y,reflection.z, 0)));

return color;
}



### #2Seabolt  Members

781
Like
0Likes
Like

Posted 18 June 2013 - 03:32 PM

I'm not sure I understand the question, the area you've circled has specular highlights. You could try to fake some specular lighting on the crests of your waves, but that'll be very fake looking.

Perception is when one imagination clashes with another

### #3xlope01  Members

215
Like
0Likes
Like

Posted 18 June 2013 - 04:00 PM

I'm not sure I understand the question, the area you've circled has specular highlights. You could try to fake some specular lighting on the crests of your waves, but that'll be very fake looking.

yeap, this is what I am trying to do.

This is what I have manage to do, looks better than before but still doesn't look that good.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.