Skip to content

Commit

Permalink
[ShaderGraph] Added tilling and offset param to Triplanar params node
Browse files Browse the repository at this point in the history
  • Loading branch information
TothBenoit committed Nov 26, 2024
1 parent e71c1eb commit 19c14e5
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions hrt/shgraph/nodes/TriplanarParams.hx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class TriplanarParams extends ShaderNodeHxsl {

static var SRC = {
@sginput(2.0) var sharpness : Float;
@sginput(1.0) var tiling : Vec3;
@sginput(0.0) var offset : Vec3;
@sgconst var LOCAL : Int = 0;
@sgoutput var weight : Vec3;
@sgoutput var uvX : Vec2;
Expand All @@ -28,15 +30,17 @@ class TriplanarParams extends ShaderNodeHxsl {
if ( LOCAL == 0 ) {
weight = pow(abs(transformedNormal), vec3(sharpness));
weight = weight / (weight.x + weight.y + weight.z);
uvX = transformedPosition.zy;
uvY = transformedPosition.xz;
uvZ = transformedPosition.xy;
var tiledAndOffsetPos = transformedPosition.xyz * tiling + offset;
uvX = tiledAndOffsetPos.zy;
uvY = tiledAndOffsetPos.xz;
uvZ = tiledAndOffsetPos.xy;
} else {
weight = pow(abs(input.normal), vec3(sharpness));
weight = weight / (weight.x + weight.y + weight.z);
uvX = relativePosition.zy;
uvY = relativePosition.xz;
uvZ = relativePosition.xy;
var tiledAndOffsetPos = relativePosition.xyz * tiling + offset;
uvX = tiledAndOffsetPos.zy;
uvY = tiledAndOffsetPos.xz;
uvZ = tiledAndOffsetPos.xy;
}
}
};
Expand Down

0 comments on commit 19c14e5

Please sign in to comment.