mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2024-12-22 17:47:34 +08:00
tweak sampling for SSAO, shadow filters.
This commit is contained in:
parent
2f92a6eff0
commit
87d25d0637
@ -138,17 +138,29 @@ vec3 applyBump(mat3 tbnMatrix, vec3 bump, float puddle_values){
|
||||
return normalize(bump*tbnMatrix);
|
||||
}
|
||||
|
||||
vec2 tapLocation(int sampleNumber,int nb, float nbRot,float jitter,float distort)
|
||||
{
|
||||
float alpha = (sampleNumber+jitter)/nb;
|
||||
float angle = jitter*6.28 + alpha * nbRot * 6.28;
|
||||
// vec2 tapLocation(int sampleNumber,int nb, float nbRot,float jitter,float distort)
|
||||
// {
|
||||
// float alpha = (sampleNumber+jitter)/nb;
|
||||
// float angle = jitter*6.28 + alpha * nbRot * 6.28;
|
||||
|
||||
float sin_v, cos_v;
|
||||
// float sin_v, cos_v;
|
||||
|
||||
sin_v = sin(angle);
|
||||
cos_v = cos(angle);
|
||||
// sin_v = sin(angle);
|
||||
// cos_v = cos(angle);
|
||||
|
||||
return vec2(cos_v, sin_v)*sqrt(alpha);
|
||||
// return vec2(cos_v, sin_v)*sqrt(alpha);
|
||||
// }
|
||||
vec2 tapLocation_simple(
|
||||
int samples, int totalSamples, float rotation, float rng
|
||||
){
|
||||
const float PI = 3.141592653589793238462643383279502884197169;
|
||||
float alpha = float(samples + rng) * (1.0 / float(totalSamples));
|
||||
float angle = alpha * (rotation * PI);
|
||||
|
||||
float sin_v = sin(angle);
|
||||
float cos_v = cos(angle);
|
||||
|
||||
return vec2(cos_v, sin_v) * sqrt(alpha);
|
||||
}
|
||||
|
||||
|
||||
@ -398,7 +410,8 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
|
||||
int SampleCount = 7;
|
||||
for(int i = 0; i < SampleCount; i++){
|
||||
vec2 offsetS = tapLocation(i,SampleCount,1.618,noise,0.0);
|
||||
// vec2 offsetS = tapLocation(i,SampleCount,1.618,noise,0.0);
|
||||
vec2 offsetS = tapLocation_simple(i, 7, 9, noise) * 0.5;
|
||||
|
||||
float weight = 1.0+(i+noise)*rdMul/9.0*shadowMapResolution;
|
||||
float isShadow = shadow2D(shadow, projectedShadowPosition + vec3(rdMul*offsetS, -diffthresh*weight)).x / SampleCount;
|
||||
|
@ -153,6 +153,19 @@ void GriAndEminShadowFix(
|
||||
|
||||
#include "/lib/Shadow_Params.glsl"
|
||||
|
||||
|
||||
const float PI = 3.141592653589793238462643383279502884197169;
|
||||
vec2 tapLocation_simple(
|
||||
int samples, int totalSamples, float rotation, float rng
|
||||
){
|
||||
float alpha = float(samples + rng) * (1.0 / float(totalSamples));
|
||||
float angle = alpha * (rotation * PI);
|
||||
|
||||
float sin_v = sin(angle);
|
||||
float cos_v = cos(angle);
|
||||
|
||||
return vec2(cos_v, sin_v) * sqrt(alpha);
|
||||
}
|
||||
void main() {
|
||||
/* DRAWBUFFERS:3 */
|
||||
vec2 texcoord = gl_FragCoord.xy*texelSize;
|
||||
@ -238,13 +251,18 @@ void main() {
|
||||
float diffthreshM = diffthresh*mult*d0*k/20.;
|
||||
float avgDepth = 0.0;
|
||||
|
||||
int seed = (frameCounter%40000) * 2 + (1+frameCounter);
|
||||
float samplePos = fract(R2_samples(seed).x + blueNoise(gl_FragCoord.xy).x) * 1.61803398874;
|
||||
// int seed = (frameCounter%40000) * 2 + (1+frameCounter);
|
||||
// float samplePos = fract(R2_samples(seed).x + blueNoise(gl_FragCoord.xy).x) * 1.61803398874;
|
||||
|
||||
int seed = (frameCounter%40000) + frameCounter*2;
|
||||
float samplePos = fract(R2_samples(seed).y + blueNoise(gl_FragCoord.xy).y);
|
||||
float noise = 0.5+blueNoise();
|
||||
|
||||
for(int i = 0; i < VPS_Search_Samples; i++){
|
||||
|
||||
vec2 offsetS = tapLocation_alternate(i+1, i/VPS_Search_Samples, 7, 20, samplePos) * noise;
|
||||
// vec2 offsetS = tapLocation_alternate(i+1, i/VPS_Search_Samples, 7, 20, samplePos) * noise;
|
||||
|
||||
vec2 offsetS = tapLocation_simple(i, 7, 9, samplePos);
|
||||
|
||||
|
||||
float weight = 3.0 + (i+blueNoise() ) *rdMul/SHADOW_FILTER_SAMPLE_COUNT*shadowMapResolution*distortFactor/2.7;
|
||||
|
@ -249,6 +249,18 @@ vec2 tapLocation(int sampleNumber, float spinAngle,int nb, float nbRot,float r0)
|
||||
|
||||
return vec2(cos_v, sin_v)*ssR;
|
||||
}
|
||||
vec2 tapLocation_simple(
|
||||
int samples, int totalSamples, float rotation, float rng
|
||||
){
|
||||
const float PI = 3.141592653589793238462643383279502884197169;
|
||||
float alpha = float(samples + rng) * (1.0 / float(totalSamples));
|
||||
float angle = alpha * (rotation * PI);
|
||||
|
||||
float sin_v = sin(angle);
|
||||
float cos_v = cos(angle);
|
||||
|
||||
return vec2(cos_v, sin_v) * sqrt(alpha);
|
||||
}
|
||||
|
||||
vec3 viewToWorld(vec3 viewPos) {
|
||||
vec4 pos;
|
||||
@ -803,14 +815,19 @@ void main() {
|
||||
smallbias = -0.0005;
|
||||
noise = 0.5;
|
||||
}
|
||||
|
||||
|
||||
projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5);
|
||||
|
||||
#ifdef BASIC_SHADOW_FILTER
|
||||
#ifndef Variable_Penumbra_Shadows
|
||||
if(LabSSS > 0) smallbias = -0.0002;
|
||||
#endif
|
||||
float rdMul = filteredShadow.x*distortFactor*d0*k/shadowMapResolution;
|
||||
|
||||
for(int i = 0; i < samples; i++){
|
||||
vec2 offsetS = tapLocation(i,samples,1.618, noise,0.0);
|
||||
// vec2 offsetS = tapLocation(i,samples,1.618, noise,0.0);
|
||||
vec2 offsetS = tapLocation_simple(i, 7, 9, noise) * 0.5;
|
||||
|
||||
float isShadow = shadow2D(shadow, projectedShadowPosition + vec3(rdMul*offsetS, smallbias) ).x;
|
||||
Shadows += isShadow/samples;
|
||||
|
@ -42,7 +42,7 @@ vec3 HableTonemap(vec3 linearColor) {
|
||||
// A = shoulder strength
|
||||
const float A = 0.45;
|
||||
// B = linear strength
|
||||
const float B = 0.28;
|
||||
const float B = 0.5;
|
||||
// C = linear angle
|
||||
const float C = 0.1;
|
||||
// D = toe strength
|
||||
|
@ -53,7 +53,7 @@ vec2 SSAO(
|
||||
int n = 0;
|
||||
for (int i = 0; i < samples; i++) {
|
||||
|
||||
vec2 sp = tapLocation_alternate(i, samples, 20, samplePos) * 0.2;
|
||||
vec2 sp = tapLocation_alternate(i, 7, 9, samplePos) * 0.2;
|
||||
|
||||
float rd = mulfov2 ;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user