Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 11 Jun 2008
Offline Last Active Mar 27 2014 04:56 PM

Posts I've Made

In Topic: Help with Smooth Gradient on Skydome

23 March 2014 - 02:34 PM

Have you thought about sampling a sky gradient texture instead ?

Something like this

In Topic: Good specular for water surface

20 March 2014 - 08:46 PM

Thanks a lot for your response Bacterius !

So following your advice, i bumped the shininess ...


To 200



To 2000



To 7000




This is much better !

I wonder why my specular effect is located on such a small area though, i'll try to tweak my shader a bit to come up with a better algorithm.


Regarding the sharpness of my waves, that's why i increased my grid resolution, and added a height map, it did not help a lot though.


And regarding color absorption in water, i am actually handling that with this function which i wrote based on this article.

sandColor = GetWaterColorAt(sourceColor, distance);


float3 GetWaterColorAt(float3 sourceColor, float depth)
float rIndex = 7.0f;
float gIndex = 10.0f;
float bIndex = 70.0f;

float sandRed = sourceColor.r;
float sandGreen = sourceColor.g;
float sandBlue = sourceColor.b;

float lostRed = (depth / rIndex) * (1.0f/3.0f);
float lostGreen = (depth / gIndex) * (1.0f/3.0f);
float lostBlue = (depth / bIndex) * (1.0f/3.0f);

sandRed = sandRed - (sandRed * lostRed);
sandGreen = sandGreen - (sandGreen * lostGreen);
sandBlue = sandBlue - (sandBlue * lostBlue);

float3 sandColor = float3(max(0, sandRed), max(0, sandGreen), max(0, sandBlue));
return sandColor;

I'll try to add caustic and reflection to see if i get better results.


Thanks again !

In Topic: Water refraction bug

24 December 2013 - 02:31 PM

Thanks a lot, I'll try that !

In Topic: Water refraction bug

23 December 2013 - 06:28 PM

Thanks for answering nfactorial.

I tried to scale the effect down by adding a 0.1f factor to it, and it does improve things. But i still have visual artefacts on the edges, I guess its the same artefacts i had before, but at a smaller scale.






New shader code :

float zw = gDepthMap.Sample(PointSampler, texCoord).x;


// Calculate sampling offset caused by refraction.
float3 diff = viewRay - refractRay;
diff = diff / zw;

texCoord = texCoord + (diff.xz * 0.1f);

Any thoughts ?

In Topic: Sampling depth buffer in shader

18 September 2013 - 06:17 AM

Awesome this works perfectly, sorry for the late answer, i needed to make sure i could reconstruct view position from depth (thanks to your brillant article !).