Skip to content

Commit

Permalink
Add config for water & reflections stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ambrosia13 committed Apr 28, 2022
1 parent 7655b1f commit 82285d1
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 22 deletions.
16 changes: 12 additions & 4 deletions assets/forgetmenot/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
"config.forgetmenot.desc.sky_resolution": "Resolution at which the sky is computed.",
"config.forgetmenot.name.sky_upsample_filter": "Sky Upsample Filter",
"config.forgetmenot.desc.sky_upsample_filter": "Uses an upsampling filter on the sky.",
"config.forgetmenot.name.raytrace_ssr": "Raymarch Reflections",
"config.forgetmenot.desc.raytrace_ssr": "Uses raymarching to give accurate reflections. Else will just flip the screen for reflections, which is inaccurate but faster.",
"config.forgetmenot.name.simple_water": "Fast Water",
"config.forgetmenot.desc.simple_water": "Uses simpler water normals. Enable this if looking at water makes your performance drop a bunch.",
"config.forgetmenot.name.vanilla_lava": "Vanilla Lava",
"config.forgetmenot.desc.vanilla_lava": "Enable for vanilla lava texture. Custom lava texture may have a minor performance impact.",

Expand All @@ -29,7 +25,19 @@
"config.forgetmenot.desc.cirrus_clouds": "Cloud shape that resembles cirrus clouds. Low performance cost.",
"config.forgetmenot.name.cloud_lighting": "Cloud Lighting Mode",
"config.forgetmenot.desc.cloud_lighting": "Cloud lighting mode. ;None - fastest;Normals - slow;Raymarched - slowest",

"config.forgetmenot.category.water_reflections": "Water & Reflections",

"config.forgetmenot.name.raytrace_ssr": "Raymarch Reflections",
"config.forgetmenot.desc.raytrace_ssr": "Uses raymarching to give accurate reflections. Else will just flip the screen for reflections, which is inaccurate but a bit faster.",
"config.forgetmenot.name.ssr_steps": "SSR Steps",
"config.forgetmenot.desc.ssr_steps": "Number of raymarching steps for raymarched reflections. Increase for a mild performance decrease but better quality reflections. Doesn't seem to impact performance much.",
"config.forgetmenot.name.simple_water": "Fast Water",
"config.forgetmenot.desc.simple_water": "Uses simpler water normals. Enable this if looking at water makes your performance drop a bunch.",
"config.forgetmenot.name.simple_sky_reflection": "Simple Sky Reflection",
"config.forgetmenot.desc.simple_sky_reflection": "If enabled, will skip calculating clouds & stars when calculating sky in reflections. May improve performance, will look weird.",
"config.forgetmenot.name.illegal_ssr": "Illegal SSR",
"config.forgetmenot.desc.illegal_ssr": "Uses cursed and highly illegal method to have easy mutli-bounce reflections. Usually doesn't cause issues. May decrease performance.",

"config.forgetmenot.category.general": "General Options",

