Skip to content

Commit

Permalink
I like structs now
Browse files Browse the repository at this point in the history
  • Loading branch information
ambrosia13 committed Mar 5, 2023
1 parent 558af0d commit b9a863a
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 68 deletions.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ If you're a developer or mod hoster, Forget-me-not is licensed under the [LGPL v

2. Install [Fabric](https://fabricmc.net/wiki/install).

3. Install [Canvas](https://modrinth.com/mod/canvas) and drag it into the `mods` folder of your Fabric installation. **Keep in mind that Canvas will never work with Sodium, Iris, OptiFine, or OptiFabric.**
3. Get Canvas Renderer mod through [Modrinth](https://modrinth.com/mod/canvas). You can also find an unofficial 1.19.3 build [here](https://cdn.discordapp.com/attachments/614626265663668276/1079640291906170921/canvas-fabric-mc119-1.0.2515-SNAPSHOT.jar). **Keep in mind that Canvas does not work with Sodium, Iris, OptiFine, or OptiFabric.**

4. Get some other mods that you want to play with, so long as they are not part of the incompatible list of mods mentioned above.
4. Download your preferred pipeline shaderpack. If you're looking for alternatives to Forget-me-not, try out [Lumi Lights](https://github.com/spiralhalo/LumiLights/releases), [Lomo (not for gameplay)](https://github.com/fewizz/lomo/releases), or [Aerie (vanilla-plus)](https://modrinth.com/shader/aerie-shaders).

5. Download your preferred pipeline shaderpack. If you're looking for alternatives to Forget-me-not, try out [Lumi Lights](https://github.com/spiralhalo/LumiLights/releases). You can also try out [Lomo](https://github.com/fewizz/lomo/releases), but as of now, it isn't meant for gameplay purposes.
5. Launch your game, put your downloaded `.zip` file into your `resourcepacks` folder and activate the resource pack. (Don't extract it!)

6. Launch your game, put your downloaded `.zip` file into your `resourcepacks` folder and activate the resource pack. (Don't extract it!)

7. Navigate to `Options / Video Settings / Canvas / Pipeline Options / Pipelines` and select the pipeline that you want to play with.
6. Navigate to `Options / Video Settings / Canvas / Pipeline Options / Pipelines` and select the pipeline that you want to play with.

## troubleshooting

Expand Down
18 changes: 13 additions & 5 deletions assets/forgetmenot/shaders/gbuffer/main.frag
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,11 @@ void resolveMaterials() {
cross(frx_vertexTangent.xyz, frx_vertexNormal.xyz),
frx_vertexNormal.xyz
);

lightmap = vec3(1.0);

#ifdef SEASONS
vec3 worldSpacePos = getClippedWorldSpacePos();
vec3 worldSpacePos = getClippedWorldSpacePos();

#ifdef SEASONS
vec3 rcpVertexColor = 1.0 / frx_vertexColor.rgb;
frx_fragColor.rgb *= mix(vec3(1.0), rcpVertexColor * getSeasonColor(frx_vertexColor.rgb, fmn_isLeafBlock, worldSpacePos), 0.5 * fmn_isFoliage * step(0.001, distance(frx_vertexColor.rgb, vec3(1.0))));

Expand All @@ -122,9 +121,18 @@ void resolveMaterials() {
frx_fragNormal = frx_fragNormal * frx_normalModelMatrix;
}

if(!isInventory) {
//if(!frx_isHand) directionalLightmap();
// Rain effects
if(fmn_rainFactor > 0.0) {
float rainReflectionFactor = linearstep(0.0, 0.5, fmn_rainFactor) * step(0.95, frx_vertexNormal.y) * smoothstep(7.0 / 8.0, 15.0 / 16.0, frx_fragLight.y);
float puddleNoise = fbmHash(worldSpacePos.xz * 0.5, 3, 0.0);
puddleNoise += hash13(mod(worldSpacePos * 20.0, 100.0)) * 0.2 - 0.1;
puddleNoise = smoothstep(0.5 - 0.2 * frx_smoothedThunderGradient, 0.7, puddleNoise);

frx_fragRoughness = mix(frx_fragRoughness, 0.0, clamp01(puddleNoise * rainReflectionFactor + frx_smoothedThunderGradient * 0.1));
frx_fragReflectance = mix(frx_fragReflectance, 0.025, puddleNoise * rainReflectionFactor);
}

if(!isInventory) {
// If the current dimension is non-vanilla, use MC's lightmap.
if(isModdedDimension()) {
lightmap = texture(frxs_lightmap, frx_vertexLight.xy).rgb;
Expand Down
58 changes: 49 additions & 9 deletions assets/forgetmenot/shaders/lib/inc/fog.glsl
Original file line number Diff line number Diff line change
@@ -1,16 +1,56 @@
#include forgetmenot:shaders/lib/inc/cubemap.glsl
/*
#include forgetmenot:shaders/lib/inc/fog.glsl
float getFogTransmittance(const in float blockDist, const in float undergroundFactor) {
float fogAccumulator = length(max(0.0, blockDist - 20.0)) / 1500.0;
Contains various things for working with fog densities and color.
*/

float fogDensity = mix(0.5, 10.0, linearstep(0.1, -0.1, getSunVector().y));
fogDensity *= mix(1.0, 6.0, fmn_rainFactor);
fogDensity = mix(3.0, fogDensity, undergroundFactor);
fogDensity = mix(fogDensity, 30.0, float(frx_worldIsNether));
struct FogProfile {
float density;
float amount;
float scale;
};

float fogTransmittance = exp2(-fogAccumulator * fogDensity);
FogProfile getOverworldFogProfile(const in float undergroundFactor, const in float fogFalloff) {
FogProfile fp;

return fogTransmittance;
// Density modifiers
fp.density = mix(15.0, 1.0, fogFalloff);

// Density absolutes
fp.density = mix(fp.density, 15.0, fmn_rainFactor);
fp.density = mix(20.0, fp.density, undergroundFactor);

// Amount modifiers
fp.amount = mix(0.6, 0.0, fogFalloff);

// Amount absolutes
fp.amount = mix(fp.amount, 0.7, fmn_rainFactor);
fp.amount = mix(0.35, fp.amount, undergroundFactor);
fp.amount = mix(fp.amount, 0.0, float(frx_cameraInWater));

// Scale modifiers
fp.scale = 1.0;

// Scale absolutes
fp.scale = mix(3.0, fp.scale, undergroundFactor);

return fp;
}

FogProfile getNetherFogProfile() {
return FogProfile(15.0, 0.45, 3.0);
}

FogProfile getEndFogProfile() {
return FogProfile(15.0, 0.3, 3.0);
}

FogProfile getFogProfile(const in float undergroundFactor) {
if(frx_worldIsNether == 1) return getNetherFogProfile();
if(frx_worldIsEnd == 1) return getEndFogProfile();

float fogFalloff = linearstep(0.0, 0.2, getSunVector().y);
return getOverworldFogProfile(undergroundFactor, fogFalloff);
}

vec3 getFogScattering(const in vec3 viewDir, const in float vlFactor, const in float undergroundFactor, const in samplerCube skybox, const in sampler2D multiscatteringLut) {
Expand Down
6 changes: 4 additions & 2 deletions assets/forgetmenot/shaders/lib/inc/sky_display.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,11 @@ vec3 getSkyColor(
vec3 dayColor = dayColorSample + sun;
vec3 nightColor = nightColorSample + moon;

return 40.0 * blueHourMultiplier * (dayColor + nightColor);
vec3 result = 40.0 * blueHourMultiplier * (dayColor + nightColor);

return result * (1.0 + 9.0 * frx_skyFlashStrength);
} else if(frx_worldIsNether == 1) {
return normalize(pow(frx_fogColor.rgb, vec3(2.2))) * 0.2;
return normalize(pow(frx_fogColor.rgb, vec3(2.2))) * 0.4;
} else if(frx_worldIsEnd == 1) {
vec3 starCoord = viewDir * 1.5;

Expand Down
41 changes: 23 additions & 18 deletions assets/forgetmenot/shaders/post/fabulous/sort.frag
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ void main() {
composite = mix(composite, translucent_color.rgb, translucent_color.a * getClosestDepth(translucent_depth, composite_depth) * step(material.isWater, 0.5)); // that last part disables water blending
composite = mix(composite, particles_color.rgb, particles_color.a * getClosestDepth(particles_depth, composite_depth));
composite = mix(composite, entity_color.rgb, entity_color.a * getClosestDepth(entity_depth, composite_depth));
composite = mix(composite, weather_color.rgb, weather_color.a * step(weather_depth, composite_depth));

sceneSpacePosBack = setupSceneSpacePos(texcoord, main_depth);
sceneSpacePos = setupSceneSpacePos(texcoord, composite_depth);
Expand All @@ -143,7 +142,7 @@ void main() {
composite *= mix(fNormalize(waterFogColor), vec3(1.0), exp(-waterFogDistance));

// Water scattering
composite = mix(waterFogColor * max(material.skyLight, frx_smoothedEyeBrightness.y), composite, exp(-waterFogDistance * (WATER_DIRT_AMOUNT + 0.4 * frx_cameraInWater)) * 0.99 + 0.01);
composite = mix(waterFogColor * max(material.skyLight, frx_smoothedEyeBrightness.y), composite, exp(-waterFogDistance * (WATER_DIRT_AMOUNT)) * 0.99 + 0.01);
}

// ----------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -209,25 +208,27 @@ void main() {
const int VOLUMETRIC_FOG_STEPS = 5;

float blockDistance = rcp(inversesqrt(dot(sceneSpacePos, sceneSpacePos)));
float undergroundFactor = max(frx_smoothedEyeBrightness.y, material.skyLight);

float fogDensity = mix(30.0, 1.0, linearstep(0.0, 0.2, getSunVector().y));
fogDensity *= mix(1.0, 2.0, fmn_rainFactor);
fogDensity = mix(20.0, fogDensity, undergroundFactor);
fogDensity = mix(fogDensity, 15.0, float(frx_worldIsNether));
// float fogDensity = mix(30.0, 1.0, linearstep(0.0, 0.2, getSunVector().y));
// fogDensity *= mix(1.0, 2.0, fmn_rainFactor);
// fogDensity = mix(20.0, fogDensity, undergroundFactor);
// fogDensity = mix(fogDensity, 15.0, float(frx_worldIsNether));

// float fogAmount = mix(0.5, 0.0, linearstep(0.0, 0.2, getSunVector().y));
// fogAmount *= mix(1.0, 2.0, fmn_rainFactor);
// fogAmount = mix(0.35, fogAmount, undergroundFactor);
// fogAmount = mix(fogAmount, 0.45, float(frx_worldIsNether));

float fogAmount = mix(0.5, 0.0, linearstep(0.0, 0.2, getSunVector().y));
fogAmount *= mix(1.0, 2.0, fmn_rainFactor);
fogAmount = mix(0.35, fogAmount, undergroundFactor);
fogAmount = mix(fogAmount, 0.45, float(frx_worldIsNether));
// float fogScale = 1.0;
// fogScale = mix(3.0, fogScale, undergroundFactor);
// fogScale = mix(fogScale, 3.0, float(frx_worldIsNether));

float fogScale = 1.0;
fogScale = mix(3.0, fogScale, undergroundFactor);
fogScale = mix(fogScale, 3.0, float(frx_worldIsNether));
float undergroundFactor = linearstep(0.0, 0.5, max(frx_eyeBrightness.y, material.skyLight));
FogProfile fp = getFogProfile(undergroundFactor);

float fogAccumulator = 0.0;

if(fogAmount > 0.0) {
if(fp.amount > 0.0) {
vec3 startPos = vec3(0.0);
vec3 endPos = viewDir * min(blockDistance, min(128.0, frx_viewDistance));

Expand All @@ -237,18 +238,22 @@ void main() {
for(int i = 0; i < VOLUMETRIC_FOG_STEPS; i++) {
vec3 fogPos = startPos + rayStep * (i + interleavedGradient(i));

vec3 samplePos = (fogPos + frx_cameraPos) * vec3(0.0125, 0.025, 0.0125) * fogScale;
fogAccumulator += 0.5 * smoothstep(1.0 - clamp01(fogAmount), 1.0, fbmHash3D(samplePos, 3, 0.1 * undergroundFactor)) / VOLUMETRIC_FOG_STEPS;
vec3 samplePos = (fogPos * vec3(0.0125, 0.025, 0.0125) + frx_cameraPos * vec3(0.0125, 0.025, 0.0125)) * fp.scale;
fogAccumulator += 0.5 * smoothstep(1.0 - clamp01(fp.amount), 1.0, fbmHash3D(samplePos, 3, 0.1 * undergroundFactor)) / VOLUMETRIC_FOG_STEPS;
}

fogAccumulator *= rcp(inversesqrt(dot(endPos, endPos))) / 128.0;
}

float fogTransmittance = exp2(-fogAccumulator * fogDensity);
float fogTransmittance = exp2(-fogAccumulator * fp.density);
vec3 fogScattering = getFogScattering(viewDir, 0.0, undergroundFactor, u_skybox, u_multiscattering);

composite = mix(fogScattering, composite, fogTransmittance);

// ----------------------------------------------------------------------------------------------------
// Weather blending
composite = mix(composite, weather_color.rgb, weather_color.a * step(weather_depth, composite_depth));

// ----------------------------------------------------------------------------------------------------
// Writing to buffers
fragColor = vec4(composite, fogTransmittance);
Expand Down
36 changes: 36 additions & 0 deletions assets/forgetmenot/shaders/post/fabulous/volumetric_fog.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include forgetmenot:shaders/lib/inc/header.glsl
#include forgetmenot:shaders/lib/inc/noise.glsl

uniform sampler2D u_color;

in vec2 texcoord;

layout(location = 0) out float fogTransmittance;

void main() {
const int VOLUMETRIC_FOG_STEPS = 5;

float blockDistance = rcp(inversesqrt(dot(sceneSpacePos, sceneSpacePos)));
float undergroundFactor = max(frx_smoothedEyeBrightness.y, material.skyLight);

float fogAccumulator = 0.0;


vec3 startPos = vec3(0.0);
vec3 endPos = viewDir * min(blockDistance, min(128.0, frx_viewDistance));

vec3 rayStep = (endPos - startPos) / VOLUMETRIC_FOG_STEPS;

for(int i = 0; i < VOLUMETRIC_FOG_STEPS; i++) {
vec3 fogPos = startPos + rayStep * (i + interleavedGradient(i));

vec3 samplePos = (fogPos + frx_cameraPos) * vec3(0.025, 0.05, 0.025);
fogAccumulator += 0.5 * smoothstep(0.5, 1.0, fbmHash3D(samplePos, 3)) / VOLUMETRIC_FOG_STEPS;
}

fogAccumulator *= rcp(inversesqrt(dot(endPos, endPos))) / 128.0;
fogAccumulator *= linearstep(0.0, 0.5, mix(material.skyLight, 1.0, floor(composite_depth)));

fogTransmittance = exp2(-fogAccumulator * 30.0);

}
62 changes: 34 additions & 28 deletions assets/forgetmenot/shaders/post/final.frag
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,39 @@ in float exposure;

layout(location = 0) out vec4 fragColor;

// Lottes 2016, "Advanced Techniques and Optimization of HDR Color Pipelines"
vec3 lottes(vec3 x) {
const vec3 a = vec3(1.6);
const vec3 d = vec3(0.977);
const vec3 hdrMax = vec3(8.0);
const vec3 midIn = vec3(0.18);
const vec3 midOut = vec3(0.267);

const vec3 b =
(-pow(midIn, a) + pow(hdrMax, a) * midOut) /
((pow(hdrMax, a * d) - pow(midIn, a * d)) * midOut);
const vec3 c =
(pow(hdrMax, a * d) * pow(midIn, a) - pow(hdrMax, a) * pow(midIn, a * d) * midOut) /
((pow(hdrMax, a * d) - pow(midIn, a * d)) * midOut);

return pow(x, a) / (pow(x, a * d) * b + c);
struct ExposureProfile {
float bias;
float minExposure;
float maxExposure;
};

ExposureProfile getOverworldExposureProfile() {
return ExposureProfile(0.4, 0.4, 2.0);
}
ExposureProfile getNetherExposureProfile() {
return ExposureProfile(0.2, 1.5, 2.0);
}
ExposureProfile getEndExposureProfile() {
return ExposureProfile(0.2, 1.0, 1.4);
}

ExposureProfile getExposureProfile() {
if(frx_worldIsNether == 1) return getNetherExposureProfile();
if(frx_worldIsEnd == 1) return getEndExposureProfile();
return getOverworldExposureProfile();
}

float getExposureValue(const in ExposureProfile ep, const in float luminance) {
float ev100 = log2(luminance * 100.0 * ep.bias / 12.5);
float exposureValue = 1.0 / (1.2 * exp2(ev100));

return clamp(exposureValue, ep.minExposure, ep.maxExposure);
}
float getExposureValue(const in float luminance) {
return getExposureValue(getExposureProfile(), luminance);
}
float getExposureValue() {
return getExposureValue(exposure);
}

void main() {
Expand All @@ -49,18 +66,7 @@ void main() {
vec3 finalColor = color.rgb;

#ifdef ENABLE_BLOOM
//finalColor *= 0.5 / clamp(exposure * 0.9 + 0.1, 0.1, 1.5);
//finalColor *= 0.5 * rcp(clamp(exposure, 0.2, 1.5));

const float bias = 0.2;
float ev100 = log2(exposure * 100.0 * bias / 12.5);

const float minExposure = 0.4;
const float maxExposure = 2.0;
float exposureValue = 1.0 / (1.2 * exp2(ev100));
exposureValue = clamp(exposureValue, minExposure, maxExposure);

finalColor *= exposureValue;
finalColor *= getExposureValue();
#endif

// aces tonemap
Expand Down
2 changes: 2 additions & 0 deletions assets/minecraft/materials/lava.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"disableAo": true,
"disableDiffuse": true,
"layers": [
{
"vertexSource": "minecraft:shaders/material/varying.vert",
Expand Down

0 comments on commit b9a863a

Please sign in to comment.