From 86b1595966d3128fffa46d1eeb8f247c86e99e74 Mon Sep 17 00:00:00 2001 From: Josh Britain <50422789+jbritain@users.noreply.github.com> Date: Wed, 13 Nov 2024 12:57:25 +0000 Subject: [PATCH] fix typos and improve comment readability in shadow section --- .../Your First Shader/1_composite.mdx | 2 +- .../Beginners/Your First Shader/4_shadows.mdx | 28 ++++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/content/docs/guides/Beginners/Your First Shader/1_composite.mdx b/src/content/docs/guides/Beginners/Your First Shader/1_composite.mdx index a269c44..281599f 100644 --- a/src/content/docs/guides/Beginners/Your First Shader/1_composite.mdx +++ b/src/content/docs/guides/Beginners/Your First Shader/1_composite.mdx @@ -11,7 +11,7 @@ This tutorial is still being developed. Some statements may be incorrect, and th ::: ## Setting up the file structure -Minecraft shaders require a specific structure of files in the right places to load code. While it's important to understand this structure, to save time, we will be working with the Base 330 pack from shaderLABs. Download it from [here](https://github.com/shaderLABS/Base-330), and extract it into your `shaderpacks` folder. You should have the following structure. +Minecraft shaders require a specific structure of files in the right places to load code. While it's important to understand this structure, to save time, we will be working with the Base 330 pack from shaderLABS. Download it from [here](https://github.com/shaderLABS/Base-330), and extract it into your `shaderpacks` folder. You should have the following structure. ``` . diff --git a/src/content/docs/guides/Beginners/Your First Shader/4_shadows.mdx b/src/content/docs/guides/Beginners/Your First Shader/4_shadows.mdx index 6ac0c99..7d66e06 100644 --- a/src/content/docs/guides/Beginners/Your First Shader/4_shadows.mdx +++ b/src/content/docs/guides/Beginners/Your First Shader/4_shadows.mdx @@ -186,9 +186,9 @@ We can then add ```glsl #include /lib/distort.glsl ``` -to our `shadow.vsh`. *This should be included before the `main` function, as you cannot define functions within a function. I put mine just before my `out` declarations. +to our `shadow.vsh`. *This should be included before the `main` function, as you cannot define functions within a function.* I put mine just before my `out` declarations. -**We should also move our declaration of `shadowmapresolution` to `distort.glsl`.** This way, we can access this variable anywhere we are sampling the shadow map. +**We should also move our declaration of `shadowMapResolution` to `distort.glsl`.** This way, we can access this variable anywhere we are sampling the shadow map. :::caution[Warning] Preprocessor directives *do not have a semicolon on the end*. @@ -268,21 +268,35 @@ Let's go back to `composite.fsh` and make a new function called `getShadow`. It vec3 getShadow(vec3 shadowScreenPos){ float transparentShadow = step(shadowScreenPos.z, texture(shadowtex0, shadowScreenPos.xy).r); // sample the shadow map containing everything - // note that a value of 1.0 means 100% of sunlight is getting through, not that there is 100% shadowing + /* + note that a value of 1.0 means 100% of sunlight is getting through + not that there is 100% shadowing + */ - if(transparentShadow == 1.0){ // since this shadow map contains everything, there is no shadow at all so we return full sunlight + if(transparentShadow == 1.0){ + /* + since this shadow map contains everything, + there is no shadow at all, so we return full sunlight + */ return vec3(1.0); } float opaqueShadow = step(shadowScreenPos.z, texture(shadowtex1, shadowScreenPos.xy).r); // sample the shadow map containing only opaque stuff - if(opaqueShadow == 0.0){ // there is a shadow cast by something opaque, so we return no sunlight + if(opaqueShadow == 0.0){ + // there is a shadow cast by something opaque, so we return no sunlight return vec3(0.0); } - vec4 shadowColor = texture(shadowcolor0, shadowScreenPos.xy); // contains the color and alpha (transparency) of the thing casting a shadow + // contains the color and alpha (transparency) of the thing casting a shadow + vec4 shadowColor = texture(shadowcolor0, shadowScreenPos.xy); - return shadowColor.rgb * (1.0 - shadowColor.a); // we use 1 - the alpha to get how much light is let through and multiply that light by the color of the caster + + /* + we use 1 - the alpha to get how much light is let through + and multiply that light by the color of the caster + */ + return shadowColor.rgb * (1.0 - shadowColor.a); } ```