diff --git a/Checker/Checker.fsproj b/Checker/Checker.fsproj
index b8c4dc10..46c18a98 100644
--- a/Checker/Checker.fsproj
+++ b/Checker/Checker.fsproj
@@ -44,6 +44,32 @@
11
+
+ true
+ full
+ false
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ 5
+ bin\Debug\Checker.XML
+ true
+ ../../..
+ --update-golden
+ x64
+
+
+ pdbonly
+ true
+ true
+ bin\Release\
+ TRACE
+ 3
+ bin\Release\Checker.XML
+ true
+ ..\..\..
+ x64
+
@@ -58,7 +84,11 @@
+
+
+ PreserveNewest
+
@@ -71,8 +101,6 @@
..\lib\OpenTK.dll
-
-
Shader Minifier Library
{059c6af3-1877-4698-be34-bf7eb55d060a}
diff --git a/Checker/compression_test.fs b/Checker/compression_test.fs
new file mode 100644
index 00000000..78439a1b
--- /dev/null
+++ b/Checker/compression_test.fs
@@ -0,0 +1,86 @@
+module CompressionTests
+
+open System.Runtime.InteropServices
+open System.IO
+open System.Text
+
+#nowarn "51" // use of native pointers
+
+module Crinkler =
+ []
+ extern void InitCompressor()
+
+ []
+ extern single ApproximateModels4k(char* data, int datasize)
+
+
+let testFiles = [
+ "audio-flight-v2.frag"
+ "buoy.frag"
+ "controllable-machinery.frag"
+ "ed-209.frag"
+ "elevated.hlsl"
+ "endeavour.frag"
+ "from-the-seas-to-the-stars.frag"
+ "frozen-wasteland.frag"
+ "kinder_painter.frag"
+ "leizex.frag"
+ "lunaquatic.frag"
+ "mandelbulb.frag"
+ "ohanami.frag"
+ "orchard.frag"
+ "oscars_chair.frag"
+ "robin.frag"
+ "slisesix.frag"
+ "terrarium.frag"
+ "the_real_party_is_in_your_pocket.frag"
+ "valley_ball.glsl"
+ "yx_long_way_from_home.frag"
+]
+
+let writer = new StringWriter()
+
+let log fmt =
+ let logger str =
+ printf "%s" str
+ writer.Write(str)
+
+ Printf.ksprintf logger fmt
+
+let compressionTest args files =
+ Options.init(args)
+ let minified =
+ use out = new StringWriter()
+ let shaders, exportedNames = ShaderMinifier.minifyFiles [|for f in files -> "tests/real/" + f|]
+ Formatter.print out shaders exportedNames Options.Text
+ out.ToString().ToCharArray()
+
+ let pointer = &&minified.[0]
+ log "%-40s " (match files with [f] -> f | f::_ -> f + "..." | [] -> "?")
+ log "%5d " minified.Length
+ let compressedSize = Crinkler.ApproximateModels4k(pointer, minified.Length)
+ log "=> %8.3f\n" compressedSize
+ minified.Length, float compressedSize
+
+let compressFile (file: string) =
+ let langArg = if file.EndsWith("hlsl") then [|"--hlsl"|] else [||]
+ let extraArgs = [|"--format"; "text"|]
+ compressionTest (Array.append langArg extraArgs) [file]
+
+let run () =
+ Crinkler.InitCompressor() // Platform must be set to x64
+
+ writer.GetStringBuilder().Clear() |> ignore
+
+ // Tests for minifying multiple files together.
+ // We don't have good examples of files that fit together, but these files use the same uniforms (e.g. time, tex0).
+ let multifileInputs = ["clod.frag"; "leizex.frag"; "slisesix.frag"; "motion_blur.frag"; "mandel.frag"; "kaleidoscope.frag"]
+ let multifileOutput = compressionTest [|"--format"; "text"|] multifileInputs
+
+ // Tests for individual files.
+ let sizes = multifileOutput :: List.map compressFile testFiles
+ let minifiedSum = List.sumBy fst sizes
+ let compressedSum = List.sumBy snd sizes
+ log "Total: %5d => %9.3f\n" minifiedSum compressedSum
+
+ File.WriteAllText("tests/compression_results.log", writer.ToString())
diff --git a/Checker/main.fs b/Checker/main.fs
index 3541d360..541d30b6 100644
--- a/Checker/main.fs
+++ b/Checker/main.fs
@@ -117,7 +117,9 @@ let testGolden () =
[]
let main argv =
- //ignore(runCommand("--no-renaming --format c-array -o tests/unit/minus-zero.expected tests/unit/minus-zero.frag".Split([|' '|]))); exit 0
+ // Manually run compression tests by enabling this line:
+ // CompressionTests.run ()
+
initOpenTK()
let mutable failures = testGolden()
Options.init([|"--format"; "text"; "fake.frag"|])
diff --git a/README.md b/README.md
index f65d435d..7a8e1fc4 100644
--- a/README.md
+++ b/README.md
@@ -95,13 +95,13 @@ $ mono shader_minifier.exe # Linux, Mac...
```
USAGE: Shader Minifier [--help] [-o ] [-v] [--hlsl]
- [--format ]
+ [--format ]
[--field-names ] [--preserve-externals]
[--preserve-all-globals] [--no-inlining]
[--aggressive-inlining] [--no-renaming]
[--no-renaming-list ] [--no-sequence]
[--smoothstep] [--no-remove-unused]
- [--no-move-declarations] [...]
+ [--move-declarations] [...]
FILENAMES:
@@ -112,7 +112,7 @@ OPTIONS:
-o Set the output filename (default is shader_code.h)
-v Verbose, display additional information
--hlsl Use HLSL (default is GLSL)
- --format
+ --format
Choose to format the output (use 'text' if you want
just the shader)
--field-names
@@ -135,8 +135,7 @@ OPTIONS:
--no-sequence Do not use the comma operator trick
--smoothstep Use IQ's smoothstep trick
--no-remove-unused Do not remove unused code
- --no-move-declarations
- Do not move declarations to group them
+ --move-declarations Move declarations to group them
--help display this list of options.
```
@@ -148,8 +147,8 @@ In short:
If you pass `-` for the output, it will be printed on stdout.
* Use `--format` to control the output format. By default, it will create a C
- header. There are other options to get only the shader, or have it in a .js or
- nasm file.
+ header. There are other options to get only the shader, or have it in a
+ Javascript, Rust, or nasm file.
## Tips
@@ -414,6 +413,75 @@ if (x) y = 123,x++;
**Note**: This transformation doesn't always decrease the compressed file size.
Use `--no-sequence` to disable it and see how it performs.
+### Useless else after return
+
+When a if always ends in a return, the else can be omitted entirely.
+
+Input:
+```
+if(c)return a();else b();
+```
+
+Output:
+```
+if(c)return a();b();
+```
+
+### Ternary operator
+
+When both branches of a if+else are an expression, the if is changed into a ternary operator.
+Additionally, if they end with an assignment to the same variable, the variable is extracted from the ternary operator.
+
+Input:
+```glsl
+if (c) {
+ x = f();
+} else {
+ a = g();
+ x = 1.0;
+}
+```
+
+Output:
+```glsl
+x = c ? f() : a = g(), 1.0;
+```
+
+When both branches of a if return immediately, the if is changed into a return
+that uses a ternary operator.
+
+Input:
+```glsl
+if (y)
+ return z;
+return w;
+```
+
+Output:
+```glsl
+return y ? z : w;
+```
+
+### Loops
+
+`while` loops are rewritten as `for` loops. This sometimes enable removing semi-colons or braces,
+either by moving the preceding statement into the initialization of the `for`,
+or by moving the last statement of the loop body into the increment part of the `for`.
+
+Input:
+```glsl
+i = 0.;
+while (i < 50) {
+ f(i);
+ i++;
+}
+```
+
+Output:
+```glsl
+for(i=0.;i<50;i++)f(i);
+```
+
### Merge declarations
If multiple values of the same type are declared next to each other, we can merge
@@ -462,10 +530,32 @@ c = 4;
As shown in the example, the variable name will appear twice (`c` above) while
the type will be written only once (`int` above). In some cases, this might make
-the shader slightly longer. When the variables are renamed, this should rarely
-be an issue.
+the shader slightly longer.
+
+Enable this transformation with the flag `--move-declarations`.
+
+### Augmented operators
+
+We use the augmented operators (e.g. `+=`) where possible.
+
+Input:
+```glsl
+spe=spe*spe;
+x=x-.5;
+a=a+(a<<3);
+a=a^a>>15;
+```
+
+Output:
+```glsl
+spe*=spe;
+x-=.5;
+a+=a<<3;
+a^=a>>15;
+```
-Disable this transformation with the flag `--no-move-declarations`.
+This transformation always reduces the size of the output. However, this seems
+to have negligible impact on the size after compression.
### Rename vector fields
diff --git a/SMBolero.Client/Main.fs b/SMBolero.Client/Main.fs
index 6c321a9e..c2e9f943 100644
--- a/SMBolero.Client/Main.fs
+++ b/SMBolero.Client/Main.fs
@@ -25,7 +25,7 @@ type Model =
let initModel =
{
page = Home
- shaderInput = "int foo() { return 6 * 7; }"
+ shaderInput = "out vec4 fragColor;\nvoid main() {\n fragColor = vec4(1.,1.,1.,1.);\n}"
shaderOutput = ""
flags = "--format text"
error = None
diff --git a/Shader Minifier.fsproj b/Shader Minifier.fsproj
index da580087..0392f73b 100644
--- a/Shader Minifier.fsproj
+++ b/Shader Minifier.fsproj
@@ -32,7 +32,7 @@
true
bin\Release\
TRACE
- 3
+ 4
-o "" ../../tests\unit\empty_block.frag --smoothstep
--standalone
diff --git a/Shader Minifier.sln b/Shader Minifier.sln
index 5df3470a..5bb3b99c 100644
--- a/Shader Minifier.sln
+++ b/Shader Minifier.sln
@@ -19,29 +19,71 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{059C6AF3-1877-4698-BE34-BF7EB55D060A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{059C6AF3-1877-4698-BE34-BF7EB55D060A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {059C6AF3-1877-4698-BE34-BF7EB55D060A}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {059C6AF3-1877-4698-BE34-BF7EB55D060A}.Debug|x64.Build.0 = Debug|Any CPU
+ {059C6AF3-1877-4698-BE34-BF7EB55D060A}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {059C6AF3-1877-4698-BE34-BF7EB55D060A}.Debug|x86.Build.0 = Debug|Any CPU
{059C6AF3-1877-4698-BE34-BF7EB55D060A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{059C6AF3-1877-4698-BE34-BF7EB55D060A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {059C6AF3-1877-4698-BE34-BF7EB55D060A}.Release|x64.ActiveCfg = Release|Any CPU
+ {059C6AF3-1877-4698-BE34-BF7EB55D060A}.Release|x64.Build.0 = Release|Any CPU
+ {059C6AF3-1877-4698-BE34-BF7EB55D060A}.Release|x86.ActiveCfg = Release|Any CPU
+ {059C6AF3-1877-4698-BE34-BF7EB55D060A}.Release|x86.Build.0 = Release|Any CPU
{CF735CB3-7698-41DA-9E91-69D0057087CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CF735CB3-7698-41DA-9E91-69D0057087CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {CF735CB3-7698-41DA-9E91-69D0057087CB}.Debug|x64.ActiveCfg = Debug|x64
+ {CF735CB3-7698-41DA-9E91-69D0057087CB}.Debug|x64.Build.0 = Debug|x64
+ {CF735CB3-7698-41DA-9E91-69D0057087CB}.Debug|x86.ActiveCfg = Debug|Any CPU
{CF735CB3-7698-41DA-9E91-69D0057087CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CF735CB3-7698-41DA-9E91-69D0057087CB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {CF735CB3-7698-41DA-9E91-69D0057087CB}.Release|x64.ActiveCfg = Release|x64
+ {CF735CB3-7698-41DA-9E91-69D0057087CB}.Release|x64.Build.0 = Release|x64
+ {CF735CB3-7698-41DA-9E91-69D0057087CB}.Release|x86.ActiveCfg = Release|Any CPU
{7A0B4487-C3F6-4753-9C8D-FEE09049F52D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7A0B4487-C3F6-4753-9C8D-FEE09049F52D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7A0B4487-C3F6-4753-9C8D-FEE09049F52D}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {7A0B4487-C3F6-4753-9C8D-FEE09049F52D}.Debug|x64.Build.0 = Debug|Any CPU
+ {7A0B4487-C3F6-4753-9C8D-FEE09049F52D}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {7A0B4487-C3F6-4753-9C8D-FEE09049F52D}.Debug|x86.Build.0 = Debug|Any CPU
{7A0B4487-C3F6-4753-9C8D-FEE09049F52D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7A0B4487-C3F6-4753-9C8D-FEE09049F52D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7A0B4487-C3F6-4753-9C8D-FEE09049F52D}.Release|x64.ActiveCfg = Release|Any CPU
+ {7A0B4487-C3F6-4753-9C8D-FEE09049F52D}.Release|x64.Build.0 = Release|Any CPU
+ {7A0B4487-C3F6-4753-9C8D-FEE09049F52D}.Release|x86.ActiveCfg = Release|Any CPU
+ {7A0B4487-C3F6-4753-9C8D-FEE09049F52D}.Release|x86.Build.0 = Release|Any CPU
{2DF47B2C-A68C-430C-B23F-BF51F68DF74D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2DF47B2C-A68C-430C-B23F-BF51F68DF74D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2DF47B2C-A68C-430C-B23F-BF51F68DF74D}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {2DF47B2C-A68C-430C-B23F-BF51F68DF74D}.Debug|x64.Build.0 = Debug|Any CPU
+ {2DF47B2C-A68C-430C-B23F-BF51F68DF74D}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {2DF47B2C-A68C-430C-B23F-BF51F68DF74D}.Debug|x86.Build.0 = Debug|Any CPU
{2DF47B2C-A68C-430C-B23F-BF51F68DF74D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2DF47B2C-A68C-430C-B23F-BF51F68DF74D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2DF47B2C-A68C-430C-B23F-BF51F68DF74D}.Release|x64.ActiveCfg = Release|Any CPU
+ {2DF47B2C-A68C-430C-B23F-BF51F68DF74D}.Release|x64.Build.0 = Release|Any CPU
+ {2DF47B2C-A68C-430C-B23F-BF51F68DF74D}.Release|x86.ActiveCfg = Release|Any CPU
+ {2DF47B2C-A68C-430C-B23F-BF51F68DF74D}.Release|x86.Build.0 = Release|Any CPU
{C1A4652F-0F92-4530-B1C8-2AAC9C383650}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C1A4652F-0F92-4530-B1C8-2AAC9C383650}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C1A4652F-0F92-4530-B1C8-2AAC9C383650}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {C1A4652F-0F92-4530-B1C8-2AAC9C383650}.Debug|x64.Build.0 = Debug|Any CPU
+ {C1A4652F-0F92-4530-B1C8-2AAC9C383650}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {C1A4652F-0F92-4530-B1C8-2AAC9C383650}.Debug|x86.Build.0 = Debug|Any CPU
{C1A4652F-0F92-4530-B1C8-2AAC9C383650}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C1A4652F-0F92-4530-B1C8-2AAC9C383650}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C1A4652F-0F92-4530-B1C8-2AAC9C383650}.Release|x64.ActiveCfg = Release|Any CPU
+ {C1A4652F-0F92-4530-B1C8-2AAC9C383650}.Release|x64.Build.0 = Release|Any CPU
+ {C1A4652F-0F92-4530-B1C8-2AAC9C383650}.Release|x86.ActiveCfg = Release|Any CPU
+ {C1A4652F-0F92-4530-B1C8-2AAC9C383650}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/lib/Compressor.dll b/lib/Compressor.dll
new file mode 100644
index 00000000..e8adecbe
Binary files /dev/null and b/lib/Compressor.dll differ
diff --git a/src/ast.fs b/src/ast.fs
index cff81310..845626ae 100644
--- a/src/ast.fs
+++ b/src/ast.fs
@@ -110,12 +110,15 @@ let makeFunctionType ty name args sem =
// An ExportedName is a name that is used outside of the shader code (e.g. uniform and attribute
// values). We need to provide accessors for the developer (e.g. create macros for C/C++).
+type ExportPrefix =
+ | Variable
+ | HlslFunction
type ExportedName = {
- ty: string // "F" for hlsl functions, empty for vars
+ prefix: ExportPrefix
name: string
newName: string
}
-
+
type Shader = {
filename: string
mutable code: TopLevel list
diff --git a/src/formatter.fs b/src/formatter.fs
index 5557aae6..969d52d9 100644
--- a/src/formatter.fs
+++ b/src/formatter.fs
@@ -4,15 +4,17 @@ open System
open System.IO
open Options.Globals
+let private formatPrefix = function
+ | Ast.ExportPrefix.Variable -> "var"
+ | Ast.ExportPrefix.HlslFunction -> "F"
+
let private printHeader out (shaders: Ast.Shader[]) asAList exportedNames =
let fileName =
if options.outputName = "" || options.outputName = "-" then "shader_code.h"
else Path.GetFileName options.outputName
let macroName = fileName.Replace(".", "_").ToUpper() + "_"
- fprintfn out "/* File generated with Shader Minifier %s" Options.version
- fprintfn out " * http://www.ctrl-alt-test.fr"
- fprintfn out " */"
+ fprintfn out "// Generated with Shader Minifier %s (https://github.com/laurentlb/Shader_Minifier/)" Options.version
if not asAList then
fprintfn out "#ifndef %s" macroName
@@ -20,10 +22,7 @@ let private printHeader out (shaders: Ast.Shader[]) asAList exportedNames =
for value: Ast.ExportedName in List.sort exportedNames do
// let newName = Printer.identTable.[int newName]
- if value.ty = "" then
- fprintfn out "# define VAR_%s \"%s\"" value.name value.newName
- else
- fprintfn out "# define %s_%s \"%s\"" value.ty value.name value.newName
+ fprintfn out "# define %s_%s \"%s\"" ((formatPrefix value.prefix).ToUpper()) value.name value.newName
fprintfn out ""
for shader in shaders do
@@ -50,15 +49,10 @@ let private printIndented out (shaders: Ast.Shader[]) =
|> fprintf out "%s"
let private printJSHeader out (shaders: Ast.Shader[]) exportedNames =
- fprintfn out "/* File generated with Shader Minifier %s" Options.version
- fprintfn out " * http://www.ctrl-alt-test.fr"
- fprintfn out " */"
+ fprintfn out "// Generated with Shader Minifier %s (https://github.com/laurentlb/Shader_Minifier/)" Options.version
for value: Ast.ExportedName in List.sort exportedNames do
- if value.ty = "" then
- fprintfn out "var var_%s = \"%s\"" (value.name.ToUpper()) value.newName
- else
- fprintfn out "var %s_%s = \"%s\"" value.ty (value.name.ToUpper()) value.newName
+ fprintfn out "var %s_%s = \"%s\"" (formatPrefix value.prefix) (value.name.ToUpper()) value.newName
fprintfn out ""
for shader in shaders do
@@ -67,14 +61,10 @@ let private printJSHeader out (shaders: Ast.Shader[]) exportedNames =
fprintfn out ""
let private printNasmHeader out (shaders: Ast.Shader[]) exportedNames =
- fprintfn out "; File generated with Shader Minifier %s" Options.version
- fprintfn out "; http://www.ctrl-alt-test.fr"
+ fprintfn out "; Generated with Shader Minifier %s (https://github.com/laurentlb/Shader_Minifier/)" Options.version
for value: Ast.ExportedName in List.sort exportedNames do
- if value.ty = "" then
- fprintfn out "_var_%s: db '%s', 0" (value.name.ToUpper()) value.newName
- else
- fprintfn out "_%s_%s: db '%s', 0" value.ty (value.name.ToUpper()) value.newName
+ fprintfn out "_%s_%s: db '%s', 0" (formatPrefix value.prefix) (value.name.ToUpper()) value.newName
fprintfn out ""
for shader in shaders do
@@ -82,6 +72,17 @@ let private printNasmHeader out (shaders: Ast.Shader[]) exportedNames =
fprintfn out "_%s:%s\tdb '%s', 0" name Environment.NewLine (Printer.print shader.code)
fprintfn out ""
+let private printRustHeader out (shaders: Ast.Shader[]) exportedNames =
+ fprintfn out "// Generated with Shader Minifier %s (https://github.com/laurentlb/Shader_Minifier/)" Options.version
+
+ for value: Ast.ExportedName in List.sort exportedNames do
+ fprintfn out "pub const %s_%s: &'static [u8] = b\"%s\\0\";" ((formatPrefix value.prefix).ToUpper()) (value.name.ToUpper()) value.newName
+
+ for shader in shaders do
+ fprintfn out ""
+ let name = (Path.GetFileName shader.filename).Replace(".", "_")
+ fprintfn out "pub const %s: &'static [u8] = b\"\\%s %s\\0\";" (name.ToUpper()) Environment.NewLine (Printer.print shader.code)
+
let print out shaders exportedNames = function
| Options.IndentedText -> printIndented out shaders
| Options.Text -> printNoHeader out shaders
@@ -89,3 +90,4 @@ let print out shaders exportedNames = function
| Options.CList -> printHeader out shaders true exportedNames
| Options.JS -> printJSHeader out shaders exportedNames
| Options.Nasm -> printNasmHeader out shaders exportedNames
+ | Options.Rust -> printRustHeader out shaders exportedNames
diff --git a/src/options.fs b/src/options.fs
index 88ed4481..3529117a 100644
--- a/src/options.fs
+++ b/src/options.fs
@@ -3,7 +3,7 @@
open System.IO
open Argu
-let version = "1.3.2" // Shader Minifier version
+let version = "1.3.3" // Shader Minifier version
let debugMode = false
type OutputFormat =
@@ -13,6 +13,7 @@ type OutputFormat =
| [] CList
| [] JS
| [] Nasm
+ | [] Rust
let text() = Text
@@ -36,7 +37,7 @@ type CliArguments =
| [] NoSequence
| [] Smoothstep
| [] NoRemoveUnused
- | [] NoMoveDeclarations
+ | [] MoveDeclarations
| [] Filenames of filename:string list
interface IArgParserTemplate with
@@ -56,7 +57,7 @@ type CliArguments =
| NoSequence -> "Do not use the comma operator trick"
| Smoothstep -> "Use IQ's smoothstep trick"
| NoRemoveUnused -> "Do not remove unused code"
- | NoMoveDeclarations -> "Do not move declarations to group them"
+ | MoveDeclarations -> "Move declarations to group them"
| Filenames _ -> "List of files to minify"
type Options() =
@@ -74,7 +75,7 @@ type Options() =
member val noRenaming = false with get, set
member val noRenamingList = ["main"; "mainImage"] with get, set
member val noRemoveUnused = false with get, set
- member val noMoveDeclarations = false with get, set
+ member val moveDeclarations = false with get, set
member val filenames = [||]: string[] with get, set
module Globals =
@@ -95,7 +96,7 @@ let private argParser = lazy (
let private initPrivate argv needFiles =
let args = argParser.Value.Parse(argv)
- let opt = args.GetResult(NoRenamingList, defaultValue = "main")
+ let opt = args.GetResult(NoRenamingList, defaultValue = "main,mainImage")
let noRenamingList = [for i in opt.Split([|','|]) -> i.Trim()]
let filenames = args.GetResult(Filenames, defaultValue=[]) |> List.toArray
@@ -116,7 +117,7 @@ let private initPrivate argv needFiles =
options.noSequence <- args.Contains(NoSequence)
options.noRenaming <- args.Contains(NoRenaming)
options.noRemoveUnused <- args.Contains(NoRemoveUnused)
- options.noMoveDeclarations <- args.Contains(NoMoveDeclarations)
+ options.moveDeclarations <- args.Contains(MoveDeclarations)
options.noRenamingList <- noRenamingList
options.filenames <- filenames
true
diff --git a/src/parse.fs b/src/parse.fs
index ee5ba617..608de84d 100644
--- a/src/parse.fs
+++ b/src/parse.fs
@@ -2,22 +2,21 @@
open Options.Globals
-module private ParseImpl =
+open FParsec.Primitives
+open FParsec.CharParsers
+open FParsec
- open FParsec.Primitives
- open FParsec.CharParsers
- open FParsec
+type ParseImpl() =
- // TODO: Get rid of this global state. Not threadsafe.
- let mutable private forbiddenNames = []
+ let mutable forbiddenNames = []
let mutable reorderFunctions = false
- let private commentLine = parse {
+ let commentLine = parse {
do! skipString "//" // .>> noneOf "[")) // (pchar '[')) // > "comment, not verbatim code"
do! notFollowedBy (anyOf "[]") > "not a verbatim code"
do! skipManyTill anyChar (followedBy newline) } |> attempt
- let private commentBlock = parse {
+ let commentBlock = parse {
do! skipString "/*"
do! skipManyTill anyChar (skipString "*/") }
@@ -105,7 +104,7 @@ module private ParseImpl =
let simpleExpr = pipe2 prim (many post)
(fun prim posts -> List.fold (fun acc elt -> elt acc) prim posts)
- opp.TermParser <- simpleExpr
+ do opp.TermParser <- simpleExpr
// Operators
@@ -235,7 +234,7 @@ module private ParseImpl =
many (ch ':' >>. simpleExpr)
// eg. "int foo[] = exp, bar = 3"
- declRef.Value <- (
+ do declRef.Value <- (
let bracket = between (ch '[') (ch ']') (opt expr) |>> (fun size -> defaultArg size (Ast.Int (0, "")))
let init = ch '=' >>. exprNoComma
let var = pipe4 ident (opt bracket) semantics (opt init) Ast.makeDecl
@@ -323,7 +322,7 @@ module private ParseImpl =
(key <|> ret) .>> ch ';'
// A statement
- stmtRef.Value <- choice [
+ do stmtRef.Value <- choice [
block
jump
forLoop
@@ -367,7 +366,7 @@ module private ParseImpl =
let parse = ws >>. toplevel .>> eof
- let runParser streamName content : Ast.Shader =
+ member _.runParser streamName content : Ast.Shader =
forbiddenNames <- [ "if"; "in"; "do" ]
reorderFunctions <- false
let res = runParserOnString parse () streamName content
@@ -380,5 +379,4 @@ module private ParseImpl =
}
| Failure(str, _, _) -> failwithf "Parse error: %s" str
-
-let runParser = ParseImpl.runParser
+let runParser = (new ParseImpl()).runParser
diff --git a/src/printer.fs b/src/printer.fs
index d68f32c9..2b3a5fe4 100644
--- a/src/printer.fs
+++ b/src/printer.fs
@@ -5,9 +5,7 @@ open Ast
open Options.Globals
open System.Text.RegularExpressions
-module private PrinterImpl =
-
- let mutable outputFormat = Options.Text
+type PrinterImpl(outputFormat) =
let out a = sprintf a
@@ -47,27 +45,38 @@ module private PrinterImpl =
List.map toS li |> String.concat ","
let floatToS f =
- let si = if f < 0.M then "-" else ""
- let f = abs (float f)
-
- let str1 = f.ToString("#.################", System.Globalization.CultureInfo.InvariantCulture)
- let str2 = f.ToString("0.################e0", System.Globalization.CultureInfo.InvariantCulture)
+ let a = abs (float f)
+ let str1 = a.ToString("#.################", System.Globalization.CultureInfo.InvariantCulture)
+ let str1 = if str1 = "" then "0."
+ elif Regex.Match(str1, "^\\d+$").Success then str1 + "."
+ else str1
+ let str2 = a.ToString("0.################e0", System.Globalization.CultureInfo.InvariantCulture)
let str = [str1; str2] |> List.minBy(fun x -> x.Length)
+
+ let sign = if f < 0.M then "-" else ""
+ sign + str
- if str = "" then
- "0."
- elif Regex.Match(str, "^\\d+$").Success then
- si + str + "." // display "3." instead of "3"
+ let mutable ignoreFirstNewLine = true
+ let nl indent = // newline and optionally indent
+ if ignoreFirstNewLine then
+ ignoreFirstNewLine <- false
+ ""
else
- si + str
+ let spaces = new string(' ', indent * 2 + 1)
+ match outputFormat with
+ | Options.IndentedText -> Environment.NewLine + new string(' ', indent * 2)
+ | Options.Text | Options.JS -> ""
+ | Options.CHeader | Options.CList -> out "\"%s%s\"" Environment.NewLine spaces
+ | Options.Nasm -> out "'%s\tdb%s'" Environment.NewLine spaces
+ | Options.Rust -> out "\\%s%s" Environment.NewLine spaces
- let rec exprToS exp = exprToSLevel 0 exp
+ let rec exprToS indent exp = exprToSLevel indent 0 exp
// Convert Expr option to string, with default value.
- and exprToSOpt def exp =
- defaultArg (Option.map exprToS exp) def
+ and exprToSOpt indent def exp =
+ defaultArg (Option.map (exprToS indent) exp) def
- and exprToSLevel level = function
+ and exprToSLevel indent level = function
| Int (i, suf) -> (out "%d%s" i suf)
| Float (f, suf) -> out "%s%s" (floatToS f) suf
| Var s -> idToS s
@@ -76,37 +85,39 @@ module private PrinterImpl =
match f, args with
| Op "?:", [a1; a2; a3] ->
let prec = precedence.["?:"]
- let res = out "%s?%s:%s" (exprToSLevel prec a1) (exprToSLevel prec a2) (exprToSLevel prec a3)
+ let res = out "%s?%s%s:%s%s" (exprToSLevel indent prec a1)
+ (nl (indent+1)) (exprToSLevel (indent+1) prec a2)
+ (nl (indent+1)) (exprToSLevel (indent+1) prec a3)
if prec < level then out "(%s)" res else res
// Function calls.
| Var op, _ ->
// We set level to 1 in case in case a comma operator is used in the argument list.
- out "%s(%s)" (idToS op) (commaListToS (exprToSLevel 1) args)
+ out "%s(%s)" (idToS op) (commaListToS (exprToSLevel indent 1) args)
// Unary operators. _++ is prefix and $++ is postfix
- | Op op, [a1] when op.[0] = '$' -> out "%s%s" (exprToSLevel precedence.[op] a1) op.[1..]
- | Op op, [a1] -> out "%s%s" op (exprToSLevel precedence.["_" + op] a1)
+ | Op op, [a1] when op.[0] = '$' -> out "%s%s" (exprToSLevel indent precedence.[op] a1) op.[1..]
+ | Op op, [a1] -> out "%s%s" op (exprToSLevel indent precedence.["_" + op] a1)
// Binary operators.
| Op op, [a1; a2] ->
let prec = precedence.[op]
let res =
if prec = 1 then // "=", "+=", or other operator with right-associativity
- out "%s%s%s" (exprToSLevel (prec+1) a1) op (exprToSLevel prec a2)
+ out "%s%s%s" (exprToSLevel indent (prec+1) a1) op (exprToSLevel indent prec a2)
else
- out "%s%s%s" (exprToSLevel prec a1) op (exprToSLevel (prec+1) a2)
+ out "%s%s%s" (exprToSLevel indent prec a1) op (exprToSLevel indent (prec+1) a2)
if prec < level then out "(%s)" res
else res
- | _ -> out "%s(%s)" (exprToS f) (commaListToS exprToS args)
+ | _ -> out "%s(%s)" (exprToS indent f) (commaListToS (exprToS indent) args)
| Subscript(arr, ind) ->
- out "%s[%s]" (exprToS arr) (exprToSOpt "" ind)
+ out "%s[%s]" (exprToS indent arr) (exprToSOpt indent "" ind)
| Cast(id, e) ->
// Cast seems to have the same precedence as unary minus
- out "(%s)%s" id.Name (exprToSLevel precedence.["_-"] e)
+ out "(%s)%s" id.Name (exprToSLevel indent precedence.["_-"] e)
| VectorExp(li) ->
- out "{%s}" (commaListToS exprToS li)
+ out "{%s}" (commaListToS (exprToS indent) li)
| Dot(e, field) ->
- out "%s.%s" (exprToSLevel precedence.["."] e) field
+ out "%s.%s" (exprToSLevel indent precedence.["."] e) field
| VerbatimExp s -> s
// Add a space if needed
@@ -123,16 +134,16 @@ module private PrinterImpl =
match outputFormat with
| Options.Text | Options.JS | Options.IndentedText -> "\n"
| Options.Nasm -> "', 10, '"
- | Options.CHeader | Options.CList -> "\\n"
+ | Options.CHeader | Options.CList | Options.Rust -> "\\n"
// Print HLSL semantics
let semToS sem =
- let res = sem |> List.map exprToS |> String.concat ":"
+ let res = sem |> List.map (exprToS 0) |> String.concat ":"
if res = "" then res else ":" + res
let rec structToS prefix id decls =
let name = match id with None -> "" | Some (s: Ident) -> " " + s.Name
- let d = decls |> List.map (fun s -> declToS s + ";") |> String.concat ""
+ let d = decls |> List.map (fun s -> declToS 0 s + ";") |> String.concat ""
out "%s{%s}" (sp2 prefix name) d
and typeSpecToS = function
@@ -146,42 +157,29 @@ module private PrinterImpl =
let typeSpec = typeSpecToS ty.name
out "%s%s" (get ty.typeQ) typeSpec
- and declToS (ty, vars) =
+ and declToS indent (ty, vars) =
let out1 decl =
let size =
match decl.size with
| None -> ""
| Some (Int (0, _)) -> "[]"
- | Some n -> out "[%s]" (exprToS n)
+ | Some n -> out "[%s]" (exprToS indent n)
let init =
match decl.init with
| None -> ""
- | Some i -> out "=%s" (exprToS i)
+ | Some i -> out "=%s" (exprToS indent i)
out "%s%s%s%s" (idToS decl.name) size (semToS decl.semantics) init
if vars.IsEmpty then ""
else out "%s %s" (typeToS ty) (vars |> commaListToS out1)
- let mutable ignoreFirstNewLine = true
- let nl indent = // newline and optionally indent
- if ignoreFirstNewLine then
- ignoreFirstNewLine <- false
- ""
- else
- let spaces = new string(' ', indent * 2 + 1)
- match outputFormat with
- | Options.IndentedText -> Environment.NewLine + new string(' ', indent * 2)
- | Options.Text | Options.JS -> ""
- | Options.CHeader | Options.CList -> out "\"%s%s\"" Environment.NewLine spaces
- | Options.Nasm -> out "'%s\tdb%s'" Environment.NewLine spaces
-
let escape (s: string) =
match outputFormat with
| Options.IndentedText -> s
| Options.Text -> s
| Options.JS -> s
- | Options.CHeader | Options.CList | Options.JS -> s.Replace("\"", "\\\"").Replace("\n", "\\n")
+ | Options.CHeader | Options.CList | Options.JS | Options.Rust -> s.Replace("\"", "\\\"").Replace("\n", "\\n")
| Options.Nasm -> s.Replace("'", "\'").Replace("\n", "', 10, '")
/// Detect if the current statement might accept a dangling else.
@@ -206,29 +204,29 @@ module private PrinterImpl =
let body = List.map (stmtToS (indent+1)) b |> String.concat ""
out "{%s%s}" body (nl indent)
| Decl (_, []) -> ""
- | Decl d -> out "%s;" (declToS d)
- | Expr e -> out "%s;" (exprToS e)
+ | Decl d -> out "%s;" (declToS indent d)
+ | Expr e -> out "%s;" (exprToS indent e)
| If(cond, th, el) ->
let th = if el <> None && hasDanglingElseProblem th then Block [th] else th
let el = match el with
| None -> ""
| Some el -> out "%selse%s%s" (nl indent) (nl (indent+1)) (stmtToS' (indent+1) el |> sp)
- out "if(%s)%s%s" (exprToS cond) (stmtToSInd indent th) el
+ out "if(%s)%s%s" (exprToS indent cond) (stmtToSInd indent th) el
| ForD(init, cond, inc, body) ->
- let cond = exprToSOpt "" cond
- let inc = exprToSOpt "" inc
- out "%s(%s;%s;%s)%s" "for" (declToS init) cond inc (stmtToSInd indent body)
+ let cond = exprToSOpt indent "" cond
+ let inc = exprToSOpt indent "" inc
+ out "%s(%s;%s;%s)%s" "for" (declToS indent init) cond inc (stmtToSInd indent body)
| ForE(init, cond, inc, body) ->
- let cond = exprToSOpt "" cond
- let inc = exprToSOpt "" inc
- let init = exprToSOpt "" init
+ let cond = exprToSOpt indent "" cond
+ let inc = exprToSOpt indent "" inc
+ let init = exprToSOpt indent "" init
out "%s(%s;%s;%s)%s" "for" init cond inc (stmtToSInd indent body)
| While(cond, body) ->
- out "%s(%s)%s" "while" (exprToS cond) (stmtToSInd indent body)
+ out "%s(%s)%s" "while" (exprToS indent cond) (stmtToSInd indent body)
| DoWhile(cond, body) ->
- out "%s%s%s(%s)" "do" "while" (exprToS cond |> sp) (stmtToS indent body)
+ out "%s%s%s(%s)" "do" "while" (exprToS indent cond |> sp) (stmtToS indent body)
| Jump(k, None) -> out "%s;" (jumpKeywordToString k)
- | Jump(k, Some exp) -> out "%s%s;" (jumpKeywordToString k) (exprToS exp |> sp)
+ | Jump(k, Some exp) -> out "%s%s;" (jumpKeywordToString k) (exprToS indent exp |> sp)
| Verbatim s ->
// add a space at end when it seems to be needed
let s = if s.Length > 0 && System.Char.IsLetterOrDigit s.[s.Length - 1] then s + " " else s
@@ -236,13 +234,13 @@ module private PrinterImpl =
else escape s
| Switch(e, cl) ->
let labelToS = function
- | Case e -> out "case %s:" (exprToS e)
+ | Case e -> out "case %s:" (exprToS indent e)
| Default -> out "default:"
let caseToS (l, sl) =
let stmts = List.map (stmtToS (indent+2)) sl |> String.concat ""
out "%s%s%s" (nl (indent+1)) (labelToS l) stmts
let body = List.map caseToS cl |> String.concat ""
- out "%s(%s){%s%s}" "switch" (exprToS e) body (nl indent)
+ out "%s(%s){%s%s}" "switch" (exprToS indent e) body (nl indent)
and stmtToS indent i =
out "%s%s" (nl indent) (stmtToS' indent i)
@@ -251,7 +249,7 @@ module private PrinterImpl =
and stmtToSInd indent i = stmtToS (indent+1) i
let funToS (f: FunctionType) =
- out "%s %s(%s)%s" (typeToS f.retType) (idToS f.fName) (commaListToS declToS f.args) (semToS f.semantics)
+ out "%s %s(%s)%s" (typeToS f.retType) (idToS f.fName) (commaListToS (declToS 0) f.args) (semToS f.semantics)
let topLevelToS = function
| TLVerbatim s ->
@@ -263,10 +261,10 @@ module private PrinterImpl =
| Function (fct, body) -> out "%s%s%s{%s%s}" (nl 0) (funToS fct) (nl 0) (stmtToS 1 body) (nl 0)
| Precision ty -> out "precision %s;" (typeToS ty);
| TLDecl (_, []) -> ""
- | TLDecl decl -> out "%s%s;" (nl 0) (declToS decl)
+ | TLDecl decl -> out "%s%s;" (nl 0) (declToS 0 decl)
| TypeDecl t -> out "%s;" (typeSpecToS t)
- let print tl =
+ member _.Print tl =
let mutable wasMacro = true
// handle the required \n before a macro
ignoreFirstNewLine <- true
@@ -278,19 +276,10 @@ module private PrinterImpl =
else topLevelToS x
tl |> List.map f |> String.concat ""
+ member _.ExprToS = exprToS
+ member _.TypeToS = typeToS
-let print tl =
- PrinterImpl.outputFormat <- options.outputFormat
- PrinterImpl.print tl
-
-let printText tl =
- PrinterImpl.outputFormat <- Options.Text
- PrinterImpl.print tl
-
-let exprToS x =
- PrinterImpl.outputFormat <- Options.Text
- PrinterImpl.exprToS x
-
-let typeToS ty =
- PrinterImpl.outputFormat <- Options.Text
- PrinterImpl.typeToS ty
+let print tl = (new PrinterImpl(options.outputFormat)).Print(tl)
+let printText tl = (new PrinterImpl(Options.Text)).Print(tl)
+let exprToS x = (new PrinterImpl(Options.Text)).ExprToS 0 x
+let typeToS ty = (new PrinterImpl(Options.Text)).TypeToS ty
diff --git a/src/renamer.fs b/src/renamer.fs
index 2fa1b023..d8c43b2d 100644
--- a/src/renamer.fs
+++ b/src/renamer.fs
@@ -97,13 +97,18 @@ module private RenamerImpl =
| true, occ -> score <- score + occ
if score > fst best then best <- score, word
+ // If the score is equal, consistently pick the same string, to get a more deterministic behavior.
+ elif score = fst best && word < snd best then best <- score, word
let best = snd best
assert (best.Length > 0)
let firstLetter = best.[0]
let lastLetter = best.[best.Length - 1]
- // update table
+ // Update the context table. Due to this side-effect, variables in two identical functions
+ // may get different names. Compression tests using Crinkler show that (on average) it's
+ // still worth updating the tables. Results might differ with kkrunchy, more testing
+ // will be useful.
for c in allChars do
match contextTable.TryGetValue((c, ident)), contextTable.TryGetValue((c, firstLetter)) with
| (false, _), _ -> ()
@@ -157,6 +162,17 @@ module private RenamerImpl =
d.[id.OldName] <- newName
env.Rename(id, newName)
+ // Renaming safe across multiple files (e.g. uniform/in/out variables are
+ // renamed in a consistent way) that tries to optimize based on the context
+ // and variable reuse.
+ let multiFileRenaming contextTable (exportRenames: IDictionary) (env: Env) (id: Ident) =
+ match exportRenames.TryGetValue(id.Name) with
+ | true, newName -> env.Rename(id, newName)
+ | false, _ ->
+ let cid = char (1000 + int id.Name)
+ let newName = chooseIdent contextTable cid env.availableNames
+ env.Rename(id, newName)
+
let dontRename (env: Env) (id: Ident) =
env.Rename(id, id.Name)
@@ -165,9 +181,9 @@ module private RenamerImpl =
for name in names do env <- dontRename env (Ident name)
env
- let export env ty (id: Ident) =
+ let export env prefix (id: Ident) =
if not id.IsUniqueId then
- env.exportedNames.Value <- {ty = ty; name = id.OldName; newName = id.Name} :: env.exportedNames.Value
+ env.exportedNames.Value <- {prefix = prefix; name = id.OldName; newName = id.Name} :: env.exportedNames.Value
let renFunction env nbArgs (id: Ident) =
// we're looking for a function name, already used before,
@@ -204,7 +220,7 @@ module private RenamerImpl =
env
| None ->
let newEnv = renFunction env (List.length f.args) f.fName
- if isExternal then export env "F" f.fName
+ if isExternal then export env ExportPrefix.HlslFunction f.fName
newEnv
let renList env fct li =
@@ -245,7 +261,7 @@ module private RenamerImpl =
env
| None ->
let env = env.newName env decl.name
- export env "" decl.name
+ export env ExportPrefix.Variable decl.name
env
renList env aux vars
@@ -349,13 +365,12 @@ module private RenamerImpl =
let renameAsts shaders env =
let mutable env = env
- // First, rename top-level values.
for shader in shaders do
+ // Rename top-level and body at the same time (because the body
+ // needs the environment matching the top-level).
env <- renList env renTopLevelName shader.code
-
- // Rename local variables.
- for shader in shaders do
List.iter (renTopLevelBody env) shader.code
+
env.exportedNames.Value
let assignUniqueIds shaders =
@@ -376,7 +391,10 @@ module private RenamerImpl =
let mutable env =
if Array.length shaders > 1 then
- Env.Create(names, true, bijectiveRenaming names, shadowVariables)
+ // Env.Create(names, true, bijectiveRenaming names, shadowVariables)
+ let exportsRenames = Seq.zip [for export in exportedNames -> export.name] names |> dict
+ let contextTable = computeContextTable text
+ Env.Create(names, true, multiFileRenaming contextTable exportsRenames, shadowVariables)
else
let contextTable = computeContextTable text
Env.Create(names, true, optimizeContext contextTable, shadowVariables)
diff --git a/src/rewriter.fs b/src/rewriter.fs
index b7c56fca..988e1758 100644
--- a/src/rewriter.fs
+++ b/src/rewriter.fs
@@ -97,6 +97,9 @@ let (|Number|_|) = function
| Float (f, _) -> Some f
| _ -> None
+let augmentableOperators = set ["+"; "-"; "*"; "/"; "%"; "<<"; ">>"; "&"; "^"; "|"]
+
+
let private simplifyOperator env = function
| FunCall(Op "-", [Int (i1, su)]) -> Int (-i1, su)
| FunCall(Op "-", [FunCall(Op "-", [e])]) -> e
@@ -114,7 +117,7 @@ let private simplifyOperator env = function
| FunCall(Op "<", [Number n1; Number n2]) -> bool(n1 < n2)
| FunCall(Op ">", [Number n1; Number n2]) -> bool(n1 > n2)
| FunCall(Op "<=", [Number n1; Number n2]) -> bool(n1 <= n2)
- | FunCall(Op ">=", [Number n1; Number n2]) -> bool(n1 <= n2)
+ | FunCall(Op ">=", [Number n1; Number n2]) -> bool(n1 >= n2)
| FunCall(Op "==", [Number n1; Number n2]) -> bool(n1 = n2)
| FunCall(Op "!=", [Number n1; Number n2]) -> bool(n1 <> n2)
@@ -173,6 +176,15 @@ let private simplifyOperator env = function
// x-(y-z) -> x-y+z
| FunCall(Op "-", [x; FunCall(Op "-", [y; z])]) ->
FunCall(Op "+", [FunCall(Op "-", [x; y]); z]) |> env.fExpr env
+
+ // Match: x = x + ...
+ | FunCall(Op "=", [Var x; FunCall(Op op, [Var y; e])])
+ when x.Name = y.Name && augmentableOperators.Contains op ->
+ FunCall(Op (op + "="), [Var x; e])
+ // Unsafe when x contains NaN or Inf values.
+ //| FunCall(Op "=", [Var x; FunCall(Var fctName, [Int (0, _)])])
+ // when List.contains fctName.Name ["vec2"; "vec3"; "vec4"; "ivec2"; "ivec3"; "ivec4"] ->
+ // FunCall(Op "-=", [Var x; Var x]) // x=vec3(0); -> x-=x;
| e -> e
@@ -193,7 +205,12 @@ let private simplifyVec constr args =
// basic type of the object being constructed, the scalar construction rules (above) are used to convert
// the parameters."
let useInts = function
- | Float (f, _) when Decimal.Round(f) = f -> Int (int f, "")
+ | Float (f, _) as e when Decimal.Round(f) = f ->
+ let candidate = Int (int f, "")
+ if (Printer.exprToS candidate).Length <= (Printer.exprToS e).Length then
+ candidate
+ else
+ e
| e -> e
// vec3(1,1,1) => vec3(1)
@@ -241,7 +258,7 @@ let private simplifyExpr (didInline: bool ref) env = function
let sub1 = FunCall(Op "-", [x; a])
let sub2 = FunCall(Op "-", [b; a])
let div = FunCall(Op "/", [sub1; sub2]) |> mapExpr env
- FunCall(Var (Ident "smoothstep"), [Float (0.M,""); Float (1.M,""); div])
+ FunCall(Var (Ident "smoothstep"), [Float (0.M,""); Float (1.M,""); div])
| Dot(e, field) when options.canonicalFieldNames <> "" -> Dot(e, renameField field)
@@ -298,11 +315,11 @@ let groupDeclarations stmts =
List.collect replacements stmts
// Squeeze declarations: "float a=2.; float b;" => "float a=2.,b;"
-let rec private squeezeDeclarations = function
+let rec private squeezeConsecutiveDeclarations = function
| []-> []
| Decl(ty1, li1) :: Decl(ty2, li2) :: l when ty1 = ty2 ->
- squeezeDeclarations (Decl(ty1, li1 @ li2) :: l)
- | e::l -> e :: squeezeDeclarations l
+ squeezeConsecutiveDeclarations (Decl(ty1, li1 @ li2) :: l)
+ | e::l -> e :: squeezeConsecutiveDeclarations l
// Squeeze top-level declarations, e.g. uniforms
let rec private squeezeTLDeclarations = function
@@ -331,9 +348,9 @@ let squeezeBlockWithComma = function
| Jump(JumpKeyword.Return, Some _) -> true
| _ -> false)
// Try to remove blocks by using the comma operator
- let returnExp = b |> Seq.tryPick (function Jump(JumpKeyword.Return, e) -> e | _ -> None)
if canOptimize then
let li = List.choose (function Expr e -> Some e | _ -> None) b
+ let returnExp = b |> Seq.tryPick (function Jump(JumpKeyword.Return, e) -> e | _ -> None)
match returnExp with
| None ->
if li.IsEmpty then Block []
@@ -344,42 +361,145 @@ let squeezeBlockWithComma = function
else stmt
| stmt -> stmt
+let hasNoDecl = List.forall (function Decl _ -> false | _ -> true)
+
+let rec hasNoContinue stmts = stmts |> List.forall (function
+ | Jump (JumpKeyword.Continue, _) -> false
+ | If (_cond, bodyT, bodyF) -> hasNoContinue [bodyT] && hasNoContinue (Option.toList bodyF)
+ | Switch (_e, cases) -> cases |> List.forall (fun (_label, stmts) -> hasNoContinue stmts)
+ | _ -> true)
+
+let private simplifyBlock stmts =
+ let b = stmts
+ // Avoid some optimizations when there are preprocessor directives.
+ let hasPreprocessor = Seq.exists (function Verbatim _ -> true | _ -> false) b
+
+ // Remove dead code after return/break/...
+ let endOfCode = Seq.tryFindIndex (function Jump _ -> true | _ -> false) b
+ let b = match endOfCode with
+ | Some x when not hasPreprocessor -> List.truncate (x+1) b
+ | _ -> b
+
+ // Remove "empty" declarations of vars that were inlined. This is mandatory for correctness, not an optional optimization.
+ let b = b |> List.filter (function
+ | Decl (_, []) -> false
+ | _ -> true)
+
+ // Merge two consecutive items into one, everywhere possible in a list.
+ let rec squeeze (f : 'a * 'a -> 'a option) = function
+ | h1 :: h2 :: t ->
+ match f (h1, h2) with
+ | Some x -> squeeze f (x :: t)
+ | None -> h1 :: (squeeze f (h2 :: t))
+ | h :: t -> h :: t
+ | [] -> []
+
+ // Merge preceding expression into a for's init.
+ let b = b |> squeeze (function
+ | (Expr e, ForE (None, cond, inc, body)) -> // a=0;for(;i<5;++i); -> for(a=0;i<5;++i);
+ Some (ForE (Some e, cond, inc, body))
+ | (Expr e, While (cond, body)) -> // a=0;while(i<5); -> for(a=0;i<5;);
+ Some (ForE(Some e, Some cond, None, body))
+ | _ -> None)
+
+ // Inline inner decl-less blocks. (Presence of decl could lead to redefinitions.) a();{b();}c(); -> a();b();c();
+ let b = b |> List.collect (function
+ | Block b when hasNoDecl b -> b
+ | e -> [e])
+
+ // Remove useless else after a if that returns.
+ // if(c)return a();else b(); -> if(c)return a();b();
+ let rec endsWithReturn = function
+ | Jump(JumpKeyword.Return, _) -> true
+ | Block stmts when not stmts.IsEmpty -> stmts |> List.last |> endsWithReturn
+ | _ -> false
+ let removeUselessElseAfterReturn = List.collect (function
+ | If (cond, bodyT, Some bodyF) when endsWithReturn bodyT ->
+ let bodyF = match bodyF with
+ | Block b when hasNoDecl b -> b // inline inner empty blocks without variable
+ | Decl _ as d -> [Block [d]] // a decl must stay isolated in a block, for the same reason
+ | s -> [s]
+ If (cond, bodyT, None) :: bodyF
+ | e -> [e])
+ let b = removeUselessElseAfterReturn b
+
+ // if(a)return b;return c; -> return a?b:c;
+ let rec replaceIfReturnsWithReturnTernary = function
+ | If (cond, Jump(JumpKeyword.Return, Some retT), None) :: Jump(JumpKeyword.Return, Some retF) :: _rest ->
+ [Jump(JumpKeyword.Return, Some (FunCall(Op "?:", [cond; retT; retF])))]
+ | stmt :: rest -> stmt :: replaceIfReturnsWithReturnTernary rest
+ | stmts -> stmts
+ let b = replaceIfReturnsWithReturnTernary b
+
+ // Consecutive declarations of the same type become one. float a;float b; -> float a,b;
+ let b = squeezeConsecutiveDeclarations b
+
+ // Group declarations, optionally (may compress poorly). float a,f();float b=4.; -> float a,b;f();b=4.;
+ let b = if hasPreprocessor || not options.moveDeclarations then b else groupDeclarations b
+ b
+
let private simplifyStmt = function
| Block [] as e -> e
- | Block b ->
- // Avoid some optimizations when there are preprocessor directives.
- let hasPreprocessor = Seq.exists (function Verbatim _ -> true | _ -> false) b
-
- // Remove dead code after return/break/...
- let endOfCode = Seq.tryFindIndex (function Jump _ -> true | _ -> false) b
- let b = match endOfCode with
- | Some x when not hasPreprocessor -> List.truncate (x+1) b
- | _ -> b
-
- // Inline inner empty blocks without variable
- let b = b |> List.collect (function
- | Block b when List.forall (function Decl _ -> false | _ -> true) b ->
- b
- | Decl (_, []) -> []
- | e -> [e])
-
- // Reduce the number of declaration statements.
- let b = squeezeDeclarations b
- let b = if hasPreprocessor || options.noMoveDeclarations then b else groupDeclarations b
- match b with
- | [stmt] -> stmt
- | stmts -> Block stmts
+ | Block b -> match simplifyBlock b with
+ | [stmt] -> stmt
+ | stmts -> Block stmts
| Decl (ty, li) -> Decl (rwType ty, declsNotToInline li)
| ForD ((ty, d), cond, inc, body) -> ForD((rwType ty, declsNotToInline d), cond, inc, squeezeBlockWithComma body)
| ForE (init, cond, inc, body) -> ForE(init, cond, inc, squeezeBlockWithComma body)
- | While (cond, body) -> While (cond, squeezeBlockWithComma body)
+ | While (cond, body) ->
+ match body with
+ | Expr e -> ForE (None, Some cond, Some e, Block []) // while(c)b(); -> for(;c;b());
+ | Block stmts ->
+ match List.rev stmts with
+ | Expr last :: revBody when hasNoContinue stmts && hasNoDecl stmts ->
+ // This rewrite is only valid if:
+ // * continue is never used in this loop, and
+ // * the last expression of the body does not use any Decl from the body.
+ let block = match (List.rev revBody) with
+ | [stmt] -> stmt
+ | stmts -> Block stmts
+ ForE (None, Some cond, Some last, block) // while(c){a();b();} -> for(;c;b())a();
+ | _ -> ForE (None, Some cond, None, squeezeBlockWithComma (Block stmts))
+ | _ -> ForE (None, Some cond, None, squeezeBlockWithComma body)
| DoWhile (cond, body) -> DoWhile (cond, squeezeBlockWithComma body)
| If (True, e1, _) -> squeezeBlockWithComma e1
| If (False, _, Some e2) -> squeezeBlockWithComma e2
| If (False, _, None) -> Block []
- | If (c, b, Some (Block [])) -> If(c, b, None)
+ | If (cond, Block [], None) -> Expr cond // if(c); -> c;
+ | If (cond, Block [], Some (Block [])) -> Expr cond // if(c)else{}; -> c;
+ | If (c, b, Some (Block [])) -> If(c, b, None) // "else{}" -> ""
| If (cond, body1, body2) ->
- If (cond, squeezeBlockWithComma body1, Option.map squeezeBlockWithComma body2)
+ let (body1, body2) = squeezeBlockWithComma body1, Option.map squeezeBlockWithComma body2
+
+ let (cond, body1, body2) = // if(!c)a();else b(); -> if(c)b();else a();
+ match (cond, body1, body2) with
+ | FunCall (Op "!", [e]), bodyT, Some bodyF -> e, bodyF, Some bodyT
+ | _ -> cond, body1, body2
+
+ match (body1, body2) with
+ | (Expr eT, Some (Expr eF)) ->
+ let tryCollapseToAssignment : Expr -> (Ident * Expr) option = function
+ | FunCall (Op "=", [Var name; init]) -> Some (name, init)
+ | FunCall (Op ",", list) -> // f(),c=d -> c=f(),d
+ match List.last list with
+ | FunCall (Op "=", [Var name; init]) ->
+ let mutableList = new System.Collections.Generic.List(list)
+ mutableList[mutableList.Count - 1] <- init
+ Some (name, FunCall (Op ",", Seq.toList(mutableList)))
+ | _ -> None
+ | _ -> None
+ match (tryCollapseToAssignment eT, tryCollapseToAssignment eF) with
+ // turn if-else of assignments into assignment of ternary
+ | Some (nameT, initT), Some (nameF, initF) when nameT.Name = nameF.Name ->
+ // if(c)x=y;else x=z; -> x=c?y:z;
+ Expr (FunCall (Op "=", [Var nameT; FunCall(Op "?:", [cond; initT; initF])]))
+ // turn if-else of expressions into ternary statement
+ | _ ->
+ // if(c)x();else y(); -> c?x():y();
+ // This transformation is not legal when x() and y() have different types.
+ // Expr (FunCall(Op "?:", [cond; eT; eF]))
+ If (cond, body1, body2)
+ | _ -> If (cond, body1, body2)
| Verbatim s -> Verbatim (stripSpaces s)
| e -> e
diff --git a/tests/commands.txt b/tests/commands.txt
index c4b1c825..4bbf83f7 100644
--- a/tests/commands.txt
+++ b/tests/commands.txt
@@ -1,26 +1,29 @@
# Test output formats
---no-renaming --format c-variables -o tests/real/chocolux.expected tests/real/chocolux.frag
---no-renaming --format text -o tests/real/clod.expected tests/real/clod.frag
---no-renaming --format c-array -o tests/real/kinder_painter.expected tests/real/kinder_painter.frag
---no-renaming --format js -o tests/real/disco.expected tests/real/disco.frag
---no-renaming --format nasm -o tests/real/leizex.expected tests/real/leizex.frag
+--format c-variables -o tests/real/chocolux.expected tests/real/chocolux.frag
+--format text -o tests/real/clod.expected tests/real/clod.frag
+--format c-array -o tests/real/kinder_painter.expected tests/real/kinder_painter.frag
+--format js -o tests/real/disco.expected tests/real/disco.frag
+--format nasm -o tests/real/leizex.expected tests/real/leizex.frag
+--format rust -o tests/real/heart.expected tests/real/heart.frag
# Unit tests
--no-remove-unused --no-renaming --format c-variables -o tests/unit/blocks.expected tests/unit/blocks.frag
--no-remove-unused --hlsl --no-inlining --no-renaming --format c-variables -o tests/unit/geometry.hlsl.expected tests/unit/geometry.hlsl
---no-remove-unused --no-renaming --no-inlining --format c-array -o tests/unit/operators.expected tests/unit/operators.frag
+--no-remove-unused --no-renaming --no-inlining --move-declarations --format c-array -o tests/unit/operators.expected tests/unit/operators.frag
--no-renaming --no-inlining --format c-array -o tests/unit/minus-zero.expected tests/unit/minus-zero.frag
--no-remove-unused --no-renaming --format c-array --no-inlining -o tests/unit/float.frag.expected tests/unit/float.frag
--no-remove-unused --no-renaming --format indented --no-inlining -o tests/unit/nested_if.frag.expected tests/unit/nested_if.frag
--format indented -o tests/unit/precision.frag.expected tests/unit/precision.frag
--no-remove-unused --format c-array --no-inlining --no-renaming -o tests/unit/verbatim.frag.expected tests/unit/verbatim.frag
--no-remove-unused --format indented --no-renaming -o tests/unit/forward_declaration.frag.expected tests/unit/forward_declaration.frag
---no-remove-unused --format indented --no-renaming -o tests/unit/conditionals.frag.expected tests/unit/conditionals.frag
+--no-remove-unused --format indented --no-renaming --move-declarations -o tests/unit/conditionals.frag.expected tests/unit/conditionals.frag
--no-renaming --no-inlining --format indented -o tests/unit/pi.frag.expected tests/unit/pi.frag
--no-renaming --no-inlining --format indented -o tests/unit/vectors.frag.expected tests/unit/vectors.frag
--no-renaming --format indented -o tests/unit/deadcode.frag.expected tests/unit/deadcode.frag
+--no-renaming --no-inlining --format indented -o tests/unit/augmented.frag.expected tests/unit/augmented.frag
+--no-remove-unused --no-renaming -o tests/unit/loop.frag.expected tests/unit/loop.frag
# Inlining unit tests
@@ -42,11 +45,11 @@
# Multifile tests
---no-remove-unused --format c-array -o tests/unit/inout.expected tests/unit/inout.frag tests/unit/inout2.frag
+--no-remove-unused --move-declarations --format c-array -o tests/unit/inout.expected tests/unit/inout.frag tests/unit/inout2.frag
# Tests with full renaming
---no-remove-unused --no-move-declarations --format c-array --no-inlining -o tests/unit/many_variables.expected tests/unit/many_variables.frag
+--no-remove-unused --format c-array --no-inlining -o tests/unit/many_variables.expected tests/unit/many_variables.frag
--hlsl -o tests/real/elevated.hlsl.expected tests/real/elevated.hlsl
-o tests/real/yx_long_way_from_home.frag.expected tests/real/yx_long_way_from_home.frag
-o tests/real/oscars_chair.frag.expected tests/real/oscars_chair.frag
@@ -60,7 +63,7 @@
--format c-variables -o tests/real/heart.frag.expected tests/real/heart.frag
# Other - real files, to get a bit more coverage
---no-renaming --format indented --no-renaming-list mainImage -o tests/real/ed-209.frag.expected tests/real/ed-209.frag
+--no-renaming --format indented -o tests/real/ed-209.frag.expected tests/real/ed-209.frag
--no-renaming --format indented -o tests/real/ohanami.frag.expected tests/real/ohanami.frag
--no-renaming --format indented -o tests/real/terrarium.frag.expected tests/real/terrarium.frag
--no-renaming --format indented -o tests/real/monjori.frag.expected tests/real/monjori.frag
@@ -68,3 +71,7 @@
--no-renaming --format indented -o tests/real/slisesix.frag.expected tests/real/slisesix.frag
--no-renaming --format indented -o tests/real/from-the-seas-to-the-stars.frag.expected tests/real/from-the-seas-to-the-stars.frag
--no-renaming --format indented -o tests/real/lunaquatic.frag.expected tests/real/lunaquatic.frag
+--no-renaming --format indented -o tests/real/frozen-wasteland.frag.expected tests/real/frozen-wasteland.frag
+--no-renaming --format indented -o tests/real/controllable-machinery.frag.expected tests/real/controllable-machinery.frag
+--no-renaming --format indented -o tests/real/endeavour.frag.expected tests/real/endeavour.frag
+--no-renaming --format indented -o tests/real/audio-flight-v2.frag.expected tests/real/audio-flight-v2.frag
diff --git a/tests/compression_results.log b/tests/compression_results.log
new file mode 100644
index 00000000..5c1d6164
--- /dev/null
+++ b/tests/compression_results.log
@@ -0,0 +1,23 @@
+clod.frag... 8960 => 1545.563
+audio-flight-v2.frag 4650 => 902.661
+buoy.frag 4239 => 632.427
+controllable-machinery.frag 7773 => 1227.926
+ed-209.frag 7926 => 1363.748
+elevated.hlsl 3416 => 603.918
+endeavour.frag 2661 => 541.942
+from-the-seas-to-the-stars.frag 14370 => 2345.702
+frozen-wasteland.frag 4609 => 812.410
+kinder_painter.frag 2905 => 450.888
+leizex.frag 2327 => 515.566
+lunaquatic.frag 5231 => 1055.816
+mandelbulb.frag 2419 => 546.857
+ohanami.frag 3292 => 736.461
+orchard.frag 5643 => 1034.091
+oscars_chair.frag 4653 => 984.586
+robin.frag 6343 => 1057.981
+slisesix.frag 4587 => 937.138
+terrarium.frag 3634 => 747.342
+the_real_party_is_in_your_pocket.frag 12248 => 1815.043
+valley_ball.glsl 4386 => 888.496
+yx_long_way_from_home.frag 3030 => 615.535
+Total: 119302 => 21362.097
diff --git a/tests/real/README.md b/tests/real/README.md
new file mode 100644
index 00000000..59957807
--- /dev/null
+++ b/tests/real/README.md
@@ -0,0 +1,37 @@
+This is a third-party directory. Files in this directory do not have the same
+license as the main repository. These files are used only for testing purposes.
+Do not use them in any other way without their author first.
+
+## How we use the files
+
+1. Parser coverage. We need to ensure that Shader Minifier can parse a variety
+ of shader files. These files help us improve the coverage and be more
+ confident when we make changes to the parser.
+
+2. AST transformation coverage. When we implement AST transformations, we run
+ them on the test shaders. We call a shader compiler to ensure the output
+ still compiles. Additionally, we manually review the changes to the minified
+ shaders to spot potential issues.
+
+3. Compression tests. We use these tests to check that Shader Minifier output
+ stays small and compresses well. We need a variety of test files that are
+ "realistic" (synthetic files wouldn't have the same compression profile).
+
+4. Performance tests. We check the performance of Shader Minifier on real
+ shaders and make sure it remains fast enough.
+
+
+## Updating the files
+
+- `.expected` files are generated by Shader Minifier. They are updated when we
+ run the tests.
+- If you own any of these files, you can reach out to update the file, clarify
+ the attribution, or have it deleted.
+- If you want to contribute new files, you can send a pull request. We prefer
+ files that increase the code coverage or are representative of the modern
+ demoscene.
+
+Note: When the project started, it was not open-source and shaders were
+collected from various sources. They are not always well attributed; sorry about
+that, we're more careful from now on. We add files that have a compatible
+license and add attribution in the file header.
diff --git a/tests/real/audio-flight-v2.frag b/tests/real/audio-flight-v2.frag
new file mode 100644
index 00000000..e9a465fa
--- /dev/null
+++ b/tests/real/audio-flight-v2.frag
@@ -0,0 +1,350 @@
+/**
+ Copied from https://www.shadertoy.com/view/7tfyRl
+ License: Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
+
+ AudioFlight 🚀 v2 - music Boris Brejcha - Gravity
+ 4/14/22 | @byt3_m3chanic
+
+ Path shader based around @Shane's stuff - he has a ton of amazing ones.
+ https://www.shadertoy.com/view/MlXSWX
+
+ Music EQ based around @blackle's domain rep tricks
+
+ Lots of fo
+
+*/
+
+
+#define R iResolution
+#define T iTime
+#define M iMouse
+
+#define PI2 6.28318530718
+#define PI 3.14159265358
+
+#define MINDIST .0001
+#define MAXDIST 125.
+
+#define r2(a) mat2(cos(a),sin(a),-sin(a),cos(a))
+
+float hash21(vec2 p){ return fract(sin(dot(p, vec2(27.609, 57.583)))*43758.5453); }
+float sampleFreq(float freq) {
+ return texture(iChannel0, vec2(freq, 0.1)).x;
+}
+
+//http://mercury.sexy/hg_sdf/
+float pMod(inout float p, float size) {
+ float c = floor((p + size*0.5)/size);
+ p = mod(p + size*0.5, size) - size*0.5;
+ return c;
+}
+vec2 pMod(inout vec2 p, float size) {
+ vec2 c = floor((p + size*0.5)/size);
+ p = mod(p + size*0.5, size) - size*0.5;
+ return c;
+}
+vec3 pMod(inout vec3 p, float size) {
+ vec3 c = floor((p + size*0.5)/size);
+ p = mod(p + size*0.5, size) - size*0.5;
+ return c;
+}
+float pModPolar(inout vec2 p, float repetitions) {
+ float angle = 2.*PI/repetitions;
+ float a = atan(p.y, p.x) + angle/2.,
+ r = length(p),
+ c = floor(a/angle);
+ a = mod(a,angle) - angle/2.;
+ p = vec2(cos(a), sin(a))*r;
+ if (abs(c) >= (repetitions/2.)) c = abs(c);
+ return c;
+}
+float vmax(vec2 v) { return max(v.x, v.y); }
+float vmax(vec3 v) { return max(max(v.x, v.y), v.z); }
+float fBox(vec3 p, vec3 b) {
+ vec3 d = abs(p) - b;
+ return length(max(d, vec3(0))) + vmax(min(d, vec3(0)));
+}
+float fBox2(vec2 p, vec2 b) {
+ vec2 d = abs(p) - b;
+ return length(max(d, vec2(0))) + vmax(min(d, vec2(0)));
+}
+//@iq
+float sdCap( vec3 p, float h, float r ){
+ p.y -= clamp( p.y, 0.0, h );
+ return length( p ) - r;
+}
+// @Shane - https://www.shadertoy.com/view/MlXSWX
+vec2 path(in float z){
+ vec2 p1 =vec2(2.35*sin(z * .125)+2.38*cos(z * .25), 3.5*cos(z * .0945));
+ vec2 p2 =vec2(3.2*sin(z * .19), 4.31*sin(z * .125)-2.38*cos(z * .115));
+ return (p1 - p2)*.3;
+}
+
+// globals
+float time,tm,travelSpeed;
+
+// globals and stuff
+float glow,iqd,flight,beams,gcolor,objglow,offWobble,boxsize;
+float ga,sa,slp;
+vec3 g_hp,s_hp;
+mat2 r4,r5;
+
+const vec3 cxz = vec3(3.15,4.75,3.);
+const float scale = 3.0;
+
+vec2 fragtail(vec3 pos) {
+ float ss=1.15;
+ float r = 1e5;
+
+ for (int i = 0;i<2;i++) {
+ pos=abs(pos);
+ if ( pos.x- pos.y<0.) pos.yx = pos.xy;
+ if ( pos.x- pos.z<0.) pos.zx = pos.xz;
+ if ( pos.y- pos.z<0.) pos.zy = pos.yz;
+
+ pos.x=scale * pos.x-cxz.x*(scale-1.);
+ pos.y=scale * pos.y-cxz.y*(scale-1.);
+ pos.z=scale * pos.z;
+
+ if (pos.z>0.5*cxz.z*(scale-1.)) pos.z-=cxz.z*(scale-1.);
+
+ r = fBox2(pos.xy,vec2(5,1.5+.25*sin(pos.x*5.)))-.0015;
+ ss*=1./scale;
+ }
+
+ return vec2(r*ss,1.);
+}
+
+//@blackle domain rep https://www.shadertoy.com/view/Wl3fD2
+vec2 edge(vec2 p) {
+ vec2 p2 = abs(p);
+ if (p2.x > p2.y) return vec2((p.x < 0.) ? -1. : 1., 0.);
+ else return vec2(0., (p.y < 0.) ? -1. : 1.);
+}
+float ths= 13.25;
+// scene map
+vec2 map (in vec3 p, float sg) {
+
+ vec2 res = vec2(100.,-1.);
+ float msize = 7.25;
+
+ // set path(s) vector(s)
+ vec2 tun = p.xy - path(p.z);
+ vec3 q = vec3(tun,p.z);
+ vec3 o = vec3(tun+vec2(0.,.0),p.z+travelSpeed+4.25);
+
+ vec3 s = q;
+
+ o.zx*=r5;
+ o.yz*=r4;
+ o = abs(o)-(offWobble*.25);
+ float obj = fBox(o,vec3(.15*offWobble))-.015;
+ if(objMAXDIST)break;
+ d += i<42? t.x*.35 : t.x;
+ m = t.y;
+ }
+ return vec2(d,m);
+}
+
+vec3 normal(vec3 p, float t) {
+ float e = MINDIST*t;
+ vec2 h = vec2(1,-1)*.5773;
+ return normalize(
+ h.xyy*map( p + h.xyy*e,0.).x +
+ h.yyx*map( p + h.yyx*e,0.).x +
+ h.yxy*map( p + h.yxy*e,0.).x +
+ h.xxx*map( p + h.xxx*e,0.).x );
+}
+
+//iq of hsv2rgb
+vec3 hsv2rgb( in vec3 c ) {
+ vec3 rgb = clamp( abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0 );
+ return c.z * mix( vec3(1.0), rgb, c.y);
+}
+
+void mainImage( out vec4 O, in vec2 F ) {
+ // precal
+ time = iTime;
+ tm = mod(time*.3, 18.);
+ travelSpeed = (time * 5.);
+
+ offWobble = 1.5+1.15*sin(tm+time*.1);
+
+ r4 =r2(time);
+ r5 =r2(time);
+
+ // pixel screen coordinates
+ vec2 uv = (F.xy - R.xy*0.5)/max(R.x,R.y);
+ vec3 C = vec3(0.),
+ FC = vec3(.03);
+
+ float crop = clamp((-.05)+(T*.05),0.,.18);
+ if(uv.y-crop){
+ vec3 lp = vec3(0.,0.,0.-travelSpeed);
+ vec3 ro = vec3(0.,0,.15);
+
+ // mouse
+ float x = M.xy==vec2(0) || M.z<0. ? 0.:(M.y/R.y*1.-.5)*PI;
+ float y = M.xy==vec2(0) || M.z<0. ? 0.:-(M.x/R.x*2.-1.)*PI;
+
+ ro.zy*=r2(x);
+
+ ro +=lp;
+
+ lp.xy += path(lp.z);
+ ro.xy += path(ro.z);
+
+ // set camera
+ vec3 f=normalize(lp-ro),
+ r=normalize(cross(vec3(0,1,0),f)),
+ u=normalize(cross(f,r)),
+ c=ro+f*.183,
+ i=c+uv.x*r+uv.y*u,
+ rd=i-ro;
+
+ // center tracking
+ rd.xy = r2( (.2*sin(time*.3))-path(lp.z).x/ 24. )*rd.xy;
+ rd.xz = r2( y-path(lp.z+1.).y/ 14. )*rd.xz;
+
+ // march
+ vec2 t = marcher(ro,rd, 164,1.);
+ float d = t.x,
+ m = t.y;
+ s_hp=g_hp;
+
+ // if visible
+ if(dths) {
+ C =(h * diff + spec);
+ } else {
+ if(m==3.||m==4.) C =(hsv2rgb(vec3(s_hp.z*.01,.8,.6)) * diff);
+ }
+
+ }
+
+ if(tm>ths) {
+ if(mod(T,.1)<.05)FC=vec3(.8);
+ }else{
+
+ C += abs(glow*.7)*hsv2rgb(vec3(s_hp.z*.01,.8,.6));
+ C += abs(objglow*.65)*vec3(1,1,1);
+ }
+ C = mix( C, FC, 1.-exp(-0.000075*t.x*t.x*t.x));
+ C += abs(beams*.65)*hsv2rgb(vec3(s_hp.z*.025,.8,.6));
+ C += abs(flight*.75)*vec3(.5,1,.2);
+ }
+
+
+ float px = 1./R.x;
+
+
+ float d1 = fBox2(uv+vec2(-.485,.2675),vec2(.005))-.002;
+ d1=smoothstep(px,-px,d1);
+ C=mix(C,vec3(0.212,0.671,0.576),d1);
+
+ d1 = fBox2(uv+vec2(-.465,.2675),vec2(.005))-.002;
+ d1=smoothstep(px,-px,d1);
+ C=mix(C,vec3(0.757,0.686,0.341),d1);
+
+ d1 = fBox2(uv+vec2(-.445,.2675),vec2(.005))-.002;
+ d1=smoothstep(px,-px,d1);
+ C=mix(C,vec3(0.882,0.459,0.867),d1);
+
+ C=pow(C, vec3(0.4545));
+ O = vec4(C,1.0);
+}
diff --git a/tests/real/audio-flight-v2.frag.expected b/tests/real/audio-flight-v2.frag.expected
new file mode 100644
index 00000000..f3a2e55b
--- /dev/null
+++ b/tests/real/audio-flight-v2.frag.expected
@@ -0,0 +1,270 @@
+#define R iResolution
+
+#define T iTime
+
+#define M iMouse
+
+#define PI2 6.28318530718
+
+#define PI 3.14159265358
+
+#define MINDIST.0001
+
+#define MAXDIST 125.
+
+#define r2(a)mat2(cos(a),sin(a),-sin(a),cos(a))
+
+float sampleFreq(float freq)
+{
+ return texture(iChannel0,vec2(freq,.1)).x;
+}
+float pMod(inout float p,float size)
+{
+ float c=floor((p+size*.5)/size);
+ p=mod(p+size*.5,size)-size*.5;
+ return c;
+}
+vec2 pMod(inout vec2 p,float size)
+{
+ vec2 c=floor((p+size*.5)/size);
+ p=mod(p+size*.5,size)-size*.5;
+ return c;
+}
+vec3 pMod(inout vec3 p,float size)
+{
+ vec3 c=floor((p+size*.5)/size);
+ p=mod(p+size*.5,size)-size*.5;
+ return c;
+}
+float pModPolar(inout vec2 p,float repetitions)
+{
+ float angle=2.*PI/repetitions,a=atan(p.y,p.x)+angle/2.,r=length(p),c=floor(a/angle);
+ a=mod(a,angle)-angle/2.;
+ p=vec2(cos(a),sin(a))*r;
+ if(abs(c)>=repetitions/2.)
+ c=abs(c);
+ return c;
+}
+float vmax(vec2 v)
+{
+ return max(v.x,v.y);
+}
+float vmax(vec3 v)
+{
+ return max(max(v.x,v.y),v.z);
+}
+float fBox(vec3 p,vec3 b)
+{
+ vec3 d=abs(p)-b;
+ return length(max(d,vec3(0)))+vmax(min(d,vec3(0)));
+}
+float fBox2(vec2 p,vec2 b)
+{
+ vec2 d=abs(p)-b;
+ return length(max(d,vec2(0)))+vmax(min(d,vec2(0)));
+}
+float sdCap(vec3 p,float h,float r)
+{
+ p.y-=clamp(p.y,0.,h);
+ return length(p)-r;
+}
+vec2 path(float z)
+{
+ vec2 p1=vec2(2.35*sin(z*.125)+2.38*cos(z*.25),3.5*cos(z*.0945)),p2=vec2(3.2*sin(z*.19),4.31*sin(z*.125)-2.38*cos(z*.115));
+ return(p1-p2)*.3;
+}
+float time,tm,travelSpeed,glow,iqd,flight,beams,gcolor,objglow,offWobble,boxsize,ga,sa,slp;
+vec3 g_hp,s_hp;
+mat2 r4,r5;
+const vec3 cxz=vec3(3.15,4.75,3);
+vec2 fragtail(vec3 pos)
+{
+ float ss=1.15,r=1e5;
+ for(int i=0;i<2;i++)
+ {
+ pos=abs(pos);
+ if(pos.x-pos.y<0.)
+ pos.yx=pos.xy;
+ if(pos.x-pos.z<0.)
+ pos.zx=pos.xz;
+ if(pos.y-pos.z<0.)
+ pos.zy=pos.yz;
+ pos.x=3.*pos.x-cxz.x*2.;
+ pos.y=3.*pos.y-cxz.y*2.;
+ pos.z=3.*pos.z;
+ if(pos.z>.5*cxz.z*2.)
+ pos.z-=cxz.z*2.;
+ r=fBox2(pos.xy,vec2(5,1.5+.25*sin(pos.x*5.)))-.0015;
+ ss*=1./3.;
+ }
+ return vec2(r*ss,1);
+}
+vec2 edge(vec2 p)
+{
+ vec2 p2=abs(p);
+ return p2.x>p2.y?
+ vec2(p.x<0.?
+ -1.:
+ 1.,0):
+ vec2(0,p.y<0.?
+ -1.:
+ 1.);
+}
+float ths=13.25;
+vec2 map(vec3 p,float sg)
+{
+ vec2 res=vec2(100,-1);
+ float msize=7.25;
+ vec2 tun=p.xy-path(p.z);
+ vec3 q=vec3(tun,p.z),o=vec3(tun+vec2(0),p.z+travelSpeed+4.25),s=q;
+ o.zx*=r5;
+ o.yz*=r4;
+ o=abs(o)-offWobble*.25;
+ float obj=fBox(o,vec3(.15*offWobble))-.015;
+ if(objMAXDIST)
+ break;
+ d+=i<42?
+ t.x*.35:
+ t.x;
+ m=t.y;
+ }
+ return vec2(d,m);
+}
+vec3 normal(vec3 p,float t)
+{
+ float e=MINDIST*t;
+ vec2 h=vec2(1,-1)*.5773;
+ return normalize(h.xyy*map(p+h.xyy*e,0.).x+h.yyx*map(p+h.yyx*e,0.).x+h.yxy*map(p+h.yxy*e,0.).x+h.xxx*map(p+h.xxx*e,0.).x);
+}
+vec3 hsv2rgb(vec3 c)
+{
+ vec3 rgb=clamp(abs(mod(c.x*6.+vec3(0,4,2),6.)-3.)-1.,0.,1.);
+ return c.z*mix(vec3(1),rgb,c.y);
+}
+void mainImage(out vec4 O,vec2 F)
+{
+ time=iTime;
+ tm=mod(time*.3,18.);
+ travelSpeed=time*5.;
+ offWobble=1.5+1.15*sin(tm+time*.1);
+ r4=r2(time);
+ r5=r2(time);
+ vec2 uv=(F.xy-R.xy*.5)/max(R.x,R.y);
+ vec3 C=vec3(0),FC=vec3(.03);
+ float crop=clamp(-.05+T*.05,0.,.18);
+ if(uv.y-crop)
+ {
+ vec3 lp=vec3(0,0,-travelSpeed),ro=vec3(0,0,.15);
+ float x=M.xy==vec2(0)||M.z<0.?
+ 0.:
+ (M.y/R.y-.5)*PI,y=M.xy==vec2(0)||M.z<0.?
+ 0.:
+ -(M.x/R.x*2.-1.)*PI;
+ ro.zy*=r2(x);
+ ro+=lp;
+ lp.xy+=path(lp.z);
+ ro.xy+=path(ro.z);
+ vec3 f=normalize(lp-ro),r=normalize(cross(vec3(0,1,0),f)),u=normalize(cross(f,r)),c=ro+f*.183,i=c+uv.x*r+uv.y*u,rd=i-ro;
+ rd.xy=r2(.2*sin(time*.3)-path(lp.z).x/24.)*rd.xy;
+ rd.xz=r2(y-path(lp.z+1.).y/14.)*rd.xz;
+ vec2 t=marcher(ro,rd,164,1.);
+ float d=t.x,m=t.y;
+ s_hp=g_hp;
+ if(dths)
+ C=h*diff+spec;
+ else
+ if(m==3.||m==4.)
+ C=hsv2rgb(vec3(s_hp.z*.01,.8,.6))*diff;
+ }
+ if(tm>ths)
+ {
+ if(mod(T,.1)<.05)
+ FC=vec3(.8);
+ }
+ else
+ C+=abs(glow*.7)*hsv2rgb(vec3(s_hp.z*.01,.8,.6)),C+=abs(objglow*.65)*vec3(1);
+ C=mix(C,FC,1.-exp(-7.5e-5*t.x*t.x*t.x));
+ C+=abs(beams*.65)*hsv2rgb(vec3(s_hp.z*.025,.8,.6));
+ C+=abs(flight*.75)*vec3(.5,1,.2);
+ }
+ float px=1./R.x,d1=fBox2(uv+vec2(-.485,.2675),vec2(.005))-.002;
+ d1=smoothstep(px,-px,d1);
+ C=mix(C,vec3(.212,.671,.576),d1);
+ d1=fBox2(uv+vec2(-.465,.2675),vec2(.005))-.002;
+ d1=smoothstep(px,-px,d1);
+ C=mix(C,vec3(.757,.686,.341),d1);
+ d1=fBox2(uv+vec2(-.445,.2675),vec2(.005))-.002;
+ d1=smoothstep(px,-px,d1);
+ C=mix(C,vec3(.882,.459,.867),d1);
+ C=pow(C,vec3(.4545));
+ O=vec4(C,1);
+}
diff --git a/tests/real/buoy.frag b/tests/real/buoy.frag
new file mode 100644
index 00000000..89ffb8a1
--- /dev/null
+++ b/tests/real/buoy.frag
@@ -0,0 +1,424 @@
+// Source: https://www.shadertoy.com/view/XdsGDB
+// Created by TekF
+// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
+
+const float tau = 6.28318530717958647692;
+
+// Gamma correction
+#define GAMMA (2.2)
+
+vec3 ToLinear( in vec3 col )
+{
+ // simulate a monitor, converting colour values into light values
+ return pow( col, vec3(GAMMA) );
+}
+
+vec3 ToGamma( in vec3 col )
+{
+ // convert back into colour values, so the correct light will come out of the monitor
+ return pow( col, vec3(1.0/GAMMA) );
+}
+
+vec3 localRay;
+
+// Set up a camera looking at the scene.
+// origin - camera is positioned relative to, and looking at, this point
+// distance - how far camera is from origin
+// rotation - about x & y axes, by left-hand screw rule, relative to camera looking along +z
+// zoom - the relative length of the lens
+void CamPolar( out vec3 pos, out vec3 ray, in vec3 origin, in vec2 rotation, in float distance, in float zoom, in vec2 fragCoord )
+{
+ // get rotation coefficients
+ vec2 c = vec2(cos(rotation.x),cos(rotation.y));
+ vec4 s;
+ s.xy = vec2(sin(rotation.x),sin(rotation.y)); // worth testing if this is faster as sin or sqrt(1.0-cos);
+ s.zw = -s.xy;
+
+ // ray in view space
+ ray.xy = fragCoord.xy - iResolution.xy*.5;
+ ray.z = iResolution.y*zoom;
+ ray = normalize(ray);
+ localRay = ray;
+
+ // rotate ray
+ ray.yz = ray.yz*c.xx + ray.zy*s.zx;
+ ray.xz = ray.xz*c.yy + ray.zx*s.yw;
+
+ // position camera
+ pos = origin - distance*vec3(c.x*s.y,s.z,c.x*c.y);
+}
+
+
+// Noise functions, distinguished by variable types
+
+vec2 Noise( in vec3 x )
+{
+ vec3 p = floor(x);
+ vec3 f = fract(x);
+ f = f*f*(3.0-2.0*f);
+// vec3 f2 = f*f; f = f*f2*(10.0-15.0*f+6.0*f2);
+
+ vec2 uv = (p.xy+vec2(37.0,17.0)*p.z);
+
+ vec4 rg = textureLod( iChannel0, (uv+f.xy+0.5)/256.0, 0.0 );
+
+ return mix( rg.yw, rg.xz, f.z );
+}
+
+vec2 NoisePrecise( in vec3 x )
+{
+ vec3 p = floor(x);
+ vec3 f = fract(x);
+ f = f*f*(3.0-2.0*f);
+// vec3 f2 = f*f; f = f*f2*(10.0-15.0*f+6.0*f2);
+
+ vec2 uv = (p.xy+vec2(37.0,17.0)*p.z);
+
+ vec4 rg = mix( mix(
+ textureLod( iChannel0, (uv+0.5)/256.0, 0.0 ),
+ textureLod( iChannel0, (uv+vec2(1,0)+0.5)/256.0, 0.0 ),
+ f.x ),
+ mix(
+ textureLod( iChannel0, (uv+vec2(0,1)+0.5)/256.0, 0.0 ),
+ textureLod( iChannel0, (uv+1.5)/256.0, 0.0 ),
+ f.x ),
+ f.y );
+
+
+ return mix( rg.yw, rg.xz, f.z );
+}
+
+vec4 Noise( in vec2 x )
+{
+ vec2 p = floor(x.xy);
+ vec2 f = fract(x.xy);
+ f = f*f*(3.0-2.0*f);
+// vec3 f2 = f*f; f = f*f2*(10.0-15.0*f+6.0*f2);
+
+ vec2 uv = p.xy + f.xy;
+ return textureLod( iChannel0, (uv+0.5)/256.0, 0.0 );
+}
+
+vec4 Noise( in ivec2 x )
+{
+ return textureLod( iChannel0, (vec2(x)+0.5)/256.0, 0.0 );
+}
+
+vec2 Noise( in ivec3 x )
+{
+ vec2 uv = vec2(x.xy)+vec2(37.0,17.0)*float(x.z);
+ return textureLod( iChannel0, (uv+0.5)/256.0, 0.0 ).xz;
+}
+
+
+float Waves( vec3 pos )
+{
+ pos *= .2*vec3(1,1,1);
+
+ const int octaves = 5;
+ float f = 0.0;
+
+ // need to do the octaves from large to small, otherwise things don't line up
+ // (because I rotate by 45 degrees on each octave)
+ pos += iTime*vec3(0,.1,.1);
+ for ( int i=0; i < octaves; i++ )
+ {
+ pos = (pos.yzx + pos.zyx*vec3(1,-1,1))/sqrt(2.0);
+ f = f*2.0+abs(Noise(pos).x-.5)*2.0;
+ pos *= 2.0;
+ }
+ f /= exp2(float(octaves));
+
+ return (.5-f)*1.0;
+}
+
+float WavesDetail( vec3 pos )
+{
+ pos *= .2*vec3(1,1,1);
+
+ const int octaves = 8;
+ float f = 0.0;
+
+ // need to do the octaves from large to small, otherwise things don't line up
+ // (because I rotate by 45 degrees on each octave)
+ pos += iTime*vec3(0,.1,.1);
+ for ( int i=0; i < octaves; i++ )
+ {
+ pos = (pos.yzx + pos.zyx*vec3(1,-1,1))/sqrt(2.0);
+ f = f*2.0+abs(NoisePrecise(pos).x-.5)*2.0;
+ pos *= 2.0;
+ }
+ f /= exp2(float(octaves));
+
+ return (.5-f)*1.0;
+}
+
+float WavesSmooth( vec3 pos )
+{
+ pos *= .2*vec3(1,1,1);
+
+ const int octaves = 2;
+ float f = 0.0;
+
+ // need to do the octaves from large to small, otherwise things don't line up
+ // (because I rotate by 45 degrees on each octave)
+ pos += iTime*vec3(0,.1,.1);
+ for ( int i=0; i < octaves; i++ )
+ {
+ pos = (pos.yzx + pos.zyx*vec3(1,-1,1))/sqrt(2.0);
+ //f = f*2.0+abs(Noise(pos).x-.5)*2.0;
+ f = f*2.0+sqrt(pow(NoisePrecise(pos).x-.5,2.0)+.01)*2.0;
+ pos *= 2.0;
+ }
+ f /= exp2(float(octaves));
+
+ return (.5-f)*1.0;
+}
+
+float WaveCrests( vec3 ipos, in vec2 fragCoord )
+{
+ vec3 pos = ipos;
+ pos *= .2*vec3(1,1,1);
+
+ const int octaves1 = 6;
+ const int octaves2 = 16;
+ float f = 0.0;
+
+ // need to do the octaves from large to small, otherwise things don't line up
+ // (because I rotate by 45 degrees on each octave)
+ pos += iTime*vec3(0,.1,.1);
+ vec3 pos2 = pos;
+ for ( int i=0; i < octaves1; i++ )
+ {
+ pos = (pos.yzx + pos.zyx*vec3(1,-1,1))/sqrt(2.0);
+ f = f*1.5+abs(Noise(pos).x-.5)*2.0;
+ pos *= 2.0;
+ }
+ pos = pos2 * exp2(float(octaves1));
+ pos.y = -.05*iTime;
+ for ( int i=octaves1; i < octaves2; i++ )
+ {
+ pos = (pos.yzx + pos.zyx*vec3(1,-1,1))/sqrt(2.0);
+ f = f*1.5+pow(abs(Noise(pos).x-.5)*2.0,1.0);
+ pos *= 2.0;
+ }
+ f /= 1500.0;
+
+ f -= Noise(ivec2(fragCoord.xy)).x*.01;
+
+ return pow(smoothstep(.4,-.1,f),6.0);
+}
+
+
+vec3 Sky( vec3 ray )
+{
+ return vec3(.4,.45,.5);
+}
+
+
+vec3 boatRight, boatUp, boatForward;
+vec3 boatPosition;
+
+void ComputeBoatTransform( void )
+{
+ vec3 samples[5];
+
+ samples[0] = vec3(0,0, 0);
+ samples[1] = vec3(0,0, .5);
+ samples[2] = vec3(0,0,-.5);
+ samples[3] = vec3( .5,0,0);
+ samples[4] = vec3(-.5,0,0);
+
+ samples[0].y = WavesSmooth(samples[0]);
+ samples[1].y = WavesSmooth(samples[1]);
+ samples[2].y = WavesSmooth(samples[2]);
+ samples[3].y = WavesSmooth(samples[3]);
+ samples[4].y = WavesSmooth(samples[4]);
+
+ boatPosition = (samples[0]+samples[1]+samples[2]+samples[3]+samples[4])/5.0;
+
+ boatRight = samples[3]-samples[4];
+ boatForward = samples[1]-samples[2];
+ boatUp = normalize(cross(boatForward,boatRight));
+ boatRight = normalize(cross(boatUp,boatForward));
+ boatForward = normalize(boatForward);
+
+ boatPosition += .0*boatUp;
+}
+
+vec3 BoatToWorld( vec3 dir )
+{
+ return dir.x*boatRight+dir.x*boatUp+dir.x*boatForward;
+}
+
+vec3 WorldToBoat( vec3 dir )
+{
+ return vec3( dot(dir,boatRight), dot(dir,boatUp), dot(dir,boatForward) );
+}
+
+float TraceBoat( vec3 pos, vec3 ray )
+{
+ vec3 c = boatPosition;
+ float r = 1.0;
+
+ c -= pos;
+
+ float t = dot(c,ray);
+
+ float p = length(c-t*ray);
+ if ( p > r )
+ return 0.0;
+
+ return t-sqrt(r*r-p*p);
+}
+
+
+vec3 ShadeBoat( vec3 pos, vec3 ray )
+{
+ pos -= boatPosition;
+ vec3 norm = normalize(pos);
+ pos = WorldToBoat(pos);
+
+ vec3 lightDir = normalize(vec3(-2,3,1));
+ float ndotl = dot(norm,lightDir);
+
+ // allow some light bleed, as if it's subsurface scattering through plastic
+ vec3 light = smoothstep(-.1,1.0,ndotl)*vec3(1.0,.9,.8)+vec3(.06,.1,.1);
+
+ // anti-alias the albedo
+ float aa = 4.0/iResolution.x;
+
+ //vec3 albedo = ((fract(pos.x)-.5)*(fract(pos.y)-.5)*(fract(pos.z)-.5) < 0.0) ? vec3(0) : vec3(1);
+ vec3 albedo = vec3(1,.01,0);
+ albedo = mix( vec3(.04), albedo, smoothstep( .25-aa, .25, abs(pos.y) ) );
+ albedo = mix( mix( vec3(1), vec3(.04), smoothstep(-aa*4.0,aa*4.0,cos(atan(pos.x,pos.z)*6.0)) ), albedo, smoothstep( .2-aa*1.5, .2, abs(pos.y) ) );
+ albedo = mix( vec3(.04), albedo, smoothstep( .05-aa*1.0, .05, abs(abs(pos.y)-.6) ) );
+ albedo = mix( vec3(1,.8,.08), albedo, smoothstep( .05-aa*1.0, .05, abs(abs(pos.y)-.65) ) );
+
+ vec3 col = albedo*light;
+
+ // specular
+ vec3 h = normalize(lightDir-ray);
+ float s = pow(max(0.0,dot(norm,h)),100.0)*100.0/32.0;
+
+ vec3 specular = s*vec3(1,1,1);
+
+ vec3 rr = reflect(ray,norm);
+ specular += mix( vec3(0,.04,.04), Sky(rr), smoothstep( -.1, .1, rr.y ) );
+
+ float ndotr = dot(norm,ray);
+ float fresnel = pow(1.0-abs(ndotr),5.0);
+ fresnel = mix( .001, 1.0, fresnel );
+
+ col = mix( col, specular, fresnel );
+
+ return col;
+}
+
+
+float OceanDistanceField( vec3 pos )
+{
+ return pos.y - Waves(pos);
+}
+
+float OceanDistanceFieldDetail( vec3 pos )
+{
+ return pos.y - WavesDetail(pos);
+}
+
+vec3 OceanNormal( vec3 pos )
+{
+ vec3 norm;
+ vec2 d = vec2(.01*length(pos),0);
+
+ norm.x = OceanDistanceFieldDetail( pos+d.xyy )-OceanDistanceFieldDetail( pos-d.xyy );
+ norm.y = OceanDistanceFieldDetail( pos+d.yxy )-OceanDistanceFieldDetail( pos-d.yxy );
+ norm.z = OceanDistanceFieldDetail( pos+d.yyx )-OceanDistanceFieldDetail( pos-d.yyx );
+
+ return normalize(norm);
+}
+
+float TraceOcean( vec3 pos, vec3 ray )
+{
+ float h = 1.0;
+ float t = 0.0;
+ for ( int i=0; i < 100; i++ )
+ {
+ if ( h < .01 || t > 100.0 )
+ break;
+ h = OceanDistanceField( pos+t*ray );
+ t += h;
+ }
+
+ if ( h > .1 )
+ return 0.0;
+
+ return t;
+}
+
+
+vec3 ShadeOcean( vec3 pos, vec3 ray, in vec2 fragCoord )
+{
+ vec3 norm = OceanNormal(pos);
+ float ndotr = dot(ray,norm);
+
+ float fresnel = pow(1.0-abs(ndotr),5.0);
+
+ vec3 reflectedRay = ray-2.0*norm*ndotr;
+ vec3 refractedRay = ray+(-cos(1.33*acos(-ndotr))-ndotr)*norm;
+ refractedRay = normalize(refractedRay);
+
+ const float crackFudge = .0;
+
+ // reflection
+ vec3 reflection = Sky(reflectedRay);
+ float t=TraceBoat( pos-crackFudge*reflectedRay, reflectedRay );
+
+ if ( t > 0.0 )
+ {
+ reflection = ShadeBoat( pos+(t-crackFudge)*reflectedRay, reflectedRay );
+ }
+
+
+ // refraction
+ t=TraceBoat( pos-crackFudge*refractedRay, refractedRay );
+
+ vec3 col = vec3(0,.04,.04); // under-sea colour
+ if ( t > 0.0 )
+ {
+ col = mix( col, ShadeBoat( pos+(t-crackFudge)*refractedRay, refractedRay ), exp(-t) );
+ }
+
+ col = mix( col, reflection, fresnel );
+
+ // foam
+ col = mix( col, vec3(1), WaveCrests(pos,fragCoord) );
+
+ return col;
+}
+
+
+void mainImage( out vec4 fragColor, in vec2 fragCoord )
+{
+ ComputeBoatTransform();
+
+ vec2 camRot = vec2(.5,.5)+vec2(-.35,4.5)*(iMouse.yx/iResolution.yx);
+ vec3 pos, ray;
+ CamPolar( pos, ray, vec3(0), camRot, 3.0, 1.0, fragCoord );
+
+ float to = TraceOcean( pos, ray );
+ float tb = TraceBoat( pos, ray );
+
+ vec3 result;
+ if ( to > 0.0 && ( to < tb || tb == 0.0 ) )
+ result = ShadeOcean( pos+ray*to, ray, fragCoord );
+ else if ( tb > 0.0 )
+ result = ShadeBoat( pos+ray*tb, ray );
+ else
+ result = Sky( ray );
+
+ // vignette effect
+ result *= 1.1*smoothstep( .35, 1.0, localRay.z );
+
+ fragColor = vec4(ToGamma(result),1.0);
+}
diff --git a/tests/real/chocolux.expected b/tests/real/chocolux.expected
index d00f70eb..e0bd23a1 100644
--- a/tests/real/chocolux.expected
+++ b/tests/real/chocolux.expected
@@ -1,48 +1,48 @@
-/* File generated with
- * http://www.ctrl-alt-test.fr
- */
+// Generated with (https://github.com/laurentlb/Shader_Minifier/)
#ifndef CHOCOLUX_EXPECTED_
# define CHOCOLUX_EXPECTED_
+# define VAR_resolution "k"
+# define VAR_time "v"
const char *chocolux_frag =
- "uniform vec2 resolution;"
- "uniform float time;"
- "float h(vec3 q)"
+ "uniform vec2 k;"
+ "uniform float v;"
+ "float s(vec3 y)"
"{"
- "float f=distance(q,vec3(cos(time)+sin(time*.2),.3,2.+cos(time*.5)*.5));"
- "f*=distance(q,vec3(-cos(time*.7),.3,2.+sin(time*.5)));"
- "f*=distance(q,vec3(-sin(time*.2)*.5,sin(time),2));"
- "f*=cos(q.y)*cos(q.x)-.1-cos(q.z*7.+time*7.)*cos(q.x*3.)*cos(q.y*4.)*.1;"
+ "float f=distance(y,vec3(cos(v)+sin(v*.2),.3,2.+cos(v*.5)*.5));"
+ "f*=distance(y,vec3(-cos(v*.7),.3,2.+sin(v*.5)));"
+ "f*=distance(y,vec3(-sin(v*.2)*.5,sin(v),2));"
+ "f*=cos(y.y)*cos(y.x)-.1-cos(y.z*7.+v*7.)*cos(y.x*3.)*cos(y.y*4.)*.1;"
"return f;"
"}"
"void main()"
"{"
- "vec2 p=-1.+2.*gl_FragCoord.xy/resolution.xy;"
- "vec3 o=vec3(p.x,p.y*1.25-.3,0),d=vec3(p.x+cos(time)*.3,p.y,1)/64.;"
- "vec4 c=vec4(0);"
- "float t=0.;"
- "for(int i=0;i<75;i++)"
+ "vec2 y=-1.+2.*gl_FragCoord.xy/k.xy;"
+ "vec3 f=vec3(y.x,y.y*1.25-.3,0),c=vec3(y.x+cos(v)*.3,y.y,1)/64.;"
+ "vec4 d=vec4(0);"
+ "float x=0.;"
+ "for(int r=0;r<75;r++)"
"{"
- "if(h(o+d*t)<.4)"
+ "if(s(f+c*x)<.4)"
"{"
- "t-=5.;"
- "for(int j=0;j<5;j++)"
+ "x-=5.;"
+ "for(int b=0;b<5;b++)"
"{"
- "if(h(o+d*t)<.4)"
+ "if(s(f+c*x)<.4)"
"break;"
- "t+=1.;"
+ "x+=1.;"
"}"
- "vec3 e=vec3(.01,0,0),n=vec3(0);"
- "n.x=h(o+d*t)-h(vec3(o+d*t+e.xyy));"
- "n.y=h(o+d*t)-h(vec3(o+d*t+e.yxy));"
- "n.z=h(o+d*t)-h(vec3(o+d*t+e.yyx));"
- "n=normalize(n);"
- "c+=max(dot(vec3(0,0,-.5),n),0.)+max(dot(vec3(0,-.5,.5),n),0.)*.5;"
+ "vec3 b=vec3(.01,0,0),i=vec3(0);"
+ "i.x=s(f+c*x)-s(vec3(f+c*x+b.xyy));"
+ "i.y=s(f+c*x)-s(vec3(f+c*x+b.yxy));"
+ "i.z=s(f+c*x)-s(vec3(f+c*x+b.yyx));"
+ "i=normalize(i);"
+ "d+=max(dot(vec3(0,0,-.5),i),0.)+max(dot(vec3(0,-.5,.5),i),0.)*.5;"
"break;"
"}"
- "t+=5.;"
+ "x+=5.;"
"}"
- "gl_FragColor=c+t*.025*vec4(.1,.2,.5,1);"
+ "gl_FragColor=d+x*.025*vec4(.1,.2,.5,1);"
"}";
#endif // CHOCOLUX_EXPECTED_
diff --git a/tests/real/clod.expected b/tests/real/clod.expected
index a3243b44..0141317a 100644
--- a/tests/real/clod.expected
+++ b/tests/real/clod.expected
@@ -1 +1 @@
-uniform vec2 resolution;uniform float time;uniform sampler2D tex0,tex1,tex2,tex3;float f(vec3 o){float a=(sin(o.x)+o.y*.25)*.35;o=vec3(cos(a)*o.x-sin(a)*o.y,sin(a)*o.x+cos(a)*o.y,o.z);return dot(cos(o)*cos(o),vec3(1))-1.2;}vec3 s(vec3 o,vec3 d){float t=0.,a,b;for(int i=0;i<75;i++){if(f(o+d*t)<0.){a=t-.125;b=t;for(int i=0;i<10;i++){t=(a+b)*.5;if(f(o+d*t)<0.)b=t;else a=t;}vec3 e=vec3(.1,0,0),p=o+d*t,n=-normalize(vec3(f(p+e),f(p+e.yxy),f(p+e.yyx))+vec3(sin(p*75.))*.01);return vec3(mix((max(-dot(n,vec3(.577)),0.)+.125*max(-dot(n,vec3(-.707,-.707,0)),0.))*(mod(length(p.xy)*20.,2.)<1.?vec3(.71,.85,.25):vec3(.79,.93,.4)),vec3(.93,.94,.85),vec3(pow(t/9.,5.))));}t+=.125;}return vec3(.93,.94,.85);}void main(){vec2 p=-1.+2.*gl_FragCoord.xy/resolution.xy;gl_FragColor=vec4(s(vec3(sin(time*1.5)*.5,cos(time)*.5,time),normalize(vec3(p.xy,1))),1);}
+uniform vec2 v;uniform float s;uniform sampler2D y,c,n,C;float m(vec3 v){float s=(sin(v.x)+v.y*.25)*.35;v=vec3(cos(s)*v.x-sin(s)*v.y,sin(s)*v.x+cos(s)*v.y,v.z);return dot(cos(v)*cos(v),vec3(1))-1.2;}vec3 m(vec3 v,vec3 s){float y=0.,c,f;for(int r=0;r<75;r++){if(m(v+s*y)<0.){c=y-.125;f=y;for(int u=0;u<10;u++){y=(c+f)*.5;if(m(v+s*y)<0.)f=y;else c=y;}vec3 d=vec3(.1,0,0),i=v+s*y,n=-normalize(vec3(m(i+d),m(i+d.yxy),m(i+d.yyx))+vec3(sin(i*75.))*.01);return vec3(mix((max(-dot(n,vec3(.577)),0.)+.125*max(-dot(n,vec3(-.707,-.707,0)),0.))*(mod(length(i.xy)*20.,2.)<1.?vec3(.71,.85,.25):vec3(.79,.93,.4)),vec3(.93,.94,.85),vec3(pow(y/9.,5.))));}y+=.125;}return vec3(.93,.94,.85);}void main(){vec2 i=-1.+2.*gl_FragCoord.xy/v.xy;gl_FragColor=vec4(m(vec3(sin(s*1.5)*.5,cos(s)*.5,s),normalize(vec3(i.xy,1))),1);}
diff --git a/tests/real/controllable-machinery.frag b/tests/real/controllable-machinery.frag
new file mode 100644
index 00000000..1f38e68e
--- /dev/null
+++ b/tests/real/controllable-machinery.frag
@@ -0,0 +1,543 @@
+// Copied from https://www.shadertoy.com/view/fsXyDj
+// "Controllable Machinery" by dr2 - 2022
+// License: Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
+
+// (Extension of "Machinery"; control widget in world space - as in "Maze Ball Solved 2")
+
+#define AA 0 // (= 0/1) optional antialiasing
+
+#if 0
+#define VAR_ZERO min (iFrame, 0)
+#else
+#define VAR_ZERO 0
+#endif
+
+float PrBoxDf (vec3 p, vec3 b);
+float PrRoundBoxDf (vec3 p, vec3 b, float r);
+float PrCylDf (vec3 p, float r, float h);
+float PrRoundCylDf (vec3 p, float r, float rt, float h);
+float PrCaps2Df (vec2 p, float r, float h);
+float Minv3 (vec3 p);
+float Maxv3 (vec3 p);
+float Minv2 (vec2 p);
+float Maxv2 (vec2 p);
+float SmoothMax (float a, float b, float r);
+float SmoothBump (float lo, float hi, float w, float x);
+vec2 Rot2D (vec2 q, float a);
+mat3 StdVuMat (float el, float az);
+vec3 HsvToRgb (vec3 c);
+vec4 Loadv4 (int idVar);
+
+vec4 wgObj;
+vec3 ltDir, vnBlk;
+vec2 qBlk;
+float dstFar, tCur, tMov, angRot, bEdge, tCyc, cnPos, hitBlk;
+int idObj;
+const int idGr = 1, idPln = 2, idConv = 3, idSup = 4, idAx = 5, idBas = 6,
+ idWhl = 7, idSpl = 8, idCon = 9, idBlk = 10;
+const float pi = 3.1415927;
+const float nBlk = 13.;
+
+#define DMIN(id) if (d < dMin) { dMin = d; idObj = id; }
+
+float GearWlDf (vec3 p, float rad, float wlThk, float tWid, float nt, float aRot,
+ bool bev, float dMin)
+{
+ vec3 q;
+ float d, s;
+ q = p;
+ d = max (length (q.xy) - rad, abs (q.z) - wlThk);
+ if (d < dMin) {
+ q.xy = Rot2D (q.xy, aRot);
+ q.xy = Rot2D (q.xy, floor (nt * atan (q.y, - q.x) / (2. * pi) + 0.5) * 2. * pi / nt);
+ if (bev) q.xy *= 1.2 - 0.2 * q.z / wlThk;
+ s = q.x - 2. * clamp (1.5 * tWid + 0.5 * q.x * step (0., q.x) - abs (q.y), 0., tWid);
+ d = max (d, - rad - 0.95 * s);
+ }
+ return min (dMin, d);
+}
+
+vec4 BPos (float t)
+{
+ vec3 p;
+ float a;
+ t = mod (t, tCyc);
+ if (t < 5.) {
+ a = 0.;
+ p = vec3 (-1.018 + 2.118 * t / 5., bEdge, 0.);
+ } else if (t < 10.) {
+ a = 0.5 * pi * (t - 5.) / 5.;
+ p = vec3 (1.1, bEdge + 1. * sin (a), 1. - 1. * cos (a));
+ } else if ( t < 15.) {
+ a = 0.5 * pi;
+ p = vec3 (1.1 - 2.118 * (t - 10.) / 5., 1. + bEdge, 1.);
+ } else if (t < 17.5) {
+ a = 0.5 * pi;
+ p = vec3 (-1.018, 1. + bEdge, 1. - 1. * (t - 15.) / 2.5);
+ } else {
+ t -= 17.5;
+ a = -0.5 * pi * t;
+ p = vec3 (-1.018, 1. + bEdge - t * t, 0.);
+ }
+ return vec4 (p, a);
+}
+
+float GearDf (vec3 p)
+{
+ vec3 q;
+ float dMin, wlThk, tWid, nt, rad, gRat;
+ dMin = dstFar / 0.3;
+ gRat = 2.;
+ rad = 0.3;
+ wlThk = rad / 7.;
+ tWid = rad / 10.;
+ nt = 20.;
+ q = p - vec3 (-1.05, -0.21, 1.3);
+ dMin = GearWlDf (- q, rad, wlThk, tWid, nt, angRot * gRat, true, dMin);
+ dMin = GearWlDf ((q - vec3 (0.85 * rad, 0., 0.85 * rad)).yzx,
+ rad, wlThk, tWid, nt, angRot * gRat + pi / nt, true, dMin);
+ rad = 0.43;
+ wlThk = rad / 15.;
+ tWid = rad / 16.;
+ nt = 32.;
+ q = p -vec3 (0.1, 0., 1.);
+ dMin = GearWlDf ((q - vec3 (0., bEdge, 0.)).yzx, rad, wlThk, tWid, nt,
+ - angRot - 0.3 * pi / nt, false, dMin);
+ dMin = GearWlDf (- (q - vec3 (0., -0.21, 0.555)).zyx, rad / gRat, wlThk, tWid,
+ nt / gRat, - angRot * gRat, false, dMin);
+ rad = 0.32;
+ wlThk = rad / 15.;
+ tWid = rad / 12.;
+ nt = 24.;
+ q = p - vec3 (-1.05, -0.21, 0.6);
+ dMin = GearWlDf ((q - vec3 (0., 0., 0.1)), rad, wlThk, tWid, nt,
+ angRot * gRat + pi / nt, false, dMin);
+ dMin = GearWlDf ((q - vec3 (0., -0.47, 0.1)), rad / gRat, wlThk, tWid, nt / gRat,
+ - angRot * gRat * gRat, false, dMin);
+ dMin = GearWlDf ((q - vec3 (0., -0.47, -0.1)), rad, wlThk, tWid, nt,
+ - angRot * gRat * gRat - pi / nt, false, dMin);
+ dMin = GearWlDf ((q - vec3 (0., 0., -0.1)), rad / gRat, wlThk, tWid, nt / gRat,
+ angRot * gRat * gRat * gRat, false, dMin);
+ return dMin * 0.3;
+}
+
+float ObjDf (vec3 p)
+{
+ vec4 a4;
+ vec3 q, bPos;
+ float dMin, d, r, a;
+ dMin = dstFar;
+ q = p - vec3 (1.13 + bEdge, bEdge, 1.);
+ r = length (q.yz);
+ q.yz = Rot2D (q.yz, - angRot);
+ a = (r > 0.) ? atan (q.z, - q.y) / (2. * pi) : 0.;
+ q.yz = Rot2D (q.yz, 2. * pi * (floor (8. * a + 0.5)) / 8.);
+ q.z = abs (q.z);
+ d = SmoothMax (min (min (abs (r - 1.01) - 0.1, r - 0.3),
+ max (r - 1., dot (q.yz, vec2 (sin (0.8 * 2. * pi / 32.),
+ cos (0.8 * 2. * pi / 32.))))), abs (q.x) - 0.02, 0.01);
+ DMIN (idWhl);
+ d = min (PrBoxDf (p - vec3 (0., 0.98, 1.), vec3 (1.12, 0.02, 0.1)),
+ PrBoxDf (p - vec3 (-1.018, 0.98, 0.5), vec3 (0.1, 0.02, 0.5 - bEdge)));
+ DMIN (idPln);
+ d = SmoothMax (abs (PrCaps2Df ((p - vec3 (-0.05, -0.21, 0.)).yx, 0.2, 1.)) - 0.01,
+ abs (p.z) - 0.1, 0.02);
+ DMIN (idConv);
+ q = p - vec3 (-0.05, -0.21, 0.);
+ q.x = abs (q.x) - 1.;
+ d = PrRoundCylDf (q, 0.18, 0.01, 0.11);
+ DMIN (idSpl);
+ q = p - vec3 (0.65, -0.14, 1.);
+ q.x = abs (q.x) - 0.3;
+ d = PrRoundBoxDf (q, vec3 (0.01, 1.08, 0.06), 0.02);
+ q = p - vec3 (-0.05, -0.68, 0.);
+ q.xz = abs (q.xz) - vec2 (1., 0.2);
+ d = min (d, PrRoundBoxDf (q, vec3 (0.04, 0.55, 0.01), 0.02));
+ q = p - vec3 (-1.05, -0.14, 1.);
+ d = min (d, PrRoundBoxDf (q, vec3 (0.04, 1.08, 0.01), 0.02));
+ q = p - vec3 (-1.05, -0.68, 0.6);
+ q.z = abs (q.z) - 0.2;
+ d = min (d, PrRoundBoxDf (q, vec3 (0.04, 0.55, 0.01), 0.02));
+ q = p - vec3 (-0.33, -0.68, 1.555);
+ q.x = abs (q.x) - 0.3;
+ d = min (d, PrRoundBoxDf (q, vec3 (0.01, 0.55, 0.04), 0.02));
+ DMIN (idSup);
+ q = p - vec3 (0.65, bEdge, 1.);
+ d = PrCylDf (q.yzx, 0.04, 0.62);
+ q = p - vec3 (-0.36, -0.21, 1.555);
+ d = min (d, PrCylDf (q.yzx, 0.03, 0.51));
+ q = p - vec3 (-0.05, -0.21, 0.);
+ q.x -= 1.;
+ d = min (d, PrCylDf (q, 0.03, 0.27));
+ q.xz -= vec2 (-2., 0.14);
+ d = min (d, PrCylDf (q, 0.03, 0.4));
+ q.z -= 0.87;
+ d = min (d, PrCylDf (q, 0.03, 0.36));
+ q = p - vec3 (-1.05, -0.68, 0.6);
+ d = min (d, PrCylDf (q, 0.03, 0.25));
+ DMIN (idAx);
+ q = p - vec3 (0., -1.2, 0.9);
+ d = PrRoundBoxDf (q, vec3 (1.7, 0.03, 1.5), 0.02);
+ DMIN (idBas);
+ q = p - wgObj.xyz;
+ d = PrRoundCylDf (q.xzy, wgObj.w, 0.02, 0.02);
+ DMIN (idCon);
+ return dMin;
+}
+
+float ObjRay (vec3 ro, vec3 rd)
+{
+ float dHit, d;
+ dHit = 0.;
+ for (int j = VAR_ZERO; j < 150; j ++) {
+ d = ObjDf (ro + dHit * rd);
+ dHit += d;
+ if (d < 0.0005 || dHit > dstFar) break;
+ }
+ return dHit;
+}
+
+float GearRay (vec3 ro, vec3 rd)
+{
+ float dHit, d;
+ dHit = 0.;
+ for (int j = VAR_ZERO; j < 250; j ++) {
+ d = GearDf (ro + dHit * rd);
+ dHit += d;
+ if (d < 0.0005 || dHit > dstFar) break;
+ }
+ return dHit;
+}
+
+vec3 GearNf (vec3 p)
+{
+ vec4 v;
+ vec2 e;
+ e = vec2 (0.0005, -0.0005);
+ for (int j = VAR_ZERO; j < 4; j ++) {
+ v[j] = GearDf (p + ((j < 2) ? ((j == 0) ? e.xxx : e.xyy) : ((j == 2) ? e.yxy : e.yyx)));
+ }
+ v.x = - v.x;
+ return normalize (2. * v.yzw - dot (v, vec4 (1.)));
+}
+
+vec3 ObjNf (vec3 p)
+{
+ vec4 v;
+ vec2 e;
+ e = vec2 (0.0005, -0.0005);
+ for (int j = VAR_ZERO; j < 4; j ++) {
+ v[j] = ObjDf (p + ((j < 2) ? ((j == 0) ? e.xxx : e.xyy) : ((j == 2) ? e.yxy : e.yyx)));
+ }
+ v.x = - v.x;
+ return normalize (2. * v.yzw - dot (v, vec4 (1.)));
+}
+
+float BlkHit (vec3 ro, vec3 rd)
+{
+ vec4 a4;
+ vec3 rm, rdm, u, v, tm, tp;
+ float dMin, dn, df;
+ dMin = dstFar;
+ for (float k = float (VAR_ZERO); k < nBlk; k ++) {
+ a4 = BPos (tMov + tCyc * k / nBlk);
+ rm = ro - a4.xyz;
+ rdm = rd;
+ rm.zy = Rot2D (rm.zy, a4.w);
+ rdm.zy = Rot2D (rdm.zy, a4.w);
+ v = rm / rdm;
+ tp = bEdge / abs (rdm) - v;
+ tm = - tp - 2. * v;
+ dn = Maxv3 (tm);
+ df = Minv3 (tp);
+ if (df > 0. && dn < min (df, dMin)) {
+ dMin = dn;
+ hitBlk = k;
+ vnBlk = - sign (rdm) * step (tm.zxy, tm) * step (tm.yzx, tm);
+ u = (v + dn) * rdm;
+ qBlk = vec2 (dot (u.zxy, vnBlk), dot (u.yzx, vnBlk));
+ vnBlk.zy = Rot2D (vnBlk.zy, - a4.w);
+ }
+ }
+ return dMin;
+}
+
+float BlkHitSh (vec3 ro, vec3 rd, float rng)
+{
+ vec4 a4;
+ vec3 rm, rdm, v, tm, tp;
+ float dMin, dn, df;
+ dMin = dstFar;
+ for (float k = float (VAR_ZERO); k < nBlk; k ++) {
+ a4 = BPos (tMov + tCyc * k / nBlk);
+ rm = ro - a4.xyz;
+ rdm = rd;
+ rm.zy = Rot2D (rm.zy, a4.w);
+ rdm.zy = Rot2D (rdm.zy, a4.w);
+ v = rm / rdm;
+ tp = bEdge / abs (rdm) - v;
+ tm = - tp - 2. * v;
+ dn = Maxv3 (tm);
+ df = Minv3 (tp);
+ if (df > 0. && dn < min (df, dMin)) dMin = dn;
+ }
+ return smoothstep (0., rng, dMin);
+}
+
+float ObjSShadow (vec3 ro, vec3 rd)
+{
+ float sh, d, h;
+ sh = 1.;
+ d = 0.02;
+ for (int j = VAR_ZERO; j < 30; j ++) {
+ h = ObjDf (ro + rd * d);
+ sh = min (sh, smoothstep (0., 0.05 * d, h));
+ d += h;
+ if (sh < 0.05) break;
+ }
+ return sh;
+}
+
+float GearSShadow (vec3 ro, vec3 rd)
+{
+ float sh, d, h;
+ sh = 1.;
+ d = 0.02;
+ for (int j = VAR_ZERO; j < 30; j ++) {
+ h = GearDf (ro + rd * d);
+ sh = min (sh, smoothstep (0., 0.05 * d, h));
+ d += h;
+ if (sh < 0.05) break;
+ }
+ return sh;
+}
+
+vec3 ShowScene (vec3 ro, vec3 rd)
+{
+ vec4 col4;
+ vec3 vn, col, q;
+ float dstObj, dstGear, dstBlk, sh, s, r, a, nDotL;
+ int idObjT;
+ bool isMet;
+ tCyc = 18.5;
+ bEdge = 0.08;
+ isMet = false;
+ angRot = 0.1 * pi * tMov;
+ dstObj = ObjRay (ro, rd);
+ idObjT = idObj;
+ dstGear = GearRay (ro, rd);
+ if (dstGear < min (dstObj, dstFar)) {
+ dstObj = dstGear;
+ idObj = idGr;
+ } else idObj = idObjT;
+ dstBlk = BlkHit (ro, rd);
+ if (min (dstBlk, dstObj) < dstFar) {
+ if (dstBlk < dstObj) {
+ dstObj = dstBlk;
+ ro += dstObj * rd;
+ idObj = idBlk;
+ vn = vnBlk;
+ col4 = vec4 (HsvToRgb (vec3 (hitBlk / nBlk, 1., 1.)), 0.2) *
+ (1. - 0.4 * step (0.8 * bEdge, Maxv2 (abs (qBlk))));
+ } else {
+ ro += dstObj * rd;
+ vn = (idObj == idGr) ? GearNf (ro) : ObjNf (ro);
+ if (idObj == idWhl) {
+ col4 = vec4 (0.9, 0.7, 0.3, 0.2);
+ q = ro - vec3 (1.1 + bEdge + 0.03, bEdge, 1.);
+ r = length (q.yz);
+ q.yz = Rot2D (q.yz, - angRot);
+ a = fract (64. * atan (q.z, - q.y) / (2. * pi) + 0.5);
+ if (r > 0.99) vn.yz = Rot2D (vn.yz, - sin (a - 0.5));
+ if (r > 0.92) col4 *= 0.7 + 0.3 * SmoothBump (0.05, 0.95, 0.01, a);
+ isMet = true;
+ } else if (idObj == idGr) {
+ col4 = vec4 (0.9, 0.8, 0.4, 0.2);
+ isMet = true;
+ } else if (idObj == idSpl) {
+ col4 = vec4 (0.8, 0.8, 0.85, 0.2) * (1. - 0.4 * step (abs (ro.z), 0.1));
+ isMet = true;
+ } else if (idObj == idAx) {
+ col4 = vec4 (0.8, 0.8, 0.85, 0.2);
+ isMet = true;
+ } else if (idObj == idPln) {
+ col4 = (abs (vn.y) > 0.99) ? vec4 (0.5, 0.6, 0.2, 0.05) : vec4 (0.7, 0.5, 0.4, 0.1);
+ } else if (idObj == idConv) {
+ q = ro - vec3 (-0.05, -0.21, 0.);
+ col4 = vec4 (0.8, 0.8, 0.4, 0.);
+ if (sign (vn.y) != sign (q.y)) {
+ if (abs (q.x) < 1. && abs (vn.y) > 0.5) col4 *= 1. - 0.1 * SmoothBump (0.45, 0.55, 0.03,
+ fract (10. * (q.x - sign (q.y) * mod (tMov, 20.) * 2.1 / 5.)));
+ } else col4 *= 0.8 + 0.2 * smoothstep (0., 0.01, abs (abs (q.z) - 0.07));
+ } else if (idObj == idSup) {
+ col4 = vec4 (0.7, 0.5, 0.4, 0.1);
+ isMet = true;
+ } else if (idObj == idBas) {
+ q = ro;
+ q.z -= 0.9;
+ if (Maxv2 (abs (q.xz) - vec2 (1.65, 1.45)) > 0.) {
+ col4 = vec4 (0.9, 0.9, 0.9, 0.2);
+ isMet = true;
+ } else {
+ col4 = vec4 (0.3, 0.5, 0.4, 0.);
+ }
+ col4 *= (0.5 + 0.5 * step (0., Maxv2 (abs (vec2 (q.x, q.z + 1.3)) - vec2 (0.4, 0.02)))) *
+ (0.7 + 0.3 * step (0., abs (PrCaps2Df (vec2 (q.z + 1.3, q.x), 0.08, 0.5)) - 0.01));
+ } else if (idObj == idCon) {
+ col4 = vec4 (0., 1., 1., 0.2);
+ if (length (ro.xz - wgObj.xz) < 0.6 * wgObj.w)
+ col4 = mix (0.8 * col4, vec4 (1., 0., 1., 0.2), step (0., sin (2. * pi * tCur)));
+ }
+ }
+ sh = min (ObjSShadow (ro, ltDir), GearSShadow (ro, ltDir));
+ sh = 0.6 + 0.4 * min (sh, BlkHitSh (ro + 0.01 * ltDir, ltDir, 6.));
+ nDotL = max (dot (vn, ltDir), 0.);
+ if (isMet) nDotL *= nDotL;
+ col = col4.rgb * (0.1 + 0.1 * max (- dot (vn, ltDir), 0.) + 0.9 * sh * nDotL) +
+ col4.a * step (0.95, sh) * sh * pow (max (0., dot (ltDir, reflect (rd, vn))), 32.);
+ if (isMet) {
+ rd = reflect (rd, vn);
+ col = mix (col, vec3 (1.), 0.01 * step (0.1, Minv2 (fract (8. * vec2 (atan (rd.z, rd.x),
+ 2. * asin (rd.y)) + 0.5) - 0.5)));
+ }
+ } else col = vec3 (0., 0., 0.1) * (1. + 0.9 * rd.y);
+ return clamp (col, 0., 1.);
+}
+
+void mainImage (out vec4 fragColor, in vec2 fragCoord)
+{
+ mat3 vuMat;
+ vec4 stDat;
+ vec3 ro, rd, col;
+ vec2 canvas, uv;
+ float el, az, zmFac, sr;
+ canvas = iResolution.xy;
+ uv = 2. * fragCoord.xy / canvas - 1.;
+ uv.x *= canvas.x / canvas.y;
+ tCur = iTime;
+ dstFar = 30.;
+ stDat = Loadv4 (0);
+ tMov = stDat.x;
+ cnPos = stDat.y;
+ wgObj = vec4 (cnPos - 0.5, -1.12, -0.4, 0.08);
+ stDat = Loadv4 (1);
+ az = stDat.x;
+ el = stDat.y;
+ vuMat = StdVuMat (el, az);
+ zmFac = 4.;
+ ro = vuMat * vec3 (0., 0., -8.);
+ ro.z += 0.9;
+ rd = vuMat * normalize (vec3 (uv, zmFac));
+ ltDir = vuMat * normalize (vec3 (-0.5, 1., -1.));
+#if ! AA
+ const float naa = 1.;
+#else
+ const float naa = 3.;
+#endif
+ col = vec3 (0.);
+ sr = 2. * mod (dot (mod (floor (0.5 * (uv + 1.) * canvas), 2.), vec2 (1.)), 2.) - 1.;
+ for (float a = float (VAR_ZERO); a < naa; a ++) {
+ rd = vuMat * normalize (vec3 (uv + step (1.5, naa) * Rot2D (vec2 (0.5 / canvas.y, 0.),
+ sr * (0.667 * a + 0.5) * pi), zmFac));
+ col += (1. / naa) * ShowScene (ro, rd);
+ }
+ fragColor = vec4 (col, 1.);
+}
+
+float PrBoxDf (vec3 p, vec3 b)
+{
+ vec3 d;
+ d = abs (p) - b;
+ return min (max (d.x, max (d.y, d.z)), 0.) + length (max (d, 0.));
+}
+
+float PrRoundBoxDf (vec3 p, vec3 b, float r)
+{
+ return length (max (abs (p) - b, 0.)) - r;
+}
+
+float PrCylDf (vec3 p, float r, float h)
+{
+ return max (length (p.xy) - r, abs (p.z) - h);
+}
+
+float PrRoundCylDf (vec3 p, float r, float rt, float h)
+{
+ return length (max (vec2 (length (p.xy) - r, abs (p.z) - h), 0.)) - rt;
+}
+
+float PrCaps2Df (vec2 p, float r, float h)
+{
+ return length (p - vec2 (0., clamp (p.y, - h, h))) - r;
+}
+
+float Minv3 (vec3 p)
+{
+ return min (p.x, min (p.y, p.z));
+}
+
+float Maxv3 (vec3 p)
+{
+ return max (p.x, max (p.y, p.z));
+}
+
+float Minv2 (vec2 p)
+{
+ return min (p.x, p.y);
+}
+
+float Maxv2 (vec2 p)
+{
+ return max (p.x, p.y);
+}
+
+float SmoothMin (float a, float b, float r)
+{
+ float h;
+ h = clamp (0.5 + 0.5 * (b - a) / r, 0., 1.);
+ return mix (b - h * r, a, h);
+}
+
+float SmoothMax (float a, float b, float r)
+{
+ return - SmoothMin (- a, - b, r);
+}
+
+float SmoothBump (float lo, float hi, float w, float x)
+{
+ return (1. - smoothstep (hi - w, hi + w, x)) * smoothstep (lo - w, lo + w, x);
+}
+
+mat3 StdVuMat (float el, float az)
+{
+ vec2 ori, ca, sa;
+ ori = vec2 (el, az);
+ ca = cos (ori);
+ sa = sin (ori);
+ return mat3 (ca.y, 0., - sa.y, 0., 1., 0., sa.y, 0., ca.y) *
+ mat3 (1., 0., 0., 0., ca.x, - sa.x, 0., sa.x, ca.x);
+}
+
+vec2 Rot2D (vec2 q, float a)
+{
+ vec2 cs;
+ cs = sin (a + vec2 (0.5 * pi, 0.));
+ return vec2 (dot (q, vec2 (cs.x, - cs.y)), dot (q.yx, cs));
+}
+
+vec3 HsvToRgb (vec3 c)
+{
+ return c.z * mix (vec3 (1.), clamp (abs (fract (c.xxx + vec3 (1., 2./3., 1./3.)) * 6. - 3.) - 1., 0., 1.), c.y);
+}
+
+#define txBuf iChannel0
+#define txSize iChannelResolution[0].xy
+
+const float txRow = 128.;
+
+vec4 Loadv4 (int idVar)
+{
+ float fi;
+ fi = float (idVar);
+ return texture (txBuf, (vec2 (mod (fi, txRow), floor (fi / txRow)) + 0.5) / txSize);
+}
diff --git a/tests/real/controllable-machinery.frag.expected b/tests/real/controllable-machinery.frag.expected
new file mode 100644
index 00000000..54d36f5b
--- /dev/null
+++ b/tests/real/controllable-machinery.frag.expected
@@ -0,0 +1,502 @@
+#define AA 0
+
+#if 0
+
+#define VAR_ZERO min (iFrame,0)
+
+#else
+
+#define VAR_ZERO 0
+
+#endif
+
+vec4 wgObj;
+vec3 ltDir,vnBlk;
+vec2 qBlk;
+float dstFar,tCur,tMov,angRot,bEdge,tCyc,cnPos,hitBlk;
+int idObj;
+
+#define DMIN(id)if (d0.?
+ atan(q.z,-q.y)/6.2831854:
+ 0.;
+ q.yz=Rot2D(q.yz,6.2831854*floor(8.*a+.5)/8.);
+ q.z=abs(q.z);
+ d=SmoothMax(min(min(abs(r-1.01)-.1,r-.3),max(r-1.,dot(q.yz,vec2(sin(.157079635),cos(.157079635))))),abs(q.x)-.02,.01);
+ DMIN(7);
+ d=min(PrBoxDf(p-vec3(0,.98,1),vec3(1.12,.02,.1)),PrBoxDf(p-vec3(-1.018,.98,.5),vec3(.1,.02,.5-bEdge)));
+ DMIN(2);
+ d=SmoothMax(abs(PrCaps2Df((p-vec3(-.05,-.21,0)).yx,.2,1.))-.01,abs(p.z)-.1,.02);
+ DMIN(3);
+ q=p-vec3(-.05,-.21,0);
+ q.x=abs(q.x)-1.;
+ d=PrRoundCylDf(q,.18,.01,.11);
+ DMIN(8);
+ q=p-vec3(.65,-.14,1);
+ q.x=abs(q.x)-.3;
+ d=PrRoundBoxDf(q,vec3(.01,1.08,.06),.02);
+ q=p-vec3(-.05,-.68,0);
+ q.xz=abs(q.xz)-vec2(1,.2);
+ d=min(d,PrRoundBoxDf(q,vec3(.04,.55,.01),.02));
+ q=p-vec3(-1.05,-.14,1);
+ d=min(d,PrRoundBoxDf(q,vec3(.04,1.08,.01),.02));
+ q=p-vec3(-1.05,-.68,.6);
+ q.z=abs(q.z)-.2;
+ d=min(d,PrRoundBoxDf(q,vec3(.04,.55,.01),.02));
+ q=p-vec3(-.33,-.68,1.555);
+ q.x=abs(q.x)-.3;
+ d=min(d,PrRoundBoxDf(q,vec3(.01,.55,.04),.02));
+ DMIN(4);
+ q=p-vec3(.65,bEdge,1);
+ d=PrCylDf(q.yzx,.04,.62);
+ q=p-vec3(-.36,-.21,1.555);
+ d=min(d,PrCylDf(q.yzx,.03,.51));
+ q=p-vec3(-.05,-.21,0);
+ q.x-=1.;
+ d=min(d,PrCylDf(q,.03,.27));
+ q.xz-=vec2(-2,.14);
+ d=min(d,PrCylDf(q,.03,.4));
+ q.z-=.87;
+ d=min(d,PrCylDf(q,.03,.36));
+ q=p-vec3(-1.05,-.68,.6);
+ d=min(d,PrCylDf(q,.03,.25));
+ DMIN(5);
+ q=p-vec3(0,-1.2,.9);
+ d=PrRoundBoxDf(q,vec3(1.7,.03,1.5),.02);
+ DMIN(6);
+ q=p-wgObj.xyz;
+ d=PrRoundCylDf(q.xzy,wgObj.w,.02,.02);
+ DMIN(9);
+ return dMin;
+}
+float ObjRay(vec3 ro,vec3 rd)
+{
+ float dHit,d;
+ dHit=0.;
+ for(int j=VAR_ZERO;j<150;j++)
+ {
+ d=ObjDf(ro+dHit*rd);
+ dHit+=d;
+ if(d<5e-4||dHit>dstFar)
+ break;
+ }
+ return dHit;
+}
+float GearRay(vec3 ro,vec3 rd)
+{
+ float dHit,d;
+ dHit=0.;
+ for(int j=VAR_ZERO;j<250;j++)
+ {
+ d=GearDf(ro+dHit*rd);
+ dHit+=d;
+ if(d<5e-4||dHit>dstFar)
+ break;
+ }
+ return dHit;
+}
+vec3 GearNf(vec3 p)
+{
+ vec4 v;
+ vec2 e;
+ e=vec2(5e-4,-5e-4);
+ for(int j=VAR_ZERO;j<4;j++)
+ v[j]=GearDf(p+(j<2?
+ j==0?
+ e.xxx:
+ e.xyy:
+ j==2?
+ e.yxy:
+ e.yyx));
+ v.x=-v.x;
+ return normalize(2.*v.yzw-dot(v,vec4(1)));
+}
+vec3 ObjNf(vec3 p)
+{
+ vec4 v;
+ vec2 e;
+ e=vec2(5e-4,-5e-4);
+ for(int j=VAR_ZERO;j<4;j++)
+ v[j]=ObjDf(p+(j<2?
+ j==0?
+ e.xxx:
+ e.xyy:
+ j==2?
+ e.yxy:
+ e.yyx));
+ v.x=-v.x;
+ return normalize(2.*v.yzw-dot(v,vec4(1)));
+}
+float BlkHit(vec3 ro,vec3 rd)
+{
+ vec4 a4;
+ vec3 rm,rdm,u,v,tm,tp;
+ float dMin,dn,df;
+ dMin=dstFar;
+ for(float k=float(VAR_ZERO);k<13.;k++)
+ {
+ a4=BPos(tMov+tCyc*k/13.);
+ rm=ro-a4.xyz;
+ rdm=rd;
+ rm.zy=Rot2D(rm.zy,a4.w);
+ rdm.zy=Rot2D(rdm.zy,a4.w);
+ v=rm/rdm;
+ tp=bEdge/abs(rdm)-v;
+ tm=-tp-2.*v;
+ dn=Maxv3(tm);
+ df=Minv3(tp);
+ if(df>0.&&dn0.&&dn.99)
+ vn.yz=Rot2D(vn.yz,-sin(a-.5));
+ if(r>.92)
+ col4*=.7+.3*SmoothBump(.05,.95,.01,a);
+ isMet=true;
+ }
+ else
+ if(idObj==1)
+ col4=vec4(.9,.8,.4,.2),isMet=true;
+ else
+ if(idObj==8)
+ col4=vec4(.8,.8,.85,.2)*(1.-.4*step(abs(ro.z),.1)),isMet=true;
+ else
+ if(idObj==5)
+ col4=vec4(.8,.8,.85,.2),isMet=true;
+ else
+ if(idObj==2)
+ col4=abs(vn.y)>.99?
+ vec4(.5,.6,.2,.05):
+ vec4(.7,.5,.4,.1);
+ else
+ if(idObj==3)
+ {
+ q=ro-vec3(-.05,-.21,0);
+ col4=vec4(.8,.8,.4,0);
+ if(sign(vn.y)!=sign(q.y))
+ {
+ if(abs(q.x)<1.&&abs(vn.y)>.5)
+ col4*=1.-.1*SmoothBump(.45,.55,.03,fract(10.*(q.x-sign(q.y)*mod(tMov,20.)*2.1/5.)));
+ }
+ else
+ col4*=.8+.2*smoothstep(0.,.01,abs(abs(q.z)-.07));
+ }
+ else
+ if(idObj==4)
+ col4=vec4(.7,.5,.4,.1),isMet=true;
+ else
+ if(idObj==6)
+ {
+ q=ro;
+ q.z-=.9;
+ if(Maxv2(abs(q.xz)-vec2(1.65,1.45))>0.)
+ col4=vec4(.9,.9,.9,.2),isMet=true;
+ else
+ col4=vec4(.3,.5,.4,0);
+ col4*=(.5+.5*step(0.,Maxv2(abs(vec2(q.x,q.z+1.3))-vec2(.4,.02))))*(.7+.3*step(0.,abs(PrCaps2Df(vec2(q.z+1.3,q.x),.08,.5))-.01));
+ }
+ else
+ if(idObj==9)
+ {
+ col4=vec4(0,1,1,.2);
+ if(length(ro.xz-wgObj.xz)<.6*wgObj.w)
+ col4=mix(.8*col4,vec4(1,0,1,.2),step(0.,sin(6.2831854*tCur)));
+ }
+ }
+ sh=min(ObjSShadow(ro,ltDir),GearSShadow(ro,ltDir));
+ sh=.6+.4*min(sh,BlkHitSh(ro+.01*ltDir,ltDir,6.));
+ nDotL=max(dot(vn,ltDir),0.);
+ if(isMet)
+ nDotL*=nDotL;
+ col=col4.xyz*(.1+.1*max(-dot(vn,ltDir),0.)+.9*sh*nDotL)+col4.w*step(.95,sh)*sh*pow(max(0.,dot(ltDir,reflect(rd,vn))),32.);
+ if(isMet)
+ rd=reflect(rd,vn),col=mix(col,vec3(1),.01*step(.1,Minv2(fract(8.*vec2(atan(rd.z,rd.x),2.*asin(rd.y))+.5)-.5)));
+ }
+ else
+ col=vec3(0,0,.1)*(1.+.9*rd.y);
+ return clamp(col,0.,1.);
+}
+vec4 Loadv4(int idVar)
+{
+ float fi;
+ fi=float(idVar);
+ return texture(txBuf,(vec2(mod(fi,128.),floor(fi/128.))+.5)/txSize);
+}
+void mainImage(out vec4 fragColor,vec2 fragCoord)
+{
+ mat3 vuMat;
+ vec4 stDat;
+ vec3 ro,rd,col;
+ vec2 canvas,uv;
+ float el,az,zmFac,sr;
+ canvas=iResolution.xy;
+ uv=2.*fragCoord.xy/canvas-1.;
+ uv.x*=canvas.x/canvas.y;
+ tCur=iTime;
+ dstFar=30.;
+ stDat=Loadv4(0);
+ tMov=stDat.x;
+ cnPos=stDat.y;
+ wgObj=vec4(cnPos-.5,-1.12,-.4,.08);
+ stDat=Loadv4(1);
+ az=stDat.x;
+ el=stDat.y;
+ vuMat=StdVuMat(el,az);
+ zmFac=4.;
+ ro=vuMat*vec3(0,0,-8);
+ ro.z+=.9;
+ rd=vuMat*normalize(vec3(uv,zmFac));
+ ltDir=vuMat*normalize(vec3(-.5,1,-1));
+
+#if!AA
+
+
+#else
+
+
+#endif
+
+ col=vec3(0);
+ sr=2.*mod(dot(mod(floor(.5*(uv+1.)*canvas),2.),vec2(1)),2.)-1.;
+ for(float a=float(VAR_ZERO);a<3.;a++)
+ rd=vuMat*normalize(vec3(uv+step(1.5,3.)*Rot2D(vec2(.5/canvas.y,0),sr*(.667*a+.5)*3.1415927),zmFac)),col+=1./3.*ShowScene(ro,rd);
+ fragColor=vec4(col,1);
+}
diff --git a/tests/real/disco.expected b/tests/real/disco.expected
index ec9da769..05c451ab 100644
--- a/tests/real/disco.expected
+++ b/tests/real/disco.expected
@@ -1,5 +1,9 @@
-/* File generated with
- * http://www.ctrl-alt-test.fr
- */
+// Generated with (https://github.com/laurentlb/Shader_Minifier/)
+var var_RESOLUTION = "s"
+var var_TEX0 = "f"
+var var_TEX1 = "C"
+var var_TEX2 = "D"
+var var_TEX3 = "y"
+var var_TIME = "v"
-var disco_frag = `uniform vec2 resolution;uniform float time;uniform sampler2D tex0,tex1,tex2,tex3;vec4 s(vec2 px,float z){float l=3.1415,k=time*sign(z),x=px.x*320.*.0065*z,y=px.y*240.*.006*z,c=sqrt(x*x+y*y);if(c>1.)return vec4(0);else{float u=-.4*sign(z)+sin(k*.05),v=sqrt(1.-x*x-y*y),q=y*sin(u)-v*cos(u);y=y*cos(u)+v*sin(u);v=acos(y);u=acos(x/sin(v))/(2.*l)*120.*sign(q)-k;v=v*60./l;q=cos(floor(v/l));c=pow(abs(cos(u)*sin(v)),.2)*.1/(q+sin(float(int((u+l/2.)/l))+k*.6+cos(q*25.)))*pow(1.-c,.9);vec4 res;if(c<0.)res=vec4(-c/2.*abs(cos(k*.1)),0,-c*2.*abs(sin(k*.04)),1);else res=vec4(c,c*2.,c*2.,1);return res;}}void main(){vec2 p=-1.+2.*gl_FragCoord.xy/resolution.xy;vec4 c=vec4(0),d;for(int i=80;i>0;i--)c+=s(p,1.-float(i)/80.)*(.008-float(i)*5e-5);d=s(p,1.);gl_FragColor=(d.w==0.?s(p,-.2)*.02:d)+sqrt(c);}`
+var disco_frag = `uniform vec2 s;uniform float v;uniform sampler2D f,C,D,y;vec4 n(vec2 s,float f){float c=3.1415,y=v*sign(f),a=s.x*320.*.0065*f,i=s.y*240.*.006*f,C=sqrt(a*a+i*i);if(C>1.)return vec4(0);{float r=-.4*sign(f)+sin(y*.05),n=sqrt(1.-a*a-i*i),u=i*sin(r)-n*cos(r);i=i*cos(r)+n*sin(r);n=acos(i);r=acos(a/sin(n))/(2.*c)*120.*sign(u)-y;n=n*60./c;u=cos(floor(n/c));C=pow(abs(cos(r)*sin(n)),.2)*.1/(u+sin(float(int((r+c/2.)/c))+y*.6+cos(u*25.)))*pow(1.-C,.9);vec4 g;g=C<0.?vec4(-C/2.*abs(cos(y*.1)),0,-C*2.*abs(sin(y*.04)),1):vec4(C,C*2.,C*2.,1);return g;}}void main(){vec2 f=-1.+2.*gl_FragCoord.xy/s.xy;vec4 r=vec4(0);for(int i=80;i>0;i--)r+=n(f,1.-float(i)/80.)*(.008-float(i)*5e-5);vec4 i=n(f,1.);gl_FragColor=(i.w==0.?n(f,-.2)*.02:i)+sqrt(r);}`
diff --git a/tests/real/ed-209.frag.expected b/tests/real/ed-209.frag.expected
index a777470d..198051ac 100644
--- a/tests/real/ed-209.frag.expected
+++ b/tests/real/ed-209.frag.expected
@@ -35,8 +35,12 @@ float sdTriPrism(vec3 p,vec2 h)
}
float sdCappedCone(vec3 p,vec3 a,vec3 b,float ra,float rb)
{
- float rba=rb-ra,baba=dot(b-a,b-a),papa=dot(p-a,p-a),paba=dot(p-a,b-a)/baba,x=sqrt(papa-paba*paba*baba),cax=max(0.,x-(paba<.5?ra:rb)),cay=abs(paba-.5)-.5,f=clamp((rba*(x-ra)+paba*baba)/(rba*rba+baba),0.,1.),cbx=x-ra-f*rba,cby=paba-f;
- return(cbx<0.&&cay<0.?-1.:1.)*sqrt(min(cax*cax+cay*cay*baba,cbx*cbx+cby*cby*baba));
+ float rba=rb-ra,baba=dot(b-a,b-a),papa=dot(p-a,p-a),paba=dot(p-a,b-a)/baba,x=sqrt(papa-paba*paba*baba),cax=max(0.,x-(paba<.5?
+ ra:
+ rb)),cay=abs(paba-.5)-.5,f=clamp((rba*(x-ra)+paba*baba)/(rba*rba+baba),0.,1.),cbx=x-ra-f*rba,cby=paba-f;
+ return(cbx<0.&&cay<0.?
+ -1.:
+ 1.)*sqrt(min(cax*cax+cay*cay*baba,cbx*cbx+cby*cby*baba));
}
float sdCappedCylinder(vec3 p,float h,float r)
{
@@ -65,9 +69,9 @@ vec3 getRayDir(vec3 ro,vec3 lookAt,vec2 uv)
}
MarchData minResult(MarchData a,MarchData b)
{
- if(a.d.5)
{
d=sdCappedCylinder(pp,.01+pp.z*.05,fract(fs*3322.423)*.5+.9);
if(d.5)"
+ "float2 x=f+.5/1280;"
+ "float4 y=tex2D(m,x);"
+ "float3 w=normalize(mul(z,float4(f.x*2-1,-f.y*2+1,1,1)));"
+ "float2 s=w.xz/w.y;"
+ "float c=(2*s.y+1000)%8;"
+ "float3 r=float3(.55,.65,.75)+.1*D(s+t[3].w*.2,10)+.5*pow(1-w.y,8)+pow(saturate(mul(w,t[3])),16)*float3(.4,.3,.1)+float4(1+.4*c,2,3+.5*c,0)*(1-cos(12.5664*s.y))*saturate(1-abs(s.y)/10-abs(s.x+t[5+c].x*.0012-8)/20)*exp(-t[5+c].x*2e-4);"
+ "if(y.w>.5)"
"{"
- "float p=length(s.xyz-t[4].xyz),d=t[1].w-s.y;"
+ "float p=length(y.xyz-t[4].xyz),d=t[1].w-y.y;"
"if(d<0)"
"{"
- "float3 e=D(s.xz,.001*p,12-log2(p));"
- "float o=D(3*s.xz,3),a=D(666*s.xz);"
+ "float3 e=D(y.xz,.001*p,12-log2(p));"
+ "float n=D(3*y.xz,3),a=D(666*y.xz);"
"r=(.1+.75*t[2].x)*(.8+.2*a);"
- "r=lerp(r,lerp(float3(.8,.85,.9),float3(.45,.45,.2)*(.8+.2*a),t[2].x),smoothstep(.5-.8*e.y,1-1.1*e.y,o*.15));"
- "r=lerp(r,lerp(float3(.37,.23,.08),float3(.42,.4,.2),t[2].x)*(.5+.5*a),smoothstep(0,1,50*(e.y-1)+(o+t[2].x)/.4));"
- "r*=l(s,e,D(s.xz,.001*p,5));"
+ "r=lerp(r,lerp(float3(.8,.85,.9),float3(.45,.45,.2)*(.8+.2*a),t[2].x),smoothstep(.5-.8*e.y,1-1.1*e.y,n*.15));"
+ "r=lerp(r,lerp(float3(.37,.23,.08),float3(.42,.4,.2),t[2].x)*(.5+.5*a),smoothstep(0,1,50*(e.y-1)+(n+t[2].x)/.4));"
+ "r*=l(y,e,D(y.xz,.001*p,5));"
"}"
"else"
"{"
"p=(t[1].w-t[4].y)/w.y;"
- "s=t[4]+w.xyzz*p;"
- "float3 e=normalize(D(float2(512,32)*s.xz+saturate(d*60)*float2(t[3].w,0),.001*p,4)*float3(1,6,1));"
+ "y=t[4]+w.xyzz*p;"
+ "float3 a=normalize(D(float2(512,32)*y.xz+saturate(d*60)*float2(t[3].w,0),.001*p,4)*float3(1,6,1));"
"r=.12*(float3(.4,1,1)-float3(.2,.6,.4)*saturate(d*16));"
"r*=.3+.7*t[2].x;"
- "r+=pow(1-mul(-w,e),4)*(pow(mul(t[3],reflect(-w,e)),32)*float3(.32,.31,.3)+.1);"
- "r=lerp(r,l(s,e,e),smoothstep(1,0,t[2].x+d*60-D(666*s.xz+saturate(d*60)*float2(t[3].w,0)*2,5))*.5);"
+ "r+=pow(1-mul(-w,a),4)*(pow(mul(t[3],reflect(-w,a)),32)*float3(.32,.31,.3)+.1);"
+ "r=lerp(r,l(y,a,a),smoothstep(1,0,t[2].x+d*60-D(666*y.xz+saturate(d*60)*float2(t[3].w,0)*2,5))*.5);"
"}"
"r*=.7+.3*smoothstep(0,1,256*abs(d));"
"r*=exp(-.042*p);"
@@ -110,15 +108,15 @@ const char *elevated_hlsl =
"float4 s(float2 x:texcoord):color"
"{"
"float2 s=x+.5/1280;"
- "float4 r=tex2D(y,s);"
- "float3 w=tex2D(z,s);"
+ "float4 r=tex2D(m,s);"
+ "float3 w=tex2D(y,s);"
"if(r.w>.5)"
"{"
- "r=mul(m,float4(r.xyz,1));"
+ "r=mul(z,float4(r.xyz,1));"
"r.y*=-1;"
"w=0;"
"for(float d=0;d<16;d++)"
- "w.x+=tex2D(z,s+d*(.5+.5*r.xy/r.w-s)/16+float2(2,0)/1280).x,w.y+=tex2D(z,s+d*(.5+.5*r.xy/r.w-s)/16+float2(0,0)/1280).y,w.z+=tex2D(z,s+d*(.5+.5*r.xy/r.w-s)/16+float2(-2,0)/1280).z;"
+ "w.x+=tex2D(y,s+d*(.5+.5*r.xy/r.w-s)/16+float2(2,0)/1280).x,w.y+=tex2D(y,s+d*(.5+.5*r.xy/r.w-s)/16+float2(0,0)/1280).y,w.z+=tex2D(y,s+d*(.5+.5*r.xy/r.w-s)/16+float2(-2,0)/1280).z;"
"w/=16;"
"}"
"w=pow(w,.45)*t[2].z+t[2].y;"
diff --git a/tests/real/endeavour.frag b/tests/real/endeavour.frag
new file mode 100644
index 00000000..deb1adee
--- /dev/null
+++ b/tests/real/endeavour.frag
@@ -0,0 +1,234 @@
+/*
+ * Copied from https://www.shadertoy.com/view/3d2XWt
+ * Endeavor by Team210 - 64k intro by Team210 at Revision 2k19
+ * Copyright (C) 2019 Alexander Kraus
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+// Global constants
+const float pi = acos(-1.);
+const vec3 c = vec3(1.0, 0.0, -1.0);
+float a = 1.0;
+
+// Hash function
+void rand(in vec2 x, out float num)
+{
+ x += 400.;
+ num = fract(sin(dot(sign(x)*abs(x) ,vec2(12.9898,78.233)))*43758.5453);
+}
+
+// Arbitrary-frequency 2D noise
+void lfnoise(in vec2 t, out float num)
+{
+ vec2 i = floor(t);
+ t = fract(t);
+ //t = ((6.*t-15.)*t+10.)*t*t*t; // TODO: add this for slower perlin noise
+ t = smoothstep(c.yy, c.xx, t); // TODO: add this for faster value noise
+ vec2 v1, v2;
+ rand(i, v1.x);
+ rand(i+c.xy, v1.y);
+ rand(i+c.yx, v2.x);
+ rand(i+c.xx, v2.y);
+ v1 = c.zz+2.*mix(v1, v2, t.y);
+ num = mix(v1.x, v1.y, t.x);
+}
+
+// Multi-frequency 2D noise
+void mfnoise(in vec2 x, in float fmin, in float fmax, in float alpha, out float num)
+{
+ num = 0.;
+ float a = 1., nf = 0., buf;
+ for(float f = fmin; f-.05)
+ {
+ float n2;
+ mfnoise(x.xy, 30., 500., .47, n2);
+ vec2 sda = vec2(x.z+.05+.01*n2, 1.);
+ add(sdf, sda, sdf);
+ }
+
+ float R = .07+.1*sdf.x, dis;
+ lfnoise(.5*x.y*c.xx, dis);
+ vec2 sdb;
+ vec2 ya = abs(x.xz-.4*dis*c.xy)+.045*c.yx - .065*c.xy;
+ zextrude(x.y, -length(ya)+R, 1.e4, sdb.x);
+ float da;
+ stroke(sdb.x, .003, da);
+ sdb.y = 2.;
+
+ vec2 ind;
+ float phi = atan(ya.y, ya.x);
+ dhexagonpattern(vec2(56.,12.)*vec2(x.y, phi), dis, ind);
+ stroke(dis, .2, dis);
+ stroke(sdb.x, .003*step(dis,0.), sdb.x);
+ sdf.x = max(sdf.x,-da);
+ add(sdf, sdb, sdf);
+
+ // Add guard objects for debugging
+ float dr = .1;
+ vec3 y = mod(x,dr)-.5*dr;
+ float guard = -length(max(abs(y)-vec3(.5*dr*c.xx, .6),0.));
+ guard = abs(guard)+dr*.1;
+ sdf.x = min(sdf.x, guard);
+}
+
+void normal(in vec3 x, out vec3 n)
+{
+ const float dx = 5.e-4;
+ vec2 s, na;
+
+ scene(x,s);
+ scene(x+dx*c.xyy, na);
+ n.x = na.x;
+ scene(x+dx*c.yxy, na);
+ n.y = na.x;
+ scene(x+dx*c.yyx, na);
+ n.z = na.x;
+ n = normalize(n-s.x);
+}
+
+void planet_texture(in vec2 x, out vec3 col)
+{
+ vec3 light_orange = vec3(1.00,0.69,0.05),
+ orange = vec3(0.95,0.45,0.01),
+ dark_orange = vec3(0.98,0.73,0.01);
+
+ //rock like appearance
+ float d;
+ mfnoise(x, 1.,400.,.65,d);
+ col = mix(vec3(0.19,0.02,0.00), vec3(0.91,0.45,0.02), .5+.5*d);
+
+ // big structures
+ stroke(d,.01, d);
+ col = mix(mix(.8*vec3(0.99,0.49,0.02),c.yyy,d*clamp(.2-.5*x.y/12.,0.,1.)), col, smoothstep(-.05,.05,d));
+ col = mix(col, vec3(0.15,0.05,0.00), clamp(.2-.5*x.y/12.,0.,1.));
+}
+
+void mainImage( out vec4 fragColor, in vec2 fragCoord )
+{
+ a = iResolution.x/iResolution.y;
+ vec2 uv = fragCoord/iResolution.yy-0.5*vec2(a, 1.0),
+ s;
+ vec3 col = c.yyy,
+ o = .5*c.yyx + .3*iTime*c.yxy,
+ t = vec3(uv,0.) + .3*iTime*c.yxy + c.yxy,
+ dir = normalize(t-o),
+ x;
+ float d = (.04-o.z)/dir.z;
+
+ int N = 450, i;
+ for(i=0; i-.05)
+ {
+ float n2;
+ mfnoise(x.xy,30.,5e2,.47,n2);
+ vec2 sda=vec2(x.z+.05+.01*n2,1);
+ add(sdf,sda,sdf);
+ }
+ float R=.07+.1*sdf.x,dis;
+ lfnoise(.5*x.y*c.xx,dis);
+ vec2 sdb,ya=abs(x.xz-.4*dis*c.xy)+.045*c.yx-.065*c.xy;
+ zextrude(x.y,-length(ya)+R,1e4,sdb.x);
+ float da;
+ stroke(sdb.x,.003,da);
+ sdb.y=2.;
+ vec2 ind;
+ float phi=atan(ya.y,ya.x);
+ dhexagonpattern(vec2(56,12)*vec2(x.y,phi),dis,ind);
+ stroke(dis,.2,dis);
+ stroke(sdb.x,.003*step(dis,0.),sdb.x);
+ sdf.x=max(sdf.x,-da);
+ add(sdf,sdb,sdf);
+ float dr=.1;
+ vec3 y=mod(x,dr)-.5*dr;
+ float guard=-length(max(abs(y)-vec3(.5*dr*c.xx,.6),0.));
+ guard=abs(guard)+dr*.1;
+ sdf.x=min(sdf.x,guard);
+}
+void normal(vec3 x,out vec3 n)
+{
+ vec2 s,na;
+ scene(x,s);
+ scene(x+5e-4*c.xyy,na);
+ n.x=na.x;
+ scene(x+5e-4*c.yxy,na);
+ n.y=na.x;
+ scene(x+5e-4*c.yyx,na);
+ n.z=na.x;
+ n=normalize(n-s.x);
+}
+void planet_texture(vec2 x,out vec3 col)
+{
+ float d;
+ mfnoise(x,1.,4e2,.65,d);
+ col=mix(vec3(.19,.02,0),vec3(.91,.45,.02),.5+.5*d);
+ stroke(d,.01,d);
+ col=mix(mix(.8*vec3(.99,.49,.02),c.yyy,d*clamp(.2-.5*x.y/12.,0.,1.)),col,smoothstep(-.05,.05,d));
+ col=mix(col,vec3(.15,.05,0),clamp(.2-.5*x.y/12.,0.,1.));
+}
+void mainImage(out vec4 fragColor,vec2 fragCoord)
+{
+ a=iResolution.x/iResolution.y;
+ vec2 uv=fragCoord/iResolution.yy-.5*vec2(a,1),s;
+ vec3 col=c.yyy,o=.5*c.yyx+.3*iTime*c.yxy,t=vec3(uv,0)+.3*iTime*c.yxy+c.yxy,dir=normalize(t-o),x;
+ float d=(.04-o.z)/dir.z;
+ int N=450,i;
+ for(i=0;i 1.0)
- {
- gl_FragColor = vec4(1.0,0.0,0.0,1.0);
-
- return;
- }
-
- vec3 n = getN(p);
- gl_FragColor = vec4(n, 1.0);
-}
diff --git a/tests/real/extatique/raymarch.vs b/tests/real/extatique/raymarch.vs
deleted file mode 100644
index 32080f06..00000000
--- a/tests/real/extatique/raymarch.vs
+++ /dev/null
@@ -1,9 +0,0 @@
-varying vec3 dir;
-
-void main()
-{
- vec4 pos = ftransform();
- gl_Position = pos;
- dir = pos.xyz;
-
-}
diff --git a/tests/real/extatique/scene30.frag b/tests/real/extatique/scene30.frag
deleted file mode 100644
index 53e8becc..00000000
--- a/tests/real/extatique/scene30.frag
+++ /dev/null
@@ -1,41 +0,0 @@
-uniform sampler2D tex;
-uniform float angle;
-uniform float time;
-varying vec3 pos;
-varying vec3 N;
-
-
-vec4 getEnvColor(vec3 p)
-{
- float az = atan(p.x, p.y + 0.01);
- float ax = -pos.z;
-
- vec4 sample = vec4(0.0);
-
- for (int i = 0; i < 8; ++i)
- {
- float fi = float(i);
- float s = ax * 2.0 / (1.0 + fi) + time * 0.01 * (2.0 + fi);
- float t = angle + (2.5) * az / 3.14159;
-
- sample += texture2D(tex, vec2(s,t)) / (1.0 + 0.3 * fi);
- }
- return sample;
-}
-
-vec3 diffuseLighting(vec3 pos, vec3 nml)
-{
- float df1 = 0.8 * max(0.0, dot(nml, vec3(1.0,0.2, 0.0)));
- float df2 = 0.2 * max(0.0, dot(nml, vec3(-1.0,-0.1, 0.0)));
- vec3 diffuse = vec3(df1) * vec3(0.8,0.7,0.6) + vec3(df2) * vec3(0.6,0.7,0.8);
- return diffuse;
-}
-
-void main()
-{
- vec3 nml = normalize(N);
- vec3 R = reflect(-pos, normalize(nml));
- vec3 envColor = getEnvColor(R).xyz * mix(vec3(1.0), gl_Color.xyz, 0.4);
- vec3 diffuseColor = getEnvColor(pos).xyz * gl_Color.xyz;
- gl_FragColor = vec4( diffuseColor + envColor, 1.0);
-}
\ No newline at end of file
diff --git a/tests/real/extatique/scene30.vs b/tests/real/extatique/scene30.vs
deleted file mode 100644
index a38f6f0f..00000000
--- a/tests/real/extatique/scene30.vs
+++ /dev/null
@@ -1,11 +0,0 @@
-varying vec3 pos;
-varying vec3 N;
-
-void main()
-{
- pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
- gl_Position = ftransform();
- gl_FrontColor = gl_Color;
- N = gl_NormalMatrix * gl_Normal;
-
-}
\ No newline at end of file
diff --git a/tests/real/extatique/scene40.frag b/tests/real/extatique/scene40.frag
deleted file mode 100644
index 4c8325c8..00000000
--- a/tests/real/extatique/scene40.frag
+++ /dev/null
@@ -1,177 +0,0 @@
-uniform sampler2D tex;
-varying vec3 wpos;
-varying vec3 N;
-uniform vec3 eyePos;
-uniform float radius;
-uniform float medium;
-uniform vec3 center;
-uniform vec3 light1;
-uniform vec3 light2;
-uniform vec3 light3;
-uniform vec3 light4;
-
-
-vec3 getEnvColor(vec3 pos, vec2 coord)
-{
- vec3 color = texture2D(tex, coord * 0.05).xyz;
-
- vec3 light1_dist = pos * 0.1 - vec3(-0.5,-0.5,-0.5);
- vec3 light2_dist = pos * 0.1 - vec3(+0.5,+0.5,-0.5);
- vec3 light3_dist = pos * 0.1 - vec3(-0.5,+0.5,+0.5);
- vec3 light4_dist = pos * 0.1 - vec3(+0.5,-0.5,+0.5);
-
- vec3 clight1 = light1 * vec3(max(0.0, 1.25 - 1.0 * dot(light1_dist, light1_dist)));
- vec3 clight2 = light2 * vec3(max(0.0, 1.25 - 1.0 * dot(light2_dist, light2_dist)));
- vec3 clight3 = light3 * vec3(max(0.0, 1.25 - 1.0 * dot(light3_dist, light3_dist)));
- vec3 clight4 = light4 * vec3(max(0.0, 1.25 - 1.0 * dot(light4_dist, light4_dist)));
-
-
- return color + clight1 + clight2 + clight3 + clight4;
-}
-
-float exp3(float x)
-{
- float y = max(-1.15365, x);
- return 1.0 + y * (1.0 + y * (0.5 + y * 0.33333333));
-}
-
-vec3 rayColor(vec3 startPos, vec3 startDir)
-{
- vec3 total = vec3(0.0);
- vec3 p = startPos;
- vec3 dir = startDir;
- vec3 blend = vec3(0.5);
- vec3 dpos;
- vec3 color = vec3(0.0);
-
- vec3 ray;
- vec3 nml;
- vec2 coord;
- vec3 newdir;
- vec3 sample;
-
- for (int i = 0; i < 1; ++i)
- {
- ray = 40.0 * dir;
- nml = vec3(0.0);
- coord = vec2(0.0);
- dpos = p + ray;
-
- if (abs(dpos.x) > 10.0)
- {
- if (dpos.x > 10.0)
- {
- ray *= ((9.99 - p.x) / ray.x);
- nml = vec3(-1.0,0.0,0.0);
- dpos = ray + p;
- coord = dpos.yz;
- color = getEnvColor(dpos, coord);
- }
- else
- {
- ray *= ((-9.99 - p.x) / ray.x);
- nml = vec3(1.0,0.0,0.0);
-
-
- dpos = ray + p;
- coord = dpos.yz * vec2(-1.0,1.0);
- color = getEnvColor(dpos, coord);
- }
- }
-
- if (abs(dpos.y) > 10.0)
- {
- if (dpos.y > 10.0)
- {
- ray *= ((9.99 - p.y) / ray.y);
- nml = vec3(0.0,-1.0,0.0);
-
-
- dpos = ray + p;
- coord = dpos.xz * vec2(-1.0,1.0);
- color = getEnvColor(dpos, coord);
- }
- else
- {
- ray *= ((-9.99 - p.y) / ray.y);
- nml = vec3(0.0,1.0,0.0);
-
- dpos = ray + p;
- coord = dpos.xz;
- color = getEnvColor(dpos, coord);
- }
- }
-
- if (abs(dpos.z) > 10.0)
- {
- if (dpos.z > 10.0)
- {
- ray *= ((9.99 - p.z) / ray.z);
- nml = vec3(0.0,0.0,-1.0);
- dpos = ray + p;
- coord = dpos.xy * vec2(-1.0,1.0);
- color = getEnvColor(dpos, coord);
- }
- else
- {
- ray *= ((-9.99 - p.z) / ray.z);
- nml = vec3(0.0,0.0,1.0);
- dpos = ray + p;
- coord = dpos.xy;
- color = getEnvColor(dpos, coord);
- }
- }
-
- sample = color * vec3(exp3(-length(ray) * 0.04));
-
- total += sample * blend;
- blend *= sample;
-
- newdir = reflect(dir, nml);
-
- p = dpos;
- dir = newdir;
- }
- return total;
-}
-
-
-
-void snell(vec3 dir, vec3 normal, float n1, float n2, out vec3 reflectionDir, out vec3 refractionDir, out float cost2)
-{
- float n1n2 = n1 / n2;
- float cost1 = dot(-dir, normal);
- cost2 = sqrt(1.0 - n1n2 * n1n2 * (1.0 - cost1 * cost1));
-
- reflectionDir = dir + normal * (2.0 * cost1);
- refractionDir = dir * n1n2 + normal * (cost2 + n1n2 * cost1);
-}
-
-void main()
-{
- vec3 nml = normalize(N);
- vec3 dir = normalize(wpos - eyePos);
-
-
- vec3 R;
- vec3 RE;
- float cost2, fdummy;
-
-
- snell(dir, nml, 1.0, medium + 0.1, R, RE, cost2);
-
- float dist = 2.0 * cost2 * radius;
- vec3 p2 = wpos + RE * vec3(dist);
- vec3 nml2 = -(p2 - center) / radius;
- vec3 Rdummy, Rout;
- snell(RE, nml2, medium + 0.3, 1.0, Rdummy, Rout, fdummy);
- float fact = 2.0 * exp3(-dot(dist,dist) * 0.2);
- vec3 diffracted = rayColor(p2, Rout) * vec3(fact);
-
-
- vec3 specular = rayColor(wpos, R) * gl_Color.xyz;
-
-
-
- gl_FragColor = gl_Color * vec4( specular + diffracted, 1.0);
-}
\ No newline at end of file
diff --git a/tests/real/extatique/scene40.vs b/tests/real/extatique/scene40.vs
deleted file mode 100644
index 6487b04c..00000000
--- a/tests/real/extatique/scene40.vs
+++ /dev/null
@@ -1,13 +0,0 @@
-
-varying vec3 wpos;
-varying vec3 N;
-uniform vec3 eyePos;
-
-void main()
-{
- wpos = gl_Vertex.xyz;
- gl_Position = ftransform();
- gl_FrontColor = gl_Color;
- N = gl_Normal;
-
-}
\ No newline at end of file
diff --git a/tests/real/extatique/scene45.frag b/tests/real/extatique/scene45.frag
deleted file mode 100644
index a2193cd0..00000000
--- a/tests/real/extatique/scene45.frag
+++ /dev/null
@@ -1,14 +0,0 @@
-uniform sampler2D tex;
-uniform float time;
-
-
-void main()
-{
- vec2 p = gl_TexCoord[0].xy;
- float u = atan(p.y, p.x + 0.0001) * 1.0 / 3.1415926;
- float v = 0.002 / (0.01 + length(p)) - time * 0.1;
- vec4 space = texture2D(tex, vec2(u,v))
- + vec4(0.5) * texture2D(tex, vec2(u,v * 4.0))
- + vec4(0.25) * texture2D(tex, vec2(u,v * 16.0));
- gl_FragColor = gl_Color * space;
-}
\ No newline at end of file
diff --git a/tests/real/extatique/scene45.vs b/tests/real/extatique/scene45.vs
deleted file mode 100644
index e56b9174..00000000
--- a/tests/real/extatique/scene45.vs
+++ /dev/null
@@ -1,6 +0,0 @@
-void main()
-{
- gl_TexCoord[0] = gl_MultiTexCoord0;
- gl_FrontColor = gl_Color;
- gl_Position = ftransform();
-}
\ No newline at end of file
diff --git a/tests/real/extatique/skybox.frag b/tests/real/extatique/skybox.frag
deleted file mode 100644
index 7da9bd7c..00000000
--- a/tests/real/extatique/skybox.frag
+++ /dev/null
@@ -1,32 +0,0 @@
-uniform sampler2D tex;
-uniform float angle;
-uniform float time;
-varying vec3 pos;
-
-
-
-vec4 getEnvColor(vec3 p)
-{
- float az = atan(p.x, p.y + 0.01);
- float ax = -pos.z;
-
- vec4 sample = vec4(0.0);
-
- for (int i = 0; i < 8; ++i)
- {
- float fi = float(i);
- float s = ax * 1.0 / (1.0 + fi) + time * 0.01 * (2.0 + fi);
- float t = angle + (2.5) * az / 3.14159;
-
- sample += texture2D(tex, vec2(s,t)) / (1.0 + 0.3 * fi);
- }
- return sample;
-}
-
-
-
-void main()
-{
- vec4 env = getEnvColor(pos);
- gl_FragColor = vec4(env.xyz, 1.0);
-}
\ No newline at end of file
diff --git a/tests/real/extatique/skybox.vs b/tests/real/extatique/skybox.vs
deleted file mode 100644
index 3655c481..00000000
--- a/tests/real/extatique/skybox.vs
+++ /dev/null
@@ -1,7 +0,0 @@
-varying vec3 pos;
-
-void main()
-{
- pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
- gl_Position = ftransform();
-}
\ No newline at end of file
diff --git a/tests/real/extatique/skybox2.frag b/tests/real/extatique/skybox2.frag
deleted file mode 100644
index 62b24b83..00000000
--- a/tests/real/extatique/skybox2.frag
+++ /dev/null
@@ -1,142 +0,0 @@
-varying vec3 wpos;
-
-uniform vec3 eyePos;
-
-uniform sampler2D tex;
-uniform vec3 light1;
-uniform vec3 light2;
-uniform vec3 light3;
-uniform vec3 light4;
-
-
-vec3 getEnvColor(vec3 pos, vec2 coord)
-{
- vec3 color = texture2D(tex, coord * 0.05).xyz;
-
- vec3 light1_dist = pos * 0.1 - vec3(-0.5,-0.5,-0.5);
- vec3 light2_dist = pos * 0.1 - vec3(+0.5,+0.5,-0.5);
- vec3 light3_dist = pos * 0.1 - vec3(-0.5,+0.5,+0.5);
- vec3 light4_dist = pos * 0.1 - vec3(+0.5,-0.5,+0.5);
-
- vec3 clight1 = light1 * vec3(max(0.0, 1.25 - 1.0 * dot(light1_dist, light1_dist)));
- vec3 clight2 = light2 * vec3(max(0.0, 1.25 - 1.0 * dot(light2_dist, light2_dist)));
- vec3 clight3 = light3 * vec3(max(0.0, 1.25 - 1.0 * dot(light3_dist, light3_dist)));
- vec3 clight4 = light4 * vec3(max(0.0, 1.25 - 1.0 * dot(light4_dist, light4_dist)));
-
-
- return color + clight1 + clight2 + clight3 + clight4;
-}
-
-float exp3(float x)
-{
- float y = max(-1.15365, x);
- return 1.0 + y * (1.0 + y * (0.5 + y * 0.33333333));
-}
-
-vec3 rayColor(vec3 startPos, vec3 startDir)
-{
- vec3 total = vec3(0.0);
- vec3 p = startPos;
- vec3 dir = startDir;
- vec3 blend = vec3(0.5);
- vec3 dpos;
- vec3 color = vec3(0.0);
-
- vec3 ray;
- vec3 nml;
- vec2 coord;
- vec3 newdir;
- vec3 sample;
-
- for (int i = 0; i < 3; ++i)
- {
- ray = 50.0 * dir;
- nml = vec3(0.0);
- coord = vec2(0.0);
- dpos = p + ray;
-
- if (abs(dpos.x) > 10.0)
- {
- if (dpos.x > 10.0)
- {
- ray *= ((9.99 - p.x) / ray.x);
- nml = vec3(-1.0,0.0,0.0);
- dpos = ray + p;
- coord = dpos.yz;
- color = getEnvColor(dpos, coord);
- }
- else
- {
- ray *= ((-9.99 - p.x) / ray.x);
- nml = vec3(1.0,0.0,0.0);
-
-
- dpos = ray + p;
- coord = dpos.yz * vec2(-1.0,1.0);
- color = getEnvColor(dpos, coord);
- }
- }
-
- if (abs(dpos.y) > 10.0)
- {
- if (dpos.y > 10.0)
- {
- ray *= ((9.99 - p.y) / ray.y);
- nml = vec3(0.0,-1.0,0.0);
-
-
- dpos = ray + p;
- coord = dpos.xz * vec2(-1.0,1.0);
- color = getEnvColor(dpos, coord);
- }
- else
- {
- ray *= ((-9.99 - p.y) / ray.y);
- nml = vec3(0.0,1.0,0.0);
-
- dpos = ray + p;
- coord = dpos.xz;
- color = getEnvColor(dpos, coord);
- }
- }
-
- if (abs(dpos.z) > 10.0)
- {
- if (dpos.z > 10.0)
- {
- ray *= ((9.99 - p.z) / ray.z);
- nml = vec3(0.0,0.0,-1.0);
- dpos = ray + p;
- coord = dpos.xy * vec2(-1.0,1.0);
- color = getEnvColor(dpos, coord);
- }
- else
- {
- ray *= ((-9.99 - p.z) / ray.z);
- nml = vec3(0.0,0.0,1.0);
- dpos = ray + p;
- coord = dpos.xy;
- color = getEnvColor(dpos, coord);
- }
- }
-
- sample = color * vec3(exp3(-length(ray) * 0.04));
-
- total += sample * blend;
- blend *= sample;
-
- newdir = reflect(dir, nml);
-
- p = dpos;
- dir = newdir;
- }
- return total;
-}
-
-
-void main()
-{
- vec3 env = rayColor(eyePos, normalize(wpos - eyePos));
-
- gl_FragColor = gl_Color * vec4(env, 1.0);
-}
\ No newline at end of file
diff --git a/tests/real/extatique/skybox2.vs b/tests/real/extatique/skybox2.vs
deleted file mode 100644
index 6e7e3412..00000000
--- a/tests/real/extatique/skybox2.vs
+++ /dev/null
@@ -1,13 +0,0 @@
-varying vec3 wpos;
-
-uniform vec3 eyePos;
-
-void main()
-{
- wpos = gl_Vertex.xyz;
- /* pos = (gl_ModelViewMatrix * gl_Vertex).xyz; */
- gl_FrontColor = gl_Color;
- /* gl_TexCoord[0] = gl_MultiTexCoord0; */
-
- gl_Position = ftransform();
-}
\ No newline at end of file
diff --git a/tests/real/extatique/snake.frag b/tests/real/extatique/snake.frag
deleted file mode 100644
index 9d1989f7..00000000
--- a/tests/real/extatique/snake.frag
+++ /dev/null
@@ -1,18 +0,0 @@
-varying vec3 normal;
-varying float profondeur;
-
-vec4 desaturate(vec4 color, float t)
-{
- vec3 grey = vec3(dot(vec3(0.33), color.rgb));
- return vec4(mix(color.rgb, grey, t), color.a);
-}
-
-void main()
-{
- vec3 N = normal;
-
- vec3 e = vec3(0.0,0.0,-1.0);
- float diffuse = max(0.0, dot(N, e));
- vec4 C = gl_Color * vec4(0.1 + 0.9 * vec3(diffuse), diffuse);
- gl_FragColor = C * exp( -profondeur * 0.1 );
-}
\ No newline at end of file
diff --git a/tests/real/extatique/snake.vs b/tests/real/extatique/snake.vs
deleted file mode 100644
index 90e19bd1..00000000
--- a/tests/real/extatique/snake.vs
+++ /dev/null
@@ -1,12 +0,0 @@
-varying vec3 normal;
-varying float profondeur;
-
-void main()
-{
- gl_FrontColor = gl_Color;
-
- normal = normalize(gl_Normal);
- gl_Position = ftransform();
-
- profondeur = gl_Position.z;
-}
\ No newline at end of file
diff --git a/tests/real/extatique/water.frag b/tests/real/extatique/water.frag
deleted file mode 100644
index c3b6dcf0..00000000
--- a/tests/real/extatique/water.frag
+++ /dev/null
@@ -1,84 +0,0 @@
-uniform sampler2D tex;
-uniform sampler2D texu;
-uniform sampler2D texv;
-uniform float spacing;
-uniform float ratio;
-
-void main()
-{
- vec2 p0 = gl_TexCoord[0].xy;
-
- vec4 total = texture2D(tex, p0 * 2.5);
- vec2 v0 = vec2(spacing) * (vec2(texture2D(texu, p0).x, texture2D(texv, p0).x));
-
- vec2 p1 = p0 - v0;
- total = texture2D(tex, p1) * 0.9755297;
- vec2 v1 = vec2(spacing) *(vec2(texture2D(texu, p1).x, texture2D(texv, p1).x));
-
- vec2 p2 = p1 - v1;
- total += texture2D(tex, p2) * 0.9045139;
- vec2 v2 = vec2(spacing) *(vec2(texture2D(texu, p2).x, texture2D(texv, p2).x));
-
- vec2 p3 = p2 - v2;
- total += texture2D(tex, p1) * 0.7939039;
- vec2 v3 = vec2(spacing) *(vec2(texture2D(texu, p3).x, texture2D(texv, p3).x));
-
- vec2 p4 = p3 - v3;
- total += texture2D(tex, p2) * 0.6545261;
- vec2 v4 = vec2(spacing) *(vec2(texture2D(texu, p4).x, texture2D(texv, p4).x));
-
- vec2 p5 = p4 - v4;
- total += texture2D(tex, p1) * 0.5000232;
- vec2 v5 = vec2(spacing) *(vec2(texture2D(texu, p5).x, texture2D(texv, p5).x));
-
- vec2 p6 = p5 - v5;
- total += texture2D(tex, p2) * 0.3455179;
- vec2 v6 = vec2(spacing) *(vec2(texture2D(texu, p6).x, texture2D(texv, p6).x));
-
- vec2 p7 = p6 - v6;
- total += texture2D(tex, p1) * 0.2061336;
- vec2 v7 = vec2(spacing) *(vec2(texture2D(texu, p7).x, texture2D(texv, p7).x));
-
- vec2 p8 = p7 - v7;
- total += texture2D(tex, p2) * 0.0955133;
-
-
-
- vec2 p12 = p0 + v0;
- total += texture2D(tex, p12) * 0.9755297;
- vec2 v12 = vec2(spacing) *(vec2(texture2D(texu, p12).x, texture2D(texv, p12).x));
-
- vec2 p22 = p12 + v12;
- total += texture2D(tex, p22) * 0.9045139;
- vec2 v22 = vec2(spacing) *(vec2(texture2D(texu, p22).x, texture2D(texv, p22).x));
-
- vec2 p32 = p22 + v22;
- total += texture2D(tex, p12) * 0.7939039;
- vec2 v32 = vec2(spacing) *(vec2(texture2D(texu, p32).x, texture2D(texv, p32).x));
-
- vec2 p42 = p32 + v32;
- total += texture2D(tex, p22) * 0.6545261;
- vec2 v42 = vec2(spacing) *(vec2(texture2D(texu, p42).x, texture2D(texv, p42).x));
-
- vec2 p52 = p42 + v42;
- total += texture2D(tex, p12) * 0.5000232;
- vec2 v52 = vec2(spacing) *(vec2(texture2D(texu, p52).x, texture2D(texv, p52).x));
-
- vec2 p62 = p52 + v52;
- total += texture2D(tex, p22) * 0.3455179;
- vec2 v62 = vec2(spacing) *(vec2(texture2D(texu, p62).x, texture2D(texv, p62).x));
-
- vec2 p72 = p62 + v62;
- total += texture2D(tex, p12) * 0.2061336;
- vec2 v72 = vec2(spacing) *(vec2(texture2D(texu, p72).x, texture2D(texv, p72).x));
-
- vec2 p82 = p72 + v72;
- total += texture2D(tex, p22) * 0.0955133;
-
- vec2 dist = (p0 - vec2(0.5, 0.5)) * vec2(1.0,ratio);
- vec4 darkF = vec4(max(0.0, 1.0 - 2.5 * dot(dist,dist)));
-
- vec4 finalColor = gl_Color * total * vec4(0.1) * darkF;
-
- gl_FragColor = finalColor;
-}
diff --git a/tests/real/extatique/water.vs b/tests/real/extatique/water.vs
deleted file mode 100644
index e56b9174..00000000
--- a/tests/real/extatique/water.vs
+++ /dev/null
@@ -1,6 +0,0 @@
-void main()
-{
- gl_TexCoord[0] = gl_MultiTexCoord0;
- gl_FrontColor = gl_Color;
- gl_Position = ftransform();
-}
\ No newline at end of file
diff --git a/tests/real/fly.frag b/tests/real/fly.frag
deleted file mode 100644
index 7991ac02..00000000
--- a/tests/real/fly.frag
+++ /dev/null
@@ -1,20 +0,0 @@
-uniform vec2 resolution;
-uniform float time;
-uniform sampler2D tex0;
-uniform sampler2D tex1;
-uniform sampler2D tex2;
-void main(void)
-{
- vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
- vec2 uv;
-
- float an = time*.25;
-
- float x = p.x*cos(an)-p.y*sin(an);
- float y = p.x*sin(an)+p.y*cos(an);
-
- uv.x = .25*x/abs(y);
- uv.y = .20*time + .25/abs(y);
-
- gl_FragColor = vec4(texture2D(tex0,uv).xyz * y*y, 1.0);
-}
diff --git a/tests/real/from-the-seas-to-the-stars.frag.expected b/tests/real/from-the-seas-to-the-stars.frag.expected
index cddf7d9e..ded8fa7a 100644
--- a/tests/real/from-the-seas-to-the-stars.frag.expected
+++ b/tests/real/from-the-seas-to-the-stars.frag.expected
@@ -53,17 +53,17 @@ float koi(vec2 t)
return 1.;
if(abs(t.y)>.5)
return 1.;
- vec2 p=t.xy*1.8,oop=p,op;
+ vec2 p=t.xy*1.8,oop=p;
p.y*=.8;
p.x*=.9;
p.y+=pow(clamp(p.x-.7,0,1),2)*.2;
- op=p;
+ vec2 op=p;
if(p.y<0)
p.y*=mix(1.5,1.6,clamp(p.x,0,1));
p.y*=mix(1.6,1.,.5+.5*cos(clamp((p.x-.6)*11,0.,6.2831852)));
p.y-=p.x*.02;
p.x=mix(p.x,-.4,pow(clamp((p.x-.6)*1.1,0,1),1.4));
- float d=abs(p.y)+p.x*p.x*.35-.34,oopx;
+ float d=abs(p.y)+p.x*p.x*.35-.34;
p.x-=.9;
op.y-=.05;
op.y=abs(op.y);
@@ -72,7 +72,7 @@ float koi(vec2 t)
d=min(d,max(-oop.y,max(oop.x,oop.x*oop.x*4+oop.y-.7)));
oop.x+=oop.y*.3+.25;
d=min(d,max(oop.y,max(oop.x,oop.x*oop.x*4-oop.y-.5)));
- oopx=oop.x+.4;
+ float oopx=oop.x+.4;
d=min(d,max(oop.y,max(oopx,oopx*oopx*4-oop.y-.3)));
oop.x+=oop.y*.6-.7;
d=min(d,max(oop.y,max(oop.x,oop.x*oop.x*4-oop.y-.3)));
@@ -193,7 +193,7 @@ void main()
w.y=R();
w.z=R();
w.w=R();
- vec3 camtarget,campos,r,s,t;
+ vec3 camtarget,campos;
if(time>=180+3.5)
{
makeBG(0.);
@@ -388,10 +388,11 @@ void main()
ammonite();
time/=3;
p=p.zyx;
- float t=time-10,c;
+ float t=time-10;
w.x=R();
w.y=R();
w.z=R();
+ float c;
if(w.x<.1)
c=mod(t+w.y,1.+w.z*2),t-=c,col=mix(col,vec3(1,.25,1),c/3.);
p.x=-p.x-10+t;
@@ -415,10 +416,11 @@ void main()
w.z=R();
w.w=R();
w.w=R();
- float t=time,c;
+ float t=time;
w.x=R();
w.y=R();
w.z=R();
+ float c;
if(w.x<.1)
c=mod(t+w.y,1.+w.z*2),t-=c,col=mix(col,vec3(1,.25,1),w.y/3.);
p*=vec3(1.7,2,3);
@@ -434,8 +436,7 @@ void main()
w.y=R();
w.z=R();
w.w=R();
- if(w.w<.5)
- ;
+ w.w<.5;
}
}
p.xyz+=(w.xyz*2-1)*pow(length(p),2)*.001;
@@ -469,10 +470,11 @@ void main()
w.z=R();
w.w=R();
w.w=R();
- float t=time,c;
+ float t=time;
w.x=R();
w.y=R();
w.z=R();
+ float c;
if(w.x<.1)
c=mod(t+w.y,1.+w.z*2),t-=c,col=mix(col,vec3(1,.25,1),w.y/3.);
p*=vec3(1.7,2,3);
@@ -487,8 +489,7 @@ void main()
w.y=R();
w.z=R();
w.w=R();
- if(w.w<.5)
- ;
+ w.w<.5;
}
}
p.xyz+=(w.xyz*2-1)*pow(length(p),2)*.001;
@@ -504,14 +505,14 @@ void main()
w.y=R();
w.z=R();
w.w=R();
- float t=time,d;
+ float t=time;
if(R()<.1)
t-=mod(t+R()*3.,3.);
bool bigkoi=w.w FAR) break;
+ drift += fogmap(p, d);
+ d += h*mul;
+ mul+=.004;
+ //precis +=.001;
+ }
+ drift = min(drift, 1.0);
+ return d;
+}
+
+vec3 normal( in vec3 pos, in float d )
+{
+ vec2 eps = vec2( d *d* .003+.01, 0.0);
+ vec3 nor = vec3(
+ map(pos+eps.xyy) - map(pos-eps.xyy),
+ map(pos+eps.yxy) - map(pos-eps.yxy),
+ map(pos+eps.yyx) - map(pos-eps.yyx) );
+ return normalize(nor);
+}
+
+float bnoise(in vec3 p)
+{
+ p.xz*=.4;
+ float n = Noise3d(p*3.)*0.4;
+ n += Noise3d(p*1.5)*0.2;
+ return n*n*.2;
+}
+
+vec3 bump(in vec3 p, in vec3 n, in float ds)
+{
+ p.xz *= .4;
+ //p *= 1.0;
+ vec2 e = vec2(.01,0);
+ float n0 = bnoise(p);
+ vec3 d = vec3(bnoise(p+e.xyy)-n0, bnoise(p+e.yxy)-n0, bnoise(p+e.yyx)-n0)/e.x;
+ n = normalize(n-d*10./(ds));
+ return n;
+}
+
+float shadow(in vec3 ro, in vec3 rd, in float mint)
+{
+ float res = 1.0;
+
+ float t = mint;
+ for( int i=0; i<12; i++ )
+ {
+ float h = map(ro + rd*t);
+ res = min( res, 4.*h/t );
+ t += clamp( h, 0.1, 1.5 );
+ }
+ return clamp( res, 0., 1.0 );
+}
+
+vec3 Clouds(vec3 sky, vec3 rd)
+{
+
+ rd.y = max(rd.y, 0.0);
+ float ele = rd.y;
+ float v = (200.0)/(abs(rd.y)+.01);
+
+ rd.y = v;
+ rd.xz = rd.xz * v - time*8.0;
+ rd.xz *= .0004;
+
+ float f = Noise3d(rd.xzz*3.) * Noise3d(rd.zxx*1.3)*2.5;
+ f = f*pow(ele, .5)*2.;
+ f = clamp(f-.15, 0.01, 1.0);
+
+ return mix(sky, vec3(1),f );
+}
+
+
+vec3 Sky(vec3 rd, vec3 ligt)
+{
+ rd.y = max(rd.y, 0.0);
+
+ vec3 sky = mix(vec3(.1, .15, .25), vec3(.8), pow(.8-rd.y, 3.0));
+ return mix(sky, SUN_COLOUR, min(pow(max(dot(rd,ligt), 0.0), 4.5)*1.2, 1.0));
+}
+float Occ(vec3 p)
+{
+ float h = 0.0;
+ h = clamp(map(p), 0.5, 1.0);
+ return sqrt(h);
+}
+
+
+void mainImage( out vec4 fragColor, in vec2 fragCoord )
+{
+ vec2 p = fragCoord.xy/iResolution.xy-0.5;
+ vec2 q = fragCoord.xy/iResolution.xy;
+ p.x*=iResolution.x/iResolution.y;
+ vec2 mo = iMouse.xy / iResolution.xy-.5;
+ mo = (mo==vec2(-.5))?mo=vec2(-0.1,0.07):mo;
+ mo.x *= iResolution.x/iResolution.y;
+
+ vec3 ro = vec3(0.+smoothstep(0.,1.,tri(time*1.5)*.3)*1.5, smoothstep(0.,1.,tri(time*3.)*3.)*0.08, -time*3.5-130.0);
+ ro.y -= camHeight(ro.zx)-.4;
+ mo.x += smoothstep(0.7,1.,sin(time*.35))*.5-1.5 - smoothstep(-.7,-1.,sin(time*.35))*.5;
+
+ vec3 eyedir = normalize(vec3(cos(mo.x),mo.y*2.-.05+sin(time*.5)*0.1,sin(mo.x)));
+ vec3 rightdir = normalize(vec3(cos(mo.x+1.5708),0.,sin(mo.x+1.5708)));
+ vec3 updir = normalize(cross(rightdir,eyedir));
+ vec3 rd=normalize((p.x*rightdir+p.y*updir)*1.+eyedir);
+
+ vec3 ligt = normalize( vec3(1.5, .9, -.5) );
+ float fg;
+ float rz = march(ro,rd, fg, fragCoord);
+ vec3 sky = Sky(rd, ligt);
+
+ vec3 col = sky;
+
+ if ( rz < FAR )
+ {
+ vec3 pos = ro+rz*rd;
+ vec3 nor= normal( pos, rz);
+ float d = distance(pos,ro);
+ nor = bump(pos,nor,d);
+ float shd = (shadow(pos,ligt,.04));
+
+ float dif = clamp( dot( nor, ligt ), 0.0, 1.0 );
+ vec3 ref = reflect(rd,nor);
+ float spe = pow(clamp( dot( ref, ligt ), 0.0, 1.0 ),5.)*2.;
+
+ float fre = pow( clamp(1.+dot(rd, nor),0.0,1.0), 3. );
+ col = vec3(.75);
+ col = col*dif*shd + fre*spe*shd*SUN_COLOUR +abs(nor.y)*vec3(.12, .13, .13);
+ // Fake the red absorption of ice...
+ d = Occ(pos+nor*3.);
+ col *= vec3(d, d, min(d*1.2, 1.0));
+ // Fog from ice storm...
+ col = mix(col, sky, smoothstep(FAR-25.,FAR,rz));
+
+ }
+ else
+ {
+ col = Clouds(col, rd);
+ }
+
+
+ // Fog mix...
+ col = mix(col, vec3(0.6, .65, .7), fg);
+
+ // Post...
+ col = mix(col, vec3(.5), -.3);
+ //col = col*col * (3.0-2.0*col);
+ //col = clamp(pow(col,vec3(1.5)),0.0, 1.0);
+
+ col = sqrt(col);
+
+
+ // Borders...
+ float f = smoothstep(0.0, 3.0, iTime)*.5;
+ col *= f+f*pow(70. *q.x*q.y*(1.0-q.x)*(1.0-q.y), .2);
+
+
+ fragColor = vec4( col, 1.0 );
+}
diff --git a/tests/real/frozen-wasteland.frag.expected b/tests/real/frozen-wasteland.frag.expected
new file mode 100644
index 00000000..2caedc22
--- /dev/null
+++ b/tests/real/frozen-wasteland.frag.expected
@@ -0,0 +1,279 @@
+#define ITR 90
+
+#define FAR 110.
+
+#define time iTime
+
+#define MOD3 vec3(.16532,.17369,.15787)
+
+#define SUN_COLOUR vec3(1.,.95,.85)
+
+#define TRIANGLE_NOISE
+
+float height(vec2 p)
+{
+ float h=sin(p.x*.1+p.y*.2)+sin(p.y*.1-p.x*.2)*.5;
+ h+=sin(p.x*.04+p.y*.01+3.)*4.;
+ h-=sin(h*10.)*.1;
+ return h;
+}
+float camHeight(vec2 p)
+{
+ float h=sin(p.x*.1+p.y*.2)+sin(p.y*.1-p.x*.2)*.5;
+ h+=sin(p.x*.04+p.y*.01+3.)*4.;
+ return h;
+}
+float smin(float a,float b)
+{
+ float h=clamp(.5+.5*(b-a)/2.7,0.,1.);
+ return mix(b,a,h)-2.7*h*(1.-h);
+}
+
+#define MOD2 vec2(.16632,.17369)
+
+#define MOD3 vec3(.16532,.17369,.15787)
+
+float tri(float x)
+{
+ return abs(fract(x)-.5);
+}
+float hash12(vec2 p)
+{
+ p=fract(p*MOD2);
+ p+=dot(p.xy,p.yx+19.19);
+ return fract(p.x*p.y);
+}
+float vine(vec3 p,float c,float h)
+{
+ p.y+=sin(p.z*.5625+1.3)*3.5-.5;
+ p.x+=cos(p.z*2.);
+ vec2 q=vec2(mod(p.x,c)-c/2.,p.y);
+ return length(q)-h*1.4-sin(p.z*3.+sin(p.x*7.)*.5)*.1;
+}
+
+#ifdef TRIANGLE_NOISE
+
+vec3 tri3(vec3 p)
+{
+ return vec3(tri(p.z+tri(p.y)),tri(p.z+tri(p.x)),tri(p.y+tri(p.x)));
+}
+float Noise3d(vec3 p)
+{
+ float z=1.4,rz=0.;
+ vec3 bp=p;
+ for(float i=0.;i<=2.;i++)
+ {
+ vec3 dg=tri3(bp);
+ p+=dg;
+ bp*=2.;
+ z*=1.5;
+ p*=1.3;
+ rz+=tri(p.z+tri(p.x+tri(p.y)))/z;
+ bp+=.14;
+ }
+ return rz;
+}
+
+#endif
+
+#ifdef FOUR_D_NOISE
+
+vec4 quad(vec4 p)
+{
+ return abs(fract(p.yzwx+p.wzxy)-.5);
+}
+float Noise3d(vec3 q)
+{
+ float z=1.4;
+ vec4 p=vec4(q,iTime*.1);
+ float rz=0.;
+ vec4 bp=p;
+ for(float i=0.;i<=2.;i++)
+ {
+ vec4 dg=quad(bp);
+ p+=dg;
+ z*=1.5;
+ p*=1.3;
+ rz+=tri(p.z+tri(p.w+tri(p.y+tri(p.x))))/z;
+ bp=bp.yxzw*2.+.14;
+ }
+ return rz;
+}
+
+#endif
+
+#ifdef TEXTURE_NOISE
+
+float Noise3d(vec3 x)
+{
+ x*=10.;
+ float h=0.,a=.28;
+ for(int i=0;i<4;i++)
+ {
+ vec3 p=floor(x),f=fract(x);
+ f=f*f*(3.-2.*f);
+ vec2 uv=p.xy+vec2(37,17)*p.z+f.xy,rg=textureLod(iChannel0,(uv+.5)/256.,0.).yx;
+ h+=mix(rg.x,rg.y,f.z)*a;
+ a*=.5;
+ x+=x;
+ }
+ return h;
+}
+
+#endif
+
+#ifdef VALUE_NOISE
+
+float Hash(vec3 p)
+{
+ p=fract(p*MOD3);
+ p+=dot(p.xyz,p.yzx+19.19);
+ return fract(p.x*p.y*p.z);
+}
+float Noise3d(vec3 p)
+{
+ vec2 add=vec2(1,0);
+ p*=10.;
+ float h=0.,a=.3;
+ for(int n=0;n<4;n++)
+ {
+ vec3 i=floor(p),f=fract(p);
+ f*=f*(3.-2.*f);
+ h+=mix(mix(mix(Hash(i),Hash(i+add.xyy),f.x),mix(Hash(i+add.yxy),Hash(i+add.xxy),f.x),f.y),mix(mix(Hash(i+add.yyx),Hash(i+add.xyx),f.x),mix(Hash(i+add.yxx),Hash(i+add.xxx),f.x),f.y),f.z)*a;
+ a*=.5;
+ p+=p;
+ }
+ return h;
+}
+
+#endif
+
+float map(vec3 p)
+{
+ p.y+=height(p.zx);
+ float d=p.y+.5;
+ d=smin(d,vine(p+vec3(.8,0,0),30.,3.3));
+ d=smin(d,vine(p.zyx+vec3(0,0,17),33.,1.4));
+ d+=p.y*1.2*Noise3d(p*.05);
+ p.xz*=.3;
+ d+=Noise3d(p*.3);
+ return d;
+}
+float fogmap(vec3 p,float d)
+{
+ p.xz-=time*7.+sin(p.z*.3)*3.;
+ p.y-=time*.5;
+ return max(Noise3d(p*.008+.1)-.1,0.)*Noise3d(p*.1)*.3;
+}
+float march(vec3 ro,vec3 rd,out float drift,vec2 scUV)
+{
+ float precis=.1,mul=.34,h,d=hash12(scUV)*1.5;
+ drift=0.;
+ for(int i=0;iFAR)
+ break;
+ drift+=fogmap(p,d);
+ d+=h*mul;
+ mul+=.004;
+ }
+ drift=min(drift,1.);
+ return d;
+}
+vec3 normal(vec3 pos,float d)
+{
+ vec2 eps=vec2(d*d*.003+.01,0);
+ vec3 nor=vec3(map(pos+eps.xyy)-map(pos-eps.xyy),map(pos+eps.yxy)-map(pos-eps.yxy),map(pos+eps.yyx)-map(pos-eps.yyx));
+ return normalize(nor);
+}
+float bnoise(vec3 p)
+{
+ p.xz*=.4;
+ float n=Noise3d(p*3.)*.4;
+ n+=Noise3d(p*1.5)*.2;
+ return n*n*.2;
+}
+vec3 bump(vec3 p,vec3 n,float ds)
+{
+ p.xz*=.4;
+ vec2 e=vec2(.01,0);
+ float n0=bnoise(p);
+ vec3 d=vec3(bnoise(p+e.xyy)-n0,bnoise(p+e.yxy)-n0,bnoise(p+e.yyx)-n0)/e.x;
+ n=normalize(n-d*10./ds);
+ return n;
+}
+float shadow(vec3 ro,vec3 rd,float mint)
+{
+ float res=1.,t=mint;
+ for(int i=0;i<12;i++)
+ {
+ float h=map(ro+rd*t);
+ res=min(res,4.*h/t);
+ t+=clamp(h,.1,1.5);
+ }
+ return clamp(res,0.,1.);
+}
+vec3 Clouds(vec3 sky,vec3 rd)
+{
+ rd.y=max(rd.y,0.);
+ float ele=rd.y,v=2e2/(abs(rd.y)+.01);
+ rd.y=v;
+ rd.xz=rd.xz*v-time*8.;
+ rd.xz*=4e-4;
+ float f=Noise3d(rd.xzz*3.)*Noise3d(rd.zxx*1.3)*2.5;
+ f=f*pow(ele,.5)*2.;
+ f=clamp(f-.15,.01,1.);
+ return mix(sky,vec3(1),f);
+}
+vec3 Sky(vec3 rd,vec3 ligt)
+{
+ rd.y=max(rd.y,0.);
+ vec3 sky=mix(vec3(.1,.15,.25),vec3(.8),pow(.8-rd.y,3.));
+ return mix(sky,SUN_COLOUR,min(pow(max(dot(rd,ligt),0.),4.5)*1.2,1.));
+}
+float Occ(vec3 p)
+{
+ float h=0.;
+ h=clamp(map(p),.5,1.);
+ return sqrt(h);
+}
+void mainImage(out vec4 fragColor,vec2 fragCoord)
+{
+ vec2 p=fragCoord.xy/iResolution.xy-.5,q=fragCoord.xy/iResolution.xy;
+ p.x*=iResolution.x/iResolution.y;
+ vec2 mo=iMouse.xy/iResolution.xy-.5;
+ mo=mo==vec2(-.5)?
+ (mo=vec2(-.1,.07)):
+ mo;
+ mo.x*=iResolution.x/iResolution.y;
+ vec3 ro=vec3(smoothstep(0.,1.,tri(time*1.5)*.3)*1.5,smoothstep(0.,1.,tri(time*3.)*3.)*.08,-time*3.5-130.);
+ ro.y-=camHeight(ro.zx)-.4;
+ mo.x+=smoothstep(.7,1.,sin(time*.35))*.5-1.5-smoothstep(-.7,-1.,sin(time*.35))*.5;
+ vec3 eyedir=normalize(vec3(cos(mo.x),mo.y*2.-.05+sin(time*.5)*.1,sin(mo.x))),rightdir=normalize(vec3(cos(mo.x+1.5708),0,sin(mo.x+1.5708))),updir=normalize(cross(rightdir,eyedir)),rd=normalize(p.x*rightdir+p.y*updir+eyedir),ligt=normalize(vec3(1.5,.9,-.5));
+ float fg,rz=march(ro,rd,fg,fragCoord);
+ vec3 sky=Sky(rd,ligt),col=sky;
+ if(rz 1.0)
- {
- gl_FragColor = vec4(0,0,0,1);
- return;
- }
- vec3 n = getN(p);
- float a = AO(p,n);
- vec3 s = vec3(0,0,0);
- vec3 lp[3],lc[3];
- lp[0] = vec3(-4,0,4);
- lp[1] = vec3(2,3,8);
- lp[2] = vec3(4,-2,24);
- lc[0] = vec3(1.0,0.5,0.4);
- lc[1] = vec3(0.4,0.5,1.0);
- lc[2] = vec3(0.2,1.0,0.5);
- for(int i = 0; i < 3; i++)
- {
- vec3 l,lv;
- lv = lp[i] - p;
- l = normalize(lv);
- g = length(lv);
- g = max(0.0,dot(l,n)) / g * float(10);
- s += g * lc[i];
- }
- float fg = min(1.0,20.0 / length(p - org));
- gl_FragColor = vec4(s * a,1) * fg * fg;
-}
diff --git a/tests/real/gfx monitor/distancefieldRaytrace.vs b/tests/real/gfx monitor/distancefieldRaytrace.vs
deleted file mode 100644
index a3751b72..00000000
--- a/tests/real/gfx monitor/distancefieldRaytrace.vs
+++ /dev/null
@@ -1,9 +0,0 @@
-// VertexProgram
-
-varying vec3 org,dir;
-void main()
-{
- gl_Position=gl_Vertex;
- org=vec3(0,0,0);
- dir=normalize(vec3(gl_Vertex.x*1.6,gl_Vertex.y,2));
-}
diff --git a/tests/real/gfx monitor/gradation.frag b/tests/real/gfx monitor/gradation.frag
deleted file mode 100644
index f454129e..00000000
--- a/tests/real/gfx monitor/gradation.frag
+++ /dev/null
@@ -1,10 +0,0 @@
-// FragmentProgram
-
-varying vec4 p;
-
-void main()
-{
- float g = p.y * 0.5 + 0.5;
- gl_FragColor = vec4(g,g,g,0);
- return;
-}
\ No newline at end of file
diff --git a/tests/real/gfx monitor/gradation.gs b/tests/real/gfx monitor/gradation.gs
deleted file mode 100644
index d42b065a..00000000
--- a/tests/real/gfx monitor/gradation.gs
+++ /dev/null
@@ -1,10 +0,0 @@
-// VertexProgram
-
-varying vec4 p;
-
-void main()
-{
- gl_Position = gl_Vertex;
- p = gl_Vertex;
-}
-
diff --git a/tests/real/gfx monitor/raytrace.vs b/tests/real/gfx monitor/raytrace.vs
deleted file mode 100644
index 0a4cc99b..00000000
--- a/tests/real/gfx monitor/raytrace.vs
+++ /dev/null
@@ -1,10 +0,0 @@
-// VertexProgram
-// This program is 16:10 ratio
-
-varying vec3 org,dir;
-void main()
-{
- gl_Position=gl_Vertex;
- org=vec3(0,0,0);
- dir=normalize(-vec3(-gl_Vertex.x*1.6,-gl_Vertex.y,1));
-}
\ No newline at end of file
diff --git a/tests/real/heart.expected b/tests/real/heart.expected
new file mode 100644
index 00000000..4246b3c8
--- /dev/null
+++ b/tests/real/heart.expected
@@ -0,0 +1,18 @@
+// Generated with (https://github.com/laurentlb/Shader_Minifier/)
+pub const VAR_MOUSE: &'static [u8] = b"f\0";
+pub const VAR_RESOLUTION: &'static [u8] = b"y\0";
+pub const VAR_TIME: &'static [u8] = b"v\0";
+
+pub const HEART_FRAG: &'static [u8] = b"\
+ uniform float v;\
+ uniform vec2 y;\
+ uniform vec4 f;\
+ void main()\
+ {\
+ vec2 f=(2.*gl_FragCoord.xy-y)/y.y;\
+ float m=mod(v,2.)/2.,a=pow(m,.2)*.5+.5;\
+ a-=a*.2*sin(m*6.2831*5.)*exp(-m*6.);\
+ f*=vec2(.5,1.5)+a*vec2(.5,-.5);\
+ float r=atan(f.x,f.y)/3.141593,x=length(f),e=abs(r),C=(13.*e-22.*e*e+10.*e*e*e)/(6.-5.*e),F=step(x,C)*pow(1.-x/C,.25);\
+ gl_FragColor=vec4(F,0,0,1);\
+ }\0";
diff --git a/tests/real/heart.frag.expected b/tests/real/heart.frag.expected
index b872013f..05071859 100644
--- a/tests/real/heart.frag.expected
+++ b/tests/real/heart.frag.expected
@@ -1,28 +1,22 @@
-/* File generated with
- * http://www.ctrl-alt-test.fr
- */
+// Generated with (https://github.com/laurentlb/Shader_Minifier/)
#ifndef HEART_FRAG_EXPECTED_
# define HEART_FRAG_EXPECTED_
-# define VAR_mouse "m"
+# define VAR_mouse "f"
# define VAR_resolution "y"
# define VAR_time "v"
const char *heart_frag =
"uniform float v;"
"uniform vec2 y;"
- "uniform vec4 m;"
+ "uniform vec4 f;"
"void main()"
"{"
- "vec2 m=(2.*gl_FragCoord.xy-y)/y.y;"
- "float r=mod(v,2.)/2.,a=pow(r,.2)*.5+.5,u,g,e,f,x;"
- "a-=a*.2*sin(r*6.2831*5.)*exp(-r*6.);"
- "m*=vec2(.5,1.5)+a*vec2(.5,-.5);"
- "u=atan(m.x,m.y)/3.141593;"
- "g=length(m);"
- "e=abs(u);"
- "f=(13.*e-22.*e*e+10.*e*e*e)/(6.-5.*e);"
- "x=step(g,f)*pow(1.-g/f,.25);"
- "gl_FragColor=vec4(x,0,0,1);"
+ "vec2 f=(2.*gl_FragCoord.xy-y)/y.y;"
+ "float m=mod(v,2.)/2.,a=pow(m,.2)*.5+.5;"
+ "a-=a*.2*sin(m*6.2831*5.)*exp(-m*6.);"
+ "f*=vec2(.5,1.5)+a*vec2(.5,-.5);"
+ "float r=atan(f.x,f.y)/3.141593,x=length(f),e=abs(r),C=(13.*e-22.*e*e+10.*e*e*e)/(6.-5.*e),F=step(x,C)*pow(1.-x/C,.25);"
+ "gl_FragColor=vec4(F,0,0,1);"
"}";
#endif // HEART_FRAG_EXPECTED_
diff --git a/tests/real/kinder_painter.expected b/tests/real/kinder_painter.expected
index 21ac0d8a..f7c08017 100644
--- a/tests/real/kinder_painter.expected
+++ b/tests/real/kinder_painter.expected
@@ -1,184 +1,194 @@
-/* File generated with
- * http://www.ctrl-alt-test.fr
- */
+// Generated with (https://github.com/laurentlb/Shader_Minifier/)
+# define VAR_mouse "s"
+# define VAR_resolution "v"
+# define VAR_tex0 "w"
+# define VAR_tex1 "f"
+# define VAR_tex2 "o"
+# define VAR_tex3 "b"
+# define VAR_time "z"
// tests/real/kinder_painter.frag
-"uniform vec2 resolution;"
- "uniform float time;"
- "uniform vec4 mouse;"
- "uniform sampler2D tex0,tex1,tex2,tex3;"
- "vec4 fpar00[6],fpar01[6];"
- "float cylinder(vec4 sph,vec3 ro,vec3 rd)"
+"uniform vec2 v;"
+ "uniform float z;"
+ "uniform vec4 s;"
+ "uniform sampler2D w,f,o,b;"
+ "vec4 r[6],i[6];"
+ "float t(vec4 z,vec3 m,vec3 v)"
"{"
- "vec3 d=ro-sph.xyz;"
- "float a=dot(rd.xz,rd.xz),b=dot(rd.xz,d.xz),c=dot(d.xz,d.xz)-sph.w*sph.w,t;"
- "t=b*b-a*c;"
- "if(t>0.)"
- "t=-(b+sqrt(t))/a;"
- "return t-.001;"
+ "vec3 r=m-z.xyz;"
+ "float w=dot(v.xz,v.xz),d=dot(v.xz,r.xz),s=dot(r.xz,r.xz)-z.w*z.w,i;"
+ "i=d*d-w*s;"
+ "if(i>0.)"
+ "i=-(d+sqrt(i))/w;"
+ "return i-.001;"
"}"
- "float esfera(vec4 sph,vec3 ro,vec3 rd)"
+ "float d(vec4 z,vec3 m,vec3 v)"
"{"
- "vec3 d=ro-sph.xyz;"
- "float b=dot(rd,d),c=dot(d,d)-sph.w*sph.w,t=b*b-c;"
- "if(t>0.)"
- "t=-b-sqrt(t);"
- "return t-.001;"
+ "vec3 r=m-z.xyz;"
+ "float d=dot(v,r),i=dot(r,r)-z.w*z.w,w=d*d-i;"
+ "if(w>0.)"
+ "w=-d-sqrt(w);"
+ "return w-.001;"
"}"
- "bool esfera2(vec4 sph,vec3 ro,vec3 rd,float tmin)"
+ "bool d(vec4 z,vec3 m,vec3 v,float w)"
"{"
- "vec3 d=ro-sph.xyz;"
- "float b=dot(rd,d),c=dot(d,d)-sph.w*sph.w,t=b*b-c;"
- "bool r=false;"
- "if(t>0.)"
- "t=-b-sqrt(t),r=t>0.&&t0.)"
+ "f=-d-sqrt(f),s=f>0.&&f0.)"
- "t=-(b+sqrt(t)),r=t>0.&&t0.)"
+ "f=-(d+sqrt(f)),b=f>0.&&f2.5)"
- "nor.xz=inter.xz-obj.xz,nor.y=0.,nor=nor/obj.w,uv=vec2(nor.x,inter.y);"
- "else"
- " if(col.w>1.5)"
- "nor=obj.xyz,uv=inter.xz*.2;"
- "else"
- " nor=inter-obj.xyz,nor=nor/obj.w,uv=nor.xy;"
- "return nor;"
+ "vec3 w;"
+ "r=z.w>2.5?"
+ "(w.xz=m.xz-v.xz,w.y=0.,w/=v.w,vec2(w.x,m.y)):"
+ "z.w>1.5?"
+ "(w=v.xyz,m.xz*.2):"
+ "(w=m-v.xyz,w/=v.w,w.xy);"
+ "return w;"
"}"
- "vec4 cmov(vec4 a,vec4 b,bool cond)"
+ "vec4 m(vec4 z,vec4 v,bool w)"
"{"
- "return cond?b:a;"
+ "return w?"
+ "v:"
+ "z;"
"}"
- "float cmov(float a,float b,bool cond)"
+ "float m(float z,float v,bool w)"
"{"
- "return cond?b:a;"
+ "return w?"
+ "v:"
+ "z;"
"}"
- "int cmov(int a,int b,bool cond)"
+ "int m(int z,int v,bool w)"
"{"
- "return cond?b:a;"
+ "return w?"
+ "v:"
+ "z;"
"}"
- "float intersect(vec3 ro,vec3 rd,out vec4 obj,out vec4 col)"
+ "float m(vec3 v,vec3 z,out vec4 w,out vec4 f)"
"{"
- "float tmin=1e4,t;"
- "col.w=-1.;"
- "bool isok;"
- "t=esfera(fpar00[0],ro,rd);"
- "isok=t>0.&&t0.&&t0.&&t0.&&t0.&&t0.&&t0.&&b0.&&b0.&&b0.&&b0.&&b0.&&b0.&&length(x-artifactPos.xz)0.&&length(x-artifactPos.xz)0.)
{
- dist=length(planetPos-ro)-dist*800.;
+ dist=length(planetPos-ro)-dist*8e2;
vec3 p=ro+rd*dist,n=normalize(planetPos-p);
vec2 uv=.5+.5*vec2(atan(n.z,n.x),acos(n.y))/pi*vec2(5,50);
color.xyz=max(0.,.2+dot(normalize(p-lightPos),n))*(caustic(uv.x*.5+Y.z*.1,uv.y*.5,0.)+.5)*.15*vec3(1,0,1);
@@ -89,21 +91,23 @@ vec4 calcPlanet(vec3 ro,vec3 rd)
}
else
dist=FAR*99.;
- pN=vec3(-.96,.96,-.2);
- t=dot(pN,planetPos-ro)/dot(pN,rd);
+ vec3 pN=vec3(-.96,.96,-.2);
+ float t=dot(pN,planetPos-ro)/dot(pN,rd);
if(t>0.&&t52.&&d<80.)
- color.xyz=mix(color.xyz,vec3(.8,.64,.4),t/200.*norm(sin((d-50.)/30.*smoothrnd(vec2(d,3)))));
- color.w=color.w<1.?3.*length(color):color.w;
+ color.xyz=mix(color.xyz,vec3(.8,.64,.4),t/2e2*norm(sin((d-50.)/30.*smoothrnd(vec2(d,3)))));
+ color.w=color.w<1.?
+ 3.*length(color):
+ color.w;
}
return vec4(max(vec3(0),color.xyz*.3)*clamp(dot(rd,vec3(0,1,0))*8.,0.,1.),color.w);
}
vec3 calculateSky(vec3 ro,vec3 rd,int addPlanet)
{
vec3 color=max(vec3(0),(max(vec3(0),pow(dot(lightDir,rd),6.))*.7-rd.y)*mix(vec3(1,.5,0),vec3(1),min(1.,lightDir.y*1.5))+lightDir.y*3.);
- float phi=atan(rd.x,rd.z),theta=acos(rd.y/length(rd)),coeff=smoothstep(0.,.5,norm(.5*smoothrnd(300.*vec2(phi,theta)))+norm(.75*smoothrnd(500.*vec2(phi,theta)))-1.25)*saturate(1.-lightDir.y*5.);
+ float phi=atan(rd.x,rd.z),theta=acos(rd.y/length(rd)),coeff=smoothstep(0.,.5,norm(.5*smoothrnd(3e2*vec2(phi,theta)))+norm(.75*smoothrnd(5e2*vec2(phi,theta)))-1.25)*saturate(1.-lightDir.y*5.);
if(addPlanet>0)
{
vec4 p=calcPlanet(ro,rd);
@@ -115,7 +119,9 @@ vec3 calculateSky(vec3 ro,vec3 rd,int addPlanet)
}
float isoSurface(vec3 p)
{
- float b=Y.z>80.&&Y.z<112.?1.:0.;
+ float b=Y.z>80.&&Y.z<112.?
+ 1.:
+ 0.;
p=rotateX(rotateY(rotateX(rotateY(p-artifactPos.xyz,3.*Y.z),3.*Y.z),b*sin(3.*Y.z+3.*p.y)),b*sin(3.*Y.z+3.*p.x));
p*=4.+10.*max(0.,Y.z-EXPLOSIONTIME);
return-.4+p.x*p.x*p.x*p.x*p.x*p.x*p.x*p.x+p.y*p.y*p.y*p.y*p.y*p.y*p.y*p.y+p.z*p.z*p.z*p.z*p.z*p.z*p.z*p.z;
@@ -162,7 +168,7 @@ void calcBurn(vec2 x,vec3 normal,inout vec3 color)
}
vec3 calcScene(vec3 ro,vec3 rd)
{
- float upperPlane=(.1-ro.y)/rd.y,finalDepth=200.;
+ float upperPlane=(.1-ro.y)/rd.y,finalDepth=2e2;
vec3 color=calculateSky(ro,rd,1);
if(rd.y<-.01&&traceTerrain(ro+rd*upperPlane,rd,finalDepth,finalDepth)>0)
{
@@ -184,22 +190,22 @@ void main()
rd=normalize(vec3(Y.xy-.5,1));
artifactPos=vec4(10,norm(sin(Y.z+4.)),13,0);
ro=vec3(0,.25,0);
- float t=Y.z,dist,isoDistance;
+ float t=Y.z;
if(t<16.)
- t=ftime(t,0.,16.),t=1.-pow(1.-t,2.),lightPos=vec3(-400,100.-t*450.,1000),t=(t-1.)*.7,rd=rotateX(rd,-t);
+ t=ftime(t,0.,16.),t=1.-pow(1.-t,2.),lightPos=vec3(-400,1e2-t*450.,1e3),t=(t-1.)*.7,rd=rotateX(rd,-t);
else
if(t<32.)
- t=ftime(t,16.,32.),t=1.-pow(1.-t,2.),lightPos=vec3(-400,-350.+t*600.,1000),ro.y-=t*.1;
+ t=ftime(t,16.,32.),t=1.-pow(1.-t,2.),lightPos=vec3(-400,-350.+t*6e2,1e3),ro.y-=t*.1;
else
if(t<40.)
- lightPos=vec3(-400,250,1000),ro.y-=.1;
+ lightPos=vec3(-400,250,1e3),ro.y-=.1;
else
if(t<64.)
{
int scene=int((t-40.)/6.);
if(scene>=3)
artifactPos.w=1.;
- lightPos=vec3(-400,min(250.,norm(rnd(vec2(scene,2)))*400.),1000);
+ lightPos=vec3(-400,min(250.,norm(rnd(vec2(scene,2)))*4e2),1e3);
ro.xz+=vec2(.1,20)*vec2(rnd(vec2(scene,5)),rnd(vec2(scene,7)));
ro=mix(ro+vec3(.008)*abs(vec3(rnd(vec2(scene,8)),0,rnd(vec2(scene,10)))),ro+vec3(.75)*abs(vec3(rnd(vec2(scene,11)),0,rnd(vec2(scene,13)))),t-40.-float(scene));
ro.y=.2;
@@ -208,7 +214,7 @@ void main()
else
{
artifactPos.w=1.;
- lightPos=vec3(-400,norm(sin(t+10.))*250.,1000);
+ lightPos=vec3(-400,norm(sin(t+10.))*250.,1e3);
float i=smoothstep(118.,120.,t);
ro.xz=artifactPos.xz+mix(vec2(sin(t*.6),cos(t*.6))*mix(sin(t*1.5+10.)+2.,2.,i),vec2(0,2.+.75*(t-EXPLOSIONTIME)),smoothstep(-1.,1.,t-EXPLOSIONTIME));
ro.y=mix(norm(sin(t*3.)*(1.-i))*.3,0.,smoothstep(-1.,1.,t-EXPLOSIONTIME))+.2;
@@ -216,8 +222,9 @@ void main()
rd=rotateY(rd,atan(dir.y,dir.x)-pi/2.);
}
lightDir=normalize(lightPos-ro);
- dist=length(ro-artifactPos.xyz)-1.;
- isoDistance=artifactPos.w==1.?traceIso(ro,rd,dist,dist+2.,99.):FAR;
+ float dist=length(ro-artifactPos.xyz)-1.,isoDistance=artifactPos.w==1.?
+ traceIso(ro,rd,dist,dist+2.,99.):
+ FAR;
if(isoDistance100.)"
+ "vec4 i=vec4(100);"
+ "vec3 c=v;"
+ "float x=dot(c,c);"
+ "if(x>1e2)"
"return f=.5*log(x)/pow(8.,0.),y=vec4(1),false;"
"for(int t=1;t<7;t++)"
"{"
"\n#if 0\n"
- "float z=sqrt(dot(i,i)),c=acos(i.y/z),o=atan(i.x,i.z);"
+ "float z=sqrt(dot(c,c)),o=acos(c.y/z),s=atan(c.x,c.z);"
"z=pow(z,8.);"
- "c=c*8.;"
- "o=o*8.;"
- "i=v+z*vec3(sin(c)*sin(o),cos(c),sin(c)*cos(o));"
+ "o*=8.;"
+ "s*=8.;"
+ "c=v+z*vec3(sin(o)*sin(s),cos(o),sin(o)*cos(s));"
"\n#else\n"
- "float s=i.x,d=s*s,n=d*d,m=i.y,l=m*m,p=i.z,w=p*p,r=w*w,g=d+w,a=inversesqrt(g*g*g*g*g*g*g),u=n+l*l+r-6.*l*w-6.*d*l+2.*w*d,q=d-l+w;"
- "i.x=v.x+64.*s*m*p*(d-w)*q*(n-6.*d*w+r)*u*a;"
- "i.y=v.y+-16.*l*g*q*q+u*u;"
- "i.z=v.z+-8.*m*q*(n*n-28.*n*d*w+70.*n*r-28.*d*w*r+r*r)*u*a;"
+ "float d=c.x,n=d*d,m=n*n,p=c.y,e=p*p,a=c.z,w=a*a,l=w*w,g=n+w,r=inversesqrt(g*g*g*g*g*g*g),C=m+e*e+l-6.*e*w-6.*n*e+2.*w*n,F=n-e+w;"
+ "c.x=v.x+64.*d*p*a*(n-w)*F*(m-6.*n*w+l)*C*r;"
+ "c.y=v.y+-16.*e*g*F*F+C*C;"
+ "c.z=v.z+-8.*p*F*(m*m-28.*m*n*w+70.*m*l-28.*n*w*l+l*l)*C*r;"
"\n#endif\n"
- "x=dot(i,i);"
- "e=min(e,vec4(i.xyz*i.xyz,x));"
- "if(x>100.)"
- "return y=e,f=.5*log(x)/pow(8.,float(t)),false;"
+ "x=dot(c,c);"
+ "i=min(i,vec4(c.xyz*c.xyz,x));"
+ "if(x>1e2)"
+ "return y=i,f=.5*log(x)/pow(8.,float(t)),false;"
"}"
- "y=e;"
+ "y=i;"
"f=0.;"
"return true;"
"}"
- "bool t(vec3 v,vec3 f,out float y,float e,out vec3 o,out vec4 i,float g)"
+ "bool f(vec3 v,vec3 c,out float y,float e,out vec3 o,out vec4 x,float g)"
"{"
- "vec4 x=vec4(0,0,0,1.25),c;"
+ "vec4 i=vec4(0,0,0,1.25);"
"vec2 n;"
- "if(!t(x,v,f,n))"
+ "if(!f(i,v,c,n))"
"return false;"
"if(n.y<.001)"
"return false;"
@@ -60,66 +58,67 @@ const char *mandelbulb_frag =
"n.x=.001;"
"if(n.y>e)"
"n.y=e;"
- "float d,s;"
+ "float t;"
"vec3 z;"
- "s=1./sqrt(1.+g*g);"
- "for(float w=n.x;w.001)"
- "if(t(m,f,C,1e20,a,h,p))"
- "q=.1;"
- "r=vec3(1);"
- "r=mix(r,vec3(.8,.6,.2),sqrt(g.x)*1.25);"
- "r=mix(r,vec3(.8,.3,.3),sqrt(g.y)*1.25);"
- "r=mix(r,vec3(.7,.4,.3),sqrt(g.z)*1.25);"
- "r*=(.5+.5*n.y)*vec3(.14,.15,.16)*.8+q*vec3(1,.85,.4)+.5*b*vec3(.08,.1,.14);"
- "r*=vec3(pow(F,.8),pow(F,1.),pow(F,1.1));"
- "r=1.5*(r*.15+.85*sqrt(r));"
+ "vec3 d=n+C*p;"
+ "float r=clamp(.2+.8*dot(y,g),0.,1.);"
+ "r*=r;"
+ "float F=clamp(.3+.7*dot(x,g),0.,1.),a=clamp(1.25*t.w-.4,0.,1.);"
+ "a=a*a*.5+.5*a;"
+ "float E;"
+ "vec3 D;"
+ "vec4 B;"
+ "if(r>.001)"
+ "if(f(d,y,E,1e20,D,B,o))"
+ "r=.1;"
+ "i=vec3(1);"
+ "i=mix(i,vec3(.8,.6,.2),sqrt(t.x)*1.25);"
+ "i=mix(i,vec3(.8,.3,.3),sqrt(t.y)*1.25);"
+ "i=mix(i,vec3(.7,.4,.3),sqrt(t.z)*1.25);"
+ "i*=(.5+.5*g.y)*vec3(.14,.15,.16)*.8+r*vec3(1,.85,.4)+.5*F*vec3(.08,.1,.14);"
+ "i*=vec3(pow(a,.8),pow(a,1.),pow(a,1.1));"
+ "i=1.5*(i*.15+.85*sqrt(i));"
"}"
- "e=v*.5+.5;"
- "r*=.7+4.8*e.x*e.y*(1.-e.x)*(1.-e.y);"
- "r=clamp(r,0.,1.);"
- "gl_FragColor=vec4(r,1);"
+ "else"
+ " i=1.3*vec3(1,.98,.9)*(.7+.3*p.y);"
+ "vec2 d=v*.5+.5;"
+ "i*=.7+4.8*d.x*d.y*(1.-d.x)*(1.-d.y);"
+ "i=clamp(i,0.,1.);"
+ "gl_FragColor=vec4(i,1);"
"}";
#endif // MANDELBULB_EXPECTED_
diff --git a/tests/real/monjori.frag.expected b/tests/real/monjori.frag.expected
index 74e426c1..fb0fee2d 100644
--- a/tests/real/monjori.frag.expected
+++ b/tests/real/monjori.frag.expected
@@ -5,10 +5,10 @@ void main()
{
vec2 p=-1.+2.*gl_FragCoord.xy/resolution.xy;
float a=time*40.,d,e,f,g=.025,h,i,r,q;
- e=400.*(p.x*.5+.5);
- f=400.*(p.y*.5+.5);
- i=200.+sin(e*g+a/150.)*20.;
- d=200.+cos(f*g/2.)*18.+cos(e*g)*7.;
+ e=4e2*(p.x*.5+.5);
+ f=4e2*(p.y*.5+.5);
+ i=2e2+sin(e*g+a/150.)*20.;
+ d=2e2+cos(f*g/2.)*18.+cos(e*g)*7.;
r=sqrt(pow(i-e,2.)+pow(d-f,2.));
q=f/r;
e=r*cos(q)-a/2.;
diff --git a/tests/real/multitexture.frag b/tests/real/multitexture.frag
deleted file mode 100644
index 1436113f..00000000
--- a/tests/real/multitexture.frag
+++ /dev/null
@@ -1,21 +0,0 @@
-uniform vec2 resolution;
-uniform float time;
-uniform sampler2D tex0;
-uniform sampler2D tex1;
-
-void main(void)
-{
- vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
- // a rotozoom
- vec2 cst = vec2( cos(.5*time), sin(.5*time) );
- mat2 rot = 0.5*cst.x*mat2(cst.x,-cst.y,cst.y,cst.x);
- vec3 col1 = texture2D(tex0,rot*p).xyz;
-
- // scroll
- vec3 col2 = texture2D(tex1,0.5*p+sin(0.1*time)).xyz;
-
- // blend layers
- vec3 col = col2*col1;
-
- gl_FragColor = vec4(col,1.0);
-}
diff --git a/tests/real/ohanami.frag.expected b/tests/real/ohanami.frag.expected
index 062c474b..c836c9a9 100644
--- a/tests/real/ohanami.frag.expected
+++ b/tests/real/ohanami.frag.expected
@@ -11,20 +11,20 @@ float ti,col=1e3,col2=1e3,col3=1e3;
float f(vec3 p)
{
col3=p.y-(.5+.5*cos(p.x*2))*.1;
- float d=max(col3,length(p.xz)-5.5),s=1,ss=1.6,scale;
+ float d=max(col3,length(p.xz)-5.5),s=1,ss=1.6;
if(ti<1)
return d;
vec3 w=normalize(vec3(-1,1.2,-1)),u=normalize(cross(w,vec3(0,1,0)));
if(ti>12&&ti<18)
col2=(length(mod(p*2-1.02+ti/2,2)-1)-mix(.001,.06,(ti-12)/5))/2,d=min(d,col2);
int j=int(min(floor(ti-1),7));
- scale=min(.3+ti/6,1);
+ float scale=min(.3+ti/6,1);
p/=scale;
for(int i=0;d=min(d,scale*max(p.y-1,max(-p.y,length(p.xz)-.1/(p.y+.7)))/s),p.xz=abs(p.xz),p.y-=1,i8&&ti<12)
zoom=ti-6,filmoffset=vec2(cos(ti*2),sin(ti*3))/3;
if(ti>25&&ti<29)
zoom=5.5,filmoffset=vec2(cos(ti*2),sin(ti*3))/3;
- vec3 ro=vec3(-2.5,.5+cos(ti*17)*.1,3),rd=normalize(vec3(t.xy+filmoffset,zoom)),camtarget,w,u,v,ld,ld,rp;
+ vec3 ro=vec3(-2.5,.5+cos(ti*17)*.1,3),rd=normalize(vec3(t.xy+filmoffset,zoom));
if(ti==10)
ro.y+=2;
- camtarget=vec3(0,1.3,0);
- w=normalize(camtarget-ro);
- u=normalize(cross(w,vec3(0,1,0)));
- v=normalize(cross(w,-u));
+ vec3 camtarget=vec3(0,1.3,0),w=normalize(camtarget-ro),u=normalize(cross(w,vec3(0,1,0))),v=normalize(cross(w,-u));
rd=mat3(u,v,w)*rd;
gl_FragColor.xyz=vec3(.8,.8,1)/6;
- t=0.;
- d=0.;
+ float t=0.,d=0.;
for(int i=0;i<100;++i)
{
d=f(ro+rd*t);
@@ -82,33 +78,25 @@ void main()
gl_FragColor.xyz=vec3(1,.7,.8);
if(col3<.02&&(ti<17||ti>22))
gl_FragColor.xyz=vec3(.5,1,.6)/3;
- ld=normalize(vec3(1,3+cos(ti)/2,1+sin(ti*3)/2));
- e=.01;
- d2=f(ro+rd*t+ld*e);
- l=max(0,(d2-d)/e);
- d3=f(ro+rd*t+vec3(0,1,0)*e);
- l2=max(0,.5+.5*(d3-d)/e);
+ vec3 ld=normalize(vec3(1,3+cos(ti)/2,1+sin(ti*3)/2));
+ float e=.01,d2=f(ro+rd*t+ld*e),l=max(0,(d2-d)/e),d3=f(ro+rd*t+vec3(0,1,0)*e),l2=max(0,.5+.5*(d3-d)/e);
{
vec3 rp=ro+rd*t;
if(ti>12&&ti<22)
if(col2<.01||d3+d2/7>.0017&&pow(valnoise(rp.xz*8),2)>abs(ti-18)/5.)
gl_FragColor.xyz=vec3(.65);
}
- ld=normalize(vec3(1,3+cos(ti)/2,1+sin(ti*3)/2));
- e=.01;
- d2=f(ro+rd*t+ld*e);
- l=max(0,(d2-d)/e);
- d3=f(ro+rd*t+vec3(0,1,0)*e);
- l2=max(0,.5+.5*(d3-d)/e);
+ vec3 ld=normalize(vec3(1,3+cos(ti)/2,1+sin(ti*3)/2));
+ float e=.01,d2=f(ro+rd*t+ld*e),l=max(0,(d2-d)/e),d3=f(ro+rd*t+vec3(0,1,0)*e),l2=max(0,.5+.5*(d3-d)/e);
{
vec3 rp=ro+rd*t;
if(ti>12&&ti<17)
if(col2<.01||d3+d2/7>.0017&&valnoise(rp.xz*8)<(ti-12)/3.)
gl_FragColor.xyz=vec3(.65);
}
- rp=ro+rd*(t-.001);
+ vec3 rp=ro+rd*(t-.001);
t=.1;
- sh=1.;
+ float sh=1.;
for(int i=0;i<30;++i)
{
d=f(rp+ld*t)+.01;
@@ -122,7 +110,7 @@ void main()
else
{
vec3 c=vec3(.8,.8,1)/6;
- vec2 p=t.xy,e,p2;
+ vec2 p=t.xy;
for(int n=0;n<2;++n)
{
float maxr=mix(1./22.,.25,1.-n)*.4;
@@ -130,7 +118,9 @@ void main()
for(int i=-1;i<2;++i)
for(int j0=-1;j0<2;++j0)
{
- vec2 u=uo+vec2(i,(uo.x+i&1)==1?-j0:j0);
+ vec2 u=uo+vec2(i,(uo.x+i&1)==1?
+ -j0:
+ j0);
seed=u.x*881+u.y*927+n*1801;
for(int k=0;k<11;++k)
{
@@ -144,8 +134,7 @@ void main()
}
}
}
- e=vec2(.001,0);
- p2=p+(valnoise(p*18)-.5)*.01;
+ vec2 e=vec2(.001,0),p2=p+(valnoise(p*18)-.5)*.01;
float c0=dot(vec3(1./3.),samp(p2).xyz),c1=dot(vec3(1./3.),samp(p2+e.xy).xyz),c2=dot(vec3(1./3.),samp(p2+e.yx*1.8).xyz);
c*=vec3(mix(.1,1,1.-clamp(max(abs(c2-c0),abs(c1-c0))*4,0,.13)));
c=(c-.5)*1.1+.5;
diff --git a/tests/real/orchard.frag b/tests/real/orchard.frag
new file mode 100644
index 00000000..e836d18c
--- /dev/null
+++ b/tests/real/orchard.frag
@@ -0,0 +1,606 @@
+// Copied from https://www.shadertoy.com/view/wlVSz3
+// Orchard (Alternative Projection)
+// by Dave Hoskins. March 2020
+// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
+
+// This breaks the effect a little...
+//#define MOVE_CAMERA
+
+
+int spointer;
+vec3 sunLight;
+#define SUN_COLOUR vec3(1., .9, .8)
+#define FOG_COLOUR vec3(1., .7, .7)
+
+struct Stack
+{
+ vec3 pos;
+ float alpha;
+ float dist;
+ int mat;
+
+};
+
+#define STACK_SIZE 8
+Stack stack[STACK_SIZE];
+
+//==============================================================================
+//--------------------------------------------------------------------------
+float getGroundHeight(vec2 p)
+{
+ float y =(sin(p.y*.23)+cos(p.x*.18))*.8;
+ return y;
+}
+//--------------------------------------------------------------------------
+mat3 getCamMat( in vec3 ro, in vec3 ta, float cr )
+{
+ vec3 cw = normalize(ta-ro);
+ vec3 cp = vec3(sin(cr), cos(cr),0.0);
+ vec3 cu = normalize( cross(cw,cp) );
+ vec3 cv = normalize( cross(cu,cw) );
+ return mat3( cu, cv, cw );
+}
+
+//--------------------------------------------------------------------------
+// Loop the camposition around a uneven sine and cosine, and default the time 0
+// to be steep at a loop point by adding 140...
+vec3 getCamPos(float t)
+{
+ //t = sin(t*.01)*200.;
+ t+=140.;
+ vec3 p = vec3(3.0+50.0*sin(t*.03),
+ 1.5,
+ 4.0 + 50.0*cos(t*.044));
+ p.y-=getGroundHeight(p.xz);
+ return p;
+}
+
+//----------------------------------------------------------------------------------------
+// 1 out, 1 in...
+float hash11(float p)
+{
+ p = fract(p * .1031);
+ p *= p + 33.33;
+ p *= p + p;
+ return fract(p);
+}
+//----------------------------------------------------------------------------------------
+// 1 out, 2 in...
+float hash12(vec2 p)
+{
+ vec3 p3 = fract(vec3(p.xyx) * .1031);
+ p3 += dot(p3, p3.yzx + 33.33);
+ return fract((p3.x + p3.y) * p3.z);
+}
+
+// 1 out, 3 in...
+vec3 hash31(float p)
+{
+ vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973));
+ p3 += dot(p3, p3.yzx+33.33);
+ return fract((p3.xxy+p3.yzz)*p3.zyx);
+}
+
+// 3 out, 3 in...
+vec3 hash33(vec3 p3)
+{
+ p3 = fract(p3 * vec3(.1031, .1030, .0973));
+ p3 += dot(p3, p3.yxz+33.33);
+ return fract((p3.xxy + p3.yxx)*p3.zyx);
+}
+
+
+//------------------------------------------------------------------------------
+float randomTint(vec3 pos)
+{
+ float r = texture(iChannel1, pos.xz*.0027).x;
+ return r+.5;
+}
+
+//----------------------------------------------------------------------------------------
+vec3 texCube(sampler2D sam, in vec3 p, in vec3 n )
+{
+ vec3 x = texture(sam, p.yz).xyz;
+ vec3 y = texture(sam, p.zx).xyz;
+ vec3 z = texture(sam, p.xy).xyz;
+ return (x*abs(n.x) + y*abs(n.y) + z*abs(n.z))/(abs(n.x)+abs(n.y)+abs(n.z));
+}
+
+//------------------------------------------------------------------------------
+vec4 grassTexture(vec3 pos, vec3 nor)
+{
+
+ float g = texture(iChannel1, pos.xz*.5).x;
+ float s = texture(iChannel1, pos.xz*.015).x*.2;
+
+
+ vec3 flower = texture(iChannel2, pos.xz*.15).xyz;
+ float rand = texture(iChannel1, pos.xz*.003).x;
+ rand *= rand*rand;
+
+ flower =pow(flower,vec3(8, 15, 5)) *10. * rand;
+ vec4 mat = vec4(g*.05+s, g*.65, 0, g*.1);
+ mat.xyz += flower;
+
+ // Do the red ground lines...
+ pos = fract(pos);
+ mat = mix(mat, vec4(.2, 0,0,0), smoothstep(.05, .0,min(pos.x, pos.z))
+ + smoothstep(.95, 1.,max(pos.x, pos.z)));
+
+
+ return min(mat, 1.0);
+}
+
+//------------------------------------------------------------------------------
+vec4 barkTexture(vec3 p, vec3 nor)
+{
+ vec2 r = floor(p.xz / 5.0) * 0.02;
+ float br = texture(iChannel1, r).x;
+ vec3 mat = texCube(iChannel3, p*.4, nor) * vec3(.4, .3, .1*br) *br;
+ mat += texCube(iChannel3, p*.53, nor)*smoothstep(0.0,.3, mat.x)*br;
+ return vec4(mat, .1);
+}
+
+//------------------------------------------------------------------------------
+vec4 leavesTexture(vec3 p, vec3 nor)
+{
+
+ vec3 rand = texCube(iChannel2, p*.15,nor);
+ vec3 mat = vec3(0.4,1.2,0) *rand;
+ return vec4(mat, .0);
+}
+
+//------------------------------------------------------------------------------
+vec4 fruitTexture(vec3 p, vec3 nor, float i)
+{
+
+
+ float rand = texCube(iChannel2, p*.1 ,nor).x;
+ float t = dot(nor, normalize(vec3(.8, .1, .1)));
+ vec3 mat = vec3(1.,abs(t)*rand,0);
+ mat = mix(vec3(0,1,0), mat, i/10.);
+
+ return vec4(mat, .5);
+}
+
+
+
+//------------------------------------------------------------------------------
+float distanceRayPoint(vec3 ro, vec3 rd, vec3 p, out float h)
+{
+ h = dot(p-ro,rd);
+ return length(p-ro-rd*h);
+}
+
+//------------------------------------------------------------------------------
+const int SEEDS = 8 ;
+const float STEP_SIZE = 2.;
+#define SIZE .03
+
+
+// This seed code is the starfield stuff from iapafoto
+// I've just removed the alpha part...
+// https://www.shadertoy.com/view/Xl2BRR
+mat2 rotMat2D(float a)
+{
+ float si = sin(a);
+ float co = cos(a);
+ return mat2(si, co, -co, si);
+}
+
+vec3 floatingSeeds(in vec3 ro, in vec3 rd, in float tmax)
+{
+
+ float d = 0.;
+ ro /= STEP_SIZE;
+ vec3 pos = floor(ro),
+ ri = 1./rd,
+ rs = sign(rd),
+ dis = (pos-ro + .5 + rs*0.5) * ri;
+
+ float dint;
+ vec3 offset, id;
+ vec3 col = vec3(0);
+ vec3 sum = vec3(0);
+ //float size = .04;
+
+ for( int i=0; i< SEEDS; i++ )
+ {
+ id = hash33(pos);
+
+ offset = clamp(id+.2*cos(id*iTime),SIZE, 1.-SIZE);
+ d = distanceRayPoint(ro, rd, pos+offset, dint);
+
+ if (dint > 0. && dint * STEP_SIZE < tmax)
+ {
+ col = vec3(.4)*smoothstep(SIZE, 0.0,d);
+ sum += col;
+ }
+ vec3 mm = step(dis.xyz, dis.yxy) * step(dis.xyz, dis.zzx);
+ dis += mm * rs * ri;
+ pos += mm * rs;
+ }
+
+ return sum * .7;
+}
+
+//--------------------------------------------------------------------------
+float findClouds2D(in vec2 p)
+{
+ float a = 1.5, r = 0.0;
+ p*= .000001;
+ for (int i = 0; i < 5; i++)
+ {
+ r+= texture(iChannel1,p*=2.2).x*a;
+ a*=.5;
+ }
+ return max(r-1.5, 0.0);
+}
+//------------------------------------------------------------------------------
+// Use the difference between two cloud densities to light clouds in the direction of the sun.
+vec4 getClouds(vec3 pos, vec3 dir)
+{
+ if (dir.y < 0.0) return vec4(0.0);
+ float d = (4000. / dir.y);
+ vec2 p = pos.xz+dir.xz*d;
+ float r = findClouds2D(p);
+ float t = findClouds2D(p+normalize(sunLight.xz)*30.);
+ t = sqrt(max((r-t)*20., .2))*2.;
+ vec3 col = vec3(t) * SUN_COLOUR;
+ // returns colour and alpha...
+ return vec4(col, r);
+}
+
+
+//------------------------------------------------------------------------------
+// Thanks to Fizzer for the space-folded tree idea...
+/// https://www.shadertoy.com/view/4tVcWR
+vec2 map(vec3 p, float t)
+{
+
+ float matID, f;
+ p.y += getGroundHeight(p.xz);
+ float num = (floor(p.z/5.))*5.+(floor(p.x/5.0))*19.;
+ p.xz = mod(p.xz, 5.0)-2.5;
+ //p.xz *= rotMat2D(p.y*num/300.); // ... No, just too expensive. :)
+
+ float d = p.y;
+ matID = 0.0;
+
+ float s=1.,ss=1.6;
+
+ // Tangent vectors for the branch local coordinate system.
+ vec3 w=normalize(vec3(-1.5+abs(hash11(num*4.)*.8),1,-1.));
+ vec3 u=normalize(cross(w,vec3(0,1.,0.)));
+
+ float scale=3.5;
+ p/=scale;
+ vec3 q = p;
+ // Make the iterations lessen over distance for speed up...
+ int it = 10-int(min(t*.03, 9.0));
+
+ float h = hash11(num*7.)*.3+.3;
+ vec3 uwc = normalize(cross(u,w));
+ int dontFold = int(hash11(num*23.0) * 9.0)+3;
+
+ float thick = .2/(h-.24);
+ for (int i = 0; i < it; i++)
+ {
+ f = scale*max(p.y-h,max(-p.y,length(p.xz)-.06/(p.y+thick)))/s;
+ if (f <= d)
+ {
+ d = f;
+ matID = 1.0;
+ }
+
+ // Randomly don't fold the space to give more branch types...
+ if (i != dontFold)
+ p.xz = abs(p.xz);
+
+ p.y-=h;
+ p*=mat3(u,uwc,w);
+ p*=ss;
+ s*=ss;
+ }
+
+ float fr = .2;
+ f = (length(p)-fr)/s;
+ if (f <= d)
+ {
+ d = f;
+ matID = 2.0;
+ }
+
+ q.y -= h*1.84;
+ h *= 1.1;
+ for (int i = 0; i < it; i++)
+ {
+ p = (normalize(hash31(num+float(i+19))-.5))*vec3(h, 0.1, h);
+ p+=q;
+ float ds =length(p)-.015;
+ if (ds <= d)
+ {
+ matID = 3.0+float(i);
+ d = ds;
+ }
+ }
+
+ return vec2(d, matID);
+}
+
+//------------------------------------------------------------------------------
+float sphereRadius(float t)
+{
+ t = abs(t-.0);
+ t *= 0.003;
+ return clamp(t, 1.0/iResolution.y, 3000.0/iResolution.y);
+}
+
+//------------------------------------------------------------------------------
+float shadow( in vec3 ro, in vec3 rd, float dis)
+{
+ float res = 1.0;
+ float t = .1;
+ float h;
+
+ for (int i = 0; i < 15; i++)
+ {
+ vec3 p = ro + rd*t;
+
+ h = map(p,dis).x;
+ res = min(3.*h / t, res);
+ t += h;
+ }
+ res += t*t*.08; // Dim over distance
+ return clamp(res, .6, 1.0);
+}
+
+//-------------------------------------------------------------------------------------------
+// Taken almost straight from Inigo's shaders, thanks man!
+// But I've changed a few things like the for-loop is now a float,
+// which removes the need for the extra multiply and divide in GL2
+float calcOcc( in vec3 pos, in vec3 nor, float d )
+{
+ float occ = 0.0;
+ float sca = 1.0;
+ for(float h= 0.05; h < .3; h+= .07)
+ {
+ vec3 opos = pos + h*nor;
+ float d = map( opos, d ).x;
+ occ += (h-d)*sca;
+ sca *= 0.95;
+ }
+ return clamp( 1.0 - 2.0*occ, 0.0, 1.0 );
+}
+
+//-------------------------------------------------------------------------------------------
+float marchScene(in vec3 rO, in vec3 rD, vec2 co)
+{
+ float t = hash12(co)*.5;
+ vec4 normal = vec4(0.0);
+ vec3 p;
+ float alphaAcc = 0.0;
+
+ spointer = 0;
+ for( int j=min(0,iFrame); j < 140; j++ )
+ {
+ // Check if it's full or too far...
+ if (spointer == STACK_SIZE || alphaAcc >= 1.) break;
+ p = rO + t*rD;
+ float sphereR = sphereRadius(t);
+ vec2 h = map(p, t);
+ if( h.x <= sphereR)
+ {
+ //h = max(h,0.0);
+ float alpha = (1.0 - alphaAcc) * min(((sphereR-h.x+.01) / sphereR), 1.0);
+ stack[spointer].pos = p;
+ stack[spointer].alpha = alpha;
+ stack[spointer].dist = t;
+ stack[spointer].mat = int(h.y);
+ alphaAcc += alpha;
+ spointer++;
+ }
+ t += h.x+t*0.007;
+ }
+ return alphaAcc;
+}
+
+//-------------------------------------------------------------------------------------------
+vec3 lighting(in vec4 mat, in vec3 pos, in vec3 normal, in vec3 eyeDir, in float d)
+{
+
+ float sh = shadow(pos+sunLight*.01, sunLight, d);
+ float occ = calcOcc(pos, normal, d);
+ // Light surface with 'sun'...
+ vec3 col = mat.xyz * SUN_COLOUR*(max(dot(sunLight,normal)*.5+.2, 0.0))*sh;
+ // Ambient...
+
+ float fre = clamp(1.0+dot(normal,eyeDir),0.0,1.0)*.3;
+ float bac = clamp(.8*dot( normal, normalize(vec3(-sunLight.x,0.0,-sunLight.z))), 0.0, 1.0 );
+ normal = reflect(eyeDir, normal); // Specular...
+ col += pow(max(dot(sunLight, normal), 0.0), 16.0) * SUN_COLOUR * sh * mat.w * occ;
+ col += bac*mat.xyz * occ;
+ col += mat.xyz * abs(normal.y)*.3*occ;
+ col += SUN_COLOUR * fre *.2*occ;
+
+ return min(col, 1.0);
+}
+
+//------------------------------------------------------------------------------
+vec3 getNormal2(vec3 p, float e)
+{
+ return normalize( vec3( map(p+vec3(e,0.0,0.0), 0.).x - map(p-vec3(e,0.0,0.0), 0.).x,
+ map(p+vec3(0.0,e,0.0), 0.).x - map(p-vec3(0.0,e,0.0), 0.).x,
+ map(p+vec3(0.0,0.0,e), 0.).x - map(p-vec3(0.0,0.0,e), 0.).x));
+}
+
+vec3 getNormal(vec3 pos, float ds)
+{
+
+ float c = map(pos, 0.).x;
+ // Use offset samples to compute gradient / normal
+ vec2 eps_zero = vec2(ds, 0.0);
+ return normalize(vec3(map(pos + eps_zero.xyy, 0.0).x, map(pos + eps_zero.yxy, 0.0).x,
+ map(pos + eps_zero.yyx, 0.0).x) - c);
+}
+
+
+//------------------------------------------------------------------------------
+vec3 getSky(vec3 dir)
+{
+ vec3 col = mix(vec3(FOG_COLOUR), vec3(.0, 0.4,0.6),(abs(dir.y)));
+ return col;
+}
+
+vec2 rot2D(inout vec2 p, float a)
+{
+ return cos(a)*p - sin(a) * vec2(p.y, -p.x);
+}
+
+/* quaternions */
+
+vec4 qmult(vec4 p, vec4 q) {
+ vec3 pv = p.xyz, qv = q.xyz;
+ return vec4(p.w * qv + q.w * pv + cross(pv, qv), p.w * q.w - dot(pv, qv));
+}
+
+vec4 qrotor(vec3 axis, float phi) {
+ phi *= 0.5;
+ return vec4(sin(phi) * normalize(axis), cos(phi));
+}
+
+vec3 rotate(vec3 point, vec4 rotor) {
+ vec3 rotv = rotor.xyz;
+ return qmult(rotor, vec4(point * rotor.w - cross(point, rotv), dot(point, rotv))).xyz;
+}
+
+vec4 slerp(vec3 u0, vec3 u1, float t) {
+ return qrotor(cross(u0, u1), t * acos(dot(u0, u1)));
+}
+// Thaanks to DR2 for this matrix code...
+mat3 viewMat (float ay, float az)
+{
+ vec2 o, ca, sa;
+ o = vec2 (ay, az);
+ ca = cos (o);
+ sa = sin (o);
+ return mat3 (ca.y, 0., - sa.y, 0., 1., 0., sa.y, 0., ca.y) *
+ mat3 (1., 0., 0., 0., ca.x, - sa.x, 0., sa.x, ca.x);
+}
+
+//==============================================================================
+void mainImage( out vec4 fragColour, in vec2 fragCoord )
+{
+ vec2 mouseXY = iMouse.xy / iResolution.xy;
+ vec2 uv = (-iResolution.xy + 2.0 * fragCoord ) / iResolution.y;
+ sunLight = normalize(vec3(-.8,1.8,-1.5));
+
+ // Camera stuff...
+ // A simple cylindrical projection with normal Y
+ float time = iTime*1.+mouseXY.x*10.0;
+
+ #ifdef MOVE_CAMERA
+
+ vec3 camera = getCamPos(time*.2);
+ vec3 lookat = getCamPos(time*.2+10.);
+
+ #else
+
+ // Don't move the camera bodge...
+ vec3 camera = getCamPos(0.0);
+ vec3 lookat = getCamPos(0.0);
+ lookat += vec3(40.0*sin(time * 5.28), 0., 40.0*cos(time * .28) );
+
+ #endif
+
+ float ride = sin(time*.5)*.4;
+
+
+ //mat3 camMat = getCamMat(camera, lookat, 0.0);
+ //uv *= .7;
+ // I didn't want to normalize here because it'll distort across the vertical slightly...
+ // But it looks like it's needed for a unit ray length...
+// vec3 seedDir = camMat * normalize(vec3(0.0, uv.y, 1.));
+// seedDir.xz = rot2D(seedDir.xz, uv.x*1.13); // Adjusted for rotation PI (roughly!) :)
+
+
+ // Now using Quaternions, thanks to munrocket for the Quat code.
+ // https://www.shadertoy.com/view/3stXR2
+// Quarternion version..
+// vec3 seedDir = normalize(vec3(0,0, 1.));
+// vec2 rotXY = vec2(uv.x+time*.5, -uv.y+ride);
+// vec4 rotor = qrotor(vec3(0., 1., 0.), rotXY.x);
+// rotor = qmult(rotor, qrotor(vec3(1., 0., 0.), rotXY.y));
+ //seedDir = rotate(seedDir, rotor);
+
+ vec3 seedDir = normalize(vec3(0,0, 1.));
+ seedDir = viewMat (uv.y+ride, uv.x+time*.5)*seedDir;
+
+
+
+ vec3 rd = seedDir;
+
+ vec3 col = vec3(0);
+
+ vec3 sky = getSky(rd);
+
+
+ // Build the stack returning the final alpha value...
+ float alpha = marchScene(camera, rd, fragCoord);
+ vec4 mat;
+ // Render the stack...
+ if (alpha > .0)
+ {
+ for (int i = 0; i < spointer; i++)
+ {
+ vec3 pos = stack[i].pos;
+ float d = stack[i].dist;
+
+ vec3 nor = getNormal(pos, sphereRadius(d));
+ int matID = stack[i].mat;
+ if (matID == 0) mat = grassTexture(pos, nor);
+ else
+ if (matID == 1) mat = barkTexture(pos, nor);
+ else
+ if (matID == 2) mat = leavesTexture(pos, nor);
+ else
+ mat = fruitTexture(pos, nor, float(matID - 3));
+
+ mat *= randomTint(pos);
+
+ vec3 temp = lighting(mat, pos, nor, rd, d);
+ if (matID == 3) temp=temp*.4+vec3(.15, .01,0);
+
+ temp = mix(sky, temp , exp(-d*.01));
+ col += temp * stack[i].alpha;
+ }
+ }
+ vec4 cc = getClouds(camera, rd);
+ sky+= pow(max(dot(sunLight, rd), 0.0), 20.0)*SUN_COLOUR*.03;
+ //sky = clamp(sky, 0.0,1.);
+ sky = mix(sky, cc.xyz, cc.w);
+ col += sky * (1.0-alpha);
+
+ float d = stack[0].dist;
+ col+= floatingSeeds(camera, rd, d);
+
+
+ // Sun glow effect...
+ col+=pow(max(dot(sunLight, rd), 0.0), 6.0)*SUN_COLOUR*.2;
+
+ // Clamp and contrast...
+ //col = col * vec3(1.1, 1.1,.9);
+ col = clamp(col,0.,1.);
+ col = col*col*(3.0-2.0*col);
+
+
+ // The usual vignette...which manages to add more vibrancy...
+ vec2 q = fragCoord / iResolution.xy;
+ col *= 0.3 + 0.7*pow(90.0*q.x*q.y*(1.0-q.x)*(1.0-q.y), 0.5);
+ // A nice fade in start...
+
+
+ col *= smoothstep(0.0, 5.0, time);
+ fragColour = vec4(sqrt(col), 1.0);
+
+}
diff --git a/tests/real/oscars_chair.frag.expected b/tests/real/oscars_chair.frag.expected
index 4b580743..76ada657 100644
--- a/tests/real/oscars_chair.frag.expected
+++ b/tests/real/oscars_chair.frag.expected
@@ -1,6 +1,4 @@
-/* File generated with
- * http://www.ctrl-alt-test.fr
- */
+// Generated with (https://github.com/laurentlb/Shader_Minifier/)
#ifndef OSCARS_CHAIR_FRAG_EXPECTED_
# define OSCARS_CHAIR_FRAG_EXPECTED_
# define VAR_tex1 "a"
@@ -9,16 +7,16 @@ const char *oscars_chair_frag =
"#version 130\n"
"vec2 v=gl_FragCoord.xy/1280;"
"uniform sampler2D a;"
- "float y=gl_TexCoord[0].x/44100,i,m,s=1,r;"
- "vec3 c=vec3(7,5,19),z=vec3(-4,0,3),f,x,g=vec3(0,5,-7),e;"
- "float n(vec2 x,float v)"
+ "float y=gl_TexCoord[0].x/44100,i,m,s=1,f;"
+ "vec3 c=vec3(7,5,19),z=vec3(-4,0,3),x,r,g=vec3(0,5,-7),e;"
+ "float n(vec2 r,float v)"
"{"
"float y=0,c=1,m=1;"
- "for(int f=0;f25&&y<=60&&a.y<1)"
- "f=mix(f,vec3(1,.01,.01)/9,smoothstep(.2,.204,n(a,2.3)));"
- "m=.15+.017*n(v*vec2(.12,12)+n(v,2)/2,1.4)+f.x/2;"
- "f*=pow(m,4)*168;"
+ "x=mix(x,vec3(1,.01,.01)/9,smoothstep(.2,.204,n(a,2.3)));"
+ "m=.15+.017*n(v*vec2(.12,12)+n(v,2)/2,1.4)+x.x/2;"
+ "x*=pow(m,4)*168;"
"return m;"
"}"
- "if(abs(v.x)<1.5&&abs(v.y-3)<3&&x.z<-c.z+.1)"
+ "if(abs(v.x)<1.5&&abs(v.y-3)<3&&r.z<-c.z+.1)"
"{"
- "f=vec3(n(v*vec2(1,.2),2)+2)/4;"
+ "x=vec3(n(v*vec2(1,.2),2)+2)/4;"
"v=abs(v+n(v,2)/60-vec2(0,3));"
"if(v.x>1.475||v.y>2.975)"
- "f*=.3;"
+ "x*=.3;"
"return 11-clamp(abs(max(abs(v.x-.7)+.3,abs(v.y-1.4)-.3)-.7),.05,.14)*11+n(v*vec2(1,.2),2.5);"
"}"
"m=1-smoothstep(.1,.12,n(v/2+10,2.5)-.1);"
- "f=mix(vec3(.7),mix(vec3(1,1,.5)/1.4+n(v*8,1.2)/15,vec3(.65,1,.5),m)/4*min(v.y*3-1.5+.8,1),step(.5,v.y))-step(.4,n(v*3,1.6))/140;"
- "return n(v,2)/2-f.y*4;"
+ "x=mix(vec3(.7),mix(vec3(1,1,.5)/1.4+n(v*8,1.2)/15,vec3(.65,1,.5),m)/4*min(v.y*3-1.5+.8,1),step(.5,v.y))-step(.4,n(v*3,1.6))/140;"
+ "return n(v,2)/2-x.y*4;"
"}"
"vec3 t(vec2 v,out vec3 y)"
"{"
- "f=vec3(.004,0,0);"
- "return normalize(vec3(p(v+f.xy,y)-p(v-f.xy,y),.16,p(v+f.yx,y)-p(v-f.yx,y)));"
+ "x=vec3(.004,0,0);"
+ "return normalize(vec3(p(v+x.xy,y)-p(v-x.xy,y),.16,p(v+x.yx,y)-p(v-x.yx,y)));"
"}"
"float n(vec3 v)"
"{"
- "float x=y>81?-1.4:-2.827;"
+ "float r=y>81?"
+ "-1.4:"
+ "-2.827;"
"v-=z;"
- "v.y+=(n(v.xz*=mat2(cos(x),sin(x),-sin(x),cos(x)),2.5)/2+.5)*clamp(y/3-29,0,5)+c.y-1.25;"
+ "v.y+=(n(v.xz*=mat2(cos(r),sin(r),-sin(r),cos(r)),2.5)/2+.5)*clamp(y/3-29,0,5)+c.y-1.25;"
"v.x+=n(v.yz,2.5)*clamp(y/3-29,0,5)-max(0,v.y)/10;"
"v.z=abs(v.z);"
"return min(min(min(max(length(max(abs(v.xz)-vec2(.45,.41),0))-.25,abs(v.y)-.02),length(v-vec3(clamp(v.x,-.6,.6),-.1,.6))-.025),length(vec3(abs(v.x)-.6+min(0,v.y)/5,v.y-clamp(v.y,-1.24,1.5*step(0,v.x)),v.z-.6))-.025),max(length(max(abs(v.yz-vec2(1,0))-vec2(.5,.35),0))-.25,abs(v.x-.6)-.03));"
"}"
- "float h(vec3 v,vec3 y)"
+ "float h(vec3 v,vec3 x)"
"{"
- "float x=0,f=0;"
- "for(;f<200&&x<30;++f)"
- "i=min(i,m=n(v+y*x)),x+=m/2;"
- "return x;"
+ "float y=0,r=0;"
+ "for(;r<200&&y<30;++r)"
+ "i=min(i,m=n(v+x*y)),y+=m/2;"
+ "return y;"
"}"
"vec3 w(vec3 v,vec3 a)"
"{"
- "vec3 r;"
- "x=v+a*(m=min((sign(a.x)*c.x-v.x)/a.x,min((sign(a.y)*c.y-v.y)/a.y,(sign(a.z)*c.z-v.z)/a.z)));"
- "if(abs(x.y)>c.y-.001)"
- "i=0,f=t(x.xz/2,r),r*=min(vec3(.75,1,.75)+min(c.x-abs(x.x),c.z-abs(x.z))/4,1)*smoothstep(0,2.2,length(x-z-vec3(0,-c.y+1.25,0)));"
+ "vec3 f;"
+ "r=v+a*(m=min((sign(a.x)*c.x-v.x)/a.x,min((sign(a.y)*c.y-v.y)/a.y,(sign(a.z)*c.z-v.z)/a.z)));"
+ "if(abs(r.y)>c.y-.001)"
+ "i=0,x=t(r.xz/2,f),f*=min(vec3(.75,1,.75)+min(c.x-abs(r.x),c.z-abs(r.z))/4,1)*smoothstep(0,2.2,length(r-z-vec3(0,-c.y+1.25,0)));"
"else"
"{"
"i=1;"
- "f=t(vec2(x.x-x.z-c.z,x.y+c.y),r).xzy;"
- "if(abs((x/c).x)>abs((x/c).z)&&abs((x/c).x)>abs((x/c).y))"
- "f=f.zyx*vec3(-sign(x.x),1,-1);"
- "r*=mix(vec3(1,1,.5),vec3(1),min((-abs(x.y)+c.y)/4,1))*sqrt(min((-abs(x.y)+c.y)*8+.4,1));"
+ "x=t(vec2(r.x-r.z-c.z,r.y+c.y),f).xzy;"
+ "if(abs((r/c).x)>abs((r/c).z)&&abs((r/c).x)>abs((r/c).y))"
+ "x=x.zyx*vec3(-sign(r.x),1,-1);"
+ "f*=mix(vec3(1,1,.5),vec3(1),min((-abs(r.y)+c.y)/4,1))*sqrt(min((-abs(r.y)+c.y)*8+.4,1));"
"}"
- "r*=mix(4,1,smoothstep(1,2,length(x/c)))*max(0,1+3*dot(f,normalize(g-x)))/16*(1-smoothstep(0,2.5,length(max(abs(x)-c+1,0))));"
- "r=(r+pow(clamp(dot(normalize(normalize(g-x)-a),f),0,1),64)*(r*.8+.2))*exp2(-length(g-x)/1.2)*s*20*mix(.02,2,smoothstep(.6,.7,dot(normalize(g-x),e)));"
+ "f*=mix(4,1,smoothstep(1,2,length(r/c)))*max(0,1+3*dot(x,normalize(g-r)))/16*(1-smoothstep(0,2.5,length(max(abs(r)-c+1,0))));"
+ "f=(f+pow(clamp(dot(normalize(normalize(g-r)-a),x),0,1),64)*(f*.8+.2))*exp2(-length(g-r)/1.2)*s*20*mix(.02,2,smoothstep(.6,.7,dot(normalize(g-r),e)));"
"if(y<=97)"
- "r+=pow(vec3(2.2,.7,.3)*exp(-abs(n(x.xz/2+x.y/4-y/2,1.5))*10*n(-x.xy+y-x.z,1.5)+n(x.xy-y/3,2)*6-x.y-c.y-x.z-c.z+(y-88)/4+x.x/9),vec3(2))/70;"
- "return r;"
+ "f+=pow(vec3(2.2,.7,.3)*exp(-abs(n(r.xz/2+r.y/4-y/2,1.5))*10*n(-r.xy+y-r.z,1.5)+n(r.xy-y/3,2)*6-r.y-c.y-r.z-c.z+(y-88)/4+r.x/9),vec3(2))/70;"
+ "return f;"
"}"
"void main()"
"{"
@@ -95,68 +95,69 @@ const char *oscars_chair_frag =
"{"
"gl_FragColor*=0;"
"for(int p=-6;p<=6;++p)"
- "for(int t=-6;t<=6;++t)"
- "if(t*t+p*p<37)"
- "gl_FragColor=mix(gl_FragColor,max(gl_FragColor,texelFetch(a,ivec2(gl_FragCoord.xy+vec2(t,p)*texelFetch(a,ivec2(gl_FragCoord.xy),0).w),0)),.06);"
+ "for(int d=-6;d<=6;++d)"
+ "if(d*d+p*p<37)"
+ "gl_FragColor=mix(gl_FragColor,max(gl_FragColor,texelFetch(a,ivec2(gl_FragCoord.xy+vec2(d,p)*texelFetch(a,ivec2(gl_FragCoord.xy),0).w),0)),.06);"
"}"
"else"
" if(abs((v.y+=.22)-.5)<.2)"
"{"
- "vec3 t=vec3(0);"
+ "vec3 d=vec3(0);"
"for(int p=0;p<8;++p)"
"{"
- "float l=2.7,d;"
- "vec3 o=vec3(10+y/4,-4,-1),b=vec3(-7,-2,0),u,C;"
+ "float l=2.7;"
+ "vec3 t=vec3(10+y/4,-4,-1),o=vec3(-7,-2,0);"
"m=0;"
"if(y>97)"
- "b=o=vec3(0,-4,y-97),b.z-=1,g=vec3(0,3,-22),s=.4,c=vec3(3,7,28),z=vec3(-4,0,13);"
+ "o=t=vec3(0,-4,y-97),o.z-=1,g=vec3(0,3,-22),s=.4,c=vec3(3,7,28),z=vec3(-4,0,13);"
"else"
" if(y>81)"
- "b=o=vec3(0,-3.6,97-y),b.z-=1,g=vec3(0,5,-5),s=.01,l=1.7,c=vec3(7,5,9),z=vec3(0,0,-2);"
+ "o=t=vec3(0,-3.6,97-y),o.z-=1,g=vec3(0,5,-5),s=.01,l=1.7,c=vec3(7,5,9),z=vec3(0,0,-2);"
"else"
" if(y>60)"
- "o=vec3((y-60)/5-1,-2,13),b=vec3(-7,-5,-7),g=vec3(0,5,-3),m=sin(y-60)/10-.9,c=vec3(7,5,9),z=vec3(-4,0,2);"
+ "t=vec3((y-60)/5-1,-2,13),o=vec3(-7,-5,-7),g=vec3(0,5,-3),m=sin(y-60)/10-.9,c=vec3(7,5,9),z=vec3(-4,0,2);"
"else"
" if(y>25)"
- "o=vec3(0,0,25-y/2.7),b=vec3(0,-4,18-y/2.7),g=vec3(-2,5,-7),c=vec3(9,5,14),z=vec3(3.5,0,-6);"
+ "t=vec3(0,0,25-y/2.7),o=vec3(0,-4,18-y/2.7),g=vec3(-2,5,-7),c=vec3(9,5,14),z=vec3(3.5,0,-6);"
"else"
" m=-.9;"
- "r=7;"
+ "f=7;"
"e=vec3(0,cos(m),sin(m));"
- "u=normalize(b-o);"
- "C=normalize(vec3(-u.z,0,u.x));"
+ "vec3 u=normalize(o-t),C=normalize(vec3(-u.z,0,u.x));"
"if(y>81&&y<=97)"
"u.y+=n(vec2(y+6)/2,2)*.05,C.y+=n(vec2(y)/3,2)*.08;"
"u=mat3(C,cross(C,u),u)*normalize(vec3(v*2+vec2(p&1,p/2)/1200-1,l));"
- "d=h(o,u);"
- "if(d<30)"
- "x=o+u*d,f=vec3(.02,0,0),f=normalize(vec3(n(x+f.xyy)-m,n(x+f.yxy)-m,n(x+f.yyx)-m)),r=2,C=w(x,reflect(u,f))*pow(1+dot(u,f),3);"
+ "float D=h(t,u);"
+ "if(D<30)"
+ "r=t+u*D,x=vec3(.02,0,0),x=normalize(vec3(n(r+x.xyy)-m,n(r+x.yxy)-m,n(r+x.yyx)-m)),f=2,C=w(r,reflect(u,x))*pow(1+dot(u,x),3);"
"else"
"{"
- "C=w(o,u);"
- "l=(.3+.7*pow(1+dot(u,f),2)/4)*(.1+.9*step(x.y,-c.y+.01));"
- "o=reflect(u,f);"
- "d=m;"
- "r=2;"
- "i=100.;"
- "u=normalize(g-x);"
- "h(x+u*.01,u);"
- "C*=.4+.6*smoothstep(0,n(x)/5,i);"
- "if(x.y<-c.y+.01)"
- "if(h(x,o)<30)"
+ "C=w(t,u);"
+ "l=(.3+.7*pow(1+dot(u,x),2)/4)*(.1+.9*step(r.y,-c.y+.01));"
+ "t=reflect(u,x);"
+ "D=m;"
+ "f=2;"
+ "i=1e2;"
+ "u=normalize(g-r);"
+ "h(r+u*.01,u);"
+ "C*=.4+.6*smoothstep(0,n(r)/5,i);"
+ "if(r.y<-c.y+.01)"
+ "if(h(r,t)<30)"
"l*=.2,C*=.7;"
- "C+=w(x,o)*l*mix(vec3(1),C,.8);"
+ "C+=w(r,t)*l*mix(vec3(1),C,.8);"
"}"
"if(y>60&&y<=97)"
- "gl_FragColor.w=y<=81?(d-15)/6:d/15;"
+ "gl_FragColor.w=y<=81?"
+ "(D-15)/6:"
+ "D/15;"
"C*=smoothstep(0,2,abs(y-60))*smoothstep(0,3,abs(y-112))*(1-(pow(abs(v.x*2-1),4)+pow(abs(v.y*2-1)*2.5,4))*.4);"
"C=pow(.003+C*40,vec3(1,1.1,1.2));"
- "t+=C/(C+.4)*1.1;"
+ "d+=C/(C+.4)*1.1;"
"}"
"m=0;"
"for(int p=0;p<64;++p)"
"m+=texture(a,clamp((v-vec2(.4,.532)+vec2(p&7,p/8)/10000)*4*vec2(2.25,4),0,1)).x+texture(a,clamp((v-vec2(.38,.33)+vec2(p&7,p/8)/10000)*vec2(2.25,4),0,1)).y;"
- "gl_FragColor.xyz=sqrt(t/8)+m/104*clamp((6-abs(y-10))/5,0,1);"
+ "gl_FragColor.xyz=sqrt(d/8)+m/104*clamp((6-abs(y-10))/5,0,1);"
"}"
"}";
diff --git a/tests/real/relief_tunnel.frag b/tests/real/relief_tunnel.frag
deleted file mode 100644
index c9d3ec2d..00000000
--- a/tests/real/relief_tunnel.frag
+++ /dev/null
@@ -1,34 +0,0 @@
-uniform vec2 resolution;
-uniform float time;
-uniform sampler2D tex0;
-uniform sampler2D tex1;
-uniform sampler2D tex2;
-uniform sampler2D tex3;
-
-void main(void)
-{
- vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
- vec2 uv;
-
- float r = sqrt( dot(p,p) );
- float a = atan(p.y,p.x) + 0.5*sin(0.5*r-0.5*time);
-
- float s = 0.5 + 0.5*cos(7.0*a);
- s = smoothstep(0.0,1.0,s);
- s = smoothstep(0.0,1.0,s);
- s = smoothstep(0.0,1.0,s);
- s = smoothstep(0.0,1.0,s);
-
- uv.x = time + 1.0/( r + .2*s);
- uv.y = 3.0*a/3.1416;
-
- float w = (0.5 + 0.5*s)*r*r;
-
- vec3 col = texture2D(tex0,uv).xyz;
-
- float ao = 0.5 + 0.5*cos(7.0*a);
- ao = smoothstep(0.0,0.4,ao)-smoothstep(0.4,0.7,ao);
- ao = 1.0-0.5*ao*r;
-
- gl_FragColor = vec4(col*w*ao,1.0);
-}
diff --git a/tests/real/robin.frag b/tests/real/robin.frag
new file mode 100644
index 00000000..b71aa3f6
--- /dev/null
+++ b/tests/real/robin.frag
@@ -0,0 +1,459 @@
+// Copied from https://www.shadertoy.com/view/4tl3RM
+// Robin
+// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
+// Created by David Hoskins.
+
+// The winter Robin - a UK resident bird.
+// They occasionally sing at night next to street lights.
+// Despite their cute appearance, they are aggressively territorial.
+
+// Sphere tracing based on eiffie's circle-of-confusion ideas.
+// Distance estimation shapes, like 'Segment' - thanks to iq.
+
+//--------------------------------------------------------------------------
+#define SUN_COLOUR vec3(1., .76, .6)
+
+vec4 animParts; // .x = Puff Chest, head tilt, head nod, .w = tweet!
+vec4 body; // .x = Tilt down, wings, jump, .w = crouching.
+vec2 zoomTurn; // Zoom and turn hacked into a vec2 to keep the global vars low.
+
+vec4 aStack[2];
+vec4 dStack[2];
+
+// CubeMap OpenGL clamping fix, thanks to w23/reinder...
+vec3 CubeMap(in samplerCube sam, in vec3 v, float size)
+{
+ float M = max(max(abs(v.x), abs(v.y)), abs(v.z));
+ float scale = (float(size) - 1.) / float(size);
+ if (abs(v.x) != M) v.x *= scale;
+ if (abs(v.y) != M) v.y *= scale;
+ if (abs(v.z) != M) v.z *= scale;
+ return texture(sam, v).xyz;
+}
+
+//----------------------------------------------------------------------------------------
+float Hash(float p)
+{
+ vec2 p2 = fract(vec2(p * 5.3983, p * 5.4427));
+ p2 += dot(p2.yx, p2.xy + vec2(21.5351, 14.3137));
+ return fract(p2.x * p2.y * 95.4337);
+}
+
+float Hash(vec2 p)
+{
+ p = fract(p * vec2(5.3983, 5.4427));
+ p += dot(p.yx, p.xy + vec2(21.5351, 14.3137));
+ return fract(p.x * p.y * 95.4337);
+}
+
+//----------------------------------------------------------------------
+float noise( in vec3 x )
+{
+ vec3 p = floor(x);
+ vec3 f = fract(x);
+ f = f*f*(3.0-2.0*f);
+
+ vec2 uv = (p.xy+vec2(37.0,17.0)*p.z) + f.xy;
+ vec2 rg = textureLod( iChannel1, (uv+ 0.5)/256.0, 0.0 ).yx;
+ return mix( rg.x, rg.y, f.z );
+}
+
+//----------------------------------------------------------------------
+float fbm( vec3 p )
+{
+ float f;
+ f = 1.600*noise( p ); p = p*2.02;
+ f += 0.3500*noise( p ); p = p*2.33;
+ f += 0.2250*noise( p ); p = p*2.01;
+ return f;
+}
+
+vec2 Rot2(vec2 p, float a)
+{
+ float si = sin(a);
+ float co = cos(a);
+ return mat2(co, si, -si, co) * p;
+}
+float Noise(float n)
+{
+ float f = fract(n);
+ n = floor(n);
+ f = f*f*(3.0-2.0*f);
+ return mix(Hash(n), Hash(n+1.0), f);
+
+}
+
+float NoiseSlope(float n, float loc)
+{
+ float f = fract(n);
+ n = floor(n);
+ f = smoothstep(0.0, loc, f);
+ return mix(Hash(n), Hash(n+1.0), f);
+
+}
+//----------------------------------------------------------------------------------------
+float Sphere( vec3 p, float s )
+{
+ return length(p)-s;
+}
+
+//--------------------------------------------------------------------------
+vec3 TexCube(in vec3 p, in vec3 n )
+{
+ vec3 x = texture(iChannel0, p.yz ).xzy;
+ vec3 y = texture(iChannel0, p.zx ).xyz;
+ //y = y*y;
+ vec3 z = texture(iChannel1, p.xy, 2.0).yyy;
+ return (x*abs(n.x) + y*abs(n.y) + z*abs(n.z))/(abs(n.x)+abs(n.y)+abs(n.z))*.9;
+}
+
+float Cylinder( vec3 p, vec2 h )
+{
+ vec2 d = abs(vec2(length(p.xz),p.y)) - h;
+ return min(max(d.x,d.y),0.0) + length(max(d,0.0));
+}
+
+//----------------------------------------------------------------------------------------
+float Segment(vec3 p, vec3 a, vec3 b, float r1, float r2)
+{
+ vec3 pa = p - a;
+ vec3 ba = b - a;
+ float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );
+ return length( pa - ba*h ) - r1 + r2*h;
+}
+
+//----------------------------------------------------------------------------------------
+float RoundBox( vec3 p, vec3 b, float r )
+{
+ return length(max(abs(p)-b,0.0))-r;
+}
+
+//----------------------------------------------------------------------------------------
+float sMin( float a, float b, float k )
+{
+
+ float h = clamp(0.5 + 0.5*(b-a)/k, 0.0, 1.0 );
+ return mix( b, a, h ) - k*h*(1.-h);
+}
+//----------------------------------------------------------------------------------------
+vec3 Colour( vec3 p, vec3 nor, out float spec)
+{
+ vec3 post = p;
+ p.xz = Rot2(p.xz, zoomTurn.x);
+ vec3 orig = p;
+ p.y-=body.z;
+ p.yz = Rot2(p.yz, body.x);
+ vec3 mat = TexCube(p*.5, nor).zxy * .45;
+
+ spec = 0.0;
+
+ // Body
+ float d = RoundBox(p-vec3(0.0, -1.4,-.3),vec3(.3+.1*animParts.x, .0, .1+.3*animParts.x), .3);
+ d = sMin(d, Sphere(p-vec3(0.0, -.25,0.0), 1.33), 2.2);
+
+ // Wings...
+ vec3 p2 = p;
+ p2.x = abs(p2.x);
+ d = sMin(d,Segment(p2,vec3(1.5, -.2,1.7), vec3(1.5, -1.,-1.6), .3, .3), .4);
+ vec3 wing = vec3(.4, 0.32, 0.2)*texture(iChannel1, p2.zy*vec2(.05, .3)).x;
+ mat = mix(wing*wing, mat, clamp(Segment(p2,vec3(1.3, 0.2,.2), vec3(1.5+body.y, -1.,-1.6), .4, .4), 0., 1.0));
+
+ // Tail...
+ vec3 tail = vec3(.4)*texture(iChannel1, p.zy*vec2(.05, .3)).x;
+ mat = mix(tail*tail, mat, clamp(Segment(p2,vec3(.1, -.5, -1.5), vec3(.15, -1.2, -8.0), .2, .2), 0.0, 1.0));
+
+ p2 = p;
+ p2.xy = Rot2(p2.xy, animParts.y); // Tilt head
+ p2.zy = Rot2(p2.zy, animParts.z); // Nod
+
+ // Red Breast and head...
+ d = sMin(d, Sphere(p2-vec3(0.0, 1.,1.4), .8), 1.0);
+ float f = Sphere(p-vec3(0.0, -.9, 2.1), 1.5);
+ f = min(f, Sphere(p2-vec3(0.0, .5, 1.9),1.2));
+ f += fbm(p*20.0)*.2;
+ f = max(f, -Sphere(p2-vec3(0.0, 2.0, 1.2), 1.1));
+ mat = mix(mat,vec3(.4, .1, 0.0) * (.8+fbm(p*12.)*.2), clamp((d-f)*3.0 - (1.0-step(-3.0, orig.y))*3.0,0.0, 1.0));
+
+ // Beak...
+ if (d > Segment(p2-vec3(0.0, .9,2.5),vec3(0.0, 0.0,-.4), vec3(.0, animParts.w*.2,.4), .15, .1))
+ {
+ spec = .2;
+ mat = vec3(0.02, 0.01, 0.);
+ }
+ // Black shiny eyes
+ p2.x = abs(p2.x);
+ if (Sphere(p2-vec3(.35, 1.1,2.05), .11) < d)
+ {
+ mat = vec3(0.);
+ spec = .25;
+ }
+ // Post...
+ vec3 pCol = mix(vec3(.2), vec3(.05,.04, .0),fbm(post*2.0)*.5);
+ pCol = mix( pCol,vec3(.05), abs(sin( length(post.xz-vec2(0.2, .4))*34.0))*abs(nor.y));
+ mat = mix(pCol,mat, step(-3.4, post.y));
+
+ // Legs...
+ orig.y-=body.w;
+ orig.x = abs(orig.x);
+ f = 1.0-clamp(Segment(orig,vec3(0.5, -2.0-body.z,-.5), vec3(.8, -3.5,0.6), .53, .03)+(1.0-step(-3.5,orig.y))*50.0, .0, 1.0);
+ mat = mix( mat, vec3(.05,.02, .02), f);
+ spec = mix(spec, .1, f);
+
+ return mat;
+
+
+}
+
+//--------------------------------------------------------------------------
+
+float Map( vec3 p )
+{
+ float d;
+ vec3 post = p;
+
+ p.xz = Rot2(p.xz, zoomTurn.x);
+ vec3 o = p;
+
+ p.y-=body.z;
+ p.yz = Rot2(p.yz, body.x);
+ // Body
+ d = RoundBox(p-vec3(0.0, -1.4,-.3),vec3(.3+.1*animParts.x, .0, .1+.3*animParts.x), .3);
+ d = sMin(d, Sphere(p-vec3(0.0, -.25,0.0), 1.33), 2.2);
+
+ //Wings...
+ vec3 p2 = p;
+ p2.x = abs(p2.x);
+ d = sMin(d,Segment(p2,vec3(1.3, 0.2,.2), vec3(1.5+body.y, -.5,-1.6), .2, .2), .4);
+
+
+ // Tail...
+ d = sMin(d,Segment(p2,vec3(.6, -.5, -1.5), vec3(.15, -1.2, -8.0), .2, .2), 2.4);
+
+ // Rotate head..
+ p.xy = Rot2(p.xy, animParts.y);
+ p.zy = Rot2(p.zy, animParts.z);
+
+ // Head...
+ d = sMin(d, Sphere(p-vec3(0.0, 1.,1.4), .8), 1.0);
+ //animParts.w = .1;
+ // Beak...
+ d = sMin(d,Segment(p-vec3(0.0, 1.,2.5),vec3(0.0, 0.0,-.4), vec3(.0, animParts.w*.2,.15), .1, .096), .2);
+ d = sMin(d,Segment(p-vec3(0.0, 1.05,2.5),vec3(0.0, -animParts.w*.25,-1.5), vec3(.0, -animParts.w,.16), .1, .1), .05);
+ // Eyes...
+ p.x = abs(p.x);
+ d = min(d, Sphere(p-vec3(.35, 1.1,2.05), .11));
+ // Post...
+ d = min(d, Cylinder(post-vec3(0.2, -12.0, .4), vec2(1.8, 8.5)- fbm(post*5.0)*.1));
+ // Legs...
+ o.x = abs(o.x);
+ o.y-=body.w;
+ d = min(d, Segment(o,vec3(0.5, -2.+body.z+body.w,-.5), vec3(.8, -3.5,0.5), .09, .1));
+ d = min(d, Segment(o,vec3(.8, -3.5,0.5), vec3(.8, -3.5,1.2), .04, .04));
+ d = min(d, Segment(o,vec3(.8, -3.5,0.5), vec3(1.4, -3.5,0.8), .04, .04));
+ d = min(d, Segment(o,vec3(.8, -3.5,0.5), vec3(.1, -3.5,0.8), .04, .04));
+
+ return d;
+}
+
+
+//--------------------------------------------------------------------------
+float Shadow( in vec3 ro, in vec3 rd)
+{
+ float res = 1.0;
+ float t = 0.01;
+ float h;
+
+ for (int i = 0; i < 8; i++)
+ {
+ h = Map( ro + rd*t );
+ res = min(2.5*h / t, res);
+ t += h*.5+.05;
+ }
+ return max(res, 0.0);
+}
+
+////--------------------------------------------------------------------------
+vec3 DoLighting(in vec3 mat, in vec3 pos, in vec3 normal, in vec3 eyeDir, in float d, in float specular)
+{
+ vec3 sunLight = normalize( vec3( -.1, 0.4, 0.3 ) );
+ float sh = Shadow(pos, sunLight);
+ // Light surface with 'sun'...
+ vec3 col = mat * SUN_COLOUR*(max(dot(sunLight,normal), 0.0)) *sh;
+ // Ambient...
+ col += mat * CubeMap(iChannel3, normal, 64.0)*.5;
+
+ normal = reflect(eyeDir, normal); // Specular...
+ col += pow(max(dot(sunLight, normal), 0.0), 1.0) * SUN_COLOUR* texture(iChannel3, normal).xyz * specular *sh;
+ return col;
+}
+
+
+//--------------------------------------------------------------------------
+vec3 GetNormal(vec3 p, float sphereR)
+{
+ vec2 eps = vec2(.01, 0.0);
+ return normalize( vec3(
+ Map(p+eps.xyy) - Map(p-eps.xyy),
+ Map(p+eps.yxy) - Map(p-eps.yxy),
+ Map(p+eps.yyx) - Map(p-eps.yyx) ) );
+}
+
+//--------------------------------------------------------------------------
+float SphereRadius(in float t)
+{
+ return t*.012;
+ //return max(t, 4.0/iResolution.x);
+}
+
+//--------------------------------------------------------------------------
+float Scene(in vec3 rO, in vec3 rD, in vec2 fragCoord)
+{
+ //float t = 0.0;
+ float t = 2.+.1 * Hash(fragCoord.xy*fract(iTime));
+ float alphaAcc = 0.0;
+ vec3 p = vec3(0.0);
+ int hits = 0;
+
+ for( int j=0; j < 40; j++ )
+ {
+ if (hits == 8 || alphaAcc >=1.0 || t > 45.0) break;
+ p = rO + t*rD;
+ float sphereR = SphereRadius(t);
+ float h = Map(p);
+ // Is it within the sphere?...
+ if( h < sphereR)
+ {
+ // Accumulate the alphas with the scoop of geometry from the sphere...
+ // Think of it as filling up an expanding ice-cream scoop flying out of the camera!
+ float alpha = max((1.0 - alphaAcc) * min(((sphereR-h) / sphereR), 1.0),0.0);
+ // put it on the 2 stacks, alpha and distance...
+ aStack[1].yzw = aStack[1].xyz; aStack[1].x = aStack[0].w; aStack[0].yzw = aStack[0].xyz; aStack[0].x = alpha;
+ dStack[1].yzw = dStack[1].xyz; dStack[1].x = dStack[0].w; dStack[0].yzw = dStack[0].xyz; dStack[0].x = t;
+ alphaAcc += alpha;
+ hits++;
+ }
+ t += h*.8;
+ }
+ return clamp(alphaAcc, 0.0, 1.0);
+}
+
+
+//--------------------------------------------------------------------------
+vec3 PostEffects(vec3 rgb, vec2 xy)
+{
+ // Gamma first...
+ rgb = sqrt(rgb);
+
+ // Then...
+ #define CONTRAST 1.1
+ #define SATURATION 1.2
+ #define BRIGHTNESS 1.15
+ rgb = mix(vec3(.5), mix(vec3(dot(vec3(.2125, .7154, .0721), rgb*BRIGHTNESS)), rgb*BRIGHTNESS, SATURATION), CONTRAST);
+
+ // Vignette...
+
+ rgb *= .5 +.5* pow(100.0*xy.x*xy.y*(1.0-xy.x)* (1.0-xy.y), 0.4);
+
+
+ return clamp(rgb, 0.0, 1.0);
+}
+
+
+//--------------------------------------------------------------------------
+vec3 CameraPath( float t )
+{
+ //t = sin(t*.3);
+ t+= 5.0;
+ vec3 p = vec3(1.4+sin(t)*3.5, -.2, 5.0-+sin(t)*2.5);
+ return p;
+}
+
+float TweetVolume(float t)
+{
+ float n = NoiseSlope(t*11.0, .1) * abs(sin(t*14.0))*.5;
+ n = (n*smoothstep(0.4, 0.9, NoiseSlope(t*.5+4.0, .1)));
+ return n;
+}
+
+
+//--------------------------------------------------------------------------
+void mainImage( out vec4 fragColor, in vec2 fragCoord )
+{
+ float m = (iMouse.x/iResolution.x)*20.0;
+ float gTime = iTime;
+ vec2 xy = fragCoord.xy / iResolution.xy;
+ vec2 uv = (-1.0 + 2.0 * xy) * vec2(iResolution.x/iResolution.y,1.0);
+
+ float t = mod(gTime, 40.0);
+ zoomTurn.y = smoothstep(6.0, 0.0, t)+smoothstep(39.0, 40.0, t);
+
+ vec3 cameraPos = CameraPath(gTime*.2);
+ cameraPos.z += zoomTurn.y*8.0;
+
+ vec3 camTarget = vec3(Noise(gTime*1.9-30.0)*.5-.25,Noise(gTime*2.0)*.5-.3,.0);
+
+
+ vec3 cw = normalize(camTarget-cameraPos);
+ vec3 cp = vec3(0.0, 1.0, 0.0);
+ vec3 cu = normalize(cross(cw,cp));
+ vec3 cv = cross(cu,cw);
+ vec3 dir = normalize(uv.x*cu + uv.y*cv + (1.0- zoomTurn.y*.4)*cw);
+
+ // Puff Chest...
+ animParts.x = Noise(gTime*2.0)+1.0;
+ // head tilt...
+ animParts.y = (NoiseSlope(gTime*1.2+sin(gTime*.3)*.7+.7, .05)-.5)* 1.5;
+ // Nod...
+ animParts.z = (NoiseSlope(gTime*.4-33.0, .05))* .5;
+ // Tweet...
+
+ animParts.w = TweetVolume(gTime)*.8+.02;
+ body.x = sin(NoiseSlope(gTime*.5, .3)*4.14) *.25+.25;
+ body.y = NoiseSlope(gTime*.73, .3);
+ t = mod(gTime*2., 15.0);
+ body.z = -(smoothstep(0.0, .5, t)* smoothstep(.6,.5, t )) * .5;
+ animParts.z -= body.z;
+ body.y = body.z;
+ float jump = smoothstep(0.4, .6, t)* smoothstep(.8,.6, t ) * .8;
+ body.z += jump;
+ body.w = jump;
+ zoomTurn.x = smoothstep(0.4, .8, t);
+ if (mod(gTime*2.0, 30.0) >= 15.0)
+ {
+ zoomTurn.x = 1.0- zoomTurn.x;
+ }
+ vec3 col = vec3(.0);
+
+ for (int i = 0; i <2; i++)
+ {
+ dStack[i] = vec4(-20.0);
+ aStack[i] = vec4(0.0);
+ }
+ float alpha = Scene(cameraPos, dir, fragCoord);
+
+ // Render both stacks...
+ for (int s = 0; s < 2; s++)
+ {
+ for (int i = 0; i < 4; i++)
+ {
+ float specular = 0.0;
+
+ float d = dStack[s][i];
+ if (d < 0.0) continue;
+ float sphereR = SphereRadius(d);
+ vec3 pos = cameraPos + dir * d;
+ vec3 normal = GetNormal(pos, sphereR);
+ vec3 alb = Colour(pos, normal, specular);
+ col += DoLighting(alb, pos, normal, dir, d, specular)* aStack[s][i];
+ }
+ }
+ // Fill in the rest with woodland background...
+ float mi = smoothstep(1.9, .0, zoomTurn.y);
+ vec3 back = mix(CubeMap(iChannel2, dir, 128.0), CubeMap(iChannel3, dir, 64.0)*.7, mi);
+ col += back* back*SUN_COLOUR* (1.0-alpha);
+
+
+ col = PostEffects(col, xy) * smoothstep(.0, 2.0, iTime);
+
+ fragColor=vec4(col,1.0);
+}
diff --git a/tests/real/slisesix.frag.expected b/tests/real/slisesix.frag.expected
index abb368dd..b717cf0f 100644
--- a/tests/real/slisesix.frag.expected
+++ b/tests/real/slisesix.frag.expected
@@ -30,7 +30,7 @@ float techo(float x,float y)
y=1.-y;
if(x<.1||x>.9)
return y;
- x=x-.5;
+ x-=.5;
return-(sqrt(x*x+y*y)-.4);
}
float distToBox(vec3 p,vec3 abc)
@@ -41,64 +41,47 @@ float distToBox(vec3 p,vec3 abc)
float columna(float x,float y,float z,float mindist,float offx)
{
vec3 p=vec3(x,y,z);
- float di0=distToBox(p,vec3(.14,1,.14)),y2,y3,y4,di1,di2,di3,di4,di9,di5,di6,di7,di8,di;
+ float di0=distToBox(p,vec3(.14,1,.14));
if(di0>mindist*mindist)
return mindist+1.;
- y2=y-.4;
- y3=y-.35;
- y4=y-1.;
- di1=distToBox(p,vec3(.1,1,.1));
- di2=distToBox(p,vec3(.12,.4,.12));
- di3=distToBox(p,vec3(.05,.35,.14));
- di4=distToBox(p,vec3(.14,.35,.05));
- di9=distToBox(vec3(x,y4,z),vec3(.14,.02,.14));
- di5=distToBox(vec3((x-y2)*.7071,(y2+x)*.7071,z),vec3(.07071,.07071,.12));
- di6=distToBox(vec3(x,(y2+z)*.7071,(z-y2)*.7071),vec3(.12,.07071,.07071));
- di7=distToBox(vec3((x-y3)*.7071,(y3+x)*.7071,z),vec3(.07071,.07071,.14));
- di8=distToBox(vec3(x,(y3+z)*.7071,(z-y3)*.7071),vec3(.14,.07071,.07071));
- di=min(min(min(di1,di2),min(di3,di4)),min(min(di5,di6),min(di7,di8)));
+ float y2=y-.4,y3=y-.35,y4=y-1.,di1=distToBox(p,vec3(.1,1,.1)),di2=distToBox(p,vec3(.12,.4,.12)),di3=distToBox(p,vec3(.05,.35,.14)),di4=distToBox(p,vec3(.14,.35,.05)),di9=distToBox(vec3(x,y4,z),vec3(.14,.02,.14)),di5=distToBox(vec3((x-y2)*.7071,(y2+x)*.7071,z),vec3(.07071,.07071,.12)),di6=distToBox(vec3(x,(y2+z)*.7071,(z-y2)*.7071),vec3(.12,.07071,.07071)),di7=distToBox(vec3((x-y3)*.7071,(y3+x)*.7071,z),vec3(.07071,.07071,.14)),di8=distToBox(vec3(x,(y3+z)*.7071,(z-y3)*.7071),vec3(.14,.07071,.07071)),di=min(min(min(di1,di2),min(di3,di4)),min(min(di5,di6),min(di7,di8)));
di=min(di,di9);
return di;
}
float bicho(vec3 x,float mindist)
{
x-=vec3(.64,.5,1.5);
- float r2=dot(x,x),sa=smoothstep(0.,.5,r2),fax=.75+.25*sa,r,a1,si1,co1,mindist2,rr,ca,c,a;
+ float r2=dot(x,x),sa=smoothstep(0.,.5,r2),fax=.75+.25*sa;
x.x*=fax;
x.y*=.8+.2*sa;
x.z*=fax;
r2=dot(x,x);
- r=sqrt(r2);
- a1=1.-smoothstep(0.,.75,r);
+ float r=sqrt(r2),a1=1.-smoothstep(0.,.75,r);
a1*=.4;
- si1=sin(a1);
- co1=cos(a1);
+ float si1=sin(a1),co1=cos(a1);
x.xy=mat2(co1,si1,-si1,co1)*x.xy;
- mindist2=1e5;
- rr=.05+sqrt(dot(x.xz,x.xz));
- ca=.46625-6.*rr*exp2(-10.*rr);
+ float mindist2=1e5,rr=.05+sqrt(dot(x.xz,x.xz)),ca=.46625-6.*rr*exp2(-10.*rr);
for(int j=1;j<7;j++)
{
- float an=6.2831/7.*float(j),aa=an+.4*rr*noise3f(vec3(4.*rr,2.5,an))+.29,rc=cos(aa),rs=sin(aa),dd;
+ float an=6.2831/7.*float(j),aa=an+.4*rr*noise3f(vec3(4.*rr,2.5,an))+.29,rc=cos(aa),rs=sin(aa);
vec3 q=vec3(x.x*rc-x.z*rs,x.y+ca,x.x*rs+x.z*rc);
- dd=dot(q.yz,q.yz);
+ float dd=dot(q.yz,q.yz);
if(q.x>0.&&q.x<1.5&&dd>10&7)>6)
peld=1.;
dis+=.005*peld;
@@ -106,8 +89,7 @@ float map(vec3 pos,out int sid,out int submat)
sid=0;
if(peld>1e-7)
sid=2;
- fx=fract(pos.x+128.);
- fz=fract(pos.z+128.);
+ float fx=fract(pos.x+128.),fz=fract(pos.z+128.);
if(pos.y>1.)
{
dis=max(techo(fx,pos.y),techo(fz,pos.y));
@@ -174,42 +156,40 @@ void main()
if(matID!=666)
{
- vec3 nor=calcNormal(pos),lig;
- float kke=1e-4,bumpa=.0075,kk,spe,llig,im,dif,dif2,ao,totao,sca,so;
+ vec3 nor=calcNormal(pos);
+ float kke=1e-4,bumpa=.0075;
if(matID!=5)
bumpa*=.75;
if(matID==4)
bumpa*=.5;
bumpa/=kke;
- kk=fbm(32.*pos);
+ float kk=fbm(32.*pos);
nor.x+=bumpa*(fbm(32.*vec3(pos.x+kke,pos.yz))-kk);
nor.y+=bumpa*(fbm(32.*vec3(pos.x,pos.y+kke,pos.z))-kk);
nor.z+=bumpa*(fbm(32.*vec3(pos.xy,pos.z+kke))-kk);
nor=normalize(nor);
- spe=0.;
- lig=vec3(.5-pos.x,.8-pos.y,1.5-pos.z);
- llig=dot(lig,lig);
- im=inversesqrt(llig);
- lig=lig*im;
- dif=dot(nor,lig);
- if(matID==4)
- dif=.5+.5*dif;
- else
- dif=.1+.9*dif;
+ float spe=0.;
+ vec3 lig=vec3(.5-pos.x,.8-pos.y,1.5-pos.z);
+ float llig=dot(lig,lig),im=inversesqrt(llig);
+ lig*=im;
+ float dif=dot(nor,lig);
+ dif=matID==4?
+ .5+.5*dif:
+ .1+.9*dif;
dif=clamp(dif,0.,1.);
dif*=2.5*exp2(-1.75*llig);
- dif2=(nor[0]+nor[1])*.075;
+ float dif2=(nor[0]+nor[1])*.075;
if(matID==0)
{
- float xoff=13.1*float(subMatID&255),fb=fbm(16.*vec3(pos.x+xoff,pos.yz)),baldscale,fx,m;
+ float xoff=13.1*float(subMatID&255),fb=fbm(16.*vec3(pos.x+xoff,pos.yz));
rgb=vec3(.7)+fb*vec3(.2,.22,.25);
- baldscale=float(subMatID>>9&15)/14.;
+ float baldscale=float(subMatID>>9&15)/14.;
baldscale=.51+.34*baldscale;
rgb*=baldscale;
- fx=1.;
+ float fx=1.;
if((subMatID&256)!=0)
fx=-1.;
- m=sin(64.*pos.z*fx+64.*pos.x+4.*fb);
+ float m=sin(64.*pos.z*fx+64.*pos.x+4.*fb);
m=smoothstep(.25,.5,m)-smoothstep(.5,.75,m);
rgb+=m*vec3(.15);
}
@@ -226,11 +206,11 @@ void main()
else
if(matID==4)
{
- float ft=fbm(16.*pos),fs,fre;
+ float ft=fbm(16.*pos);
rgb=vec3(.82,.73,.65)+ft*vec3(.1);
- fs=.9+.1*fbm(32.*pos);
+ float fs=.9+.1*fbm(32.*pos);
rgb*=fs;
- fre=max(-dot(nor,rd),0.);
+ float fre=max(-dot(nor,rd),0.);
rgb-=vec3(fre*fre*.45);
spe=clamp((nor.y-nor.z)*.707,0.,1.);
spe=.2*pow(spe,32.);
@@ -240,31 +220,30 @@ void main()
float fb=fbm(16.*pos);
rgb=vec3(.64,.61,.59)+fb*vec3(.21,.19,.19)+dif2;
}
- totao=0.;
- sca=10.;
+ float ao,totao=0.,sca=10.;
for(int aoi=0;aoi<5;aoi++)
{
- float hr=.01+.015*float(aoi*aoi),dd;
+ float hr=.01+.015*float(aoi*aoi);
vec3 aopos=nor*hr+pos;
int kk,kk2;
- dd=map(aopos,kk,kk2);
+ float dd=map(aopos,kk,kk2);
ao=-(dd-hr);
totao+=ao*sca;
sca*=.5;
}
ao=1.-clamp(totao,0.,1.);
- so=0.;
+ float so=0.;
for(int i=0;i<6;i++)
{
- float h=float(i)/6.,dd;
+ float h=float(i)/6.;
vec3 aopos=lig*(.01+h)+pos;
int kk,kk2;
- dd=map(aopos,kk,kk2);
+ float dd=map(aopos,kk,kk2);
so+=(1.-h)*dd*2.*(10./6.);
}
dif*=clamp((so-.4)*1.5,0.,1.);
rgb=vec3(spe)+rgb*(ao*vec3(.25,.3,.35)+dif*vec3(1.95,1.65,1.05));
- rgb=rgb*exp2(-.4*t);
+ rgb*=exp2(-.4*t);
}
rgb=(sqrt(rgb)*.7+.3*rgb)*vec3(.83,1,.83)*1.2;
rgb*=.25+.75*clamp(.6*abs(pixel.x-1.)*abs(pixel.x+1.),0.,1.);
diff --git a/tests/real/square_tunnel.frag b/tests/real/square_tunnel.frag
deleted file mode 100644
index d4710f23..00000000
--- a/tests/real/square_tunnel.frag
+++ /dev/null
@@ -1,20 +0,0 @@
-uniform vec2 resolution;
-uniform float time;
-uniform sampler2D tex0;
-uniform sampler2D tex1;
-uniform sampler2D tex2;
-uniform sampler2D tex3;
-
-void main(void)
-{
- vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
- vec2 uv;
-
- float r = pow( pow(p.x*p.x,16.0) + pow(p.y*p.y,16.0), 1.0/32.0 );
- uv.x = .5*time + 0.5/r;
- uv.y = 1.0*atan(p.y,p.x)/3.1416;
-
- vec3 col = texture2D(tex0,uv).xyz;
-
- gl_FragColor = vec4(col*r*r*r,1.0);
-}
diff --git a/tests/real/sult.expected b/tests/real/sult.expected
index 97fdc42a..4a3650cc 100644
--- a/tests/real/sult.expected
+++ b/tests/real/sult.expected
@@ -1,55 +1,51 @@
-/* File generated with
- * http://www.ctrl-alt-test.fr
- */
+// Generated with (https://github.com/laurentlb/Shader_Minifier/)
#ifndef SULT_EXPECTED_
# define SULT_EXPECTED_
# define VAR_resolution "r"
-# define VAR_time "m"
+# define VAR_time "c"
const char *sult_frag =
- "float y=5.,z=.9,x=0.,a=90.,s=0.;"
- "vec3 v=vec3(1),n=vec3(0,0,1),f=vec3(0,0,1.5);"
+ "float v=5.,z=.9,x=0.,a=90.,y=0.;"
+ "vec3 m=vec3(1),n=vec3(0,0,1),s=vec3(0,0,1.5);"
"uniform vec2 r;"
- "uniform float m;"
- "vec3 rotatey(vec3 v,float y)"
+ "uniform float c;"
+ "vec3 rotatey(vec3 v,float m)"
"{"
- "return vec3(v.x*cos(y)+v.z*sin(y),v.y,v.z*cos(y)-v.x*sin(y));"
+ "return vec3(v.x*cos(m)+v.z*sin(m),v.y,v.z*cos(m)-v.x*sin(m));"
"}"
- "float c=0.,w=10.;"
- "float e(vec3 v)"
+ "float f=0.,w=10.;"
+ "float e(vec3 m)"
"{"
- "float z=m,w,a=0.,g,o,f;"
+ "float y=c,a,g=0.,C,z,F;"
"vec3 r;"
- "v+=(sin(v.zxy*1.7+z)+sin(v.yzx+z*3.))*.2;"
- "if(y<6.)"
- "a=length(v.xyz*vec3(1,1,.1)-vec3(0,-.1,z*.15-.3))-.34;"
- "else"
- " a=length(v.xy+vec2(0,.7))-.3+(sin(v.z*17.+z*.6)+sin(v.z*2.)*6.)*.01;"
- "v.xy=vec2(atan(v.x,v.y)*1.113,1.6-length(v.xy)-sin(z*2.)*.3);"
- "r=fract(v.xzz+.5).xyz-.5;"
- "r.y=(v.y-.35)*1.3;"
- "w=max(abs(v.y-.3)-.05,abs(length(fract(v.xz)-.5)-.4)-.03);"
- "c=step(a,w);"
- "return min(min(w,a),v.y-.2);"
+ "m+=(sin(m.zxy*1.7+y)+sin(m.yzx+y*3.))*.2;"
+ "g=v<6.?"
+ "length(m.xyz*vec3(1,1,.1)-vec3(0,-.1,y*.15-.3))-.34:"
+ "length(m.xy+vec2(0,.7))-.3+(sin(m.z*17.+y*.6)+sin(m.z*2.)*6.)*.01;"
+ "m.xy=vec2(atan(m.x,m.y)*1.113,1.6-length(m.xy)-sin(y*2.)*.3);"
+ "r=fract(m.xzz+.5).xyz-.5;"
+ "r.y=(m.y-.35)*1.3;"
+ "a=max(abs(m.y-.3)-.05,abs(length(fract(m.xz)-.5)-.4)-.03);"
+ "f=step(g,a);"
+ "return min(min(a,g),m.y-.2);"
"}"
- "vec3 d=vec3(.19,.2,.24),o=vec3(1),l=vec3(.45,.01,0),g=vec3(.17,0,0);"
+ "vec3 d=vec3(.19,.2,.24),C=vec3(1),F=vec3(.45,.01,0),g=vec3(.17,0,0);"
"void main()"
"{"
- "vec2 t=-1.+2.*gl_FragCoord.xy/r.xy;"
- "vec3 i=normalize(rotatey(rotatey(vec3(t.y*z,t.x*z*1.33,1),-x*.035).yxz,(a+s*m)*.035)),p=n+f*m,u,h,F;"
- "float C=1.,b=0.,Z,Y,X=0.,W,V,U,T;"
- "u=vec3(.01,0,0);"
- "h=u.yyy;"
- "while(C>.1)"
+ "vec2 l=-1.+2.*gl_FragCoord.xy/r.xy;"
+ "vec3 I=normalize(rotatey(rotatey(vec3(l.y*z,l.x*z*1.33,1),-x*.035).yxz,(a+y*c)*.035)),H=n+s*c;"
+ "float u=1.,E=0.,i,B,A=0.,D,p,G,J;"
+ "vec3 K=vec3(.01,0,0),L=K.yyy,M;"
+ "for(;u>.1;)"
"{"
- "for(Z=X,Y=1.;Z.005;Z+=Y)"
- "Y=e(p+i*Z);"
- "if(Z.005;i+=B)"
+ "B=e(H+I*i);"
+ "if(i>16;
- a=a+(a<<3);
- a=a^a>>4;
- a=a*668265261;
- a=a^a>>15;
+ a+=a<<3;
+ a^=a>>4;
+ a*=668265261;
+ a^=a>>15;
return a;
}
float H(int a)
{
a=a^61^a>>16;
- a=a+(a<<3);
- a=a^a>>4;
- a=a*668265261;
- a=a^a>>15;
+ a+=a<<3;
+ a^=a>>4;
+ a*=668265261;
+ a^=a>>15;
return float(a)/2147483647;
}
vec2 rand2(int a)
@@ -58,7 +58,7 @@ void main()
if(coord.x<1280&&coord.y<720)
{
uint x=imageLoad(d0,coord).x;
- vec3 sc=mix(vec3(1),vec3(0,.35,.9),smoothstep(0.,23.,-time)),ec=mix(vec3(1,1.3,.28),vec3(.9,.2,.3),smoothstep(100.,138.,-time));
+ vec3 sc=mix(vec3(1),vec3(0,.35,.9),smoothstep(0.,23.,-time)),ec=mix(vec3(1,1.3,.28),vec3(.9,.2,.3),smoothstep(1e2,138.,-time));
p=mix(sc,ec,sqrt(clamp(float(x>>20)/1024,0,1)))*(x&1048575)/100;
p*=smoothstep(0,14,-time);
vec2 q=abs(vec2(coord)/vec2(1280,720)-.5);
@@ -79,7 +79,7 @@ void main()
for(int i=0;i<256;++i)
{
int seed=coord.x+coord.y*720+m*10000+i*100000000;
- float r=H(seed=IH(seed))*1.08,phi,u;
+ float r=H(seed=IH(seed))*1.08;
if(H(seed=IH(seed))<.02+smoothstep(0.,25.,abs(time-90.)))
{
if(r<.15)
@@ -126,12 +126,11 @@ void main()
p*=1.+max(0.,time-130)/6.;
vec3 q=p.zxy,x,w=vec3(H(seed=IH(seed)),H(seed=IH(seed)),H(seed=IH(seed)));
q.z-=.7;
- phi=w.x*3.141592*2;
- u=w.y*2-1;
+ float phi=w.x*3.141592*2,u=w.y*2-1;
u=sqrt(1-u*u);
x=vec3(cos(phi)*u,sin(phi)*u,w.y*2-1)*pow(w.z,1./3)*3;
q=mix(q,q+x*.5,.1*pow(H(seed),16.));
- q=q+x*.2*(1.-min(time/30.,1.)+max(0.,time-130)/20.);
+ q+=x*.2*(1.-min(time/30.,1.)+max(0.,time-130)/20.);
u=time/8.+199.*step(.5,H(int(floor(time/60.*64.))))*step(60.,time)*step(time,120);
q.xy=mat2(cos(u),sin(u),-sin(u),cos(u))*q.xy;
u=.4+time/9.;
@@ -139,6 +138,8 @@ void main()
q.xz*=1.+H(seed=IH(seed))*max(0.,time-120)/20.;
q.xz=400*q.xz+vec2(640,360)+randc(rand2(seed))*q.y*15.;
if(q.x>0&&q.z>0&&q.x<1280&&q.z<720)
- imageAtomicAdd(d0,ivec2(q.x,q.z),1|int(col>.5?1:0)<<20);
+ imageAtomicAdd(d0,ivec2(q.x,q.z),1|int(col>.5?
+ 1:
+ 0)<<20);
}
}
diff --git a/tests/real/the orange guy/ball_pixel.glsl b/tests/real/the orange guy/ball_pixel.glsl
deleted file mode 100644
index a1a03a45..00000000
--- a/tests/real/the orange guy/ball_pixel.glsl
+++ /dev/null
@@ -1,56 +0,0 @@
-const int N_BALLS = 8; /* le nombre de points spirales */
-
-uniform vec4 col[N_BALLS]; /* couleurs des points spirales */
-uniform vec3 pos[N_BALLS]; /* position des points spirales */
-uniform float intensity[N_BALLS]; /* "taille" des points spirales */
-
-
-uniform float localTime;
-uniform float progression;
-
-/* renvoie la couleur de l'image en ce point.
- On l'appelle plusieurs fois pour faire des symétries (bourrin !) */
-vec3 coul(vec2 p)
-{
- float prog = progression;
- float p2 = prog * prog;
- float time = localTime;
-
- vec3 couleur = vec3(0.0,0.0,0.0);
-
-
- float l = min(0.0, 1.5 * progression - 0.5);
-
- float dist_factor = (6.0 + 3.0 * sin(time));
-
-
- for (int i = 0; i < N_BALLS; ++i)
- {
- vec2 diff = (pos[i].xy - p);
- float d = dot(diff, diff); /* d = distance entre le pixel et le point spirale i */
-
- float angle = atan(diff.y, diff.x);
-
- /* on accumule la contribution de chaque spirale */
-
- float s = cos(5.0 * (angle - (1.0 + float(i) * 0.05 - prog * 1.5 ) * time) + d * dist_factor );
-
- s *= min(1.0, abs(0.7 + prog * 0.3 - s) * 15.0);
-
- float spiral_factor = max(0.0, s * (1.0 - p2) );
- float contrib = spiral_factor * intensity[i] * exp(-0.02 * d) + l;
-
- couleur += col[i].rgb * contrib;
-
- }
- return couleur;
-}
-
-void main()
-{
- vec2 p = gl_TexCoord[0].xy * 0.7;
-
- vec3 couleur = coul(p);
-
- gl_FragColor = vec4( couleur * 1.1, 1.0 );
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/ball_vertex.glsl b/tests/real/the orange guy/ball_vertex.glsl
deleted file mode 100644
index 8778fedf..00000000
--- a/tests/real/the orange guy/ball_vertex.glsl
+++ /dev/null
@@ -1,5 +0,0 @@
-void main()
-{
- gl_TexCoord[0] = gl_MultiTexCoord0;
- gl_Position = ftransform();
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/bloom2_pixel.glsl b/tests/real/the orange guy/bloom2_pixel.glsl
deleted file mode 100644
index 0547975e..00000000
--- a/tests/real/the orange guy/bloom2_pixel.glsl
+++ /dev/null
@@ -1,35 +0,0 @@
-uniform sampler2D tex;
-uniform float invTexWidth;
-
-
-void main()
-{
- vec2 p = gl_TexCoord[0].xy;
- vec2 dp = vec2(invTexWidth, 0.0);
-
- /*
- vec3 a = texture2D(tex, p - 3.0 * dp).rgb;
- vec3 b = texture2D(tex, p - 2.0 * dp).rgb;
- vec3 c = texture2D(tex, p - 1.0 * dp).rgb;
- vec3 d = texture2D(tex, p ).rgb;
- vec3 e = texture2D(tex, p + 1.0 * dp).rgb;
- vec3 f = texture2D(tex, p + 2.0 * dp).rgb;
- vec3 g = texture2D(tex, p + 3.0 * dp).rgb;
- vec3 final = 0.015625 * (a + g)
- + 0.09375 * (b + f)
- + 0.234375 * (c + e)
- + 0.3125 * d;
-
- gl_FragColor = vec4( final, 1.0 );
- */
-
-
- vec3 a = texture2D(tex, p - 2.1428571 * dp).rgb;
- vec3 b = texture2D(tex, p - 0.6 * dp).rgb;
- vec3 c = texture2D(tex, p + 0.6 * dp).rgb;
- vec3 d = texture2D(tex, p + 2.1428571 * dp).rgb;
- vec3 final = (2.0 * 0.21875) * (a + d)
- + (2.0 * 0.78125) * (b + c);
- gl_FragColor = vec4( final, 1.0 );
-
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/bloom2_vertex.glsl b/tests/real/the orange guy/bloom2_vertex.glsl
deleted file mode 100644
index 8778fedf..00000000
--- a/tests/real/the orange guy/bloom2_vertex.glsl
+++ /dev/null
@@ -1,5 +0,0 @@
-void main()
-{
- gl_TexCoord[0] = gl_MultiTexCoord0;
- gl_Position = ftransform();
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/bloom_pixel.glsl b/tests/real/the orange guy/bloom_pixel.glsl
deleted file mode 100644
index 7bb6e39b..00000000
--- a/tests/real/the orange guy/bloom_pixel.glsl
+++ /dev/null
@@ -1,40 +0,0 @@
-uniform sampler2D tex;
-uniform float invTexHeight;
-
-
-void main()
-{
- vec2 p = gl_TexCoord[0].xy;
- vec2 dp = vec2(0.0, invTexHeight);
-
- const vec3 limit = vec3(0.5,0.5,0.5);
- const vec3 mini = vec3(0.0,0.0,0.0);
-
- /* first version (7 samples) */
- /*
- vec3 a = max(mini, texture2D(tex, p - 3.0 * dp).rgb - limit);
- vec3 b = max(mini, texture2D(tex, p - 2.0 * dp).rgb - limit);
- vec3 c = max(mini, texture2D(tex, p - 1.0 * dp).rgb - limit);
- vec3 d = max(mini, texture2D(tex, p ).rgb - limit);
- vec3 e = max(mini, texture2D(tex, p + 1.0 * dp).rgb - limit);
- vec3 f = max(mini, texture2D(tex, p + 2.0 * dp).rgb - limit);
- vec3 g = max(mini, texture2D(tex, p + 3.0 * dp).rgb - limit);
- vec3 final = 0.015625 * (a + g)
- + 0.09375 * (b + f)
- + 0.234375 * (c + e)
- + 0.3125 * d;
-
- gl_FragColor = vec4( final * 2.0, 1.0 );
- */
-
- /* second version (4 samples) */
-
- vec3 a = max(mini, texture2D(tex, p - 2.1428571 * dp).rgb - limit);
- vec3 b = max(mini, texture2D(tex, p - 0.6 * dp).rgb - limit);
- vec3 c = max(mini, texture2D(tex, p + 0.6 * dp).rgb - limit);
- vec3 d = max(mini, texture2D(tex, p + 2.1428571 * dp).rgb - limit);
- vec3 final = (2.0 * 0.21875) * (a + d)
- + (2.0 * 0.78125) * (b + c);
- gl_FragColor = vec4( final, 1.0 );
-
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/bloom_vertex.glsl b/tests/real/the orange guy/bloom_vertex.glsl
deleted file mode 100644
index 8778fedf..00000000
--- a/tests/real/the orange guy/bloom_vertex.glsl
+++ /dev/null
@@ -1,5 +0,0 @@
-void main()
-{
- gl_TexCoord[0] = gl_MultiTexCoord0;
- gl_Position = ftransform();
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/dfc_pixel.glsl b/tests/real/the orange guy/dfc_pixel.glsl
deleted file mode 100644
index ac990f9a..00000000
--- a/tests/real/the orange guy/dfc_pixel.glsl
+++ /dev/null
@@ -1,67 +0,0 @@
-const float PI = 3.1415926;
-
-
-uniform float localTime;
-
-vec3 coul2(float x, float y)
-{
- float h = (x + 1.0) * 350.0;
- float w = (y + 1.0) * 350.0;
-
- float hi = (h - 350.0) / 20.0;
- float wi = (w - 350.0) / 20.0;
-
- float xo = hi;
- float yo = wi + localTime;/*cos(hi/5.0) + wi + 0.1; */
-
- float xa = cos(hi/5.0);
- float ya = cos(wi/5.0);
-
- float cosxa = cos(xa);
- float sinxa = sin(xa);
- float cosya = cos(ya);
- float sinya = sin(ya);
-
- vec3 res = vec3(0.0,0.0,0.0);
-
- for (int l = 0; l <= 30; l++)
- {
- float li = (float(l) - 15.0) * 2.0;
-
- float zo = li;
-
- float za = cos(li / 20.0);
-
- float tmp = yo * cosxa + zo * sinxa;
- zo = zo * cosxa - yo * sinxa;
- yo = tmp;
-
- float tmp2 = xo * cosya + zo * sinya;
- zo = zo * cosya - xo * sinya;
- xo = tmp2;
- /*
- float tmp3 = xo * cos(za) + yo * sin(za);
- yo = yo * cos(za) - xo * sin(za);
- xo = tmp3;
- */
- vec3 color = vec3(128.0) + vec3(128.0) * vec3(cos(zo), cos(zo + PI * 2.0 / 3.0), cos(zo - PI * 2.0 / 3.0));
-
- float length = sqrt( xo * xo + yo * yo + zo * zo ) - 30.0;
- float contrib = 0.25 / (1.0 + 400.0 * length * length);
-
- res = res * (1.0 - contrib) + color * contrib;
- /* res += contrib * color; */
- }
-
- return res;
- }
-
-void main()
-{
- vec2 p = 0.5 * gl_TexCoord[0].xy + vec2(0.1,0.1);
-
-
- gl_FragColor = vec4( 0.15 * coul2(p.x, p.y) , 1.0);
-}
-
-
diff --git a/tests/real/the orange guy/dfc_vertex.glsl b/tests/real/the orange guy/dfc_vertex.glsl
deleted file mode 100644
index 88eb6b1d..00000000
--- a/tests/real/the orange guy/dfc_vertex.glsl
+++ /dev/null
@@ -1,6 +0,0 @@
-
-void main()
-{
- gl_TexCoord[0] = gl_MultiTexCoord0;
- gl_Position = ftransform();
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/final_pixel.glsl b/tests/real/the orange guy/final_pixel.glsl
deleted file mode 100644
index 69573fa7..00000000
--- a/tests/real/the orange guy/final_pixel.glsl
+++ /dev/null
@@ -1,18 +0,0 @@
-uniform sampler2D tonemappedTexture;
-uniform sampler2D bloomTexture;
-uniform sampler2D paperTexture;
-uniform int paper;
-uniform float paperInvSize;
-
-
-void main()
-{
- vec2 p = gl_TexCoord[0].xy;
-
- vec4 main = texture2D(tonemappedTexture, p);
- vec4 bloom = texture2D(bloomTexture, p);
-
- vec4 paper = float(paper) * 1.8 * texture2D(paperTexture, gl_FragCoord.xy * paperInvSize) + vec4(1.0,1.0,1.0,1.0) * (1.0 - float(paper));
-
- gl_FragColor = paper * (main * 0.8 + 0.2 * bloom);
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/final_vertex.glsl b/tests/real/the orange guy/final_vertex.glsl
deleted file mode 100644
index 8778fedf..00000000
--- a/tests/real/the orange guy/final_vertex.glsl
+++ /dev/null
@@ -1,5 +0,0 @@
-void main()
-{
- gl_TexCoord[0] = gl_MultiTexCoord0;
- gl_Position = ftransform();
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/font_pixel.glsl b/tests/real/the orange guy/font_pixel.glsl
deleted file mode 100644
index 15673791..00000000
--- a/tests/real/the orange guy/font_pixel.glsl
+++ /dev/null
@@ -1,11 +0,0 @@
-uniform sampler2D tex;
-uniform sampler2D fill;
-
-void main()
-{
- vec2 p = gl_TexCoord[0].xy;
- vec4 letter = texture2D(tex, p);
- vec4 fill = texture2D(fill, p * 3.0);
-
- gl_FragColor = letter * fill * gl_Color;
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/font_vertex.glsl b/tests/real/the orange guy/font_vertex.glsl
deleted file mode 100644
index 1320daa3..00000000
--- a/tests/real/the orange guy/font_vertex.glsl
+++ /dev/null
@@ -1,7 +0,0 @@
-
-void main()
-{
- gl_TexCoord[0] = gl_MultiTexCoord0;
- gl_Position = ftransform();
- gl_FrontColor = gl_Color;
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/logofinal_pixel.glsl b/tests/real/the orange guy/logofinal_pixel.glsl
deleted file mode 100644
index e5707aab..00000000
--- a/tests/real/the orange guy/logofinal_pixel.glsl
+++ /dev/null
@@ -1,8 +0,0 @@
-uniform sampler2D tex;
-
-void main()
-{
- vec2 p = gl_TexCoord[0].xy;
- vec4 sample0 = texture2D(tex, p);
- gl_FragColor = gl_Color * sample0;
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/logofinal_vertex.glsl b/tests/real/the orange guy/logofinal_vertex.glsl
deleted file mode 100644
index 1320daa3..00000000
--- a/tests/real/the orange guy/logofinal_vertex.glsl
+++ /dev/null
@@ -1,7 +0,0 @@
-
-void main()
-{
- gl_TexCoord[0] = gl_MultiTexCoord0;
- gl_Position = ftransform();
- gl_FrontColor = gl_Color;
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/orange_pixel.glsl b/tests/real/the orange guy/orange_pixel.glsl
deleted file mode 100644
index de661e29..00000000
--- a/tests/real/the orange guy/orange_pixel.glsl
+++ /dev/null
@@ -1,38 +0,0 @@
-uniform sampler2D tex;
-uniform sampler2D grain;
-
-const int NPOINTS = 5;
-
-uniform float env;
-
-uniform vec3 pos[NPOINTS];
-uniform float intensity[NPOINTS];
-uniform float localTime;
-uniform float zoom;
-
-
-const float PI = 3.14159265;
-
-void main()
-{
- float x = gl_TexCoord[0].s * zoom;
- float y = gl_TexCoord[0].t * zoom;
- float u = localTime * 0.25;
-
- vec4 color = vec4(0.0);
-
- for (int i = 0; i < 5; i++)
- {
- vec3 diff = vec3(x, y, 0.0) - pos[i];
- float angle = atan(diff.y, diff.x);
- float d = env * 1.0; /* length(pos[i]);*/
- float t = (d + localTime) * 0.03 ;
- float s = u + angle / PI + (float(i) * 0.1);
- float dist = length(diff);
- vec4 grain = texture2D(grain, vec2(0.5, 0.3 * dist));
-
- color += (texture2D(tex, vec2(s,t)) * grain) * (intensity[i] / (1.0 + 0.2 * dist));
- }
-
- gl_FragColor = vec4(color.rgb * 0.6 + 0.4 * env, 1.0);
-}
diff --git a/tests/real/the orange guy/orange_vertex.glsl b/tests/real/the orange guy/orange_vertex.glsl
deleted file mode 100644
index 88eb6b1d..00000000
--- a/tests/real/the orange guy/orange_vertex.glsl
+++ /dev/null
@@ -1,6 +0,0 @@
-
-void main()
-{
- gl_TexCoord[0] = gl_MultiTexCoord0;
- gl_Position = ftransform();
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/particle_pixel.glsl b/tests/real/the orange guy/particle_pixel.glsl
deleted file mode 100644
index ab69325a..00000000
--- a/tests/real/the orange guy/particle_pixel.glsl
+++ /dev/null
@@ -1,15 +0,0 @@
-uniform sampler2D tex;
-
-uniform float intensity;
-uniform float alpha;
-
-void main()
-{
- vec4 color = texture2D(tex, gl_TexCoord[0].xy);
- float opacity = dot(color.rgb, vec3(0.33,0.33,0.33)) * color.a * alpha;
-
-
- if (opacity < 0.05) discard;
-
- gl_FragData[0] = vec4(color.rgb * intensity, opacity);
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/particle_vertex.glsl b/tests/real/the orange guy/particle_vertex.glsl
deleted file mode 100644
index 4c125181..00000000
--- a/tests/real/the orange guy/particle_vertex.glsl
+++ /dev/null
@@ -1,8 +0,0 @@
-void main()
-{
- gl_TexCoord[0] = gl_MultiTexCoord0;
-
- gl_Position = ftransform();
-
- gl_FrontColor = gl_Color;
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/put_pixel.glsl b/tests/real/the orange guy/put_pixel.glsl
deleted file mode 100644
index c7855f3d..00000000
--- a/tests/real/the orange guy/put_pixel.glsl
+++ /dev/null
@@ -1,4 +0,0 @@
-void main()
-{
- gl_FragColor = gl_Color;
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/put_vertex.glsl b/tests/real/the orange guy/put_vertex.glsl
deleted file mode 100644
index 1320daa3..00000000
--- a/tests/real/the orange guy/put_vertex.glsl
+++ /dev/null
@@ -1,7 +0,0 @@
-
-void main()
-{
- gl_TexCoord[0] = gl_MultiTexCoord0;
- gl_Position = ftransform();
- gl_FrontColor = gl_Color;
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/puttexture_pixel.glsl b/tests/real/the orange guy/puttexture_pixel.glsl
deleted file mode 100644
index 206e02ae..00000000
--- a/tests/real/the orange guy/puttexture_pixel.glsl
+++ /dev/null
@@ -1,20 +0,0 @@
-uniform sampler2D tex0;
-uniform sampler2D tex1;
-uniform sampler2D tex2;
-uniform sampler2D tex3;
-
-uniform float amountTex0;
-uniform float amountTex1;
-uniform float amountTex2;
-uniform float amountTex3;
-
-void main()
-{
- vec2 p = gl_TexCoord[0].xy;
- vec4 sample0 = texture2D(tex0, p);
- vec4 sample1 = texture2D(tex1, p);
- vec4 sample2 = texture2D(tex2, p);
- vec4 sample3 = texture2D(tex3, p);
- gl_FragColor = gl_Color * (amountTex0 * sample0 + sample1 * amountTex1
- + amountTex2 * sample2 + sample3 * amountTex3 );
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/puttexture_vertex.glsl b/tests/real/the orange guy/puttexture_vertex.glsl
deleted file mode 100644
index 1320daa3..00000000
--- a/tests/real/the orange guy/puttexture_vertex.glsl
+++ /dev/null
@@ -1,7 +0,0 @@
-
-void main()
-{
- gl_TexCoord[0] = gl_MultiTexCoord0;
- gl_Position = ftransform();
- gl_FrontColor = gl_Color;
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/scene10_pixel.hlsl b/tests/real/the orange guy/scene10_pixel.hlsl
deleted file mode 100644
index 95a5ad21..00000000
--- a/tests/real/the orange guy/scene10_pixel.hlsl
+++ /dev/null
@@ -1,30 +0,0 @@
-const int N_SPIRALES = 12; /* le nombre de points spirales */
-
-uniform vec4 pos[N_SPIRALES]; /* position des points spirales, rayon, intensite */
-uniform float musicVolume;
-
-static const vec3 WHITE = vec3(1.0,1.0,1.0);
-
-vec3 coul(vec2 p)
-{
- float f = 0.0;
- for (int i = 0; i < N_SPIRALES; ++i)
- {
- vec2 diff = pos[i].xy - p;
- float dist = pow(dot(diff, diff), 1.0 / 4.0);
- float s = abs(dist - pos[i].z);
-
- f = f + pos[i].w * exp(-s * (50.0 - musicVolume * 20.0));
- }
-
- return WHITE * max(0.0, 1.2 - f);
-}
-
-void main()
-{
- vec2 p = gl_TexCoord[0].xy;
-
- vec3 couleur = coul(p);
-
- gl_FragColor = vec4( couleur * (1.0 + musicVolume), 1.0 );
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/scene10_vertex.glsl b/tests/real/the orange guy/scene10_vertex.glsl
deleted file mode 100644
index 88eb6b1d..00000000
--- a/tests/real/the orange guy/scene10_vertex.glsl
+++ /dev/null
@@ -1,6 +0,0 @@
-
-void main()
-{
- gl_TexCoord[0] = gl_MultiTexCoord0;
- gl_Position = ftransform();
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/tonemapping_pixel.glsl b/tests/real/the orange guy/tonemapping_pixel.glsl
deleted file mode 100644
index bb5bd3ed..00000000
--- a/tests/real/the orange guy/tonemapping_pixel.glsl
+++ /dev/null
@@ -1,18 +0,0 @@
-uniform sampler2D tex;
-
-void main()
-{
- vec3 color = texture2D(tex, gl_TexCoord[0].xy).rgb;
- float luminance = dot( vec3(0.3, 0.59, 0.11), color);
-
- /*float luminance = dot( vec3(0.33, 0.33, 0.33), color);*/
-
- /* [0 .. infinity] is mapped to [0 .. 1] */
-
- float factor = luminance / (1.0 + luminance);
-
- /* interesting bug : make black area */
- /* float factor = sin((luminance * 3.141596 * 0.5) / (1.0 + luminance));*/
-
- gl_FragColor = vec4( factor * color, 1.0 );
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/tonemapping_vertex.glsl b/tests/real/the orange guy/tonemapping_vertex.glsl
deleted file mode 100644
index 8778fedf..00000000
--- a/tests/real/the orange guy/tonemapping_vertex.glsl
+++ /dev/null
@@ -1,5 +0,0 @@
-void main()
-{
- gl_TexCoord[0] = gl_MultiTexCoord0;
- gl_Position = ftransform();
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/tunnel_pixel.glsl b/tests/real/the orange guy/tunnel_pixel.glsl
deleted file mode 100644
index 7f847f8b..00000000
--- a/tests/real/the orange guy/tunnel_pixel.glsl
+++ /dev/null
@@ -1,20 +0,0 @@
-
-varying vec2 st;
-uniform float alpha;
-uniform sampler2D tex;
-uniform float time;
-uniform vec4 color;
-varying float prof;
-
-void main()
-{
-
- vec3 texcolor = texture2D(tex, st).rgb;
-
- float opacity = alpha < 0.9 ? 1.0 : 1.0 - 0.7 * dot(vec3(0.33,0.33,0.33), texcolor);
-
- opacity *= exp(-0.10 * abs(prof));
-
- gl_FragData[0] = color * vec4(texcolor * 1.6, opacity);
-
-}
\ No newline at end of file
diff --git a/tests/real/the orange guy/tunnel_vertex.glsl b/tests/real/the orange guy/tunnel_vertex.glsl
deleted file mode 100644
index 0f0cba38..00000000
--- a/tests/real/the orange guy/tunnel_vertex.glsl
+++ /dev/null
@@ -1,13 +0,0 @@
-varying vec2 st;
-varying float prof;
-
-
-void main()
-{
- st = gl_MultiTexCoord0.xy;
-
- vec4 p = ftransform();
- prof = gl_Color.x * 50.0;
-
- gl_Position = p;
-}
\ No newline at end of file
diff --git a/tests/real/the wind under my wings/f_blurhighlights.cpp b/tests/real/the wind under my wings/f_blurhighlights.cpp
deleted file mode 100644
index ab4f8a18..00000000
--- a/tests/real/the wind under my wings/f_blurhighlights.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-#version 110
-#define float4 vec4
-#define float3 vec3
-#define float2 vec2
-#define oUV gl_TexCoord[0]
-#define tex3D texture3D
-#define tex2D texture2D
-#define tex1D texture1D
-
- uniform sampler2D texture2d_1;
-/* uniform sampler1D texture_transfer_function;
- uniform sampler1D texture_palette_function;
-
-
- uniform float3 VolumeSize;
- uniform float3 RelativeSize;
- uniform float3 Registration_Offset;
- uniform float pet_alpha_blending;
- uniform float3 MousePos;
- uniform int Projection_mode;
-uniform float3 InVolumePosition;
- uniform float3 Windowing_Levels;
-
- uniform float isosurface;
-uniform float Sharpening;
-
-*/
-
- uniform float Limit;
-
-
-
-
-
-
-
-void main (void)
-{
-
-
-
-float4 cl;
-cl=vec4 (0.0);
-int count=0;
-
-// loop, highlight speculars (>0.9)
-for (int y=-8;y<9;y++) {
- for (int x=-8;x<9;x++){
-count++;
-float2 dd=float2 (x,y)*1.02;
-
-//dd=ray.xy*5.0;
-float2 Dist=dd*0.0015;
-float4 res=tex2D(texture2d_1,oUV.xy+Dist);
-//res*=res;
-//if (res.w<0.9) {res*=res*0.35+0.05; }
-cl+=res;
-}
-}
-cl/=float (count);
-
-
-
-//cl=tex2D(texture2d_1,oUV.xy)*vec4 (1.0,0.0,0.0,1.0)+vec4 (0.2,0.0,0.0,0.0);
-
-//cl*=1.2;
-//cl+=float4 (0.0,0.02,0.05,1);
-//cl=vec4 (0.0);
-
-
-//cl=tex2D(texture2d_1,oUV.xy)*1.0;
-
-/*
-//Depth blurring
-
-float dpth=0;
-int count=0;
-for (int y=-4;y<5;y++) {
- for (int x=-4;x<5;x++){
-count++;
-float2 dd=float2 (x,y)*0.7;
-
-//dd=ray.xy*5.0;
-
-float2 Dist=dd*0.0015;
-dpth+=tex2D(texture2d_2,UV.xy+Dist).x;
-}
-}
-dpth/=float (count);
-//dpth=sin(dpth*3.14159);
-dpth+=0.1;
-dpth=pow(dpth,6.0);
-//dpth+=Limit;
-dpth=1.1-dpth;
-//if (dpth<0.7) dpth=0.0;
-count=0;
-cl=vec4(0.0);
-dpth=clamp(dpth,0.0,1.0);
-
-dpth=Limit+((1.0-Limit)-(Limit))*dpth;
-
-if (dpth>0.02) {
-for (int y=-4;y<5;y++) {
- for (int x=-4;x<5;x++){
-count++;
-
-float2 dd=float2 (x,y);
-
-//if ( (x)==(y)) { dd*=120.0;}
-
-float2 Dist=dd*0.0015*dpth;
-cl+=tex2D(texture2d_1,UV.xy+Dist);
-}
-}
-
-cl/=float (count);
-}
-else
-cl=tex2D(texture2d_1,UV.xy);
-
-
-
-*/
-
-
-
-
-
-
-
-
-
-gl_FragData[0]=cl;
- gl_FragData[1]=cl;
-
-/*
-float3 currentuv;
-
-
-
-if (Projection_mode==0) {
-currentuv.xy=oUV.st;
-currentuv.z=0.0+InVolumePosition.z;
-}
-else
-if (Projection_mode==1) {
-currentuv.xz=oUV.st;
-currentuv.y=0.0+InVolumePosition.y;
-}
-else
-if (Projection_mode==2) {
-currentuv.zy=oUV.ts;
-currentuv.x=0.0+InVolumePosition.x;
-}
-float4 original= tex3D (texture3d,currentuv);
-float divisor=1.0/(Windowing_Levels.y-Windowing_Levels.x);
-
-
-
-
-original-=Windowing_Levels.x*float4 (1,1,1,1);
-original*=divisor;
-
-
-//original.x=max (0.0,min (1.0,original.x));
-
-
-gl_FragColor=currentuv.xyzz;
-//gl_FragColor=float4 (1.0,0.0,0.0,1.0);
-//gl_FragColor*=Sharpening;
-*/
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/real/the wind under my wings/f_blurpass.cpp b/tests/real/the wind under my wings/f_blurpass.cpp
deleted file mode 100644
index f6b1f434..00000000
--- a/tests/real/the wind under my wings/f_blurpass.cpp
+++ /dev/null
@@ -1,498 +0,0 @@
-#version 110
-#define float4 vec4
-#define float3 vec3
-#define float2 vec2
-#define oUV gl_TexCoord[0]
-#define tex3D texture3D
-#define tex2D texture2D
-#define tex1D texture1D
-
- uniform sampler2D texture2d_1;
- uniform sampler2D texture2d_s;
- uniform sampler2D texture2d_velocities;
- uniform sampler2D texture2d_2;
- uniform sampler2D texture2d_random;
-/* uniform sampler1D texture_transfer_function;
- uniform sampler1D texture_palette_function;
-
-
- uniform float3 VolumeSize;
- uniform float3 RelativeSize;
- uniform float3 Registration_Offset;
- uniform float pet_alpha_blending;
- uniform float3 MousePos;
- uniform int Projection_mode;
-uniform float3 InVolumePosition;
- uniform float3 Windowing_Levels;
-
- uniform float isosurface;
-uniform float Sharpening;
-
-*/
-
- uniform float Limit;
- uniform float Flo;
-
-uniform float PosY;
-uniform float ttime;
-uniform float fttime;
-uniform float DSP;
-uniform float DSP2;
-
-
-
-
-
-void main (void)
-{
-
-
-
-
-//float ff=tex2D (texture2d_1,oUV.xy).x;
-//ff=abs (ff-cl.x);
-//ff=0.5+0.5*sin(ff*10000.0);
-//cl=ff*vec4 (1.0);
-
-
-
-/*
-
-
-float PI=3.1415926535;
-float2 UV=oUV.xy;
-
-UV-=float2 (0.5,0.5);
-UV*=2.0;
-
-
-float3 DirV =float3 (UV.x,UV.y,0.6);
-float lgn=length (DirV);
-DirV/=lgn;
-
-UV.xy=UV.xy+(DirV.xy-UV.xy)*-0.0;
-UV*=0.5;
-UV+=float2 (0.5,0.5);
-*/
- float2 UV=oUV.xy;
-float4 cl=tex2D (texture2d_1,UV.xy);
-
-cl=float4 (0.0);
-float3 Direction=tex2D (texture2d_velocities,UV.xy).xyz;
-//Direction.xy=float2 (0.5);
-Direction.xyz-=float3 (0.5);
-Direction*=2.0;
-
-float alpha=1.0*length (Direction.xyz);
-alpha=clamp (alpha,0.0,1.0);
-//alpha=1-alpha;
-//alpha*=alpha;
-//alpha=1-alpha;
-
-//alpha*=alpha;
-//alpha=0.1;
-//Direction*=0.01;
-//Direction=vec3 (0.0,0.01,0.0);
-if (alpha>0.01)
-{
- for (int t=0;t<10;t++) {
-UV.xy-=Direction.xy*0.01;
- cl+=tex2D (texture2d_1,UV.xy);
-};
-
- cl*=1.0/10.0;
-//Direction=tex2D (texture2d_velocities,UV.xy).xyz;
-//cl=Direction.xyzz*1.0+vec4 (0.5);
-//cl.x+=0.15*alpha;
-//=float4 (1.0,0.0,0.0,1.0)*alpha;
-}
-else cl=tex2D (texture2d_1,UV.xy);
-
-//float4 clnow=tex2D( texture2d_1,oUV.xy);
-//cl=cl+(clnow-cl)*0.5;
-
-UV=oUV.xy;
-if (fttime>186.0) if (fttime<242.0) if (UV.x>0.5) UV.x=1.0-UV.x;
-
-float fx=tex2D (texture2d_1,UV.xy).x;
-
-
-if (ttime>169.0)
-if (ttime<184.0){
-
- if (UV.y>0.5) UV.y=1.0-UV.y;
-}
-
-if (ttime<197.0)
-if (ttime>184.0){
-if (UV.x>0.5) UV.x=1.0-UV.x;
-}
-
-
-
-
-if (ttime<86.0)
-if (ttime>26.5)
-if (UV.x>0.5) UV.x=1.0-UV.x;
-
-
-
-
-
-if (ttime>98.0)
-if (ttime<106.0) {
-
-float fft=((UV.x-0.5) / (UV.y-0.5));
-fft=1.0*atan (fft);
-
-//fft=mod (fft,1.4);
-
-
-float dist=length (UV.xy-vec2 (0.5));
-
-vec2 UVn;
-UVn.x=dist * sin(fft)+0.5;
-UVn.y=dist * cos(fft)+0.5;
-
-UV=UVn;
-}
-
-
-
-
-
-
-
-
-
-//1.0-UV.x;
-
-
-//if (UV.y>0.5) UV.y=1.0-UV.y;
-//if (UV.x>fx) UV.x=1.0-UV.x;
-//+(fx-0.5);
-cl=1.0*tex2D (texture2d_1,UV.xy);
-cl+=1.0*tex2D (texture2d_s,UV.xy);
-
-vec4 cln=cl;
-
-if ((ttime>86.0) && (ttime<104.0)){
-
-
-float cll2=cl.y;
-// if (UV.y>0.8) UV.y=1.0-UV.y+0.6;
-
-cl=1.0*tex2D (texture2d_1,UV.xy);
-cl+=1.0*tex2D (texture2d_s,UV.xy);
-
-vec4 cln=vec4(tex2D(texture2d_1,UV.xy).x)+vec4(tex2D(texture2d_s,UV.xy).x);
-if (cll2>0.9) cl*=100.0;
-//vec4 (1.7,0.8,1.0,0.0);
-float fl=(ttime-92.0)*0.125;
-fl=clamp (fl,0.0,1.0);
-cl=cl+(cln-cl)*fl;
-
-}
-
-
-
-
-
-
-if (ttime>104.0) {
-
-
-float cll2=cl.y;
-float cll3=cl.z;
-
-float fl2=(ttime-123.0)*0.25;
-
-fl2=clamp (fl2,0.0,1.0);
-fl2=0.0;
-float ff=UV.x;
-
-if (fttime<186.0)
-if (UV.x>0.5+fl2) UV.x=1.0-UV.x;
-
-//UV.x=UV.x+(ff-UV.x)*fl2;
-
-
-
-
-cl=vec4(tex2D(texture2d_1,UV.xy).x)+vec4(tex2D(texture2d_s,UV.xy).x);
-if (cll2>0.9)
-cl*=1.7*vec4 (0.7,0.8,1.0,0.0);
-
-fl2=(ttime-131.0)*0.3;
-
-if (fttime>186.0);
-fl2=(ttime-129.0)*0.25;
-
-fl2=clamp (fl2,0.0,1.0);
-cl=cl+(cln-cl)*fl2;
-//if (cll3>0.6) cl*=1.7*vec4 (0.7,0.9,1.0,0.0);
-}
-
-
-
-
-cl+=vec4(DSP*DSP*oUV.y)*0.25;
-
-
-float flx=1.9;
-if (ttime>140.0) flx=1.2;
-
-
-if (cl.z>flx)
-{
-float ures=pow(sin(UV.x*5.0),5.0);
-if (ures>0.5) ures=-1.0; else ures=1.0;
- float uu=pow(1.1*sin(5.0*ttime+2000.0*UV.x)*sin(2000.0*UV.y),8.0);
-uu*=pow(1.1*sin(ures*-15.0*ttime+200.0*UV.x)*sin(ures*-10.0*ttime+200.0*UV.y),8.0);
-
-if (uu>0.0)
-cl*=0.0;
-
-
-}
-
-
-
-
-if (ttime<250.0)
-if (length (cl)<0.1) {
-float ures=pow(sin(UV.x*15.0),5.0);
-if (ures>0.5) ures=-1.0; else ures=1.0;
- float uu=pow(1.1*sin(5.0*ttime+2000.0*UV.x)*sin(2000.0*UV.y),8.0);
-uu*=pow(1.1*sin(ures*-5.0*ttime+400.0*UV.x)*sin(ures*-10.0*ttime+400.0*UV.y),8.0);
-
-
-float fl2=(ttime-32.0)*0.125;
-fl2=clamp (fl2,0.0,1.0);
-
-if (uu>0.04)
-cl+=fl2*vec4 (0.43)*vec4 (0.7,1.0,1.0,1.0)*pow((1.0-oUV.y),2.0);
-
-
-}
-
-/*
-if (ttime>230.0)
-if (sin(oUV.y*100.0)>0.0)
-cl=vec4 (cl.x);
-*/
-
-
-float ffade=ttime-230.0;
-ffade=clamp (ffade,0.0,1.0);
-if (fttime>230.0)
-cl*=ffade;
-
-
-
-
-
-//cl*=0.5+DSP2;
-
-
-float fls=
-min (length (vec2 (2.0,0.5)*(oUV.xy-vec2 (0.5,0.4))),
-length (vec2 (0.5,2.0)*(oUV.xy-vec2 (0.5,0.4))));
-fls=1.0-fls;
-fls=clamp (fls,0.0,1.0);
-fls=pow (fls,2.0);
-//float fls2=length (oUV.xy-vec2 (0.5));
-
-fls=
-length (vec2 (2.0,0.5)*(oUV.xy-vec2 (0.5,0.4)));
-fls=1.0-fls;
-fls=clamp (fls,0.0,1.0);
-fls=pow (fls,3.0);
-//fls*=clamp (10.0*sin(oUV.y*1200.0),0.0,1.0);
-
-
-if (fttime<130.0)
-cl*=1.0+2.0*DSP2*fls*vec4 (0.5,0.7,1.0,1.0);
-
-if (fttime>190.0)
-cl*=1.0+2.0*DSP2*fls*vec4 (0.5,0.7,1.0,1.0);
-
-
-
-//fls=(oUV.x-0.5)+(oUV.y-0.5);
-//fls=1.0-fls;
-//cl*=1.0+1.5*vec4 (0.6,0.8,0.9,1.0)*5.0*vec4 (pow(fls,8.0));
-//cl=tex2D (texture2d_1,vec2 (sin(oUV.x),sin(oUV.y)));
-
-
-vec4 clnn=vec4 (pow (cl.x*1.1,3.0),pow (cl.y*1.1,3.0),pow (cl.z*1.1,3.0),pow (cl.z*1.1,2.0));
-
-
-
-if (ttime>86.0)
-cl=vec4 (cl.x)+(clnn-vec4 (cl.x))*0.3;
-else
-cl=vec4 (cl.y)+(0.8*clnn-vec4 (cl.y))*0.25;
-
-
-
-
-
-
-
-
-//cl=clnn;
-
-
-
-
-//*vec4 (0.2,0.5,1.0,1.0);
-
-
-//cl=vec4(tex2D(texture2d_1,UV.xy).x)+vec4(tex2D(texture2d_s,UV.xy).x);
-
-/*
-
-
-// blur effect
-float lgn2=length (float2 (1.0,2.0)*(UV.xy-float2 (0.5)));
-lgn2*=lgn2;
-//pow(lgn2,1.8);
-int count=0;
-for (int y=-5;y<6;y++) {
- for (int x=-5;x<6;x++){
-count++;
-
-float2 dd=float2 (x,y);
-if ( (x)==(y)) {
- dd*=2.0;
-}
-
-float2 Dist=float2 (x,y)*0.0025*lgn2;
-Dist=dd*0.0025*lgn2;
-cl+=tex2D(texture2d_1,UV.xy+Dist);
-
-}
-}
-cl/=float (count)*(lgn2+(1.0-lgn2)*0.85);
-
-
-vec4 cll=cl;
-
-cl=tex2D (texture2d_1,oUV.xy);
-
-
-
-
-
-
-
-
-//Depth blurring
-
-float dpth=0.0;
- count=0;
- float Limit2=1.0-Limit;
-for (int y=-4;y<5;y++) {
- for (int x=-4;x<5;x++){
-count++;
-float2 dd=float2 (x,y)*0.7*Limit2;
-
-//dd=ray.xy*5.0;
-
-float2 Dist=dd*0.0018;
-dpth+=tex2D(texture2d_2,UV.xy+Dist).x;
-}
-}
-dpth/=float (count);
-//dpth=sin(dpth*3.14159);
-//dpth+=0.1;
-dpth=pow(dpth,126.0);
-//dpth+=Limit;
-dpth=1.0-1.0*dpth;
-//if (dpth<0.7) dpth=0.0;
-count=0;
-cl=vec4(0.0);
-dpth=clamp(dpth,0.0,1.0);
-
-dpth=Limit+((1.0-Limit)-(Limit))*dpth;
-dpth*=Flo;
-//dpth=1.0;
-
-float vel=tex2D(texture2d_velocities,UV.xy).x;
-if (dpth>0.02)
-{
-for (int y=-4;y<5;y++) {
- for (int x=-4;x<5;x++){
-count++;
-
-float2 dd=float2 (x,y)*0.7;//;*vec2 (3.0,3.0);
-
-//float2 dd2=float((x+4)*9+(y+4))*float2 (-1.0,1.0)*0.4;
-//dd=dd+(dd2-dd)*-vel*0.4;
-
-
-float2 Dist=dd*0.0018*dpth;
-cl+=tex2D(texture2d_1,UV.xy+Dist);
-//cl.x=dpth;
- }
-}
-
-cl/=float (count);
-}
-else
-cl=tex2D(texture2d_1,UV.xy);
-
-
-
-if (vel>0.01) {
-vec4 newcl=vec4 (0.0);
-for (int x=0;x<15;x++){
-float2 dd2=float(x)*float2 (-1.0,1.0)*0.003*vel;
-newcl+=tex2D(texture2d_1,UV.xy+dd2);
-}
-newcl*=1.0/15.0;
-
-cl=cl+(newcl-cl)*0.5;
-}
-
-
-
-//cl*=0.4;
-
-//cl+=tex2D(texture2d_velocities,UV.xy)*0.5;
-
-
-//cl=tex2D(texture2d_1,UV.xy);
-//cl=vec4 (dpth);
-*/
-
-//cl=vec4 (tex2D(texture2d_1,UV.xy));
-//cl=vec4 (tex2D(texture2d_velocities,UV.xy));
-
-
-
-
-
-//cl=cll;
-
-
-
-gl_FragData[0]=cl;
- gl_FragData[1]=cl;
-
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/real/the wind under my wings/f_blurpass2.cpp b/tests/real/the wind under my wings/f_blurpass2.cpp
deleted file mode 100644
index 7995ec0d..00000000
--- a/tests/real/the wind under my wings/f_blurpass2.cpp
+++ /dev/null
@@ -1,264 +0,0 @@
-#version 110
-#define float4 vec4
-#define float3 vec3
-#define float2 vec2
-#define oUV gl_TexCoord[0]
-#define tex3D texture3D
-#define tex2D texture2D
-#define tex1D texture1D
-
- uniform sampler2D texture2d_1;
- uniform sampler2D texture2d_velocities;
- uniform sampler2D texture2d_2;
- uniform sampler2D texture2d_random;
-/* uniform sampler1D texture_transfer_function;
- uniform sampler1D texture_palette_function;
-
-
- uniform float3 VolumeSize;
- uniform float3 RelativeSize;
- uniform float3 Registration_Offset;
- uniform float pet_alpha_blending;
- uniform float3 MousePos;
- uniform int Projection_mode;
-uniform float3 InVolumePosition;
- uniform float3 Windowing_Levels;
-
- uniform float isosurface;
-uniform float Sharpening;
-
-*/
-
- uniform float Limit;
- uniform float Flo;
-
-uniform float PosY;
-uniform vec3 MotionBlur;
-
-
-
-
-
-void main (void)
-{
-
-vec2 MotionBlurPos=vec2 (0.0,0.0);
-
-
-
-//float ff=tex2D (texture2d_1,oUV.xy).x;
-//ff=abs (ff-cl.x);
-//ff=0.5+0.5*sin(ff*10000.0);
-//cl=ff*vec4 (1.0);
-
-
-
-/*
-
-
-float PI=3.1415926535;
-float2 UV=oUV.xy;
-
-UV-=float2 (0.5,0.5);
-UV*=2.0;
-
-
-float3 DirV =float3 (UV.x,UV.y,0.6);
-float lgn=length (DirV);
-DirV/=lgn;
-
-UV.xy=UV.xy+(DirV.xy-UV.xy)*-0.0;
-UV*=0.5;
-UV+=float2 (0.5,0.5);
-*/
- float2 UV=oUV.xy;
-float4 cl=tex2D (texture2d_1,UV.xy);
-
-cl=float4 (0.0);
-float3 Direction=tex2D (texture2d_velocities,UV.xy).xyz;
-//Direction.xy=float2 (0.5);
-Direction.xyz-=float3 (0.5);
-Direction*=2.0;
-
-float alpha=1.0*length (Direction.xyz);
-alpha=clamp (alpha,0.0,1.0);
-//alpha=1-alpha;
-//alpha*=alpha;
-//alpha=1-alpha;
-
-//alpha*=alpha;
-//alpha=0.1;
-Direction*=0.01;
-if (alpha>0.01)
-{
- for (int t=0;t<10;t++) {
-UV.xy-=Direction.xy;
- cl+=tex2D (texture2d_1,UV.xy);
-};
-cl*=1.0/10.0;
-//cl.x+=0.15*alpha;
-//=float4 (1.0,0.0,0.0,1.0)*alpha;
-}
-else
-cl=tex2D (texture2d_1,UV.xy);
-
-float4 clnow=tex2D( texture2d_1,oUV.xy);
-
-cl=cl+(clnow-cl)*0.5;
-
-UV=oUV.xy;
-
-
-
-
-
-
-// blur effect
-float lgn2=length (float2 (1.0,2.0)*(UV.xy-float2 (0.5)));
-lgn2*=lgn2;
-float xxx=1.0+(gl_Color.x)*5.0;
-//xxx=1.0;
-xxx=clamp (xxx,1.0,100.0);
-//pow(lgn2,1.8);
-int count=0;
-{
- for (int y=-3;y<3;y++) {
- for (int x=-3;x<3;x++){
-count++;
-
-float2 dd=float2 (x,y);
-if ( (x)==(y)) {
- //dd*=2.0;
-}
-
-float2 Dist=float2 (x,y)*0.0025*lgn2;
-Dist=dd*0.0018*lgn2*xxx;
-
-Dist+=MotionBlurPos;
-MotionBlurPos+=MotionBlur.xy*0.01;
-
-cl+=tex2D(texture2d_1,UV.xy+Dist);
-
-}
-}
-cl/=float (count)*(lgn2+(1.0-lgn2)*0.85);
-}
-
-vec4 cll=cl*1.03;
-cll+=gl_Color;
-//cll=tex2D (texture2d_1,oUV.xy);
-
-
-
-/*
-
-
-
-
-//Depth blurring
-
-float dpth=0.0;
- count=0;
- float Limit2=1.0-Limit;
-for (int y=-4;y<5;y++) {
- for (int x=-4;x<5;x++){
-count++;
-float2 dd=float2 (x,y)*0.7*Limit2;
-
-//dd=ray.xy*5.0;
-
-float2 Dist=dd*0.0018;
-dpth+=tex2D(texture2d_2,UV.xy+Dist).x;
-}
-}
-dpth/=float (count);
-//dpth=sin(dpth*3.14159);
-//dpth+=0.1;
-dpth=pow(dpth,126.0);
-//dpth+=Limit;
-dpth=1.0-1.0*dpth;
-//if (dpth<0.7) dpth=0.0;
-count=0;
-cl=vec4(0.0);
-dpth=clamp(dpth,0.0,1.0);
-
-dpth=Limit+((1.0-Limit)-(Limit))*dpth;
-dpth*=Flo;
-//dpth=1.0;
-
-float vel=tex2D(texture2d_velocities,UV.xy).x;
-if (dpth>0.02)
-{
-for (int y=-4;y<5;y++) {
- for (int x=-4;x<5;x++){
-count++;
-
-float2 dd=float2 (x,y)*0.7;//;*vec2 (3.0,3.0);
-
-//float2 dd2=float((x+4)*9+(y+4))*float2 (-1.0,1.0)*0.4;
-//dd=dd+(dd2-dd)*-vel*0.4;
-
-
-float2 Dist=dd*0.0018*dpth;
-cl+=tex2D(texture2d_1,UV.xy+Dist);
-//cl.x=dpth;
- }
-}
-
-cl/=float (count);
-}
-else
-cl=tex2D(texture2d_1,UV.xy);
-
-
-
-if (vel>0.01) {
-vec4 newcl=vec4 (0.0);
-for (int x=0;x<15;x++){
-float2 dd2=float(x)*float2 (-1.0,1.0)*0.003*vel;
-newcl+=tex2D(texture2d_1,UV.xy+dd2);
-}
-newcl*=1.0/15.0;
-
-cl=cl+(newcl-cl)*0.5;
-}
-
-
-
-//cl*=0.4;
-
-//cl+=tex2D(texture2d_velocities,UV.xy)*0.5;
-
-
-//cl=tex2D(texture2d_1,UV.xy);
-//cl=vec4 (dpth);
-
-//cl=vec4 (tex2D(texture2d_2,UV.xy).x);
-
-
-
-
-*/
-
-cl=cll;
-
-
-
-gl_FragData[0]=cl;
- gl_FragData[1]=cl;
-
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/real/the wind under my wings/f_combineSSAO.cpp b/tests/real/the wind under my wings/f_combineSSAO.cpp
deleted file mode 100644
index e5cb7c32..00000000
--- a/tests/real/the wind under my wings/f_combineSSAO.cpp
+++ /dev/null
@@ -1,316 +0,0 @@
-#version 110
-#define float4 vec4
-#define float3 vec3
-#define float2 vec2
-#define oUV gl_TexCoord[0]
-#define tex3D texture3D
-#define tex2D texture2D
-#define tex1D texture1D
-
-#define SSAO se= ep+ddd*sign (dot (ray,norm))*ray; \
-occluderFragment = tex2D(texture2d_1,se.xy); \
-shadow=occluderFragment.w;\
-occluderFragment.a=tex2D (texture2d_2,se.xy).x;\
-occNorm = (occluderFragment.xyz*2.0)-vec3 (1.0);\
-depthDifference = depth-occluderFragment.a;\
-normDiff = 1.0-1.0*dot(occNorm,norm);\
-addition=step(0.00002,depthDifference)*normDiff*(1.0-smoothstep(0.000002,0.20,depthDifference));\
- bl += addition;
-
-
-
-
-
-
-
- uniform sampler2D texture2d_1;
- uniform sampler2D texture2d_2;
- uniform sampler2D texture2d_3;
- uniform sampler2D texture2d_projected;
- uniform sampler2D texture2d_random;
- uniform float Limit;
- uniform float fttime;
-uniform mat4 ProjectionMatrix;
-
-
-
-
-
-
-
-
-
-
-
-void main (void)
-{
-float4 cl;
-float depth;
-
-
-
-// random vector
-vec3 fres = normalize((texture2D(texture2d_random,oUV.xy*2.0+float2 (Limit*1.0)).xyz*2.0) - vec3(1.0));
-
-// depth
-depth=tex2D (texture2d_2,oUV.xy).x;
-
-vec3 ep=vec3 (oUV.xy,depth);
-float bl=0.0;
-vec3 ray;
-vec3 se;
-vec3 occNorm;
-float depthDifference,normDiff;
-float3 norm=((tex2D (texture2d_1,oUV.xy).xyz-0.5)*2.0);
-float4 GlobalIllumination=float4 (0.0);
-bl=1.0;
-
-
-
-float ddd=0.002;
-float shadow;
-float addition;
-vec4 occluderFragment;
-
- //for (int i=0;i<24;i++)
-
-bool occluder;
-occluder=true;
-//if (tex2D(texture2d_1,oUV.xy).w<0.9) occluder=false;
-
-if (occluder) {
-
-
-//1
-ray= reflect (vec3(0.53812504, 0.18565957, -0.43192),fres);
-SSAO
-//2
-ray= reflect (vec3(0.13790712, 0.24864247, 0.44301823),fres);
-SSAO
-//3
-ray= reflect (vec3(0.33715037, 0.56794053, -0.005789503),fres);
-SSAO
-//4
-ray= reflect ( vec3(-0.6999805, -0.04511441, -0.0019965635),fres);
-SSAO
-//5
-ray= reflect ( vec3(0.06896307, -0.15983082, -0.85477847),fres);
-SSAO
-//6
-ray= reflect (vec3(0.056099437, 0.006954967, -0.1843352),fres);
-SSAO
-//7
-ray= reflect ( vec3(-0.014653638, 0.14027752, 0.0762037),fres);
-SSAO
-//8
-ray= reflect ( vec3(0.010019933, -0.1924225, -0.034443386),fres);
-SSAO
-//9
-ray= reflect ( vec3(-0.35775623, -0.5301969, -0.43581226),fres);
-SSAO
-//10
-ray= reflect ( vec3(-0.3169221, 0.106360726, 0.015860917),fres);
-SSAO
-//11
-ray= reflect ( vec3(0.010350345, -0.58698344, 0.0046293875),fres);
-SSAO
-//12
-
-ray= reflect ( vec3(-0.08972908, -0.49408212, 0.3287904),fres);
-SSAO
-//13
-ray= reflect ( vec3(0.7119986, -0.0154690035, -0.09183723),fres);
-SSAO
-//14
-ray= reflect ( vec3(-0.053382345, 0.059675813, -0.5411899),fres);
-SSAO
-//15
-ray= reflect ( vec3(0.035267662, -0.063188605, 0.54602677),fres);
-SSAO
-//16
-/*
-ray= reflect ( vec3(-0.47761092, 0.2847911, -0.0271716),fres);
-SSAO
-//17
-ray= reflect ( vec3 ( -0.559644, -0.554896, -0.61554),fres);
-SSAO
-//18
-ray= reflect (vec3 ( 0.65487, 0.496541, -0.569729),fres);
-SSAO
-//19
-ray= reflect (vec3 ( 0.382319, -0.719566, 0.579705),fres);
-SSAO
-//20
-ray= reflect ( vec3 ( 0.800123, 0.344357, 0.491142),fres);
-SSAO
-//21
-ray= reflect ( vec3 ( 0.426191, -0.414526, 0.804071),fres);
-SSAO
-*/
-
-
-
-bl=1.0-bl*0.09*5.10;
-//bl=1.0-bl*0.09*0.80;
-
-
-
-//bl=1.0-clamp (bl,0.0,1.0);
-//bl*=2.0;
-//bl+=0.02;
-}
-
-//bl=0.0;
-norm=normalize(norm);
-// SS lighting
-float ccl=1.0-0.0*pow(dot (norm,float3 (0.0,0.0,1.0)),2.0);
-
-// shadow
-
-//bl=1.0;
-//bl*=1.0-tex2D(texture2d_1,oUV.xy).w*0.5;
-
-
-// SS Reflections
-//float4 NormMot=norm.xyzz;
-///float2 DiffusedUV=norm.xy*0.025+oUV.xy;
-///float4 Refl=2.5*tex2D (texture2d_3,DiffusedUV);
-
-
-gl_FragData[0]=bl*ccl*tex2D(texture2d_3,oUV.xy);
-
-gl_FragData[0]=tex2D(texture2d_1,oUV.xy);
-gl_FragData[1]=tex2D(texture2d_3,oUV.xy);
-
-
-int count=0;
-vec4 Comp=vec4 (0.0);
-vec4 Comp2=vec4 (0.0);
-for (int y=-3;y<4;y++) {
- for (int x=-3;x<4;x++){
-count++;
-float2 dd=float2 (x,y)*0.0005+oUV.xy;
-Comp+=tex2D (texture2d_1,dd);
- }
-}
-
-Comp/=float (count);
-Comp2/=float (count);
-vec4 ResDP=tex2D (texture2d_1,oUV.xy);
-
-Comp*=2.0;
-Comp-=vec4 (1.0);
-
-ResDP*=2.0;
-ResDP-=vec4 (1.0);
-
-
-float dt=1.0*length (Comp.xyz-ResDP.xyz);
-dt=4.0+3.8*(1.0-max (dt,1.0*(abs(dot (Comp,ResDP)))));
-//dt=10.0*(max (dt,(abs(dot (Comp,ResDP)))));
-//dt=0.2*abs(dot (Comp,ResDP));
-//dt=(3.0+3.0*(abs(dot (Comp,ResDP))));
-//dt=1.0;
-//dt=1.0;
-dt+=0.4;
-
-gl_FragData[0]=tex2D (texture2d_3,oUV.xy)*1.0*vec4 (dt);
-
-// fogging
-gl_FragData[0]*=1.0-vec4 (pow (tex2D (texture2d_2,oUV.xy).x,30.0));
-
-if (fttime>260.0)
-gl_FragData[0]=tex2D (texture2d_3,oUV.xy);
-
-
-//if (sin (oUV.y*1100.0)<0.0) gl_FragData[0]*=2.8*vec4 (0.6,0.6,0.6,0.6);
-//if (sin (oUV.x*1200.0)<0.0) gl_FragData[0]*=vec4 (1.0,0.6,0.6,0.6);
-//if (int(oUV.y*100.0)%2==0) gl_FragData[0]=vec4 (0.0);
-
-//gl_FragData[0]+=1.3*vec4 (pow(tex2D (texture2d_3,oUV.xy).x,3.0));
-
-//gl_FragData[0]*=0.3;
-//tex2D (texture2d_3,oUV.xy);
-
-
-//dt=10.0*length (Comp.xyz-ResDP.xyz);
-//gl_FragData[0]=vec4 (dt);
-
-//gl_FragData[0]=tex2D (texture2d_3,oUV.xy);
-//gl_FragData[0]=vec4 (dt);
-//gl_FragData[0]=tex2D (texture2d_3,oUV.xy)*vec4 (bl);
-
-//gl_FragData[0]=vec4(bl)*tex2D(texture2d_3,oUV.xy)+0.0*vec4 (0.0,0.05,0.1,0.0);;
-
-/*
-if (oUV.y<0.5)
-{
-if (oUV.x>0.5)
-gl_FragData[0]=tex2D(texture2d_3,vec2 (1.0-oUV.x,oUV.y));
-else
-gl_FragData[0]=tex2D(texture2d_3,oUV.xy);
-}
-else
-{
-
-if (oUV.x>0.5)
-gl_FragData[0]=tex2D(texture2d_3,vec2 (1.0-oUV.x,1.0-oUV.y));
-else
-gl_FragData[0]=tex2D(texture2d_3,vec2 (oUV.x,1.0-oUV.y));
-}
-*/
-
-/*
-float ff=0.5*3.1515926535+atan ((oUV.x-0.5)/(oUV.y-0.5));
-ff=sin (0.5*ff);
-float fd=length (oUV.xy-vec2 (0.5));
-///ff*=2.0;
-//ff*=0.1;
-vec2 Res=fd*vec2 (sin(ff),cos(ff));
-
-gl_FragData[0]=tex2D (texture2d_3,Res);
-//0.5+0.5*vec4(ff);
-
-*/
-
-
-
-//gl_FragData[0]=tex2D(texture2d_3,oUV.xy)*1.2;
-
-//gl_FragData[0]=5.0*vec4 (pow(tex2D(texture2d_2,oUV.xy).x-0.7,4.0));
-//gl_FragData[0]=vec4(bl)*0.2+0.1*tex2D(texture2d_2,oUV.xy);
-
-//gl_FragData[0]=vec4(bl);
-/*
-if (occluder)
-gl_FragData[0]=vec4(1.0);
-else
-gl_FragData[0]=vec4(0.0);
-*/
-
-// Highlights
-//if (tex2D (texture2d_1,oUV.xy).w>0.9) gl_FragData[0]=tex2D (texture2d_3,oUV.xy);
-//gl_FragData[0].w=tex2D (texture2d_1,oUV.xy).w;
-
-//gl_FragData[1]=tex2D(texture2d_3,oUV.xy);
-
-//gl_FragData[0]=tex2D (texture2d_2,oUV.xy);
-
-
-
-
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/real/the wind under my wings/f_godrays.cpp b/tests/real/the wind under my wings/f_godrays.cpp
deleted file mode 100644
index 24b2fe6e..00000000
--- a/tests/real/the wind under my wings/f_godrays.cpp
+++ /dev/null
@@ -1,229 +0,0 @@
-#version 110
-#define float4 vec4
-#define float3 vec3
-#define float2 vec2
-#define oUV gl_TexCoord[0]
-#define tex3D texture3D
-#define tex2D texture2D
-#define tex1D texture1D
-
- uniform sampler2D texture2d_1;
-/* uniform sampler1D texture_transfer_function;
- uniform sampler1D texture_palette_function;
-
-
- uniform float3 VolumeSize;
- uniform float3 RelativeSize;
- uniform float3 Registration_Offset;
- uniform float pet_alpha_blending;
- uniform float3 MousePos;
- uniform int Projection_mode;
-uniform float3 InVolumePosition;
- uniform float3 Windowing_Levels;
-
- uniform float isosurface;
-uniform float Sharpening;
-
-*/
-
- uniform float Limit;
-
-
-
-
-
-
-
-void main (void)
-{
-
-
-
-
-float v=0.102;
-
-float dss=1.0-pow(length(oUV.xy-float2 (0.5,0.5)),1.0);
-float2 dirr=float2 (0.5,0.5);
-//dss=1;
-//dss*=1.5;
-
-v*=dss*dss;
-//v=0.002;
-float2 MX=float2 (v,0.0);
-float2 MU=float2 (0.0,v);
-dirr.y*=1.0;
- vec4 cl=float4 (0.0);
-/*
-for (int t=0;t<7;t++) {
-float ff=float (t)/(20.0f);
-// cl+=0.11*(1-ff)*tex2D (texture2d_1,ff*dirr+(1-ff)*oUV.st);
-cl+=0.19*(1-ff)*tex2D (texture2d_1,ff*dirr+(1-ff)*oUV.st);
-
-}
-
-0.05,0.1,0.15,0.2,0.25,0.3
-*/
-//float cl=0.3;
-float4 sti=tex2D (texture2d_1,oUV.st);
-cl+=0.191*tex2D (texture2d_1,oUV.st);
-
-cl+=0.191*(0.95)*tex2D (texture2d_1,0.93*0.075*dirr+(1.0-0.93*0.075)*oUV.st);
-cl+=0.191*(0.9)*tex2D (texture2d_1,0.93*0.15*dirr+(1.0-0.93*0.015)*oUV.st);
-cl+=0.191*(0.85)*tex2D (texture2d_1,0.93*0.225*dirr+(1.0-0.93*0.225)*oUV.st);
-
-cl+=0.191*(0.8)*tex2D (texture2d_1,0.93*0.300*dirr+(1.0-0.93*0.300)*oUV.st);
-cl+=0.191*(0.75)*tex2D (texture2d_1,0.93*0.375*dirr+(1.0-0.93*0.375)*oUV.st);
-cl+=0.191*(0.7)*tex2D (texture2d_1,0.93*0.450*dirr+(1.0-0.93*0.450)*oUV.st);
-
-cl=tex2D(texture2d_1,oUV.st)+cl*0.7*float4 (0.4,0.6,1.0,0.0);
-//cl*=dss*sti;
-
-
-
-
-
-
-
-
-
-
-
-//float4 cl;
-//cl=tex2D (texture2d_1,oUV.xy)*1.0*vec4 (0.0,0.0,1.0,0.0);
-cl=vec4 (0.0);
-int count=0;
-float2 DirV=oUV.xy-float2 (0.5,0.5);
-//DirV=-normalize (DirV);
-DirV*=-1.0;
- for (int x=0;x<18;x++){
-count++;
-
-float2 Dist=DirV*float(x)*0.05;
-float4 res=tex2D(texture2d_1,oUV.xy+Dist);
-res*=res*1.5;
-//res*=1.0+0.5*sin(oUV.x*12.0);
-//res*=1.0+0.7*sin(oUV.y*24.0);
-cl+=res;
-}
-
-cl/=float (count);
-cl=tex2D(texture2d_1,oUV.st)*0.9+cl*3.5;
-//*float4 (0.4,0.6,1.0,0.0);
-//cl*=float4 (1.0,1.0,1.0,1.0);
-
-
-
-/*
-//Depth blurring
-
-float dpth=0;
-int count=0;
-for (int y=-4;y<5;y++) {
- for (int x=-4;x<5;x++){
-count++;
-float2 dd=float2 (x,y)*0.7;
-
-//dd=ray.xy*5.0;
-
-float2 Dist=dd*0.0015;
-dpth+=tex2D(texture2d_2,UV.xy+Dist).x;
-}
-}
-dpth/=float (count);
-//dpth=sin(dpth*3.14159);
-dpth+=0.1;
-dpth=pow(dpth,6.0);
-//dpth+=Limit;
-dpth=1.1-dpth;
-//if (dpth<0.7) dpth=0.0;
-count=0;
-cl=vec4(0.0);
-dpth=clamp(dpth,0.0,1.0);
-
-dpth=Limit+((1.0-Limit)-(Limit))*dpth;
-
-if (dpth>0.02) {
-for (int y=-4;y<5;y++) {
- for (int x=-4;x<5;x++){
-count++;
-
-float2 dd=float2 (x,y);
-
-//if ( (x)==(y)) { dd*=120.0;}
-
-float2 Dist=dd*0.0015*dpth;
-cl+=tex2D(texture2d_1,UV.xy+Dist);
-}
-}
-
-cl/=float (count);
-}
-else
-cl=tex2D(texture2d_1,UV.xy);
-
-
-
-*/
-
-
-
-
-
-
-
-
-
-gl_FragData[0]=cl;
- gl_FragData[1]=cl;
-
-/*
-float3 currentuv;
-
-
-
-if (Projection_mode==0) {
-currentuv.xy=oUV.st;
-currentuv.z=0.0+InVolumePosition.z;
-}
-else
-if (Projection_mode==1) {
-currentuv.xz=oUV.st;
-currentuv.y=0.0+InVolumePosition.y;
-}
-else
-if (Projection_mode==2) {
-currentuv.zy=oUV.ts;
-currentuv.x=0.0+InVolumePosition.x;
-}
-float4 original= tex3D (texture3d,currentuv);
-float divisor=1.0/(Windowing_Levels.y-Windowing_Levels.x);
-
-
-
-
-original-=Windowing_Levels.x*float4 (1,1,1,1);
-original*=divisor;
-
-
-//original.x=max (0.0,min (1.0,original.x));
-
-
-gl_FragColor=currentuv.xyzz;
-//gl_FragColor=float4 (1.0,0.0,0.0,1.0);
-//gl_FragColor*=Sharpening;
-*/
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/real/the wind under my wings/f_simpleblur.cpp b/tests/real/the wind under my wings/f_simpleblur.cpp
deleted file mode 100644
index 23024b4c..00000000
--- a/tests/real/the wind under my wings/f_simpleblur.cpp
+++ /dev/null
@@ -1,175 +0,0 @@
-#version 110
-#define float4 vec4
-#define float3 vec3
-#define float2 vec2
-#define oUV gl_TexCoord[0]
-#define tex3D texture3D
-#define tex2D texture2D
-#define tex1D texture1D
-
- uniform sampler2D texture2d_1;
-/* uniform sampler1D texture_transfer_function;
- uniform sampler1D texture_palette_function;
-
-
- uniform float3 VolumeSize;
- uniform float3 RelativeSize;
- uniform float3 Registration_Offset;
- uniform float pet_alpha_blending;
- uniform float3 MousePos;
- uniform int Projection_mode;
-uniform float3 InVolumePosition;
- uniform float3 Windowing_Levels;
-
- uniform float isosurface;
-uniform float Sharpening;
-
-*/
-
- uniform float Limit;
-
-
-
-
-
-
-
-void main (void)
-{
-
-
-
-float4 cl;
-//cl=tex2D (texture2d_1,oUV.xy)*1.0*vec4 (0.0,0.0,1.0,0.0);
-cl=vec4 (0.0);
-int count=0;
-for (int y=-6;y<7;y++) {
- for (int x=-6;x<7;x++){
-count++;
-float2 dd=float2 (x,y)*1.5;
-
-//dd=ray.xy*5.0;
-float2 Dist=dd*0.15;
-float4 res=tex2D(texture2d_1,oUV.xy+Dist);
-cl+=res;
-}
-}
-cl/=float (count);
-//cl*=0.0;
-cl=float4 (1.0,0.0,0.0,0.0);
-
-cl.w=tex2D (texture2d_1,oUV.xy).w;
-/*
-//Depth blurring
-
-float dpth=0;
-int count=0;
-for (int y=-4;y<5;y++) {
- for (int x=-4;x<5;x++){
-count++;
-float2 dd=float2 (x,y)*0.7;
-
-//dd=ray.xy*5.0;
-
-float2 Dist=dd*0.0015;
-dpth+=tex2D(texture2d_2,UV.xy+Dist).x;
-}
-}
-dpth/=float (count);
-//dpth=sin(dpth*3.14159);
-dpth+=0.1;
-dpth=pow(dpth,6.0);
-//dpth+=Limit;
-dpth=1.1-dpth;
-//if (dpth<0.7) dpth=0.0;
-count=0;
-cl=vec4(0.0);
-dpth=clamp(dpth,0.0,1.0);
-
-dpth=Limit+((1.0-Limit)-(Limit))*dpth;
-
-if (dpth>0.02) {
-for (int y=-4;y<5;y++) {
- for (int x=-4;x<5;x++){
-count++;
-
-float2 dd=float2 (x,y);
-
-//if ( (x)==(y)) { dd*=120.0;}
-
-float2 Dist=dd*0.0015*dpth;
-cl+=tex2D(texture2d_1,UV.xy+Dist);
-}
-}
-
-cl/=float (count);
-}
-else
-cl=tex2D(texture2d_1,UV.xy);
-
-
-
-*/
-
-
-
-
-
-
-
-
-
-gl_FragData[0]=cl;
- gl_FragData[1]=cl;
-
-/*
-float3 currentuv;
-
-
-
-if (Projection_mode==0) {
-currentuv.xy=oUV.st;
-currentuv.z=0.0+InVolumePosition.z;
-}
-else
-if (Projection_mode==1) {
-currentuv.xz=oUV.st;
-currentuv.y=0.0+InVolumePosition.y;
-}
-else
-if (Projection_mode==2) {
-currentuv.zy=oUV.ts;
-currentuv.x=0.0+InVolumePosition.x;
-}
-float4 original= tex3D (texture3d,currentuv);
-float divisor=1.0/(Windowing_Levels.y-Windowing_Levels.x);
-
-
-
-
-original-=Windowing_Levels.x*float4 (1,1,1,1);
-original*=divisor;
-
-
-//original.x=max (0.0,min (1.0,original.x));
-
-
-gl_FragColor=currentuv.xyzz;
-//gl_FragColor=float4 (1.0,0.0,0.0,1.0);
-//gl_FragColor*=Sharpening;
-*/
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/real/the wind under my wings/f_velocities.cpp b/tests/real/the wind under my wings/f_velocities.cpp
deleted file mode 100644
index 383da003..00000000
--- a/tests/real/the wind under my wings/f_velocities.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-#version 110
-#define float4 vec4
-#define float3 vec3
-#define float2 vec2
-#define oUV gl_TexCoord[0]
-#define tex3D texture3D
-#define tex2D texture2D
-#define tex1D texture1D
-
-varying vec3 normal;
-varying vec4 position;
-varying vec4 thecolor;
-
-varying vec2 texture_coordinate_1;
-
-
-
-void main (void)
-{
-
-
- float4 TheNormal=float4 (1.0,0.0,0.0,0.0);
-//TheNormal.w=shadow;
-gl_FragData[0]=thecolor;
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/real/the wind under my wings/v_velocities.cpp b/tests/real/the wind under my wings/v_velocities.cpp
deleted file mode 100644
index 0abe947d..00000000
--- a/tests/real/the wind under my wings/v_velocities.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-#define float4 vec4
-#define float3 vec3
-#define float2 vec2
-
-
-
-
-varying vec3 normal;
-varying vec2 texture_coordinate_1;
-varying vec4 position;
-varying vec4 thecolor;
-
-uniform mat4 ProjectionMatrix;
-
-
-void main()
-{
-mat4 Billboard;
-
-vec4 glVertex=gl_Vertex;
-
-vec4 Next_Position;
-
-//gl_Position = gl_TextureMatrix[0] * gl_Vertex;
-
-
- float4 MotionBlurPos_current=gl_TextureMatrix[0]*gl_Vertex;
- float4 MotionBlurPos_previous=gl_TextureMatrix[1]*gl_Vertex;
-
-
-
-float3 MotionBlurmotionVector=MotionBlurPos_current.xyz-MotionBlurPos_previous.xyz;
-
-
-float4 MotionBlurNormalDirection=float4 (0.0,0.0,0.0,0.0)-gl_Vertex.xyzz;
-MotionBlurNormalDirection= -gl_Normal.xyzz*1.0;
-
- ///MotionBlurNormalDirection=gl_TextureMatrix[0]*MotionBlurNormalDirection;
- // normalize (MotionBlurNormalDirection);
-
-
-
-float MotionBlurflag=dot (MotionBlurmotionVector.xyz,MotionBlurNormalDirection.xyz);
-float4 MotionBlurstretch;
-
-float smm=0.0;
-if (MotionBlurflag>-0.0)
-{
- MotionBlurstretch = MotionBlurPos_current+(MotionBlurPos_previous-MotionBlurPos_current)*1.0;
-smm=1.0;
-}
-else
-{
-smm=0.3;
- MotionBlurstretch= MotionBlurPos_current;
-}
-
-
-
- //MotionBlurstretch = MotionBlurPos_current+(MotionBlurPos_previous-MotionBlurPos_current)*1.0;
-
-
-
-
-//MotionBlurPos_current.xyz=MotionBlurPos_current.xyz/MotionBlurPos_current.w;
-//MotionBlurstretch.xyz=MotionBlurstretch.xyz/MotionBlurstretch.w;
-//MotionBlurstretch=MotionBlurPos_previous;
-gl_Position = gl_ModelViewProjectionMatrix* MotionBlurstretch;
-
-float3 MotionBlur_dP=MotionBlurstretch.xyz-MotionBlurPos_current.xyz;
-
-float4 Mot=MotionBlur_dP.xyzz;
-Mot=gl_ModelViewProjectionMatrix*Mot;
-MotionBlur_dP.xyz=Mot.xyz;
-
-MotionBlur_dP+=float3 (1.0);
-MotionBlur_dP*=0.5;
-
-
-thecolor =MotionBlur_dP.xyzz;
-//thecolor =MotionBlurNormalDirection.xyzz;
-//thecolor=float4 (smm);
-//thecolor=(MotionBlurPos_previous-MotionBlurPos_current).xyzz+float4 (0.5,0.5,0.5,0.5);
-//thecolor=gl_TextureMatrix[0]*gl_Normal.xyzz;
-//gl_Position= gl_ModelViewProjectionMatrix*gl_TextureMatrix[0]*gl_Vertex;
-
-//thecolor=MotionBlurstretch.xyzz;
-
-
-// Transforming The Normal To ModelView-Space
-// normal = gl_NormalMatrix * gl_Normal;
- //normal = gl_Normal;
-//texture_coordinate_1 = vec2(gl_MultiTexCoord0);
-
-//position=(glVertex).xyzw;
-//ShadowPosZ= ProjectionMatrix * gl_TextureMatrix[0]*gl_Vertex;
-//position=g
-// Transforming The Vertex Position To ModelView-Space
-// vec4 vertex_in_modelview_space = gl_ModelViewMatrx * gl_Vertex;
-
- // Calculating The Vector From The Vertex Position To The Light Position
-// vertex_to_light_vector = vec3(gl_LightSource[0].position – vertex_in_modelview_space);
-}
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/real/the_real_party_is_in_your_pocket.frag.expected b/tests/real/the_real_party_is_in_your_pocket.frag.expected
index a7ca9e23..c93f55ee 100644
--- a/tests/real/the_real_party_is_in_your_pocket.frag.expected
+++ b/tests/real/the_real_party_is_in_your_pocket.frag.expected
@@ -1,6 +1,4 @@
-/* File generated with
- * http://www.ctrl-alt-test.fr
- */
+// Generated with (https://github.com/laurentlb/Shader_Minifier/)
#ifndef THE_REAL_PARTY_IS_IN_YOUR_POCKET_FRAG_EXPECTED_
# define THE_REAL_PARTY_IS_IN_YOUR_POCKET_FRAG_EXPECTED_
@@ -44,11 +42,11 @@ const char *the_real_party_is_in_your_pocket_frag =
"{"
"float l=1e4;"
"m.x-=m.y*.11;"
- "vec2 i=m-vec2(-.26,0),x;"
+ "vec2 i=m-vec2(-.26,0);"
"i.x=min(-i.x,0.);"
"l=min(l,max(-m.x-.26,abs(length(i*vec2(.9,1))-.022)-.006));"
"l=min(l,v(m-vec2(-.265,0),vec2(.006,.0278)));"
- "x=m;"
+ "vec2 x=m;"
"x.x-=-.16;"
"x.x=abs(x.x);"
"l=min(l,v(x-vec2(x.y/4.+.004,0),vec2(.006,.028)));"
@@ -80,20 +78,24 @@ const char *the_real_party_is_in_your_pocket_frag =
"}"
"float m(vec3 y,float l,float x,float z,bool a)"
"{"
- "vec3 i=y;"
- "float s=.69,f;"
- "i.xy-=vec2(.29,-.745);"
- "i.xy=m(s)*i.xy;"
- "vec2 n=vec2(.04,.05),r=i.xy;"
- "i.xy=mod(i.xy,n)-n/2.;"
- "f=v(vec2(length(i.xy),i.z),vec2(x,l))-z;"
- "f=max(f,abs(r.y-.05)-(a?.3:.15));"
+ "vec3 f=y;"
+ "float i=.69;"
+ "f.xy-=vec2(.29,-.745);"
+ "f.xy=m(i)*f.xy;"
+ "vec2 n=vec2(.04,.05),s=f.xy;"
+ "f.xy=mod(f.xy,n)-n/2.;"
+ "float r=v(vec2(length(f.xy),f.z),vec2(x,l))-z;"
+ "r=max(r,abs(s.y-.05)-(a?"
+ ".3:"
+ ".15));"
"if(a)"
- "f=max(f,abs(r.x-.04)-.13);"
- "r.xy=m(-s)*r.xy;"
- "f=max(f,abs(r.x-.12+n.x)-.125);"
- "f=max(f,abs(r.y-r.x*.2+.015+(a?-.03:0.))-.1265);"
- "return f;"
+ "r=max(r,abs(s.x-.04)-.13);"
+ "s.xy=m(-i)*s.xy;"
+ "r=max(r,abs(s.x-.12+n.x)-.125);"
+ "r=max(r,abs(s.y-s.x*.2+.015+(a?"
+ "-.03:"
+ "0.))-.1265);"
+ "return r;"
"}"
"float x(float l,float m)"
"{"
@@ -103,76 +105,71 @@ const char *the_real_party_is_in_your_pocket_frag =
"vec4 x(vec3 l)"
"{"
"l.x+=.625;"
- "float y=floor(l.x/1.25),f,i,a,z,r,s;"
+ "float y=floor(l.x/1.25);"
"if(y==0.)"
"l.z-=.28;"
"l.x=mod(l.x,1.25)-.625;"
"l.xz=l.xz*m(-.5*y);"
- "vec2 c=l.xy;"
- "c.x=abs(c.x);"
- "f=m(m(c.x-.55,length(c-vec2(0,.8))-1.76,49.),c.y-.95,83.2);"
- "i=l.z-.14;"
- "a=-l.z-.09-(1.-x(.9,l.y+.3+.1)-x(.55,-(l.y+.3+.17)))*.17;"
- "z=m(m(c.x-.48,length(c-vec2(0,2.5))-2.5,117.),c.y-.87,80.);"
+ "vec2 f=l.xy;"
+ "f.x=abs(f.x);"
+ "float a=m(m(f.x-.55,length(f-vec2(0,.8))-1.76,49.),f.y-.95,83.2),z=l.z-.14,s=-l.z-.09-(1.-x(.9,l.y+.3+.1)-x(.55,-(l.y+.3+.17)))*.17,i=m(m(f.x-.48,length(f-vec2(0,2.5))-2.5,117.),f.y-.87,80.);"
"if(l.z>.01)"
- "i+=mix(.02,pow(max(0.,v(l.xy-vec2(0,.25+pow(abs(l.x),3.)),vec2(.32,.94))-.05)*100.,1.3)/1500.,1.-x(-.001,z));"
+ "z+=mix(.02,pow(max(0.,v(l.xy-vec2(0,.25+pow(abs(l.x),3.)),vec2(.32,.94))-.05)*1e2,1.3)/1500.,1.-x(-.001,i));"
"if(l.z<0.)"
- "a=v(a,m(l-vec3(0,0,-.1),vec3(.5,.5,.055))-.04,64.);"
- "c.x-=.09;"
- "c.y+=.635;"
- "f=m(f,i,192.);"
- "r=f;"
- "s=.001+v(length(c)-.01,v(length(c-vec2(.036,0))-.01,length(c-vec2(-.036,0))-.01,40.),40.);"
- "f=m(f,-l.z-.09,64.);"
+ "s=v(s,m(l-vec3(0,0,-.1),vec3(.5,.5,.055))-.04,64.);"
+ "f.x-=.09;"
+ "f.y+=.635;"
+ "a=m(a,z,192.);"
+ "float r=a,c=.001+v(length(f)-.01,v(length(f-vec2(.036,0))-.01,length(f-vec2(-.036,0))-.01,40.),40.);"
+ "a=m(a,-l.z-.09,64.);"
"if(l.z<0.)"
- "f=v(f,m(r+.03,a,64.),256.);"
+ "a=v(a,m(r+.03,s,64.),256.);"
"r=1.;"
- "f=m(m(f,min(l.z,-s+.003),256.),min(l.z,-abs(z)-.001),448.);"
- "f=m(f,min(l.z-.13,-v(l.xy-vec2(0,-.118))),512.);"
- "f=m(f,min(l.z-.13,-abs(length(vec2(max(abs(l.x)-.12,0.),l.y+.117))-.035)+.003),512.);"
- "f=m(m(f,min(1.,-min(1.,max(m(abs(l.x)-.31,abs(l.y-.49)-.29,500.),abs(l.z-.185)-.1))+.004),576.),-abs(l.z-.01)-1e-4,384.);"
+ "a=m(m(a,min(l.z,-c+.003),256.),min(l.z,-abs(i)-.001),448.);"
+ "a=m(a,min(l.z-.13,-v(l.xy-vec2(0,-.118))),512.);"
+ "a=m(a,min(l.z-.13,-abs(length(vec2(max(abs(l.x)-.12,0.),l.y+.117))-.035)+.003),512.);"
+ "a=m(m(a,min(1.,-min(1.,max(m(abs(l.x)-.31,abs(l.y-.49)-.29,5e2),abs(l.z-.185)-.1))+.004),576.),-abs(l.z-.01)-1e-4,384.);"
"if(l.y<0.)"
"{"
"if(l.y<-.5)"
- "f+=(1.-smoothstep(-.001,.002,m(l+vec3(0,.03,-.2),.13,.007,.001,true)))*.005,f=m(f,-m(l+vec3(0,0,-.2),.13,.007,.001,false),1024.);"
+ "a+=(1.-smoothstep(-.001,.002,m(l+vec3(0,.03,-.2),.13,.007,.001,true)))*.005,a=m(a,-m(l+vec3(0,0,-.2),.13,.007,.001,false),1024.);"
"vec2 d=vec2(-.32,-.314),p=vec2(.124,.033);"
- "float h=length(l.xy-vec2(.405,-.28))-.07,t=length(l.xy-vec2(.202,-.345))-.07,e=v(v(l.xy-d,p)-.005,v(l.xy-d,p.yx)-.005,512.),b,w,k,g,o;"
- "f=m(f,min(l.z,-h+.004),320.);"
- "f=m(f,min(l.z,-t+.004),320.);"
- "f=m(f,min(l.z,-min(1.,e)+.006),192.);"
+ "float b=length(l.xy-vec2(.405,-.28))-.07,o=length(l.xy-vec2(.202,-.345))-.07,e=v(v(l.xy-d,p)-.005,v(l.xy-d,p.yx)-.005,512.);"
+ "a=m(a,min(l.z,-b+.004),320.);"
+ "a=m(a,min(l.z,-o+.004),320.);"
+ "a=m(a,min(l.z,-min(1.,e)+.006),192.);"
"l.xy-=vec2(.405,-.28);"
- "b=(1.-x(.002,min(min(n(l.xy,vec2(0,-.035),vec2(-.014,.024)),n(l.xy,vec2(-.03,-.035),vec2(-.014,.024))),n(l.xy,vec2(-.02),vec2(-.01,-.02)))-.0025))*.002;"
+ "float g=(1.-x(.002,min(min(n(l.xy,vec2(0,-.035),vec2(-.014,.024)),n(l.xy,vec2(-.03,-.035),vec2(-.014,.024))),n(l.xy,vec2(-.02),vec2(-.01,-.02)))-.0025))*.002;"
"l.xy+=vec2(.405,-.28);"
"l.xy-=vec2(.202,-.345);"
- "w=min(min(min(n(l.xy,vec2(-.03,-.035),vec2(-.03,.024)),n(l.xy,vec2(-.03,-.035),vec2(-.018,-.035))),n(l.xy,vec2(-.03,.024),vec2(-.018,.024))),n(l.xy,vec2(-.03,-.0055),vec2(-.018,-.0055)));"
+ "float w=min(min(min(n(l.xy,vec2(-.03,-.035),vec2(-.03,.024)),n(l.xy,vec2(-.03,-.035),vec2(-.018,-.035))),n(l.xy,vec2(-.03,.024),vec2(-.018,.024))),n(l.xy,vec2(-.03,-.0055),vec2(-.018,-.0055)));"
"if(l.x>-.018)"
"w=min(min(w,abs(length(l.xy-vec2(-.018,-.02025))-.01475)),abs(length(l.xy-vec2(-.018,.00925))-.01475));"
"w=(1.-x(.002,w-.0025))*.002;"
"l.xy+=vec2(.202,-.345);"
- "k=max(-l.z,m(abs(l.z)-.17,max(-.015,s),96.));"
- "g=min(max(-l.z,m(abs(l.z)-.17+w,t,128.)),max(-l.z,m(abs(l.z)-.17+b,h,128.)));"
- "vec3 u=l;"
- "u.z-=pow(length(l.xy-d),2.)/2.-.01;"
- "g=m(min(g,max(-l.z,m(abs(u.z)-.18,e,768.))),-(length(u-vec3(d,.19))-.026),512.);"
- "u.xy-=d;"
- "u.xy=abs(u.xy);"
- "if(u.x0.)"
- "c=vec2(c.x-o*c.y,-o*c.x-c.y)/2.;"
- "c.x-=clamp(c.x,-2.,0.);"
- "g=m(g,-max(-u.z,-length(c)*sign(c.y)+.565),512.);"
- "if(g0.)"
+ "f=vec2(f.x-C*f.y,-C*f.x-f.y)/2.;"
+ "f.x-=clamp(f.x,-2.,0.);"
+ "t=m(t,-max(-h.z,-length(f)*sign(f.y)+.565),512.);"
+ "if(t0.&&o.x0.&&h.xo.y||abs(k)<1e-5)"
+ "k=x(r+p*d);"
+ "e=k.x;"
+ "if(d>h.y||abs(e)<1e-5)"
"break;"
- "e+=k;"
+ "d+=e;"
"}"
- "if(e0.)"
- "return y=g,d;"
+ "if(i.x>0.)"
+ "return y=f,i;"
"m=-1.;"
- "i=vec2(-1,-3);"
- "f=(i.x-l.y)/v.y;"
- "a=(i.y-l.z)/v.z;"
- "c=s((l-vec3(0,i+2.))*vec3(0,.5,.5),v*vec3(0,.5,.5));"
- "r=l.yz+v.yz*c.y-i-2.;"
- "if(c.x0.&&r.x<0.&&r.y<0.)"
- "y=vec3(-r*.5,0).zxy,m=c.y;"
+ "vec2 h=vec2(-1,-3);"
+ "float r=(h.x-l.y)/v.y,d=(h.y-l.z)/v.z;"
+ "vec2 c=s((l-vec3(0,h+2.))*vec3(0,.5,.5),v*vec3(0,.5,.5)),p=l.yz+v.yz*c.y-h-2.;"
+ "if(c.x0.&&p.x<0.&&p.y<0.)"
+ "y=vec3(-p*.5,0).zxy,m=c.y;"
"else"
- " if(f>0.&&(f0.&&(r0.&&(a5.||abs(u.y)>2.5||abs(u.z)>3.3)"
- "return vec4(-1);"
- "return vec4(m,0,0,0);"
+ " if(d>0.&&(d5.||abs(w.y)>2.5||abs(w.z)>3.3?"
+ "vec4(-1):"
+ "vec4(m,0,0,0);"
"}"
"float y;"
"float m()"
@@ -254,153 +249,165 @@ const char *the_real_party_is_in_your_pocket_frag =
"}"
"vec3 h(vec3 l,vec3 v)"
"{"
- "vec3 f=vec3(0),a=vec3(1);"
- "bool y=false;"
+ "vec3 y=vec3(0),f=vec3(1);"
+ "bool a=false;"
"for(int i=0;i<4;++i)"
"{"
"v=normalize(v);"
- "vec3 z,p,e,c,r;"
- "vec4 u=s(l,v,z);"
- "float d=u.x,g,k;"
+ "vec3 z,p,e;"
+ "vec4 r=s(l,v,z);"
+ "float d=r.x;"
"if(d<0.)"
"{"
- "f+=max(a*vec3(.9)*(.5+.5*dot(v,normalize(vec3(-2,4,1))))*.4*1.3*vec3(1,.9,.65)+a*vec3(.9)*step(.9,dot(v,normalize(vec3(6,2,1))))*10.4*2.3+a*vec3(.9)*step(.95,dot(v,normalize(vec3(-2,1,3))))*10.4*1.5,0.)*pow(max(.5+.5*-v.z,0.),.2);"
+ "y+=max(f*vec3(.9)*(.5+.5*dot(v,normalize(vec3(-2,4,1))))*.4*1.3*vec3(1,.9,.65)+f*vec3(.9)*step(.9,dot(v,normalize(vec3(6,2,1))))*10.4*2.3+f*vec3(.9)*step(.95,dot(v,normalize(vec3(-2,1,3))))*10.4*1.5,0.)*pow(max(.5+.5*-v.z,0.),.2);"
"break;"
"}"
- "g=floor(u.y/8.);"
- "u.y=mod(u.y,8.);"
- "c=l+v*d;"
- "vec2 o=vec2(6.28319*m(),m()*2.-1.);"
- "r=z+vec3(sqrt(1.-o.y*o.y)*vec2(cos(o.x),sin(o.x)),o.y);"
- "k=u.y>1.5?mix(c.x>0.?.1:.05,.5,pow(1.-clamp(dot(-v,z),0.,1.),2.)):mix(.2,.8,pow(1.-clamp(dot(-v,z),0.,1.),1.5));"
- "if(u.y>5.5&&u.y<6.5)"
+ "float c=floor(r.y/8.);"
+ "r.y=mod(r.y,8.);"
+ "vec3 h=l+v*d;"
+ "vec2 w=vec2(6.28319*m(),m()*2.-1.);"
+ "vec3 k=z+vec3(sqrt(1.-w.y*w.y)*vec2(cos(w.x),sin(w.x)),w.y);"
+ "float t=r.y>1.5?"
+ "mix(h.x>0.?"
+ ".1:"
+ ".05,.5,pow(1.-clamp(dot(-v,z),0.,1.),2.)):"
+ "mix(.2,.8,pow(1.-clamp(dot(-v,z),0.,1.),1.5));"
+ "if(r.y>5.5&&r.y<6.5)"
"{"
- "if(y)"
+ "if(a)"
"break;"
- "l=c+z*2e-4;"
- "a*=mix(.1,.8,pow(1.-clamp(dot(-v,z),0.,1.),3.))*mix(vec3(1),vec3(1,.9,.5),.5);"
+ "l=h+z*2e-4;"
+ "f*=mix(.1,.8,pow(1.-clamp(dot(-v,z),0.,1.),3.))*mix(vec3(1),vec3(1,.9,.5),.5);"
"v=reflect(v,z)+(vec3(m(),m(),m())-.5)*.3;"
"}"
"else"
- " if(u.y>4.5&&u.y<5.5)"
+ " if(r.y>4.5&&r.y<5.5)"
"{"
- "if(y)"
+ "if(a)"
"break;"
- "k=.02;"
- "if(m()>k)"
- "l=c-z*2e-4*-sign(v.z),v=v+(vec3(m(),m(),m())-.5)*.1;"
+ "t=.02;"
+ "if(m()>t)"
+ "l=h-z*2e-4*-sign(v.z),v+=(vec3(m(),m(),m())-.5)*.1;"
"else"
- " l=c+z*2e-4,v=reflect(v,z)+(vec3(m(),m(),m())-.5)*.3;"
+ " l=h+z*2e-4,v=reflect(v,z)+(vec3(m(),m(),m())-.5)*.3;"
"}"
"else"
- " if(u.y<.5||u.y>2.5)"
+ " if(r.y<.5||r.y>2.5)"
"{"
- "vec3 b=u.y>2.5?vec3(.08):vec3(.7);"
- "if(u.y>3.5)"
+ "vec3 b=r.y>2.5?"
+ "vec3(.08):"
+ "vec3(.7);"
+ "if(r.y>3.5)"
"{"
"b=vec3(.008);"
- "if(!y)"
+ "if(!a)"
"{"
- "if(c.y>.5)"
+ "if(h.y>.5)"
"{"
- "vec2 w=u.zw-vec2(-.38,.6);"
- "float h=min(min(min(min(min(min(max(length(w-vec2(.005))-.0125,-(length(w-vec2(-.012,.005))-.025)),max(length(w-vec2(-.02,.005))-.0125,-(length(w-vec2(-.045,.005))-.03))),max(length(w-vec2(.005))-.0125,-(length(w-vec2(-.012,.005))-.025))),max(length(w-vec2(.03,.005))-.0125,-(length(w-vec2(.02,.005))-.02))),abs(length(w-vec2(-.037,-.0398))-.0104)),n(w,vec2(-.064,-.05),vec2(-.064,-.03))),max(-w.x-.063,abs(length(vec2(max(0.,w.x+.06),w.y+.035))-.006)));"
- "w.x-=.091;"
- "h=min(h,n(w,vec2(-.064,-.05),vec2(-.064,-.03)));"
- "h=min(h,max(-w.x-.063,abs(length(vec2(max(0.,w.x+.06),w.y+.035))-.006)));"
- "h=min(h,n(w,vec2(-.054,-.05),vec2(-.059,-.041)));"
- "w.x+=.091;"
- "h=min(h,n(w,vec2(.009,-.05),vec2(.009,-.03)));"
- "h=min(h,n(w,vec2(.009,-.05),vec2(.018,-.05)));"
- "h=min(h,n(w,vec2(.009,-.03),vec2(.018,-.03)));"
- "h=min(h,n(w,vec2(.009,-.039),vec2(.018,-.039)));"
- "w.x=abs(w.x+.01);"
- "w.x=abs(w.x-.006);"
- "h=min(h,n(w,vec2(0,-.05),vec2(.006,-.03)));"
- "b=mix(b,vec3(.3),step(h-.0018,0.));"
+ "vec2 o=r.zw-vec2(-.38,.6);"
+ "float g=min(min(min(min(min(min(max(length(o-vec2(.005))-.0125,-(length(o-vec2(-.012,.005))-.025)),max(length(o-vec2(-.02,.005))-.0125,-(length(o-vec2(-.045,.005))-.03))),max(length(o-vec2(.005))-.0125,-(length(o-vec2(-.012,.005))-.025))),max(length(o-vec2(.03,.005))-.0125,-(length(o-vec2(.02,.005))-.02))),abs(length(o-vec2(-.037,-.0398))-.0104)),n(o,vec2(-.064,-.05),vec2(-.064,-.03))),max(-o.x-.063,abs(length(vec2(max(0.,o.x+.06),o.y+.035))-.006)));"
+ "o.x-=.091;"
+ "g=min(g,n(o,vec2(-.064,-.05),vec2(-.064,-.03)));"
+ "g=min(g,max(-o.x-.063,abs(length(vec2(max(0.,o.x+.06),o.y+.035))-.006)));"
+ "g=min(g,n(o,vec2(-.054,-.05),vec2(-.059,-.041)));"
+ "o.x+=.091;"
+ "g=min(g,n(o,vec2(.009,-.05),vec2(.009,-.03)));"
+ "g=min(g,n(o,vec2(.009,-.05),vec2(.018,-.05)));"
+ "g=min(g,n(o,vec2(.009,-.03),vec2(.018,-.03)));"
+ "g=min(g,n(o,vec2(.009,-.039),vec2(.018,-.039)));"
+ "o.x=abs(o.x+.01);"
+ "o.x=abs(o.x-.006);"
+ "g=min(g,n(o,vec2(0,-.05),vec2(.006,-.03)));"
+ "b=mix(b,vec3(.3),step(g-.0018,0.));"
"}"
- "if(length(u.zw-vec2(-.43,.605))<.014)"
- "f+=a*3.*vec3(1,.01,.01)*(.8+8.*(1.-x(.01,length(u.zw-vec2(-.43,.605)))));"
- "if(u.w>0.&&c.y<.2)"
+ "if(length(r.zw-vec2(-.43,.605))<.014)"
+ "y+=f*3.*vec3(1,.01,.01)*(.8+8.*(1.-x(.01,length(r.zw-vec2(-.43,.605)))));"
+ "if(r.w>0.&&h.y<.2)"
"{"
- "b=mix(b,vec3(.3),step(n(u.zw-vec2(0,.103)),0.));"
+ "b=mix(b,vec3(.3),step(n(r.zw-vec2(0,.103)),0.));"
"{"
- "vec2 h=vec2(-.07,.02),w=vec2(-.09,.03),t=vec2(-.1,0),q=t+normalize(t-w)*.03,C=vec2(-.065,-.026);"
- "b=mix(b,vec3(.520661,.00153787,.064975),step(min(m(u.zw-vec2(.16,.103),t,q,C),m(u.zw-vec2(.16,.103),h,w,t))-.007,0.));"
+ "vec2 g=vec2(-.07,.02),o=vec2(-.09,.03),C=vec2(-.1,0),D=C+normalize(C-o)*.03,B=vec2(-.065,-.026);"
+ "b=mix(b,vec3(.520661,.00153787,.064975),step(min(m(r.zw-vec2(.16,.103),C,D,B),m(r.zw-vec2(.16,.103),g,o,C))-.007,0.));"
"}"
"{"
- "vec2 w=u.zw-vec2(.16,.103);"
- "w-=vec2(-.029,-.015);"
- "w.x+=cos(w.y*30.)*.01;"
- "w.y-=cos(w.x*20.)*.01;"
- "b=mix(b,vec3(.093564,.0865052,.434048),step(abs(length(w)-.02)-.007,0.));"
+ "vec2 o=r.zw-vec2(.16,.103);"
+ "o-=vec2(-.029,-.015);"
+ "o.x+=cos(o.y*30.)*.01;"
+ "o.y-=cos(o.x*20.)*.01;"
+ "b=mix(b,vec3(.093564,.0865052,.434048),step(abs(length(o)-.02)-.007,0.));"
"}"
"{"
- "vec2 w=u.zw-vec2(.16,.103),h=vec2(-.01,.02),t=vec2(-.007,0),C=vec2(-.007,-.0205),q=C+normalize(C-t)*.01,F=vec2(.02,-.02);"
- "b=mix(b,vec3(.186082,.481799,.0177778),step(min(m(w,C,q,F),m(w,h,t,C))-.007,0.));"
+ "vec2 o=r.zw-vec2(.16,.103),g=vec2(-.01,.02),C=vec2(-.007,0),D=vec2(-.007,-.0205),B=D+normalize(D-C)*.01,A=vec2(.02,-.02);"
+ "b=mix(b,vec3(.186082,.481799,.0177778),step(min(m(o,D,B,A),m(o,g,C,D))-.007,0.));"
"}"
"{"
- "vec2 w=u.zw-vec2(.16,.103);"
- "w-=vec2(.045,-.015);"
- "w.x+=cos(w.y*20.+1.)*.005;"
- "w.y-=cos(w.x*20.+25.)*.01;"
- "b=mix(b,vec3(.730857,.454964,.000553633),step(abs(length(w)-.02)-.007,0.));"
+ "vec2 o=r.zw-vec2(.16,.103);"
+ "o-=vec2(.045,-.015);"
+ "o.x+=cos(o.y*20.+1.)*.005;"
+ "o.y-=cos(o.x*20.+25.)*.01;"
+ "b=mix(b,vec3(.730857,.454964,.000553633),step(abs(length(o)-.02)-.007,0.));"
"}"
"{"
- "vec2 w=u.zw-vec2(.24,.103),h=vec2(-.006,-.026),t=vec2(-.002,0),C=vec2(-.007,.016),q=C+normalize(C-t)*.012,F=vec2(.02),T=q+normalize(F-q)*.05,Z=vec2(.002,-.007),Y=vec2(.025,-.028);"
- "b=mix(b,vec3(0,.332318,.292872),step(min(min(min(m(w,C,q,F),m(w,h,t,C)),m(w,F,T,Z)),m(w,Z,(Z+Y)/2.+vec2(.001),Y))-.007,0.));"
+ "vec2 o=r.zw-vec2(.24,.103),g=vec2(-.006,-.026),C=vec2(-.002,0),D=vec2(-.007,.016),B=D+normalize(D-C)*.012,A=vec2(.02),E=B+normalize(A-B)*.05,F=vec2(.002,-.007),G=vec2(.025,-.028);"
+ "b=mix(b,vec3(0,.332318,.292872),step(min(min(min(m(o,D,B,A),m(o,g,C,D)),m(o,A,E,F)),m(o,F,(F+G)/2.+vec2(.001),G))-.007,0.));"
"}"
"}"
"{"
- "vec2 w=vec2(160,144)/1.5,h=(u.zw-vec2(-.001,.486))*3.75*vec2(w.y/w.x,1)*.5+.5,t=fract(h*w);"
- "h=floor(h*w)/w;"
- "if(max(abs(h.x-.5),abs(h.y-.5))<.5)"
+ "vec2 o=vec2(160,144)/1.5,g=(r.zw-vec2(-.001,.486))*3.75*vec2(o.y/o.x,1)*.5+.5,C=fract(g*o);"
+ "g=floor(g*o)/o;"
+ "if(max(abs(g.x-.5),abs(g.y-.5))<.5)"
"{"
- "vec3 q=vec3(0);"
- "vec2 C=(h*2.-1.)*vec2(w.x/w.y,1);"
- "float F=min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(n(vec4(1.54,.53,.91,.72),C),n(vec4(.63,.78,.91,.72),C)),n(vec4(.61,1.675,.72,.64),C)),n(vec4(2.7,3.11,.72,.64),C)),n(vec4(3.45,3.65,.72,.64),C)),n(vec4(4.71,5.02,.72,.64),C)),n(vec4(5.3,5.51,.72,.64),C)),n(vec4(5.96,6.43,.72,.64),C)),n(vec4(3.2,1.27,.45,.35),C)),n(vec4(1.3,2.3,.45,.35),C)),n(vec4(2.58,4.2,.45,.35),C)),n(vec4(3.2,3.95,.35,.25),C)),n(vec4(5.2,5.93,.35,.25),C)),n(vec4(7.9,8.15,.35,.25),C)),n(vec4(.2,1.16,.32,.17),C)),max(length(C)-.84,-length(C)+.72)),max(length(C)-.52,-length(C)+.45)),max(length(C)-.17,-length(C)+.08)),Z=floor(h.y*8.);"
- "q=.5+.5*cos(vec3(.8,.3,2)*(Z+1.));"
- "q=mix(q,vec3(1),step(F,0.));"
- "q*=vec3(1,1,.8);"
- "q*=smoothstep(.1,.2,t.x)*smoothstep(.1,.2,t.y);"
- "f+=a*3.*q;"
+ "vec3 D=vec3(0);"
+ "vec2 B=(g*2.-1.)*vec2(o.x/o.y,1);"
+ "float A=min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(n(vec4(1.54,.53,.91,.72),B),n(vec4(.63,.78,.91,.72),B)),n(vec4(.61,1.675,.72,.64),B)),n(vec4(2.7,3.11,.72,.64),B)),n(vec4(3.45,3.65,.72,.64),B)),n(vec4(4.71,5.02,.72,.64),B)),n(vec4(5.3,5.51,.72,.64),B)),n(vec4(5.96,6.43,.72,.64),B)),n(vec4(3.2,1.27,.45,.35),B)),n(vec4(1.3,2.3,.45,.35),B)),n(vec4(2.58,4.2,.45,.35),B)),n(vec4(3.2,3.95,.35,.25),B)),n(vec4(5.2,5.93,.35,.25),B)),n(vec4(7.9,8.15,.35,.25),B)),n(vec4(.2,1.16,.32,.17),B)),max(length(B)-.84,-length(B)+.72)),max(length(B)-.52,-length(B)+.45)),max(length(B)-.17,-length(B)+.08)),F=floor(g.y*8.);"
+ "D=.5+.5*cos(vec3(.8,.3,2)*(F+1.));"
+ "D=mix(D,vec3(1),step(A,0.));"
+ "D*=vec3(1,1,.8);"
+ "D*=smoothstep(.1,.2,C.x)*smoothstep(.1,.2,C.y);"
+ "y+=f*3.*D;"
"b=vec3(.1);"
"}"
"}"
"}"
"}"
- "if(u.y>3.&&u.y<3.2)"
+ "if(r.y>3.&&r.y<3.2)"
"b=vec3(.4);"
- "a*=b;"
- "l=c+z*2e-4;"
- "v=r;"
- "y=true;"
+ "f*=b;"
+ "l=h+z*2e-4;"
+ "v=k;"
+ "a=true;"
"}"
"else"
"{"
- "vec3 w=g>1.5?vec3(1,.02,.2):g>.5?vec3(.2,1,.02):vec3(.02,.2,1);"
- "if(m()>mix(.2,1.,k))"
+ "vec3 o=c>1.5?"
+ "vec3(1,.02,.2):"
+ "c>.5?"
+ "vec3(.2,1,.02):"
+ "vec3(.02,.2,1);"
+ "if(m()>mix(.2,1.,t))"
"{"
- "if(u.y>1.5)"
- "w=vec3(.02);"
- "a*=w;"
- "l=c+z*2e-4;"
- "v=r;"
- "y=true;"
+ "if(r.y>1.5)"
+ "o=vec3(.02);"
+ "f*=o;"
+ "l=h+z*2e-4;"
+ "v=k;"
+ "a=true;"
"}"
"else"
"{"
- "if(y)"
+ "if(a)"
"break;"
- "a*=u.y>1.5?vec3(.5):.9*mix(w,vec3(1),.25);"
- "l=c+z*2e-4;"
+ "f*=r.y>1.5?"
+ "vec3(.5):"
+ ".9*mix(o,vec3(1),.25);"
+ "l=h+z*2e-4;"
"v=reflect(v,z)+(vec3(m(),m(),m())-.5)*.4;"
"}"
"}"
- "if(max(a.x,max(a.y,a.z))<.001)"
+ "if(max(f.x,max(f.y,f.z))<.001)"
"break;"
"}"
- "return f;"
+ "return y;"
"}"
"void main()"
"{"
@@ -408,14 +415,14 @@ const char *the_real_party_is_in_your_pocket_frag =
"for(int v=0;v<16;++v)"
"{"
"y=float(v)+gl_TexCoord[0].x*16.;"
- "float w=m()*6.28319;"
- "vec2 f=vec2(cos(w),sin(w))*sqrt(1.-sqrt(1.-m()))*1.2;"
+ "float a=m()*6.28319;"
+ "vec2 o=vec2(cos(a),sin(a))*sqrt(1.-sqrt(1.-m()))*1.2;"
"if(int(y)%4==0)"
- "f*=15.*length(f);"
- "l+=h(vec3(0,0,4.8),vec3((gl_FragCoord.xy-vec2(960,540)+f)/540.,-3.5))/48.;"
+ "o*=15.*length(o);"
+ "l+=h(vec3(0,0,4.8),vec3((gl_FragCoord.xy-vec2(960,540)+o)/540.,-3.5))/48.;"
"}"
"l/=(l+1.)/2.;"
- "gl_FragColor.xyz=pow(l+.01*vec3(1,1,.5),vec3(1./2.2))+m()/100.;"
+ "gl_FragColor.xyz=pow(l+.01*vec3(1,1,.5),vec3(1./2.2))+m()/1e2;"
"}";
#endif // THE_REAL_PARTY_IS_IN_YOUR_POCKET_FRAG_EXPECTED_
diff --git a/tests/real/to_the_road_of_ribbon.expected b/tests/real/to_the_road_of_ribbon.expected
index ea722071..786f6d68 100644
--- a/tests/real/to_the_road_of_ribbon.expected
+++ b/tests/real/to_the_road_of_ribbon.expected
@@ -1,6 +1,4 @@
-/* File generated with
- * http://www.ctrl-alt-test.fr
- */
+// Generated with (https://github.com/laurentlb/Shader_Minifier/)
#ifndef TO_THE_ROAD_OF_RIBBON_EXPECTED_
# define TO_THE_ROAD_OF_RIBBON_EXPECTED_
@@ -28,22 +26,22 @@ const char *to_the_road_of_ribbon_frag =
"{"
"vec2 t=-1.+2.*gl_FragCoord.xy/resolution.xy;"
"t.x*=resolution.x/resolution.y;"
- "vec4 v=vec4(1),c;"
- "vec3 o=vec3(sin(time)*.5,cos(time*.5)*.25+.25,time),m=normalize(vec3(t.x*1.6,t.y,1)),y=o,n;"
- "float e=0.,f;"
+ "vec4 v=vec4(1);"
+ "vec3 m=vec3(sin(time)*.5,cos(time*.5)*.25+.25,time),o=normalize(vec3(t.x*1.6,t.y,1)),c=m,f;"
+ "float e=0.;"
"for(int r=0;r<64;r++)"
- "e=o(y),y+=e*m;"
- "n=y;"
- "f=length(y-o)*.02;"
- "m=reflect(m,gn(y));"
- "y+=m;"
- "for(int r=0;r<64;r++)"
- "e=o(y),y+=e*m;"
- "v=max(dot(gn(y),vec3(.1,.1,0)),0.)+vec4(.3,cos(time*.5)*.5+.5,sin(time*.5)*.5+.5,1)*min(length(y-o)*.04,1.);"
- "if(oa(n)>ob(n))"
+ "e=o(c),c+=e*o;"
+ "f=c;"
+ "float r=length(c-m)*.02;"
+ "o=reflect(o,gn(c));"
+ "c+=o;"
+ "for(int g=0;g<64;g++)"
+ "e=o(c),c+=e*o;"
+ "v=max(dot(gn(c),vec3(.1,.1,0)),0.)+vec4(.3,cos(time*.5)*.5+.5,sin(time*.5)*.5+.5,1)*min(length(c-m)*.04,1.);"
+ "if(oa(f)>ob(f))"
"v=mix(v,vec4(cos(time*.3)*.5+.5,cos(time*.2)*.5+.5,sin(time*.3)*.5+.5,1),.3);"
- "c=(v+vec4(f)+(1.-min(n.y+1.9,1.))*vec4(1,.8,.7,1))*min(time*.5,1.);"
- "gl_FragColor=vec4(c.xyz,1);"
+ "vec4 g=(v+vec4(r)+(1.-min(f.y+1.9,1.))*vec4(1,.8,.7,1))*min(time*.5,1.);"
+ "gl_FragColor=vec4(g.xyz,1);"
"}";
#endif // TO_THE_ROAD_OF_RIBBON_EXPECTED_
diff --git a/tests/real/tunnel.frag b/tests/real/tunnel.frag
deleted file mode 100644
index 1ab25c20..00000000
--- a/tests/real/tunnel.frag
+++ /dev/null
@@ -1,22 +0,0 @@
-uniform vec2 resolution;
-uniform float time;
-uniform sampler2D tex0;
-uniform sampler2D tex1;
-uniform sampler2D tex2;
-uniform sampler2D tex3;
-
-void main(void)
-{
- vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
- vec2 uv;
-
- float a = atan(p.y,p.x);
- float r = sqrt(dot(p,p));
-
- uv.x = .75*time+.1/r;
- uv.y = a/3.1416;
-
- vec3 col = texture2D(tex0,uv).xyz;
-
- gl_FragColor = vec4(col*r,1.0);
-}
diff --git a/tests/real/twist.frag b/tests/real/twist.frag
deleted file mode 100644
index 82b4bea3..00000000
--- a/tests/real/twist.frag
+++ /dev/null
@@ -1,22 +0,0 @@
-uniform vec2 resolution;
-uniform float time;
-uniform sampler2D tex0;
-uniform sampler2D tex1;
-uniform sampler2D tex2;
-uniform sampler2D tex3;
-
-void main(void)
-{
- vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
- vec2 uv;
-
- float a = atan(p.y,p.x);
- float r = sqrt(dot(p,p));
-
- uv.x = r - .25*time;
- uv.y = cos(a*5.0 + 2.0*sin(time+7.0*r)) ;
-
- vec3 col = (.5+.5*uv.y)*texture2D(tex0,uv).xyz;
-
- gl_FragColor = vec4(col,1.0);
-}
diff --git a/tests/real/valley_ball.glsl.expected b/tests/real/valley_ball.glsl.expected
index cd5c9786..64bdadd0 100644
--- a/tests/real/valley_ball.glsl.expected
+++ b/tests/real/valley_ball.glsl.expected
@@ -15,9 +15,9 @@ float rnd(vec2 x)
float smoothrnd(vec2 x)
{
x=mod(x,1e3);
- vec2 a=fract(x),u;
+ vec2 a=fract(x);
x-=a;
- u=a*a*(3.-2.*a);
+ vec2 u=a*a*(3.-2.*a);
return mix(mix(rnd(x+vec2(0)),rnd(x+vec2(1,0)),u.x),mix(rnd(x+vec2(0,1)),rnd(x+vec2(1)),u.x),u.y);
}
float norm(float x)
@@ -71,7 +71,9 @@ vec3 shadeTerrain(vec3 p,vec3 rd)
}
vec3 shadeSky(vec3 ro,vec3 rd)
{
- return ro.y<=-eps*eps?waterColor:(1.+Y.z*.3)*mix(vec3(-.5,-.25,0),vec3(2),1.-rd.y*.5-.5);
+ return ro.y<=-eps*eps?
+ waterColor:
+ (1.+Y.z*.3)*mix(vec3(-.5,-.25,0),vec3(2),1.-rd.y*.5-.5);
}
vec3 shadeAttractor(vec3 p,vec3 rd)
{
@@ -108,21 +110,29 @@ float traceAttractor(vec3 ro,vec3 rd)
if(B>0.)
return 9.;
D=B*B-dot(dst,dst)+sphereRadius*sphereRadius;
- if(D>0.)
- return-B-sqrt(D);
- return 9.;
+ return D>0.?
+ -B-sqrt(D):
+ 9.;
}
float traceWater(vec3 ro,vec3 rd)
{
float tPlane=-ro.y/rd.y;
- return tPlane>=eps?tPlane:9.;
+ return tPlane>=eps?
+ tPlane:
+ 9.;
}
vec4 traceRay(vec3 ro,vec3 rd,int ignore)
{
float water,attractor,terrain,minDist;
- water=ignore!=2?traceWater(ro,rd):9.;
- attractor=ignore!=3?traceAttractor(ro,rd):9.;
- terrain=ignore!=1?traceTerrain(ro,rd,min(.5,.002+min(water,attractor))):9.;
+ water=ignore!=2?
+ traceWater(ro,rd):
+ 9.;
+ attractor=ignore!=3?
+ traceAttractor(ro,rd):
+ 9.;
+ terrain=ignore!=1?
+ traceTerrain(ro,rd,min(.5,.002+min(water,attractor))):
+ 9.;
gf_DetailLevel/=20.;
minDist=min(terrain,min(water,min(attractor,9.)));
if(minDist==9.)
@@ -137,34 +147,46 @@ vec4 traceRay(vec3 ro,vec3 rd,int ignore)
}
vec3 shade(vec4 hitPoint,vec3 newRo,vec3 rd)
{
- vec3 myFog=newRo.y22&&scene<27)
@@ -191,12 +213,13 @@ void main()
else
ro=vec3(.1,.004,0)+vec3(.1,.005,20)*vec3(rnd(vec2(scene,seed++)),rnd(vec2(scene,seed++)),rnd(vec2(scene,seed++))),ro=mix(ro+vec3(.008)*vec3(rnd(vec2(scene,seed++)),rnd(vec2(scene,seed++)),rnd(vec2(scene,seed++))),ro+vec3(.008)*vec3(rnd(vec2(scene,seed++)),rnd(vec2(scene,seed++)),rnd(vec2(scene,seed++))),Y.y-float(scene)),ro.y+=height(ro.xz)+.02,ro+=.02*getTerrainNormal(ro),seed=min(1.,step(-28.,-Y.y)*sin((Y.y-float(scene))*pi)*3.);
rd=normalize(rd);
- if(scene>22&&scene<27)
- spherePos=ro+.1*vec3(mm*vec4(0,0,1,1));
- else
- spherePos=ro+.02*vec3(sin(Y.y),0,5.+cos(Y.y));
+ spherePos=scene>22&&scene<27?
+ ro+.1*vec3(mm*vec4(0,0,1,1)):
+ ro+.02*vec3(sin(Y.y),0,5.+cos(Y.y));
spherePos.y+=.01+height(spherePos.xz);
- sphereRadius=scene<14?0.:bigeps*.5+bigeps*Y.z;
+ sphereRadius=scene<14?
+ 0.:
+ bigeps*.5+bigeps*Y.z;
spherePos+=2.*bigeps*getTerrainNormal(spherePos);
lightDir=vec3(.58,.58,-.58);
lightColor=vec3(1.2)+Y.z;
diff --git a/tests/real/yx_long_way_from_home.frag.expected b/tests/real/yx_long_way_from_home.frag.expected
index 887cb18a..f3c9f253 100644
--- a/tests/real/yx_long_way_from_home.frag.expected
+++ b/tests/real/yx_long_way_from_home.frag.expected
@@ -1,6 +1,4 @@
-/* File generated with
- * http://www.ctrl-alt-test.fr
- */
+// Generated with (https://github.com/laurentlb/Shader_Minifier/)
#ifndef YX_LONG_WAY_FROM_HOME_FRAG_EXPECTED_
# define YX_LONG_WAY_FROM_HOME_FRAG_EXPECTED_
# define VAR_iChannel1 "v"
@@ -15,151 +13,154 @@ const char *yx_long_way_from_home_frag =
"uniform sampler2D v;"
"mat2 n(float v)"
"{"
- "float y=cos(v),x=sin(v);"
- "return mat2(y,-x,x,y);"
+ "float x=cos(v),f=sin(v);"
+ "return mat2(x,-f,f,x);"
"}"
"vec2 s(const float v)"
"{"
"return fract(sin(vec2(v,v+1.))*vec2(43758.5453123));"
"}"
- "int i;"
+ "int f;"
"float e(vec2 v)"
"{"
- "vec2 y=vec2(.125,0),x=v-clamp(v,-y,y);"
- "return length(x.xy);"
+ "vec2 x=vec2(.125,0),f=v-clamp(v,-x,x);"
+ "return length(f.xy);"
"}"
- "float f(vec2 v)"
+ "float p(vec2 v)"
"{"
- "return smoothstep(.5,1.,cos(v.x*10.))*1.5+sin(v.x*100.)*.5+.5;"
+ "return smoothstep(.5,1.,cos(v.x*10.))*1.5+sin(v.x*1e2)*.5+.5;"
"}"
- "float t(vec3 y)"
+ "float t(vec3 i)"
"{"
- "float x=1e9,n,r;"
- "x=min(x,length(y-vec3(0,5,0))-2.5);"
- "vec3 c=y,l;"
+ "float x=1e9;"
+ "x=min(x,length(i-vec3(0,5,0))-2.5);"
+ "vec3 c=i;"
"c.x=abs(c.x-1.1)-.2;"
- "n=max(length(c.xz+vec2(0,5))-.01,c.y-5.);"
- "l=y;"
- "if(y.y<.3)"
+ "float s=max(length(c.xz+vec2(0,5))-.01,c.y-5.);"
+ "vec3 n=i;"
+ "if(i.y<.3)"
"{"
- "y.y+=texture(v,y.xz*.125).x*9e-4;"
- "y.y+=texture(v,y.xz*2.*.125).x*.0011;"
- "y.y+=texture(v,y.xz*4.*.125).x*.0021;"
- "y.y+=texture(v,y.xz*4.*.0625).x*.0051;"
- "y.y+=texture(v,y.xz*4.*.03125).x*.01;"
- "y.y+=sin(y.x*2.)*.05;"
- "y.y-=length(sin(y.xz*.5))*.1;"
- "y.z+=sin(y.x*.5)*.5;"
- "y.z+=step(.5,mod(y.x,1.))*.3-.15;"
- "y.x=mod(y.x,.5)-.25;"
- "float s=e(y.xz),z=smoothstep(.1,.13,s);"
- "y.y+=.1-z*.03;"
- "y.y-=smoothstep(.05,0.,abs(s-.16))*.004;"
- "y.y-=(1.-z)*.01*f(y.xz);"
+ "i.y+=texture(v,i.xz*.125).x*9e-4;"
+ "i.y+=texture(v,i.xz*2.*.125).x*.0011;"
+ "i.y+=texture(v,i.xz*4.*.125).x*.0021;"
+ "i.y+=texture(v,i.xz*4.*.0625).x*.0051;"
+ "i.y+=texture(v,i.xz*4.*.03125).x*.01;"
+ "i.y+=sin(i.x*2.)*.05;"
+ "i.y-=length(sin(i.xz*.5))*.1;"
+ "i.z+=sin(i.x*.5)*.5;"
+ "i.z+=step(.5,mod(i.x,1.))*.3-.15;"
+ "i.x=mod(i.x,.5)-.25;"
+ "float y=e(i.xz),z=smoothstep(.1,.13,y);"
+ "i.y+=.1-z*.03;"
+ "i.y-=smoothstep(.05,0.,abs(y-.16))*.004;"
+ "i.y-=(1.-z)*.01*p(i.xz);"
"}"
- "y.y-=smoothstep(2.,0.,length(l.xz+vec2(-1.5,3.5)))*.2;"
- "y.y-=smoothstep(2.,0.,length(l.xz+vec2(1,-2)))*.2;"
- "r=y.y;"
- "x=min(x,r);"
+ "i.y-=smoothstep(2.,0.,length(n.xz+vec2(-1.5,3.5)))*.2;"
+ "i.y-=smoothstep(2.,0.,length(n.xz+vec2(1,-2)))*.2;"
+ "float y=i.y;"
+ "x=min(x,y);"
"{"
- "vec3 s=y;"
- "s.xz=mod(s.xz-.5,1.)-.5;"
+ "vec3 r=i;"
+ "r.xz=mod(r.xz-.5,1.)-.5;"
"}"
- "y.y-=.25;"
- "i=n0.&&!e(t+a*.002,b,u,d,k))"
- "r+=z*o*l;"
- "y=s(y.y);"
+ "vec3 o=d(y,1e-4);"
+ "float h=dot(l,o);"
+ "vec3 g,k;"
+ "float B;"
+ "if(h>0.&&!d(t+l*.002,o,g,k,B))"
+ "c+=n*h*z;"
+ "i=s(i.y);"
"}"
"else"
- " if(abs(p)>.1)"
- "return r+h(x)*z;"
+ " if(abs(a)>.1)"
+ "return c+d(x)*n;"
"else"
" break;"
"}"
"return vec3(0);"
"}"
- "vec2 e()"
+ "vec2 d()"
"{"
- "vec2 v=y;"
+ "vec2 v=i;"
"if(v.y>v.x)"
"v=1.-v;"
"v.y*=pi*2./v.x;"
@@ -167,28 +168,29 @@ const char *yx_long_way_from_home_frag =
"}"
"void main()"
"{"
- "vec2 v=gl_FragCoord.xy/iResolution.xy-.5,x;"
- "float f=iTime+(v.x+iResolution.x*v.y)*1.51269341231,z,i;"
- "y=s(f);"
- "v+=(y-.5)/iResolution.xy;"
+ "vec2 v=gl_FragCoord.xy/iResolution.xy-.5;"
+ "float x=iTime+(v.x+iResolution.x*v.y)*1.51269341231;"
+ "i=s(x);"
+ "v+=(i-.5)/iResolution.xy;"
"v.x*=iResolution.x/iResolution.y;"
- "const vec3 c=vec3(-4,2,3),t=vec3(0);"
- "const float l=distance(c,t);"
+ "const vec3 f=vec3(-4,2,3),y=vec3(0);"
+ "const float z=distance(f,y);"
"const vec2 p=vec2(1,2)*.015;"
- "vec3 r=vec3(0),o=normalize(vec3(v,2)),a;"
- "x=e();"
- "r.xy+=x*p;"
- "o.xy-=x*p*o.z/l;"
- "a=t-c;"
- "z=-atan(a.y,length(a.xz));"
- "i=-atan(a.x,a.z);"
- "r.yz*=n(z);"
- "o.yz*=n(z);"
- "r.xz*=n(i);"
- "o.xz*=n(i);"
- "r+=c;"
- "vec4 m=vec4(h(r,o),1);"
- "gl_FragColor=!isnan(m.x)&&m.x>=0.?m:vec4(0);"
+ "vec3 c=vec3(0),r=normalize(vec3(v,2));"
+ "vec2 m=d();"
+ "c.xy+=m*p;"
+ "r.xy-=m*p*r.z/z;"
+ "vec3 l=y-f;"
+ "float a=-atan(l.y,length(l.xz)),o=-atan(l.x,l.z);"
+ "c.yz*=n(a);"
+ "r.yz*=n(a);"
+ "c.xz*=n(o);"
+ "r.xz*=n(o);"
+ "c+=f;"
+ "vec4 t=vec4(h(c,r),1);"
+ "gl_FragColor=!isnan(t.x)&&t.x>=0.?"
+ "t:"
+ "vec4(0);"
"}";
#endif // YX_LONG_WAY_FROM_HOME_FRAG_EXPECTED_
diff --git a/tests/real/z_invert.frag b/tests/real/z_invert.frag
deleted file mode 100644
index b9092315..00000000
--- a/tests/real/z_invert.frag
+++ /dev/null
@@ -1,22 +0,0 @@
-uniform vec2 resolution;
-uniform float time;
-uniform sampler2D tex0;
-uniform sampler2D tex1;
-uniform sampler2D tex2;
-uniform sampler2D tex3;
-
-void main(void)
-{
- vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
- vec2 uv;
-
- float a = atan(p.y,p.x);
- float r = sqrt(dot(p,p));
-
- uv.x = cos(0.6+time) + cos(cos(1.2+time)+a)/r;
- uv.y = cos(0.3+time) + sin(cos(2.0+time)+a)/r;
-
- vec3 col = texture2D(tex0,uv*.25).xyz;
-
- gl_FragColor = vec4(col*r*r,1.0);
-}
diff --git a/tests/unit/augmented.frag b/tests/unit/augmented.frag
new file mode 100644
index 00000000..67ff64f5
--- /dev/null
+++ b/tests/unit/augmented.frag
@@ -0,0 +1,15 @@
+#extension GL_EXT_gpu_shader4 : enable
+
+int foo(int x, int y) {
+ int a=x;
+ a=a+x;
+ a=a*y;
+ a=a>>x;
+ a=a^y;
+ a=a|y;
+ return a;
+}
+
+void main() {
+ foo(0, 0);
+}
diff --git a/tests/unit/augmented.frag.expected b/tests/unit/augmented.frag.expected
new file mode 100644
index 00000000..4a5e2bed
--- /dev/null
+++ b/tests/unit/augmented.frag.expected
@@ -0,0 +1,16 @@
+#extension GL_EXT_gpu_shader4:enable
+
+int foo(int x,int y)
+{
+ int a=x;
+ a+=x;
+ a*=y;
+ a>>=x;
+ a^=y;
+ a|=y;
+ return a;
+}
+void main()
+{
+ foo(0,0);
+}
diff --git a/tests/unit/blocks.expected b/tests/unit/blocks.expected
index 47b19bcc..35eebd40 100644
--- a/tests/unit/blocks.expected
+++ b/tests/unit/blocks.expected
@@ -1,6 +1,4 @@
-/* File generated with
- * http://www.ctrl-alt-test.fr
- */
+// Generated with (https://github.com/laurentlb/Shader_Minifier/)
#ifndef BLOCKS_EXPECTED_
# define BLOCKS_EXPECTED_
@@ -11,13 +9,11 @@ const char *blocks_frag =
"float bar;"
"if(foo==2)"
"foo++;"
- "if(foo<5)"
- "if(foo==3)"
- "bar=.2;"
- "else"
- " bar=.3;"
- "else"
- " bar=.4;"
+ "bar=foo<5?"
+ "foo==3?"
+ ".2:"
+ ".3:"
+ ".4;"
"return bar;"
"}"
"int k=5;"
@@ -35,18 +31,46 @@ const char *blocks_frag =
"}"
"int test_block()"
"{"
- "if(k==0)"
- ";"
+ "k==0;"
"for(int i=0;i<2;i++)"
- "if(k==1)"
- "return k++,2;"
- "else"
- " break;"
+ "{"
+ "if(k==1)"
+ "return k++,2;"
+ "break;"
+ "}"
+ "}"
+ "float removeUselessElseAfterReturn1(float f)"
+ "{"
+ "if(f<2.)"
+ "return 1.;"
+ "f=4.;"
+ "return 5.;"
+ "}"
+ "float removeUselessElseAfterReturn2(float f)"
+ "{"
+ "float a=2.;"
+ "if(f 0.0)
+ r = 1.0;
+ else
+ r = 2.0;
+ float r2;
+ if (f > 1.0) {
+ r2 = 1.0;
+ } else {
+ foo();
+ r2 = 2.0;
+ }
+ float r3;
+ if (f > 1.0) {
+ r3 = 1.0;
+ } else {
+ r3 = 2.0;
+ foo();
+ }
+ return r+r2+r3;
+}
\ No newline at end of file
diff --git a/tests/unit/conditionals.frag.expected b/tests/unit/conditionals.frag.expected
index 02144c5c..fe878ed1 100644
--- a/tests/unit/conditionals.frag.expected
+++ b/tests/unit/conditionals.frag.expected
@@ -43,3 +43,18 @@ int foo()
int a=1;
return a;
}
+float ifStmtToExpr(float f)
+{
+ float r,r2,r3;
+ r=f>0.?
+ 1.:
+ 2.;
+ r2=f>1.?
+ 1.:
+ (foo(),2.);
+ if(f>1.)
+ r3=1.;
+ else
+ r3=2.,foo();
+ return r+r2+r3;
+}
diff --git a/tests/unit/externals.expected b/tests/unit/externals.expected
index 88532b01..2f4e5207 100644
--- a/tests/unit/externals.expected
+++ b/tests/unit/externals.expected
@@ -1,28 +1,26 @@
-/* File generated with Shader Minifier 1.3
- * http://www.ctrl-alt-test.fr
- */
+// Generated with (https://github.com/laurentlb/Shader_Minifier/)
#ifndef EXTERNALS_EXPECTED_
# define EXTERNALS_EXPECTED_
-# define VAR_e "t"
+# define VAR_e "I"
# define VAR_i "i"
-# define VAR_n "n"
+# define VAR_n "J"
const char *externals_frag =
- "uniform int i,n,t;"
- "int r()"
+ "uniform int i,J,I;"
+ "int H()"
"{"
- "int n,t,r,u,e;"
+ "int J,I,F,G,H;"
"return i;"
"}"
- "int u()"
+ "int G()"
"{"
- "int i,t,r,u,e;"
- "return n;"
+ "int i,I,F,G,H;"
+ "return J;"
"}"
- "int e()"
+ "int F()"
"{"
- "int i,r,u,n,e;"
- "return t;"
+ "int i,F,G,J,H;"
+ "return I;"
"}";
#endif // EXTERNALS_EXPECTED_
diff --git a/tests/unit/externals.preserved.expected b/tests/unit/externals.preserved.expected
index 78249489..34a2a5c7 100644
--- a/tests/unit/externals.preserved.expected
+++ b/tests/unit/externals.preserved.expected
@@ -1,24 +1,22 @@
-/* File generated with Shader Minifier 1.3
- * http://www.ctrl-alt-test.fr
- */
+// Generated with (https://github.com/laurentlb/Shader_Minifier/)
#ifndef EXTERNALS_PRESERVED_EXPECTED_
# define EXTERNALS_PRESERVED_EXPECTED_
const char *externals_frag =
"uniform int i,n,e;"
- "int t()"
+ "int H()"
"{"
- "int n,e,t,r,u;"
+ "int n,e,F,G,H;"
"return i;"
"}"
- "int r()"
+ "int G()"
"{"
- "int i,e,t,r,u;"
+ "int i,e,F,G,H;"
"return n;"
"}"
- "int u()"
+ "int F()"
"{"
- "int i,t,r,n,u;"
+ "int i,F,G,n,H;"
"return e;"
"}";
diff --git a/tests/unit/float.frag.expected b/tests/unit/float.frag.expected
index 445f5590..61af4b05 100644
--- a/tests/unit/float.frag.expected
+++ b/tests/unit/float.frag.expected
@@ -1,6 +1,4 @@
-/* File generated with
- * http://www.ctrl-alt-test.fr
- */
+// Generated with (https://github.com/laurentlb/Shader_Minifier/)
// tests/unit/float.frag
"void precision()"
diff --git a/tests/unit/forbidden.expected b/tests/unit/forbidden.expected
index 65e4fba0..4e775b3a 100644
--- a/tests/unit/forbidden.expected
+++ b/tests/unit/forbidden.expected
@@ -1,4 +1,4 @@
-struct f{float f;};float t()
+struct f{float f;};float L()
{
return 42.;
-}
\ No newline at end of file
+}
diff --git a/tests/unit/function_comma.expected b/tests/unit/function_comma.expected
index 8a8b4d6a..0c2f8136 100644
--- a/tests/unit/function_comma.expected
+++ b/tests/unit/function_comma.expected
@@ -1,13 +1,13 @@
-/* File generated with Shader Minifier 1.3
- * http://www.ctrl-alt-test.fr
- */
+// Generated with (https://github.com/laurentlb/Shader_Minifier/)
#ifndef FUNCTION_COMMA_EXPECTED_
# define FUNCTION_COMMA_EXPECTED_
const char *function_comma_frag =
"float min(float a,float b)"
"{"
- "return a246913578.)
- return 100.;
- if(x>123456789.)
- return 101.;
- return 102.;
+ return x>246913578.?
+ 1e2:
+ x>123456789.?
+ 101.:
+ 102.;
}
float inl3()
{
@@ -76,7 +76,7 @@ float noinl5()
float noinl6(float x)
{
float f=x+1.;
- x=100.;
+ x=1e2;
return f+2.;
}
float noinl7(const float x)
@@ -91,7 +91,7 @@ float noinl8()
float noinl9(float x)
{
float bar=x+1.;
- x=100.;
+ x=1e2;
return bar+2.;
}
void evil(inout float x)
@@ -113,7 +113,7 @@ int noinl11(ivec3 x)
int noinl12()
{
int i=10;
- while(--i>0)
+ for(;--i>0;)
;
return 1;
}
diff --git a/tests/unit/inline-aggro.expected b/tests/unit/inline-aggro.expected
index 26aad01a..db16cdd9 100644
--- a/tests/unit/inline-aggro.expected
+++ b/tests/unit/inline-aggro.expected
@@ -6,11 +6,11 @@ float inl1()
float inl2(float x)
{
float f=123456789.;
- if(x>2.*f)
- return 100.;
- if(x>f)
- return 101.;
- return 102.;
+ return x>2.*f?
+ 1e2:
+ x>f?
+ 101.:
+ 102.;
}
float inl3()
{
@@ -83,7 +83,7 @@ float noinl5()
float noinl6(float x)
{
float f=x+1.;
- x=100.;
+ x=1e2;
return f+2.;
}
float noinl7(const float x)
@@ -98,7 +98,7 @@ float noinl8()
float noinl9(float x)
{
float bar=x+1.;
- x=100.;
+ x=1e2;
return bar+2.;
}
void evil(inout float x)
@@ -120,7 +120,7 @@ int noinl11(ivec3 x)
int noinl12()
{
int i=10;
- while(--i>0)
+ for(;--i>0;)
;
return 1;
}
diff --git a/tests/unit/inout.expected b/tests/unit/inout.expected
index d9e31c7b..8701b7c1 100644
--- a/tests/unit/inout.expected
+++ b/tests/unit/inout.expected
@@ -1,64 +1,62 @@
-/* File generated with
- * http://www.ctrl-alt-test.fr
- */
-# define VAR_ambientLight "m"
-# define VAR_diffuseColor "i"
-# define VAR_emissiveColor "a"
-# define VAR_fragmentColor "o"
-# define VAR_mediumDensity "t"
-# define VAR_normal "c"
-# define VAR_specularColor "n"
-# define VAR_texture0 "e"
-# define VAR_viewVec "v"
+// Generated with (https://github.com/laurentlb/Shader_Minifier/)
+# define VAR_ambientLight "f"
+# define VAR_diffuseColor "z"
+# define VAR_emissiveColor "r"
+# define VAR_fragmentColor "m"
+# define VAR_mediumDensity "s"
+# define VAR_normal "d"
+# define VAR_specularColor "C"
+# define VAR_texture0 "v"
+# define VAR_viewVec "c"
// tests/unit/inout.frag
"#version 330\n"
- "uniform samplerCube e;"
- "in vec3 c,v;"
- "out vec4 o;"
+ "uniform samplerCube v;"
+ "in vec3 d,c;"
+ "out vec4 m;"
"void main()"
"{"
- "vec3 l=normalize(v),u=normalize(c),f=vec3(.1,.2,.3),x=texture(e,reflect(-l,u)).xyz,p=texture(e,refract(-l,u,1./1.5)).xyz,z=mix(f*p,x,.1);"
- "o=vec4(z,1);"
+ "vec3 s=normalize(c),f=normalize(d),p=vec3(.1,.2,.3),r=texture(v,reflect(-s,f)).xyz,z=texture(v,refract(-s,f,1./1.5)).xyz,C=mix(p*z,r,.1);"
+ "m=vec4(C,1);"
"}"
- "vec3 r(vec3 d,vec3 l,vec3 s)"
+ "vec3 t(vec3 v,vec3 d,vec3 f)"
"{"
- "float C=1.-clamp(dot(l,s),0.,1.);"
- "return C*C*C*C*C*(1.-d)+d;"
+ "float m=1.-clamp(dot(d,f),0.,1.);"
+ "return m*m*m*m*m*(1.-v)+v;"
"}"
- "vec3 r(vec3 l,vec3 y,vec3 u,vec3 f,vec3 d,float w)"
+ "vec3 t(vec3 v,vec3 m,vec3 f,vec3 d,vec3 s,float c)"
"{"
- "vec3 s=normalize(l+y),b,Z,Y;"
- "float X=1.+2048.*(1.-w)*(1.-w);"
- "b=f;"
- "Z=vec3(pow(clamp(dot(s,u),0.,1.),X)*(X+4.)/8.);"
- "Y=r(d,l,s);"
- "return mix(b,Z,Y);"
+ "vec3 r=normalize(v+m),p,z,C;"
+ "float M=1.+2048.*(1.-c)*(1.-c);"
+ "p=d;"
+ "z=vec3(pow(clamp(dot(r,f),0.,1.),M)*(M+4.)/8.);"
+ "C=t(s,v,r);"
+ "return mix(p,z,C);"
"}",
// tests/unit/inout2.frag
"#version 330\n"
- "uniform samplerCube e;"
- "uniform float t;"
- "uniform vec3 m,i,a,n;"
- "in vec3 c,v;"
- "out vec4 o;"
- "vec3 r(vec3 d,vec3 l,vec3 s)"
+ "uniform samplerCube v;"
+ "uniform float s;"
+ "uniform vec3 f,z,r,C;"
+ "in vec3 d,c;"
+ "out vec4 m;"
+ "vec3 t(vec3 v,vec3 d,vec3 f)"
"{"
- "float C=1.-clamp(dot(l,s),0.,1.);"
- "return C*C*C*C*C*(1.-d)+d;"
+ "float m=1.-clamp(dot(d,f),0.,1.);"
+ "return m*m*m*m*m*(1.-v)+v;"
"}"
"void main()"
"{"
- "vec3 f=i,z=a+mix(f*m,m,.5);"
- "o=vec4(z,1);"
+ "vec3 v=z,d=r+mix(v*f,f,.5);"
+ "m=vec4(d,1);"
"}"
- "vec3 r(vec3 l,vec3 y,vec3 u,vec3 f,vec3 d,float w)"
+ "vec3 t(vec3 v,vec3 f,vec3 d,vec3 m,vec3 s,float c)"
"{"
- "vec3 s=normalize(l+y),b,Z,Y;"
- "float X=1.+2048.*(1.-w)*(1.-w);"
- "b=f;"
- "Z=vec3(pow(clamp(dot(s,u),0.,1.),X)*(X+4.)/8.);"
- "Y=r(d,l,s);"
- "return mix(b,Z,Y);"
+ "vec3 r=normalize(v+f),z,C,p;"
+ "float M=1.+2048.*(1.-c)*(1.-c);"
+ "z=m;"
+ "C=vec3(pow(clamp(dot(r,d),0.,1.),M)*(M+4.)/8.);"
+ "p=t(s,v,r);"
+ "return mix(z,C,p);"
"}",
diff --git a/tests/unit/loop.frag b/tests/unit/loop.frag
new file mode 100644
index 00000000..d615f641
--- /dev/null
+++ b/tests/unit/loop.frag
@@ -0,0 +1,50 @@
+float f(){return 0.;}
+
+float a;
+void main()
+{
+ float c;
+ for (float d=0.; d<50.; ++d)
+ {
+ c+=cos(d);
+ }
+ float b;
+ for (b=0.; b<50.; ++b)
+ {
+ c+=cos(c);
+ }
+ b = a;
+ while (b<50.)
+ {
+ c+=cos(c);
+ b++;
+ }
+ b = a;
+ while (b<50.)
+ {
+ b++;
+ }
+ b = a;
+ while (b<50.)
+ {
+ c+=cos(c);
+ float d=f(); // d prevents moving b+=d to a for
+ b+=d;
+ }
+ b = a;
+ while (b<50.)
+ {
+ if (a < b) continue; // continue prevents moving b++ to a for
+ b++;
+ }
+ b = a;
+ while (b<50.)
+ {
+ if (a < b) a=b; else continue; // continue prevents moving b++ to a for
+ b++;
+ }
+ for (; b<50.; ++b)
+ {
+ c+=cos(b);
+ }
+}
\ No newline at end of file
diff --git a/tests/unit/loop.frag.expected b/tests/unit/loop.frag.expected
new file mode 100644
index 00000000..ff784c3c
--- /dev/null
+++ b/tests/unit/loop.frag.expected
@@ -0,0 +1,47 @@
+// Generated with (https://github.com/laurentlb/Shader_Minifier/)
+#ifndef LOOP_FRAG_EXPECTED_
+# define LOOP_FRAG_EXPECTED_
+
+const char *loop_frag =
+ "float f()"
+ "{"
+ "return 0.;"
+ "}"
+ "float a;"
+ "void main()"
+ "{"
+ "float c;"
+ "for(float d=0.;d<50.;++d)"
+ "c+=cos(d);"
+ "float b;"
+ "for(b=0.;b<50.;++b)"
+ "c+=cos(c);"
+ "for(b=a;b<50.;b++)"
+ "c+=cos(c);"
+ "for(b=a;b<50.;b++)"
+ ";"
+ "for(b=a;b<50.;)"
+ "{"
+ "c+=cos(c);"
+ "float d=f();"
+ "b+=d;"
+ "}"
+ "for(b=a;b<50.;)"
+ "{"
+ "if(a 2. ? 1 : 2) * 10 +
+ (1. <= 2. ? 1 : 2) * 100 +
+ (1. >= 2. ? 1 : 2) * 1000 +
+ (1. == 2. ? 1 : 2) * 10000 +
+ (1. != 2. ? 1 : 2) * 100000;
}
int no_parens(int a, int b, int c) {
diff --git a/tests/unit/qualifiers.expected b/tests/unit/qualifiers.expected
index c0d44b90..b6dec1ce 100644
--- a/tests/unit/qualifiers.expected
+++ b/tests/unit/qualifiers.expected
@@ -1,6 +1,4 @@
-/* File generated with Shader Minifier 1.3
- * http://www.ctrl-alt-test.fr
- */
+// Generated with (https://github.com/laurentlb/Shader_Minifier/)
#ifndef QUALIFIERS_EXPECTED_
# define QUALIFIERS_EXPECTED_
# define VAR_foo "f"
@@ -11,11 +9,11 @@ const char *qualifiers_frag =
"{"
"return f;"
"}"
- "float t(const float f)"
+ "float M(const float f)"
"{"
"return f;"
"}"
- "float o(inout float f)"
+ "float L(inout float f)"
"{"
"return f;"
"}";
diff --git a/tests/unit/switch.expected b/tests/unit/switch.expected
index a0f2d321..1043474e 100644
--- a/tests/unit/switch.expected
+++ b/tests/unit/switch.expected
@@ -29,7 +29,7 @@ void h(int G)
break;
}
}
-float e()
+float D()
{
switch(42){
case 42:
@@ -37,8 +37,8 @@ float e()
float k=2.4;
return G+k;
case 43:
- float h=4.3;
- return h+3.4;
+ float D=4.3;
+ return D+3.4;
default:
return 0.;
}
diff --git a/tests/unit/vectors.frag b/tests/unit/vectors.frag
index 5b2d66c9..2464500d 100644
--- a/tests/unit/vectors.frag
+++ b/tests/unit/vectors.frag
@@ -8,4 +8,8 @@ float swizzles() {
return v1.x + v2.x + v3.x + v4.x + v5.x + v6.x;
}
-void main() { swizzles(); }
+vec4 constructor() {
+ return vec4(1., 1e2, 2e3, 3e4);
+}
+
+void main() { swizzles(); constructor(); }
diff --git a/tests/unit/vectors.frag.expected b/tests/unit/vectors.frag.expected
index 515a6145..53ae6f41 100644
--- a/tests/unit/vectors.frag.expected
+++ b/tests/unit/vectors.frag.expected
@@ -5,7 +5,12 @@ float swizzles()
vec4 v4=v1.xxyx,v5=vec4(1,v2.zy,2),v6=vec4(v1.xy,v2.xy);
return v1.x+v2.x+v3.x+v4.x+v5.x+v6.x;
}
+vec4 constructor()
+{
+ return vec4(1,100,2e3,3e4);
+}
void main()
{
swizzles();
+ constructor();
}
diff --git a/tests/unit/verbatim.frag.expected b/tests/unit/verbatim.frag.expected
index e4d5c3bf..107b8e59 100644
--- a/tests/unit/verbatim.frag.expected
+++ b/tests/unit/verbatim.frag.expected
@@ -1,6 +1,4 @@
-/* File generated with
- * http://www.ctrl-alt-test.fr
- */
+// Generated with (https://github.com/laurentlb/Shader_Minifier/)
// tests/unit/verbatim.frag
"//Test case for https://github.com/laurentlb/Shader_Minifier/issues/168\n"