Skip to content

Commit 4260a34

Browse files
committed
Other: Shrinker.Avalonia - Update the readme.
1 parent a610818 commit 4260a34

File tree

6 files changed

+105
-43
lines changed

6 files changed

+105
-43
lines changed

README.md

Lines changed: 105 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
* Requires the [ASP.NET runtime](https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-aspnetcore-6.0.0-windows-hosting-bundle-installer), if not already installed.
66

77
## What Is It For?
8-
GLSL Shader Shrinker is a Windows GUI tool that attempts to reduce the size of GLSL fragment shader code, whilst keeping it _readable_ and understandable.
8+
GLSL Shader Shrinker is a cross-platform GUI tool that attempts to reduce the size of GLSL fragment shader code, whilst keeping it _readable_ and understandable.
99

10-
It is written in C# using WPF and Visual Studio 2019, and has several hundred NUnit-powered unit tests.
10+
It is written in C# using [Avalonia](https://avaloniaui.net/) and [JetBrains Rider](https://www.jetbrains.com/rider/), and has several hundred NUnit-powered unit tests.
1111

1212
![Main UI](img/ED209.png?raw=true "Main UI")
1313

14-
It is designed to work primarily with code from [Shadertoy](https://www.shadertoy.com/), but has limited support for other styles of GLSL too (E.g. [Bonzomatic](https://github.com/Gargaj/Bonzomatic))
14+
It is designed to work primarily with code from [Shadertoy](https://www.shadertoy.com/), but has limited support for other styles of GLSL too (E.g. [Bonzomatic](https://github.com/Gargaj/Bonzomatic), [Posh Brolly](https://www.poshbrolly.net/))
1515

16-
After writing a Shadertoy shader, usually from my boilerplate starting code, there is a sequence of operations I perform:
16+
After writing a shader, usually from my boilerplate starting code, there is a sequence of operations I perform:
1717
* Delete dead/commented-out code.
1818
* Remove unused functions.
1919
* Inline some constants (Max raymarching distance, 'hit test' accuracy, ...)
@@ -65,9 +65,9 @@ void mainImage(out vec4 fragColor, vec2 fragCoord) {
6565
---
6666
## Getting Started
6767

68-
First, download and run the Windows installer from the 'Releases' section.
68+
First, download and run the installer from the 'Releases' section.
6969

70-
**Note:** The application requires the Microsoft .NET 5 runtimes to be installed. If they are not found the application will automatically prompt for them to be downloaded.
70+
**Note:** The application requires the Microsoft .NET 7 runtimes to be installed. If they are not found the application will automatically prompt for them to be downloaded.
7171

7272
### Step 1 - Import GLSL Code
7373
You first need to import your GLSL into the tool.
@@ -81,71 +81,133 @@ This can be achieved using:
8181

8282
![Shadertoy](img/Shadertoy.png?raw=true "Shadertoy")
8383

84-
### Step 2 - Shrink GLSL Code
84+
### Step 2 - Process GLSL Code
8585
Next choose the level of processing you want to apply.
8686

8787
![Shrink](img/Shrink.png?raw=true "Shrink")
8888

89-
* Maximum processing - All options enabled.
90-
* Minimal processing - Minimal changes (Mostly code reformatting).
91-
* Custom options - Toggle exactly which processing features you require (Including GOLFing options)
89+
* Maximum - All options enabled.
90+
* Reformat - Minimal changes (Mostly code reformatting).
91+
* Remove Dead Code - Remove unreferences functions and unreachable code.
92+
* Custom - Toggle exactly which processing features you require (Including GOLFing options)
9293

9394
### Step 3 - Exporting GLSL Code
94-
Export the 'shrunk' GLSL.
95+
Export the 'processed' GLSL.
9596

9697
![Export](img/Export.png?raw=true "Export")
9798

9899
This can be achieved using:
99100
* Copy'n'paste from the clipboard. (CTRL-C)
100-
* Export from a text file.
101+
* Export to a text file.
101102

102103
...and then use with Shadertoy, Bonzomatic, etc.
103104

104105
---
105106
## Hints
106-
After shrinking your GLSL code, you might find some 'hints' are available.
107+
After processing your GLSL code, you might find some 'hints' are available.
107108
These range from 'this function isn't used' or 'this function is only used once, so you might like to inline it', all the way to some GOLFing hints.
108109

109110
![Export](img/Hints.png?raw=true "Export")
110111

111112
---
112113
## Limitations
113-
Despite a lot of effort spent trying to ensure the tool produces great output every time, there are always going to be edge cases caused by different coding styles and patterns of content.
114+
Despite a lot of effort spent trying to ensure the tool produces valid output every time, there are always going to be edge cases caused by different coding styles and patterns of content.
114115

115116
Heavy use of ```#define``` macros and ```#if...#else...#endif``` blocks can cause confusion when trying to parse the code. Compilers have the luxury of seeing which specific code path is enabled, but a tool like this needs to understand **all** possible code paths at the same time - Not always easy!
116117

117-
I apologize in advance if you find any issues - If I have the time I'll try my best to resolve them!
118-
119-
In most cases they can be worked-around using a set of 'custom' settings which disable the problematic feature.
118+
In most cases issues can be worked-around using a set of 'custom' settings which disable the problematic feature.
120119

121120
---
122121
# Features
123-
* [Remove Comments](#remove-comments)
124-
* [Keep Header Comments](#keep-header-comments)
125-
* [Remove Unused Functions](#remove-unused-functions)
126-
* [Remove Unused Variables](#remove-unused-variables)
127-
* [Remove Unreachable Code](#remove-unreachable-code)
128-
* [Remove Disabled Code](#remove-disabled-code)
129-
* [Simplify Function Declarations](#simplify-function-declarations)
130-
* [Simplify Function Parameters](#simplify-function-parameters)
131-
* [Group Variable Declarations](#group-variable-declarations)
132-
* [Join Variable Declarations and Assignments](#join-variable-declarations-and-assignments)
133-
* [Detect New Constants](#detect-new-constants)
134-
* [Inline Constant Variables](#inline-constant-variables)
135-
* [Inline Constant #defines](#inline-constant-#defines)
136-
* [Simplify Number Format](#simplify-number-format)
137-
* [Simplify Vector Construction](#simplify-vector-construction)
138-
* [Simplify Vector References](#simplify-vector-references)
139-
* [Simplify Code Branching](#simplify-code-branching)
140-
* [Combine Consecutive Assignments](#combine-consecutive-assignments)
141-
* [Combine Assignment With Single Use](#combine-assignment-with-single-use)
142-
* [Introduce +=, -=, /=, *=](#introduce-+=,--=,-/=,-*=)
143-
* [Simplify Mathematical Expressions](#simplify-mathematical-expressions)
144-
* [Perform Simple Arithmetic](#perform-simple-arithmetic)
145-
* [Replace Functions Calls With Result](#replace-functions-calls-with-result)
146-
* [Move constant parameters to within called functions](#move-constant-parameters-to-within-called-functions)
147-
* [GOLF user defined code names](#golf-user-defined-code-names)
148-
* [Define common terms](#define-common-terms)
122+
- [GLSL Shader Shrinker](#glsl-shader-shrinker)
123+
- [What Is It For?](#what-is-it-for)
124+
- [What It *Can* Do](#what-it-can-do)
125+
- [Example (Shadertoy Starting Point)](#example-shadertoy-starting-point)
126+
- [Before Processing](#before-processing)
127+
- [After Processing](#after-processing)
128+
- [Getting Started](#getting-started)
129+
- [Step 1 - Import GLSL Code](#step-1---import-glsl-code)
130+
- [Step 2 - Process GLSL Code](#step-2---process-glsl-code)
131+
- [Step 3 - Exporting GLSL Code](#step-3---exporting-glsl-code)
132+
- [Hints](#hints)
133+
- [Limitations](#limitations)
134+
- [Features](#features)
135+
- [Remove Comments](#remove-comments)
136+
- [Before](#before)
137+
- [After](#after)
138+
- [Keep Header Comments](#keep-header-comments)
139+
- [Before](#before-1)
140+
- [After](#after-1)
141+
- [Remove Unused Functions](#remove-unused-functions)
142+
- [Remove Unused Variables](#remove-unused-variables)
143+
- [Before](#before-2)
144+
- [After](#after-2)
145+
- [Remove Unreachable Code](#remove-unreachable-code)
146+
- [Before](#before-3)
147+
- [After](#after-3)
148+
- [Remove Disabled Code](#remove-disabled-code)
149+
- [Before](#before-4)
150+
- [After](#after-4)
151+
- [Simplify Function Declarations](#simplify-function-declarations)
152+
- [Before](#before-5)
153+
- [After](#after-5)
154+
- [Simplify Function Parameters](#simplify-function-parameters)
155+
- [Before](#before-6)
156+
- [After](#after-6)
157+
- [Group Variable Declarations](#group-variable-declarations)
158+
- [Before](#before-7)
159+
- [After](#after-7)
160+
- [Join Variable Declarations and Assignments](#join-variable-declarations-and-assignments)
161+
- [Before](#before-8)
162+
- [After](#after-8)
163+
- [Detect New Constants](#detect-new-constants)
164+
- [Before](#before-9)
165+
- [After](#after-9)
166+
- [Inline Constant Variables](#inline-constant-variables)
167+
- [Before](#before-10)
168+
- [After](#after-10)
169+
- [Inline Constant #defines](#inline-constant-defines)
170+
- [Before](#before-11)
171+
- [After](#after-11)
172+
- [Simplify Number Format](#simplify-number-format)
173+
- [Before](#before-12)
174+
- [After](#after-12)
175+
- [Simplify Vector Construction](#simplify-vector-construction)
176+
- [Before](#before-13)
177+
- [After](#after-13)
178+
- [Simplify Vector References](#simplify-vector-references)
179+
- [Before](#before-14)
180+
- [After](#after-14)
181+
- [Simplify Code Branching](#simplify-code-branching)
182+
- [Before](#before-15)
183+
- [After](#after-15)
184+
- [Combine Consecutive Assignments](#combine-consecutive-assignments)
185+
- [Before](#before-16)
186+
- [After](#after-16)
187+
- [Combine Assignment With Single Use](#combine-assignment-with-single-use)
188+
- [Before](#before-17)
189+
- [After](#after-17)
190+
- [Before](#before-18)
191+
- [After](#after-18)
192+
- [Introduce +=, -=, /=, \*=](#introduce-----)
193+
- [Before](#before-19)
194+
- [After](#after-19)
195+
- [Simplify Mathematical Expressions](#simplify-mathematical-expressions)
196+
- [Before](#before-20)
197+
- [After](#after-20)
198+
- [Perform Simple Arithmetic](#perform-simple-arithmetic)
199+
- [Replace Functions Calls With Result](#replace-functions-calls-with-result)
200+
- [Before](#before-21)
201+
- [After](#after-21)
202+
- [Move constant parameters to within called functions](#move-constant-parameters-to-within-called-functions)
203+
- [Before](#before-22)
204+
- [After](#after-22)
205+
- [GOLF user defined code names](#golf-user-defined-code-names)
206+
- [Before](#before-23)
207+
- [After](#after-23)
208+
- [Define common terms](#define-common-terms)
209+
- [Before](#before-24)
210+
- [After](#after-24)
149211
## Remove Comments
150212
Remove all C/C++ -style comments from the code.
151213
#### Before

img/ED209.png

-13 KB
Loading

img/Export.png

-3.36 KB
Loading

img/Hints.png

1.27 KB
Loading

img/Import.png

1.61 KB
Loading

img/Shrink.png

-3.79 KB
Loading

0 commit comments

Comments
 (0)