Expand Down
43 changes: 33 additions & 10 deletions assets/forgetmenot/pipelines/forgetmenot.json5
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,6 @@
nameKey: "config.forgetmenot.name.sky_upsample_filter",
descriptionKey: "config.forgetmenot.desc.sky_upsample_filter"
},
raytrace_ssr: {
default: false,
nameKey: "config.forgetmenot.name.raytrace_ssr",
descriptionKey: "config.forgetmenot.desc.raytrace_ssr"
},
simple_water: {
default: false,
nameKey: "config.forgetmenot.name.simple_water",
descriptionKey: "config.forgetmenot.desc.simple_water"
},
vanilla_lava: {
default: false,
nameKey: "config.forgetmenot.name.vanilla_lava",
Expand Down Expand Up @@ -255,6 +245,39 @@
},
}
},
{
includeToken: "forgetmenot:water_reflections",
categoryKey: "config.forgetmenot.category.water_reflections",
elements: {
raytrace_ssr: {
default: true,
nameKey: "config.forgetmenot.name.raytrace_ssr",
descriptionKey: "config.forgetmenot.desc.raytrace_ssr"
},
ssr_steps: {
default: 25,
min: 10,
max: 60,
nameKey: "config.forgetmenot.name.ssr_steps",
descriptionKey: "config.forgetmenot.desc.ssr_steps"
},
simple_water: {
default: false,
nameKey: "config.forgetmenot.name.simple_water",
descriptionKey: "config.forgetmenot.desc.simple_water"
},
simple_sky_reflection: {
default: false,
nameKey: "config.forgetmenot.name.simple_sky_reflection",
descriptionKey: "config.forgetmenot.desc.simple_sky_reflection"
},
illegal_ssr: {
default: true,
nameKey: "config.forgetmenot.name.illegal_ssr",
descriptionKey: "config.forgetmenot.desc.illegal_ssr"
},
}
},
{
includeToken: "forgetmenot:general_config",
categoryKey: "config.forgetmenot.category.general",
Expand Down
8 changes: 4 additions & 4 deletions assets/forgetmenot/shaders/lib/functions/sky.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ vec3 calculateSkyColor(in vec3 viewSpacePos) {
sunsetSky = mix(sunsetSky, vec3(0.225,0.302,0.510) * 0.6, smoothstep(0.3, 0.8, viewSpacePos.y));
sunsetSky = mix(sunsetSky, vec3(0.181,0.251,0.485) * 0.5, smoothstep(0.5, 1.5, viewSpacePos.y));
sunsetSky = mix(sunsetSky, sunsetSky * 0.5 + vec3(0.7, 0.5, 0.4) * 0.6, clamp01(pow(dot(viewSpacePos, getSunVector()), 3.0)));
sunsetSky = mix(sunsetSky, sunsetSky * 0.5 + vec3(1.5, 1.0, 0.4) * 0.6, clamp01(pow(dot(viewSpacePos, getSunVector()), 5.0) * 0.25));
sunsetSky = mix(sunsetSky, sunsetSky * 0.5 + vec3(0.475,0.505,0.685), clamp01(pow(dot(viewSpacePos, getMoonVector()), 3.0)));
sunsetSky = mix(sunsetSky, sunsetSky * 0.5 + vec3(1.5, 1.2, 0.4) * 0.6, clamp01(pow(dot(viewSpacePos, getSunVector()), 5.0) * 0.25));
sunsetSky = mix(sunsetSky, sunsetSky * 0.5 + vec3(0.475,0.505,0.685), clamp01(pow(dot(viewSpacePos, getMoonVector()), 5.0)));
sunsetSky = mix(sunsetSky, sunsetSky * vec3(1.2, 0.5, 0.3), clamp01(dot(frx_cameraView, getSunVector()) * 0.2));
sunsetSky = mix(sunsetSky, sunsetSky * vec3(0.5, 0.7, 1.0), clamp01(dot(frx_cameraView, getMoonVector()) * 0.2));
// sunsetSky = mix(sunsetSky, vec3(frx_luminance(sunsetSky)), -1.0);
Expand Down Expand Up @@ -146,7 +146,7 @@ vec2 calculateBasicCloudsOctaves(in vec3 viewSpacePos, int octaves, bool doLight
vec2 rayDir = frx_skyLightVector.xz / 15.0;
for(int i = 0; i < 10; i++) {
rayPos += rayDir;
cloudLighting -= getCloudNoise(rayPos, 3) * 0.1;
cloudLighting -= getCloudNoise(rayPos, 3) * 0.1;
}
}
#endif
Expand Down Expand Up @@ -180,7 +180,7 @@ vec3 sampleSky(in vec3 viewSpacePos) {

// clouds
vec3 cloudsColor = vec3(1.2);
cloudsColor = mix(cloudsColor, vec3(0.3, 0.3, 0.4), tdata.z);
cloudsColor = mix(cloudsColor, vec3(0.6, 0.55, 0.7), tdata.z);
cloudsColor = mix(cloudsColor, vec3(0.3, 0.3, 0.4), tdata.y);
cloudsColor *= 1.5;

Expand Down
2 changes: 1 addition & 1 deletion assets/forgetmenot/shaders/lib/functions/utility.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ float fbmHash(vec2 uv, int octaves) {
float noise = 0.01;
float amp = 0.5;

mat2 rotationMatrix = mat2(cos(PI / 12.0), sin(PI / 12.0), -sin(PI / 12.0), cos(PI / 12.0));
mat2 rotationMatrix = mat2(cos(PI / 6.0), sin(PI / 6.0), -sin(PI / 6.0), cos(PI / 6.0));

for (int i = 0; i < octaves; i++) {
noise += amp * (smoothHash(uv) * 0.5 + 0.51);
Expand Down
1 change: 1 addition & 0 deletions assets/forgetmenot/shaders/lib/includes.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ uniform int frxu_lod;

#include forgetmenot:performance_config
#include forgetmenot:clouds
#include forgetmenot:water_reflections
#include forgetmenot:general_config
#include forgetmenot:experimental

Expand Down
18 changes: 15 additions & 3 deletions assets/forgetmenot/shaders/post/fabulous/reflection.frag
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ void main() {
if(dot(normal, vec3(0.0, 1.0, 0.0)) > 0.7) f0 += (0.4 * frx_rainGradient + 0.35 * frx_thunderGradient) * step(5.0, light.y);
if(f0.r / 20.0 > 0.99) normal.rgb += rand3D(texcoord) / 100.0;

#ifndef ILLEGAL_SSR
#define u_previous_frame u_color
#endif

#ifdef RAYTRACE_SSR
#define SSR_STEPS 40
//#define SSR_STEPS 40
if(depth != 1.0 && f0.r > 0.0) {
vec3 clipSpacePos = vec3(texcoord, depth) * 2.0 - 1.0;
vec3 viewSpacePos = setupViewSpacePos(texcoord, depth);
Expand All @@ -43,7 +47,11 @@ void main() {
float stepLength = 1.0 / SSR_STEPS;

// sky reflection
reflectColor = mix(vec3(0.2), sampleSkyReflection(reflectionView), frx_smoothedEyeBrightness.y);
#ifdef SIMPLE_SKY_REFLECTION
reflectColor = mix(vec3(0.2), sampleFogColor(reflectionView), frx_smoothedEyeBrightness.y);
#else
reflectColor = mix(vec3(0.2), sampleSkyReflection(reflectionView), frx_smoothedEyeBrightness.y);
#endif

for(int i = 0; i < SSR_STEPS; i++) {
vec3 currentScreenPos = (clipSpacePos + rayScreenDir * float(i) * stepLength) * 0.5 + 0.5;
Expand Down Expand Up @@ -82,7 +90,11 @@ void main() {
if(clamp01(cleanReflectedScreenDir.xy) != cleanReflectedScreenDir.xy) {
cleanReflectedScreenDir.xy = clamp01(cleanReflectedScreenDir.xy);
// sky reflection
reflectColor = mix(vec3(0.2), sampleSkyReflection(reflectedViewDir), frx_smoothedEyeBrightness.y);
#ifdef SIMPLE_SKY_REFLECTION
reflectColor = mix(vec3(0.2), sampleFogColor(reflectedViewDir), frx_smoothedEyeBrightness.y);
#else
reflectColor = mix(vec3(0.2), sampleSkyReflection(reflectedViewDir), frx_smoothedEyeBrightness.y);
#endif
} else {
reflectColor = texture(u_previous_frame, cleanReflectedScreenDir.xy).rgb;
}
Expand Down

0 comments on commit 82285d1

Please sign in to comment.