Skip to content

Commit

Permalink
tweak some tutorial naming scheme stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
jbritain committed Oct 22, 2024
1 parent 5ae1220 commit e1f55e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ So, to apply our lighting, we would then do something like `color.rgb *= ambient

First, let's define some colors/brightnesses for each term. I chose the following on a whim.
```glsl
const vec3 torchColor = vec3(1.0, 0.5, 0.08);
const vec3 skyColor = vec3(0.05, 0.15, 0.3);
const vec3 blocklightColor = vec3(1.0, 0.5, 0.08);
const vec3 skylightColor = vec3(0.05, 0.15, 0.3);
const vec3 sunlightColor = vec3(1.0);
const vec3 ambientColor = vec3(0.1);
```
Expand All @@ -81,8 +81,8 @@ I have defined these before `main`, they are `const`s which means they are defin
Let's get these values applied.

```glsl
vec3 blocklight = lightmap.r * torchColor;
vec3 skylight = lightmap.g * skyColor;
vec3 blocklight = lightmap.r * blocklightColor;
vec3 skylight = lightmap.g * skylightColor;
vec3 ambient = ambientColor;
vec3 sunlight = sunlightColor; // we will fix this in a minute
Expand Down
6 changes: 3 additions & 3 deletions src/content/docs/guides/Beginners/Your First Shader/5_fog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ Like we did before, let's define a fog density. I have chosen 5.

We can then update our fog blending to make use of this value.
```glsl
float distance = length(viewPos) / far;
float fogFactor = exp(-FOG_DENSITY * (1.0 - distance));
float dist = length(viewPos) / far;
float fogFactor = exp(-FOG_DENSITY * (1.0 - dist));
color.rgb = mix(color.rgb, fogColor, clamp(fogFactor, 0.0, 1.0));
```

:::caution[Warning]
Note that we clamp the value of `fogFactor` between `0` and `1`. This is because the behaviour of `mix` is undefined if it is outside this range. Since the render distance in blocks is along three axes, blocks can be more than this distance away along the diagonals, so in some cases, `distance` could be more than `1`.
Note that we clamp the value of `fogFactor` between `0` and `1`. This is because the behaviour of `mix` is undefined if it is outside this range. Since the render distance in blocks is along three axes, blocks can be more than this distance away along the diagonals, so in some cases, `dist` could be more than `1`.
:::

![](../../../../../assets/beginner_tutorial/exponentialfog.webp)
Expand Down

0 comments on commit e1f55e8

Please sign in to comment.