Generate random value for SSAO sampling
It should improve SSAO at least with grass. However this make the algorithm even more sensitive to bad normals. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14758 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -4,7 +4,7 @@ uniform mat4 invprojm;
|
||||
uniform mat4 projm;
|
||||
uniform vec4 samplePoints[16];
|
||||
|
||||
const float strengh = 4.;
|
||||
const float strengh = 20.;
|
||||
const float radius = .1f;
|
||||
|
||||
#define SAMPLES 16
|
||||
@@ -47,7 +47,9 @@ void main(void)
|
||||
occluderPos /= occluderPos.w;
|
||||
|
||||
float depthDifference = sampleProj.z - (2. * occluderFragmentDepth - 1.0);
|
||||
bl += (distance(occluderPos, FragPos) < radius) ? step(0., depthDifference) : 0.0;
|
||||
// depthDifference between 0 and radius
|
||||
float increment = step(0., depthDifference) * step(-radius, -depthDifference);
|
||||
bl += increment * smoothstep(radius, 0, distance(samplePos, FragPos));
|
||||
}
|
||||
|
||||
// output the result
|
||||
|
||||
@@ -494,25 +494,6 @@ void MLAANeigh3Provider::OnSetConstants(IMaterialRendererServices *srv, int)
|
||||
|
||||
void SSAOProvider::OnSetConstants(IMaterialRendererServices *srv, int)
|
||||
{
|
||||
static const float array[64] = {
|
||||
0.43589, -0.9, 0.667945, 0.,
|
||||
-0.9, 0.43589, 0.667945, 0.,
|
||||
-0.8, -0.6, 0.7, 0.,
|
||||
0.6, 0.8, 0.7, 0.,
|
||||
0.866025, -0.5, 0.6830125, 0.,
|
||||
-0.5, 0.866025, 0.6830125, 0.,
|
||||
-0.3, -0.953939, 0.6269695, 0.,
|
||||
0.953939, 0.3, 0.6269695, 0.,
|
||||
0.3, -0.781025, 0.5405125, 0.,
|
||||
-0.781025, 0.3, 0.5405125, 0.,
|
||||
-0.56, -0.621611, 0.5908055, 0.,
|
||||
0.621611, 0.56, 0.5908055, 0.,
|
||||
0.734847, -0.4, 0.5674235, 0.,
|
||||
-0.4, 0.734847, 0.5674235, 0.,
|
||||
-0.2, -0.6, 0.4, 0.,
|
||||
0.6, 0.2, 0.4, 0.,
|
||||
};
|
||||
|
||||
srv->setPixelShaderConstant("invprojm", invprojm.pointer(), 16);
|
||||
srv->setPixelShaderConstant("projm", projm.pointer(), 16);
|
||||
srv->setPixelShaderConstant("samplePoints[0]", array, 64);
|
||||
|
||||
@@ -541,7 +541,19 @@ class SSAOProvider: public CallBase
|
||||
{
|
||||
private:
|
||||
core::matrix4 projm, invprojm;
|
||||
float array[64];
|
||||
public:
|
||||
SSAOProvider() : CallBase() {
|
||||
for (unsigned i = 0; i < 64; i++) {
|
||||
array[i] = rand();
|
||||
array[i] /= RAND_MAX;
|
||||
if (i % 4 != 2)
|
||||
array[i] = 2 * array[i] - 1;
|
||||
if (i % 4 == 3)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnSetConstants(video::IMaterialRendererServices *srv, int);
|
||||
void updateIPVMatrix()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user