[orx-shader-phrases] Change shader phrase declarations to const val

This commit is contained in:
Edwin Jakobs
2025-08-16 21:47:07 +02:00
parent 535c1f9685
commit fa35531c59
5 changed files with 24 additions and 24 deletions

View File

@@ -5,7 +5,7 @@ import org.openrndr.extra.shaderphrases.spacefilling.hilbertV3Phrase
import org.openrndr.extra.shaderphrases.spacefilling.inverseGray32Phrase
// https://www.shadertoy.com/view/3tB3z3
val hilbertR1BlueNoisePhrase = """#ifndef SP_HILBERT_R1_BLUE_NOISE
const val hilbertR1BlueNoisePhrase = """#ifndef SP_HILBERT_R1_BLUE_NOISE
#define SP_HILBERT_R1_BLUE_NOISE
$hilbertPhrase
$kmhfPhrase
@@ -17,7 +17,7 @@ uint hilbertR1BlueNoise(uvec2 p, uint bits, uint seed) {
#endif
"""
val hilbertR1BlueNoiseFloatPhrase = """#ifndef SP_HILBERT_R1_BLUE_NOISE_FLOAT
const val hilbertR1BlueNoiseFloatPhrase = """#ifndef SP_HILBERT_R1_BLUE_NOISE_FLOAT
#define SP_HILBERT_R1_BLUE_NOISE_FLOAT
$hilbertR1BlueNoisePhrase
float hilbertR1BlueNoiseFloat(uvec2 p, uint bits, uint seed) {
@@ -28,7 +28,7 @@ float hilbertR1BlueNoiseFloat(uvec2 p, uint bits, uint seed) {
"""
// https://www.shadertoy.com/view/3tB3z3
val inverseR1BlueNoisePhrase = """#ifndef SP_INVERSE_R1_BLUE_NOISE
const val inverseR1BlueNoisePhrase = """#ifndef SP_INVERSE_R1_BLUE_NOISE
#define SP_INVERSE_R1_BLUE_NOISE
$inverseGray32Phrase
$inverseKmhfPhrase
@@ -38,7 +38,7 @@ ivec2 inverseR1BlueNoise(uint x, uint bits) {
#endif"""
// https://www.shadertoy.com/view/3tB3z3
val hilbertR1BlueNoiseV3Phrase = """#ifndef SP_HILBERT_R1_BLUE_NOISE_V3
const val hilbertR1BlueNoiseV3Phrase = """#ifndef SP_HILBERT_R1_BLUE_NOISE_V3
#define SP_HILBERT_R1_BLUE_NOISE_V3
$hilbertV3Phrase
$kmhfPhrase
@@ -50,7 +50,7 @@ uint hilbertR1BlueNoise(uvec3 p, uint bits, uint seed) {
#endif
"""
val hilbertR1BlueNoiseFloatV3Phrase = """#ifndef SP_HILBERT_R1_BLUE_NOISE_FLOAT_V3
const val hilbertR1BlueNoiseFloatV3Phrase = """#ifndef SP_HILBERT_R1_BLUE_NOISE_FLOAT_V3
#define SP_HILBERT_R1_BLUE_NOISE_FLOAT_V3
$hilbertR1BlueNoiseV3Phrase
float hilbertR1BlueNoiseFloat(uvec3 p, uint bits, uint seed) {

View File

@@ -10,7 +10,7 @@ package org.openrndr.extra.shaderphrases.noise
* This phrase is wrapped in preprocessor guards to ensure it is only defined once during the shader compilation process.
*/
// knuth's multiplicative hash function (fixed point R1)
val kmhfPhrase = """#ifndef SP_KMHF
const val kmhfPhrase = """#ifndef SP_KMHF
#define SP_KMHF
uint kmhf(uint x) {
return 0x80000000u + 2654435789u * x;
@@ -28,10 +28,10 @@ uint kmhf(uint x) {
* during shader compilation.
*/
// inverse of Knuth's multiplicative hash function (fixed point R1)
val inverseKmhfPhrase = """#ifndef SP_INVERSE_KMHF
const val inverseKmhfPhrase = """#ifndef SP_INVERSE_KMHF
#define SP_INVERSE_KMHF
uint inverseKmhf(uint x) {
return (x - 0x80000000u) * 827988741u;
}
#endif
""".trimMargin()
"""

View File

@@ -1,6 +1,6 @@
package org.openrndr.extra.shaderphrases.noise
val permutePhrase = """#ifndef SP_PERMUTE
const val permutePhrase = """#ifndef SP_PERMUTE
#define SP_PERMUTE
$mod289Phrase
float permute(const in float x) { return mod289(((x * 34.0) + 1.0) * x); }

View File

@@ -1,6 +1,6 @@
package org.openrndr.extra.shaderphrases.noise
val grad4Phrase = """#ifndef SP_GRAD4
const val grad4Phrase = """#ifndef SP_GRAD4
#define SP_GRAD4
vec4 grad4(float j, vec4 ip) {
@@ -17,7 +17,7 @@ vec4 grad4(float j, vec4 ip) {
#endif
"""
val simplex12 = """#ifndef SP_SIMPLEX12
const val simplex12 = """#ifndef SP_SIMPLEX12
#define SP_SIMPLEX12
$mod289V2Phrase
$mod289V3Phrase
@@ -74,7 +74,7 @@ float simplex12(in vec2 v) {
#endif
"""
val simplex13 = """#ifndef SP_SIMPLEX13
const val simplex13 = """#ifndef SP_SIMPLEX13
#define SP_SIMPLEX13
$mod289V3Phrase
$mod289V4Phrase
@@ -156,7 +156,7 @@ float simplex13(in vec3 v) {
#endif
}"""
val simplex14 = """#ifndef SP_SIMPLEX14
const val simplex14 = """#ifndef SP_SIMPLEX14
#define SP_SIMPLEX14
$mod289Phrase
$mod289V2Phrase
@@ -249,7 +249,7 @@ float simplex14(vec4 v) {
#endif
"""
val simplex22 = """#ifndef SP_SIMPLEX22
const val simplex22 = """#ifndef SP_SIMPLEX22
#define SP_SIMPLEX22
$simplex12
vec2 simplex22( vec2 x ){
@@ -260,7 +260,7 @@ vec2 simplex22( vec2 x ){
#endif
"""
val simplex33 = """#ifndef SP_SIMPLEX33
const val simplex33 = """#ifndef SP_SIMPLEX33
#define SP_SIMPLEX33
$simplex13
vec3 simplex33( vec3 x ){
@@ -272,7 +272,7 @@ vec3 simplex33( vec3 x ){
#endif
"""
val simplex34 = """#ifndef SP_SIMPLEX34
const val simplex34 = """#ifndef SP_SIMPLEX34
#define SP_SIMPLEX34
$simplex14
vec3 simplex34( vec4 x ){

View File

@@ -3,7 +3,7 @@ package org.openrndr.extra.shaderphrases.noise
/**
* uniform hash shader phrase
*/
val uhash11Phrase = """
const val uhash11Phrase = """
#ifndef PHRASE_UHASH11
#define PHRASE_UHASH11
uint uhash11(uint x) {
@@ -21,7 +21,7 @@ uint uhash11(uint x) {
/**
* uniform hash shader phrase
*/
val fhash11Phrase = """
const val fhash11Phrase = """
$uhash11Phrase
#ifndef PHRASE_FHASH11
#define PHRASE_FHASH11
@@ -35,7 +35,7 @@ float fhash11(float x) {
/**
* uniform hash shader phrase
*/
val uhash12Phrase = """
const val uhash12Phrase = """
$uhash11Phrase
#ifndef PHRASE_UHASH12
#define PHRASE_UHASH12
@@ -49,7 +49,7 @@ uint uhash12(uvec2 x) {
/**
* uniform hash shader phrase
*/
val fhash12Phrase = """
const val fhash12Phrase = """
$uhash12Phrase
#ifndef PHRASE_FHASH12
#define PHRASE_FHASH12
@@ -63,7 +63,7 @@ float fhash12(vec2 x) {
/**
* uniform hash shader phrase
*/
val uhash13Phrase = """
const val uhash13Phrase = """
$uhash11Phrase
#ifndef PHRASE_UHASH13
#define PHRASE_UHASH13
@@ -77,7 +77,7 @@ uint uhash13(uvec3 x) {
/**
* uniform hash shader phrase
*/
val fhash13Phrase = """
const val fhash13Phrase = """
$uhash13Phrase
#ifndef PHRASE_FHASH13
#define PHRASE_FHASH13
@@ -91,7 +91,7 @@ float fhash13(vec3 x) {
/**
* uniform hash shader phrase
*/
val uhash14Phrase = """
const val uhash14Phrase = """
$uhash11Phrase
#ifndef PHRASE_UHASH14
#define PHRASE_UHASH14
@@ -105,7 +105,7 @@ uint uhash14(uvec4 x) {
/**
* uniform hash shader phrase
*/
val fhash14Phrase = """
const val fhash14Phrase = """
$uhash14Phrase
#ifndef PHRASE_FHASH14
#define PHRASE_FHASH14