I’ve implemented an Oil Paint Post Process effect from this article and I run into some issues.
-
The sky behaves… weird
-
The emission materials also look strange
Here is a post process code:
int TexIndex = 14;
int intensityCount[10];
float avgR[10];
float avgG[10];
float avgB[10];
for (int iLevel = 0; iLevel < 10; iLevel++){
intensityCount[iLevel] = 0;
avgR[iLevel] = 0.0;
avgG[iLevel] = 0.0;
avgB[iLevel] = 0.0;
}
//COUNT INTENSITIES
uv *= 0.5;
for (int i = 0; i < radius; ++i)
{
int offsetI = -1 *(radius / 2) + i;
float v = uv.y + offsetI * invSize.y;
int temp = i * radius;
for (int j = 0; j < radius; ++j)
{
int offsetJ = -(radius / 2) + j;
float u = uv.x + offsetJ * invSize.x;
float2 uvShifted = uv + float2(u, v);
float3 tex = SceneTextureLookup(uvShifted, TexIndex, false);
float currentIntensity = ((tex.r + tex.g + tex.b) / 3 * 10);
intensityCount[currentIntensity]++;
avgR[currentIntensity] += tex.r;
avgG[currentIntensity] += tex.g;
avgB[currentIntensity] += tex.b;
}
}
float maxIntensity = 0;
int maxIndex = 0;
//FIND CORRECT MOST COMMON INTENSITY LEVEL
for(int cLevel = 0; cLevel < 10; cLevel++){
if(intensityCount[cLevel] > maxIntensity){
maxIntensity = intensityCount[cLevel];
maxIndex = cLevel;
}
}
float newR = avgR[maxIndex] / maxIntensity;
float newG = avgG[maxIndex] / maxIntensity;
float newB = avgB[maxIndex] / maxIntensity;
float4 res = float4(newR, newG, newB, 1.0);
return res;
Do you know what cas possibly cause it and for what should I look for to fix it? I have very limited knowledge about how this code works but with what I know, it shouldn’t behave so strangely