Initial commit
This commit is contained in:
1 parent
ee9615239e
commit
16feac691f
4093 files changed
+1030491
No files matched your search
+120
@@ -0,0 +1,120 @@
|
||||
Shader ${ShaderCategory}
|
||||
{
|
||||
Properties { _MainTex ("Texture", any) = "" {} }
|
||||
|
||||
SubShader
|
||||
{
|
||||
ZTest Always Cull OFF ZWrite Off
|
||||
|
||||
HLSLINCLUDE
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_TexelSize; // 1/width, 1/height, width, height
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
v2f vert( appdata_t v )
|
||||
{
|
||||
v2f o;
|
||||
|
||||
o.vertex = UnityObjectToClipPos( v.vertex );
|
||||
o.uv = v.uv;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
|
||||
BEGINPASSTEMPLATE
|
||||
|
||||
// Pass
|
||||
// {
|
||||
// Name "${NoiseName} Raw Noise Blit (2D)"
|
||||
|
||||
// HLSLPROGRAM
|
||||
|
||||
// #pragma vertex vert
|
||||
// #pragma fragment frag
|
||||
|
||||
// ${Includes}
|
||||
|
||||
// float4 frag( v2f i ) : SV_Target
|
||||
// {
|
||||
// float3 pos = ApplyNoiseTransform( float3(i.uv.x, 0, i.uv.y) - float3(.5, 0, .5) );
|
||||
|
||||
// float n = noise_${VariantName}( pos, ${GetInputs} );
|
||||
|
||||
// return n;
|
||||
// }
|
||||
|
||||
// ENDHLSL
|
||||
// }
|
||||
|
||||
Pass // ${NoiseName} Noise
|
||||
{
|
||||
Name "${NoiseName} Raw Noise Blit (2D)"
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
${Includes}
|
||||
|
||||
float4 frag( v2f i ) : SV_Target
|
||||
{
|
||||
// calc pos for center of pixel
|
||||
float3 uv = float3( i.uv.x, 0, i.uv.y ) - float3( .5, 0, .5 );
|
||||
uv += + float3(.5, 0, .5) * _MainTex_TexelSize.xxy; // offset by half a texel so we are sampling noise for the center of the texel
|
||||
|
||||
float3 pos3D = ApplyNoiseTransform( uv.xyz );
|
||||
float2 pos2D = ApplyNoiseTransform( uv.xz );
|
||||
|
||||
float n = noise_${VariantName}( pos3D, ${GetInputs} );
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "${NoiseName} Raw Noise Blit (3D)"
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
${Includes}
|
||||
|
||||
float _UVY;
|
||||
|
||||
float4 frag( v2f i ) : SV_Target
|
||||
{
|
||||
float3 pos = ApplyNoiseTransform( float3(i.uv.x, _UVY, i.uv.y) - float3(.5, 0, .5) );
|
||||
|
||||
float n = noise_${VariantName}( pos, ${GetInputs} );
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
ENDPASSTEMPLATE
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8099751248575c489e0b5da5ac605ff
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 94e656d7d8c4ac74f943c9f10d62641e, type: 3}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
Shader ${ShaderCategory}
|
||||
{
|
||||
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", any) = "" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
|
||||
HLSLINCLUDE
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "TerrainTool.cginc"
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_TexelSize; // 1/width, 1/height, width, height
|
||||
|
||||
sampler2D _BrushTex;
|
||||
|
||||
float4 _BrushParams;
|
||||
#define BRUSH_STRENGTH (_BrushParams[0])
|
||||
#define BRUSH_TARGETHEIGHT (_BrushParams[1])
|
||||
#define BRUSH_PINCHAMOUNT (_BrushParams[2])
|
||||
#define BRUSH_ROTATION (_BrushParams[3])
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 pcUV : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 pcUV : TEXCOORD0;
|
||||
};
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.pcUV = v.pcUV;
|
||||
return o;
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
|
||||
BEGINPASSTEMPLATE
|
||||
|
||||
Pass // ${NoiseName} Noise Fill
|
||||
{
|
||||
Name "${NoiseName} Noise Fill"
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
${Includes}
|
||||
|
||||
float4 _TerrainXform;
|
||||
float4 _TerrainScale;
|
||||
|
||||
float2 TransformPosition( float2 brushUV )
|
||||
{
|
||||
return _TerrainXform.xz + brushUV * _TerrainScale.xz;
|
||||
}
|
||||
|
||||
float4 frag(v2f i) : SV_Target
|
||||
{
|
||||
float h = UnpackHeightmap( tex2D( _MainTex, i.pcUV ) );
|
||||
|
||||
float2 pos = TransformPosition( i.pcUV );
|
||||
|
||||
float n = noise_${VariantName}( pos, ${GetDefaultInputs} );
|
||||
|
||||
return PackHeightmap( n );
|
||||
// return PackHeightmap( lerp( h + n, n, OVERWRITE_HEIGHT ) );
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
ENDPASSTEMPLATE
|
||||
}
|
||||
|
||||
Fallback Off
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dae4c679dc34e914f93c2ee9bcaa3d94
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 94e656d7d8c4ac74f943c9f10d62641e, type: 3}
|
||||
+180
@@ -0,0 +1,180 @@
|
||||
#ifndef UNITY_TERRAIN_TOOL_NOISE_${VariantName}_INC
|
||||
#define UNITY_TERRAIN_TOOL_NOISE_${VariantName}_INC
|
||||
|
||||
/*=========================================================================
|
||||
|
||||
Includes
|
||||
|
||||
=========================================================================*/
|
||||
|
||||
${Includes}
|
||||
|
||||
${FractalDataDefinitions}
|
||||
|
||||
/*=========================================================================
|
||||
|
||||
Fractal Functions
|
||||
|
||||
=========================================================================*/
|
||||
|
||||
float noise_${VariantName}_Raw( float pos, ${FunctionParams} )
|
||||
{
|
||||
float prev = 0;
|
||||
float n = 0;
|
||||
|
||||
float octaves = ceil(fractalInput.octaves) + (1 - sign(frac(fractalInput.octaves)));
|
||||
|
||||
for( float i = 0; i < octaves; ++i )
|
||||
{
|
||||
prev = n;
|
||||
n += fractalInput.amplitude * get_noise_${NoiseName}( pos * fractalInput.frequency );
|
||||
fractalInput.frequency *= fractalInput.lacunarity;
|
||||
fractalInput.amplitude *= fractalInput.persistence;
|
||||
}
|
||||
|
||||
n = lerp(prev, n, frac(fractalInput.octaves));
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
float noise_${VariantName}_Raw( float2 pos, ${FunctionParams} )
|
||||
{
|
||||
float prev = 0;
|
||||
float n = 0;
|
||||
|
||||
float octaves = ceil(fractalInput.octaves) + (1 - sign(frac(fractalInput.octaves)));
|
||||
|
||||
for( float i = 0; i < octaves; ++i )
|
||||
{
|
||||
prev = n;
|
||||
n += fractalInput.amplitude * get_noise_${NoiseName}( pos * fractalInput.frequency );
|
||||
fractalInput.frequency *= fractalInput.lacunarity;
|
||||
fractalInput.amplitude *= fractalInput.persistence;
|
||||
}
|
||||
|
||||
n = lerp(prev, n, frac(fractalInput.octaves));
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
float noise_${VariantName}_Raw( float3 pos, ${FunctionParams} )
|
||||
{
|
||||
float prev = 0;
|
||||
float n = 0;
|
||||
|
||||
float octaves = ceil(fractalInput.octaves) + (1 - sign(frac(fractalInput.octaves)));
|
||||
|
||||
for( float i = 0; i < octaves; ++i )
|
||||
{
|
||||
prev = n;
|
||||
n += fractalInput.amplitude * get_noise_${NoiseName}( pos * fractalInput.frequency );
|
||||
fractalInput.frequency *= fractalInput.lacunarity;
|
||||
fractalInput.amplitude *= fractalInput.persistence;
|
||||
}
|
||||
|
||||
n = lerp(prev, n, frac(fractalInput.octaves));
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
float noise_${VariantName}_Raw( float4 pos, ${FunctionParams} )
|
||||
{
|
||||
float prev = 0;
|
||||
float n = 0;
|
||||
|
||||
float octaves = ceil(fractalInput.octaves) + (1 - sign(frac(fractalInput.octaves)));
|
||||
|
||||
for( float i = 0; i < octaves; ++i )
|
||||
{
|
||||
prev = n;
|
||||
n += fractalInput.amplitude * get_noise_${NoiseName}( pos * fractalInput.frequency );
|
||||
fractalInput.frequency *= fractalInput.lacunarity;
|
||||
fractalInput.amplitude *= fractalInput.persistence;
|
||||
}
|
||||
|
||||
n = lerp(prev, n, frac(fractalInput.octaves));
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/*=========================================================================
|
||||
|
||||
${VariantName} Noise Functions - Fractal, Warped
|
||||
|
||||
=========================================================================*/
|
||||
|
||||
float noise_${VariantName}( float pos, ${FunctionParams} )
|
||||
{
|
||||
float prev = 0;
|
||||
|
||||
float warpIterations = ceil(fractalInput.warpIterations) + (1 - sign(frac(fractalInput.warpIterations)));
|
||||
|
||||
// do warping
|
||||
for ( float i = 0; i < warpIterations; ++i )
|
||||
{
|
||||
float q = noise_${VariantName}_Raw( pos + fractalInput.warpOffsets.x, ${FunctionInputs} );
|
||||
prev = pos;
|
||||
pos = pos + fractalInput.warpStrength * q;
|
||||
}
|
||||
|
||||
pos = lerp(prev, pos, frac(fractalInput.warpIterations));
|
||||
|
||||
float f = noise_${VariantName}_Raw( pos, ${FunctionInputs} );
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
float noise_${VariantName}( float2 pos, ${FunctionParams} )
|
||||
{
|
||||
float2 prev = 0;
|
||||
|
||||
float warpIterations = ceil(fractalInput.warpIterations) + (1 - sign(frac(fractalInput.warpIterations)));
|
||||
|
||||
// do warping
|
||||
for ( float i = 0; i < warpIterations; ++i )
|
||||
{
|
||||
float2 q = float2( noise_${VariantName}_Raw( pos, ${FunctionInputs} ),
|
||||
noise_${VariantName}_Raw( pos + fractalInput.warpOffsets.xy, ${FunctionInputs} ) );
|
||||
prev = pos;
|
||||
|
||||
pos = pos + fractalInput.warpStrength * q;
|
||||
}
|
||||
|
||||
pos = lerp(prev, pos, frac(fractalInput.warpIterations));
|
||||
|
||||
float f = noise_${VariantName}_Raw( pos, ${FunctionInputs} );
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
float noise_${VariantName}( float3 pos, ${FunctionParams} )
|
||||
{
|
||||
float3 prev = 0;
|
||||
|
||||
float warpIterations = ceil(fractalInput.warpIterations) + (1 - sign(frac(fractalInput.warpIterations)));
|
||||
|
||||
// do warping
|
||||
for ( float i = 0; i < warpIterations; ++i )
|
||||
{
|
||||
float3 q = float3( noise_${VariantName}_Raw( pos.xyz, ${FunctionInputs} ),
|
||||
noise_${VariantName}_Raw( pos.xyz + fractalInput.warpOffsets.xyz, ${FunctionInputs} ),
|
||||
noise_${VariantName}_Raw( pos.xyz + float3( fractalInput.warpOffsets.x, fractalInput.warpOffsets.y, 0 ), ${FunctionInputs} ) );
|
||||
prev = pos;
|
||||
pos = pos + fractalInput.warpStrength * q;
|
||||
}
|
||||
|
||||
pos = lerp(prev, pos, frac(fractalInput.warpIterations));
|
||||
|
||||
float f = noise_${VariantName}_Raw( pos, ${FunctionInputs} );
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
float noise_${VariantName}( float4 pos, ${FunctionParams} )
|
||||
{
|
||||
float f = noise_${VariantName}_Raw( pos, ${FunctionInputs} );
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
#endif // UNITY_TERRAIN_TOOL_NOISE_${VariantName}_INC
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c40c320988718f4f8272b8fcaa1c505
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 94e656d7d8c4ac74f943c9f10d62641e, type: 3}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
#ifndef UNITY_TERRAIN_TOOL_NOISE_${VariantName}_INC
|
||||
#define UNITY_TERRAIN_TOOL_NOISE_${VariantName}_INC
|
||||
|
||||
/*=========================================================================
|
||||
|
||||
Includes
|
||||
|
||||
=========================================================================*/
|
||||
|
||||
${Includes}
|
||||
|
||||
/*=========================================================================
|
||||
|
||||
${VariantName} Noise Functions - Non-Fractal, Non-Warped
|
||||
|
||||
=========================================================================*/
|
||||
|
||||
float noise_${VariantName}( float pos )
|
||||
{
|
||||
return get_noise_${NoiseName}( pos );
|
||||
}
|
||||
|
||||
float noise_${VariantName}( float2 pos )
|
||||
{
|
||||
return get_noise_${NoiseName}( pos );
|
||||
}
|
||||
|
||||
float noise_${VariantName}( float3 pos )
|
||||
{
|
||||
return get_noise_${NoiseName}( pos );
|
||||
}
|
||||
|
||||
float noise_${VariantName}( float4 pos )
|
||||
{
|
||||
return get_noise_${NoiseName}( pos );
|
||||
}
|
||||
|
||||
#endif // UNITY_TERRAIN_TOOL_NOISE_${VariantName}_INC
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c32eb128d786de429fcf9673dcc7221
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 94e656d7d8c4ac74f943c9f10d62641e, type: 3}
|
||||
Reference in new issue
Block a user