Added WIP shader-phrases, annotations and tooling for shader phrases

resolving is done using the JVM class loader
This commit is contained in:
Edwin Jakobs
2019-08-23 16:46:24 +02:00
parent 3c162f30d4
commit 98baf2a4c3
8 changed files with 134 additions and 7 deletions

View File

@@ -0,0 +1,32 @@
@file:ShaderPhrases(exports = ["hash22","hash21","valueNoise21"])
package org.openrndr.extra.noise.phrases
import org.openrndr.extra.shaderphrases.annotations.ShaderPhrase
import org.openrndr.extra.shaderphrases.annotations.ShaderPhrases
@ShaderPhrase(exports = ["hash22"])
val phraseHash22 = """vec2 hash22(vec2 p) {
float n = sin(dot(p, vec2(41, 289)));
return fract(vec2(262144, 32768)*n);
}
"""
@ShaderPhrase(exports = ["hash21"])
val phraseHash21 = "float hash21(vec2 p) { return fract(1e4 * sin(17.0 * p.x + p.y * 0.1) * (0.1 + abs(sin(p.y * 13.0 + p.x)))); }"
@ShaderPhrase(exports = ["valueNoise21"], imports = ["hash21"])
val phraseValueNoise21 = """
float noise(vec2 x) {
vec2 i = floor(x);
vec2 f = fract(x);
float a = hash21(i);
float b = hash21(i + vec2(1.0, 0.0));
float c = hash21(i + vec2(0.0, 1.0));
float d = hash21(i + vec2(1.0, 1.0));
vec2 u = f * f * (3.0 - 2.0 * f);
return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y;
}
""".trimIndent()