-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2732456
commit bd45972
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package hrt.shgraph.nodes; | ||
|
||
using hxsl.Ast; | ||
|
||
@name("Random") | ||
@description("Gives a random number from a vec2 seed") | ||
@width(80) | ||
@group("Math") | ||
class Random extends ShaderNodeHxsl { | ||
static var SRC = { | ||
@sginput(0.0) var seed : Vec2; | ||
@sgoutput var output : Float; | ||
function fragment() { | ||
output = fract(sin(dot(seed, vec2(12.9898,78.233)))*43758.5453123); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package hrt.shgraph.nodes; | ||
|
||
using hxsl.Ast; | ||
|
||
@name("Random2D") | ||
@description("Gives a random vec2 from a vec2 seed") | ||
@width(80) | ||
@group("Math") | ||
class Random2D extends ShaderNodeHxsl { | ||
static var SRC = { | ||
@sginput(0.0) var seed : Vec2; | ||
@sgoutput var output : Vec2; | ||
function fragment() { | ||
output = vec2(fract(sin(dot(seed, vec2(12.9898,78.233)))*43758.5453123), | ||
fract(sin(dot(seed, vec2(1572.9898,132.237)))*157468.33458)); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package hrt.shgraph.nodes; | ||
|
||
using hxsl.Ast; | ||
|
||
@name("Random3D") | ||
@description("Gives a random vec3 from a vec2 seed") | ||
@width(80) | ||
@group("Math") | ||
class Random3D extends ShaderNodeHxsl { | ||
static var SRC = { | ||
@sginput(0.0) var seed : Vec2; | ||
@sgoutput var output : Vec3; | ||
function fragment() { | ||
output = vec3(fract(sin(dot(seed, vec2(12.9898,78.233)))*43758.5453123), | ||
fract(sin(dot(seed, vec2(1572.9898,132.237)))*157468.33458), | ||
fract(sin(dot(seed, vec2(14.5757,59.147)))*4756.281)); | ||
} | ||
}; | ||
} |