Skip to content
Closed
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
33381d6
update action to allow deploying other branches
cdhanna Aug 28, 2025
20f2bf8
2dshader tutorial
cdhanna Aug 30, 2025
827d325
Merge branch 'main-monogame'
cdhanna Aug 30, 2025
8499c83
edits to toc
cdhanna Aug 30, 2025
dbfe09a
restore missing chapter 4.
cdhanna Aug 31, 2025
a84df78
pass to remove all contractions
cdhanna Aug 31, 2025
9c4143d
tracking: 2.1
cdhanna Aug 31, 2025
eb08554
tracking 3.1
cdhanna Aug 31, 2025
cb91fd0
tracking 3.2
cdhanna Aug 31, 2025
d623455
tracking 3.3
cdhanna Aug 31, 2025
2b1b856
tracking 3.4
cdhanna Aug 31, 2025
c27012b
tracking 3.5
cdhanna Aug 31, 2025
8093200
tracking 3.6
cdhanna Aug 31, 2025
9dfa203
tacking 3.7
cdhanna Aug 31, 2025
00a7f5e
tracking 3.8
cdhanna Aug 31, 2025
1398f3f
update submodules
cdhanna Sep 1, 2025
aaebb02
struggling with submodules
cdhanna Sep 1, 2025
3fc677a
restore inside submodule
cdhanna Sep 1, 2025
414f8a3
copying premake step from main repo
cdhanna Sep 1, 2025
0c9437d
restore mg stuff
cdhanna Sep 1, 2025
b59721e
Merge branch 'main' into main
SimonDarksideJ Sep 1, 2025
9be7a65
Merge branch 'main' into main
SimonDarksideJ Sep 1, 2025
dafd0fc
Merge branch 'main' into main
SimonDarksideJ Sep 1, 2025
60d7a86
Fixed SpriteBatch xref, no such item in the MonoGame API called "Spri…
SimonDarksideJ Sep 1, 2025
463baec
Merge branch 'main-monogame'
cdhanna Sep 3, 2025
ff17275
adding gif support to docfx file
cdhanna Sep 3, 2025
7cdb033
submodules up to dev
cdhanna Sep 3, 2025
287c92d
build
cdhanna Sep 4, 2025
1068ddf
steal more build stuff from main repo
cdhanna Sep 4, 2025
baf71f0
add public folder to resources
cdhanna Sep 4, 2025
ff26e43
playing around with sitemap
cdhanna Sep 4, 2025
10ef1b4
use rel link
cdhanna Sep 4, 2025
71d61e9
fix toc; add hot reload at runtime message
cdhanna Sep 5, 2025
1336eb4
standardizing media link formatting
cdhanna Sep 5, 2025
7f3045c
extracted snippets and highlighted 02
cdhanna Sep 5, 2025
8ef191c
highlighting 03
cdhanna Sep 5, 2025
a9a0fa8
highlight 04
cdhanna Sep 5, 2025
eaba03a
tracking 4.1
cdhanna Sep 6, 2025
99142e6
tracking 5.1; overview gif
cdhanna Sep 6, 2025
c8a7cca
tracking 5.2; removed restatement of intro
cdhanna Sep 6, 2025
b4faa2c
tracking 5.3; mgcb pic, admonishments, minor typos
cdhanna Sep 6, 2025
f3003f8
tracking 5.4; some highlighting
cdhanna Sep 6, 2025
4d83827
tracking 5.5; note about auto shader parameter
cdhanna Sep 6, 2025
3bf0f4b
tracking 5.6
cdhanna Sep 6, 2025
bc7032d
tracking 5.7; smoothstep admonishment and top bold
cdhanna Sep 6, 2025
a12bc08
more code snippet updates in chapter 5
cdhanna Sep 6, 2025
aeee225
tracking 5.8; gradient textures in horizontal table
cdhanna Sep 6, 2025
215a3bc
more chapter 5 highlighting
cdhanna Sep 6, 2025
dc5e7c7
more code highlights for chapter 5
cdhanna Sep 7, 2025
8570b10
tracking 5.9
cdhanna Sep 7, 2025
76973fd
tracking 6-1; add overview graphic
cdhanna Sep 9, 2025
ee55ad9
tracking 6.2; mgcb screenshot and reword
cdhanna Sep 9, 2025
3bcb3a4
tracking 5.10; update to list
cdhanna Sep 9, 2025
ac84ea0
tracking 6.3
cdhanna Sep 9, 2025
1019fb5
tracking 6.4; bigger image previews
cdhanna Sep 9, 2025
017e2cb
tracking 6.5; table for colors
cdhanna Sep 10, 2025
58f4c8e
tracking 6.6
cdhanna Sep 10, 2025
48d4ddd
tracking 6.7; sources for luts
cdhanna Sep 10, 2025
d3c8191
highlighting snippets for 06
cdhanna Sep 10, 2025
c7331e3
fix css issues
cdhanna Sep 10, 2025
c31440d
tracking 7.1; overview gifs
cdhanna Sep 12, 2025
352e8e8
tracking 7.2; clarification around SV_Position
cdhanna Sep 12, 2025
c20b94e
fix admonishment typo
cdhanna Sep 12, 2025
e1a4fb4
tracking 7.3
cdhanna Sep 12, 2025
aac4d2d
tracking 7.4
cdhanna Sep 12, 2025
efc1869
tracking 7.5; number steps and mgcb screenshot
cdhanna Sep 12, 2025
6154cdb
some 07 snippets
cdhanna Sep 12, 2025
5b29b39
07 highlighting
cdhanna Sep 13, 2025
2f2b685
tracking 7.6; add missing text image
cdhanna Sep 13, 2025
44e228d
tracking 7.7; culling note
cdhanna Sep 13, 2025
113c0fa
tracking 7.8 ; walk back uber shader into admonish
cdhanna Sep 13, 2025
6e814c5
tracking 7.9 numbered steps
cdhanna Sep 13, 2025
d91ee41
tracking 8.1; dry and add overview gif
cdhanna Sep 14, 2025
1beda0a
tracking 8.2; add definitions
cdhanna Sep 14, 2025
c5ec5a9
tracking 8.3; render target null
cdhanna Sep 14, 2025
9a9929b
tracking 8.4; numbering steps and adding mgcb shots
cdhanna Sep 14, 2025
27c111c
tracking 8.5; add normal map link
cdhanna Sep 14, 2025
20a8d36
tracking 8.6; figures and workarounds
cdhanna Sep 14, 2025
f772f42
tracking 8.7; add another visual demo
cdhanna Sep 14, 2025
6478fd7
tracking 8.8
cdhanna Sep 14, 2025
0517ea0
some 08 highlights
cdhanna Sep 14, 2025
6c0c989
highlights for 08
cdhanna Sep 16, 2025
0ea6c63
add overview gif for chapter 9
cdhanna Sep 18, 2025
168f4aa
figure update
cdhanna Sep 18, 2025
3cfce22
adding mgcb
cdhanna Sep 18, 2025
a1f0ebf
tracking 9.1; numbering
cdhanna Sep 18, 2025
74f22b4
tracking 9.2; bit packing links
cdhanna Sep 18, 2025
e66e148
highlighitng and snippet context for 09
cdhanna Sep 19, 2025
265bc10
shadow visual improvements
cdhanna Sep 19, 2025
4748199
use overview gif
cdhanna Sep 19, 2025
7e802ba
tracking 10.1
cdhanna Sep 19, 2025
c94437a
format sig
cdhanna Sep 19, 2025
dc05dd9
minor clerical errors
cdhanna Sep 20, 2025
6ddec86
Review fixes
SimonDarksideJ Sep 21, 2025
a0214b6
Revert code block fixes
SimonDarksideJ Sep 21, 2025
4e4975e
tracking b2-1
cdhanna Sep 21, 2025
df41d18
tracking b2-2
cdhanna Sep 21, 2025
81306e6
Review/simon (#2)
SimonDarksideJ Sep 25, 2025
a6acacf
update hot reload for auto-start, net9, and support dotnet-run
cdhanna Sep 25, 2025
31c7a84
Rename snippet
SimonDarksideJ Oct 2, 2025
bac8e9f
Chapter 6 changes
SimonDarksideJ Oct 2, 2025
611fbbc
Feature/review continues (#3)
SimonDarksideJ Oct 8, 2025
b2baf7b
Further review and clean-up - CH6 / 7 (#4)
SimonDarksideJ Oct 11, 2025
f6094a5
updates for chapter 2
cdhanna Oct 11, 2025
a7d3c48
chapter 3 updates
cdhanna Oct 11, 2025
f8530ae
chapter 4 edits
cdhanna Oct 14, 2025
f5d039f
chapter 5 edits
cdhanna Oct 14, 2025
7039e08
chapter 6 notes
cdhanna Oct 23, 2025
056a034
some chapter 7 edits
cdhanna Oct 25, 2025
d95ce15
more chap7 notes
cdhanna Oct 25, 2025
014a349
some chap 8 comments
cdhanna Oct 26, 2025
9288f99
more chap 8 comments
cdhanna Oct 27, 2025
2c76f1a
fix chap 6 content dir, and fix chap 8 w confusion
cdhanna Nov 2, 2025
1b446d1
very minor changes
cdhanna Nov 3, 2025
a087b1d
figure 9-7
cdhanna Nov 3, 2025
b7e5362
fix fig numbers in 09
cdhanna Nov 3, 2025
56a9926
some chap 9 comments
cdhanna Nov 4, 2025
d71cd17
more chap 9 comments
cdhanna Nov 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
- name: Clone Repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
submodules: recursive

- name: Setup .NET SDK
Expand All @@ -50,4 +51,5 @@ jobs:

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

uses: actions/deploy-pages@v4
23 changes: 23 additions & 0 deletions articles/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,29 @@ items:
href: tutorials/building_2d_games/26_publish_to_itch/index.md
- name: "27: Conclusion and Next Steps"
href: tutorials/building_2d_games/27_conclusion/index.md
- name: 2D Shaders
href: tutorials/advanced/2d_shaders/
items:
- name: "01: Introduction"
href: tutorials/advanced/2d_shaders/01_introduction/
- name: "02: Hot Reload"
href: tutorials/advanced/2d_shaders/02_hot_reload/
- name: "03: The Material Class"
href: tutorials/advanced/2d_shaders/03_the_material_class/
- name: "04: Debug UI"
href: tutorials/advanced/2d_shaders/04_debug_ui/
- name: "05: Transition Effect"
href: tutorials/advanced/2d_shaders/05_transition_effect/
- name: "06: Color Swap Effect"
href: tutorials/advanced/2d_shaders/06_color_swap_effect/
- name: "07: Sprite Vertex Effect"
href: tutorials/advanced/2d_shaders/07_sprite_vertex_effect/
- name: "08: Light Effect"
href: tutorials/advanced/2d_shaders/08_light_effect/
- name: "09: Shadow Effect"
href: tutorials/advanced/2d_shaders/09_shadows_effect/
- name: "10: Next Steps"
href: tutorials/advanced/2d_shaders/10_next_steps/
- name: Console Access
href: console_access.md
- name: Help and Support
Expand Down
31 changes: 31 additions & 0 deletions articles/tutorials/advanced/2d_shaders/01_introduction/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: "Chapter 01: Getting Started"
description: "Prepare your project and get ready"
---

Welcome to the advanced 2D shaders tutorial! Before we dive into writing complex effects, this first chapter will make sure you are ready to go. We will get the starting project set up and take a quick look at the technical foundation of how shaders work with MonoGame's `SpriteBatch`.

## The Starting Code

This tutorial series builds directly on top of the final code from the "Building 2D Games" tutorial. It is essential that you start with this project.

> [!note]
> You can get the complete starting source code for this tutorial here:
> [The final chapter's source code](https://github.com/MonoGame/MonoGame.Samples/tree/3.8.4/Tutorials/learn-monogame-2d/src/24-Shaders/)

Once you have the code downloaded, open it in your IDE and run the `DungeonSlime` project to make sure everything is working correctly. You should see the title screen from the previous tutorial.

## Project Structure

The solution is organized into two main projects:

- **`DungeonSlime`**: The main game project. This contains our game logic and game-specific content.
- **`MonoGameLibrary`**: Our reusable class library. We will be adding new, generic helper classes here that could be used in any of your future MonoGame projects.

Most of our shader files (`.fx`) will be created in the `Content/effects` folder within the `DungeonSlime` project to start, and later within the `MonoGameLibrary` for shared effects.

## What is Next

Now that our project is set up, we can get to work. The focus for the first several chapters will be to create a workflow for developing shaders in MonoGame. Once we have a hot-reload system, a class to manage the effects, and a debug UI ready, we will carry on and build up 5 effects. The effects will range from simple pixel shaders and vertex shaders up to rendering techniques. As we develop these shaders together, we will build an intuition for how to tackle shader development.

Continue to the next chapter, [Chapter 02: Hot Reload](../02_hot_reload/index.md)
482 changes: 482 additions & 0 deletions articles/tutorials/advanced/2d_shaders/02_hot_reload/index.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ItemGroup>
<PackageReference Include="Gum.MonoGame" Version="2025.5.1.1" />
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.*" />
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.*" />
</ItemGroup>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#region declaration
using System;
using Microsoft.Xna.Framework.Content;

namespace MonoGameLibrary.Content;

public class WatchedAsset<T>
{

}

#endregion
{
#region members
/// <summary>
/// The latest version of the asset.
/// </summary>
public T Asset { get; set; }

/// <summary>
/// The last time the <see cref="Asset"/> was loaded into memory.
/// </summary>
public DateTimeOffset UpdatedAt { get; set; }

/// <summary>
/// The name of the <see cref="Asset"/>. This is the name used to load the asset from disk.
/// </summary>
public string AssetName { get; init; }

/// <summary>
/// The <see cref="ContentManager"/> instance that loaded the asset.
/// </summary>
public ContentManager Owner { get; init; }
#endregion

#region methods
public bool TryRefresh(out T oldAsset)
{
return Owner.TryRefresh(this, out oldAsset);
}
#endregion
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-mgcb": {
"version": "3.8.3",
"commands": [
"mgcb"
]
},
"dotnet-mgcb-editor": {
"version": "3.8.3",
"commands": [
"mgcb-editor"
]
},
"dotnet-mgcb-editor-linux": {
"version": "3.8.3",
"commands": [
"mgcb-editor-linux"
]
},
"dotnet-mgcb-editor-windows": {
"version": "3.8.3",
"commands": [
"mgcb-editor-windows"
]
},
"dotnet-mgcb-editor-mac": {
"version": "3.8.3",
"commands": [
"mgcb-editor-mac"
]
}
}
}
Binary file not shown.
Loading