Hi Holmer
I love shaderforge and I like to Improve your repository :)
Shader Forge has a problem... It generate All shader Inside fragment shader
without declaring functions
It makes hard to reading shader
It create repetitive definitions in the shader
for example when I use Rotator Instead of declaring function It will generate Inside of fragment shader
float2 node_5074 = (mul(i.uv0-node_5074_piv,float2x2( node_5074_cos, -node_5074_sin, node_5074_sin, node_5074_cos))+node_5074_piv);
You could define it as Rotation function:
float2x2 rotate2d(float _angle){
return float2x2(cos(_angle),-sin(_angle),
sin(_angle),cos(_angle));
}
I'm working on procedural generation

Shader "Hidden/Shader Forge/SFN_FBMNoise" {
Properties {
_OutputMask ("Output Mask", Vector) = (1,1,1,1)
_XY ("XY", 2D) = "black" {}
}
SubShader {
Tags {
"RenderType"="Opaque"
}
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define UNITY_PASS_FORWARDBASE
#include "UnityCG.cginc"
#pragma target 3.0
uniform float4 _OutputMask;
uniform sampler2D _XY;
struct VertexInput {
float4 vertex : POSITION;
float2 texcoord0 : TEXCOORD0;
};
struct VertexOutput {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
VertexOutput vert (VertexInput v) {
VertexOutput o = (VertexOutput)0;
o.uv = v.texcoord0;
o.pos = UnityObjectToClipPos(v.vertex );
return o;
}
// Author @patriciogv - 2015
// http://patriciogonzalezvivo.com
float random (in float2 st) {
return frac(sin(dot(st.xy,
float2(12.9898,78.233)))*
43758.5453123);
}
// Based on Morgan McGuire @morgan3d
// https://www.shadertoy.com/view/4dS3Wd
float noise (in float2 st) {
float2 i = floor(st);
float2 f = frac(st);
// Four corners in 2D of a tile
float a = random(i);
float b = random(i + float2(1.0, 0.0));
float c = random(i + float2(0.0, 1.0));
float d = random(i + float2(1.0, 1.0));
float2 u = f * f * (3.0 - 2.0 * f);
return lerp(a, b, u.x) +
(c - a)* u.y * (1.0 - u.x) +
(d - b) * u.x * u.y;
}
#define OCTAVES 6
float fbm (in float2 st) {
// Initial values
float value = 0.0;
float amplitude = .5;
float frequency = 0.;
//
// Loop of octaves
for (int i = 0; i < OCTAVES; i++) {
value += amplitude * noise(st);
st *= 2.;
amplitude *= .5;
}
return value;
}
float4 frag(VertexOutput i) : COLOR {
// Read inputs
float4 _xy = tex2D( _XY, i.uv );
// Operator
float2 st =_xy;
float3 color = float3(0,0,0);
color += fbm(st*3.0);
float4 outputColor = float4(color,1.0);
// Return
return outputColor * _OutputMask;
}
ENDCG
}
}
}
But What Is my problem?
My Problem Is that I can't add functions through mySFN_FBMNoise.cs and I have to convert them to variables!!
Hi Holmer
I love shaderforge and I like to Improve your repository :)
Shader Forge has a problem... It generate All shader Inside fragment shader
without declaring functions
It makes hard to reading shader
It create repetitive definitions in the shader
for example when I use Rotator Instead of declaring function It will generate Inside of fragment shader
float2 node_5074 = (mul(i.uv0-node_5074_piv,float2x2( node_5074_cos, -node_5074_sin, node_5074_sin, node_5074_cos))+node_5074_piv);You could define it as Rotation function:
I'm working on procedural generation
But What Is my problem?
My Problem Is that I can't add functions through my
SFN_FBMNoise.csand I have to convert them to variables!!