<?xml version="1.0" encoding="utf-8"?>
<scenedata>
	<material>
		<name>previewmaterial</name>
		<phong>
			<diffuse_albedo>
				<shader>
						<shader><![CDATA[
def paramScale() real :
#	global scale
# set this first for your scene.
	4.0

def noiseScale() real :
# additional perturbation's scale
# relative to global scale
	175.0
* paramScale()

def noiseAmount() real :
# additional perturbation's amount. zero = noise off
	0.1
/	paramScale()

def paramRatio() real :
# length ratio.
# Set to its reciprocal for a vertical essence (1.0 / value)
	8.0

def paramIterations1() real :
# number of veins (age)
	8.0

def paramIterations2() real :
# number of sub-veins (veins per veins)
	3.5

def paramTension() real :
# tension (distribution) of veins
# min:				0.0 (flat. Defeats shader)
# max:				5.0 +/- 1
# neutral:	1.0
	1.1

def complexity() int :
# level of intrication of the features
	8

# RGB colors (2)

def col1() vec3 :
vec3(0.4, 0.2, 0.0)

def col2() vec3 :
vec3(0.5, 0.3, 0.1)

#
#		Don't mess with the below, or share results :D
#

def fracNoise(real ratio) real :
	fbm(
		texi() * noiseScale() / ratio,
		texj() * noiseScale(),
		0.0,
		complexity()
	)

def fracNoise2(real ratio) real :
	pow(
		0.5 + fbm(
			(texi() * paramScale()) / ratio,
			texj() * paramScale(),
			fracNoise(ratio) * noiseAmount(),
			complexity()
		) / 2.0,
		paramTension()
	) * 2.0 - 1.0


def essence(real iterations, real ratio) real :
	fract(fracNoise2(ratio) * iterations)

def eval(vec3 pos) vec3 :
	lerp(
		col1(),
		col2(),
		(
		(	essence(paramIterations1(), paramRatio())
		+	essence(paramIterations1() * paramIterations2(), paramRatio())
		)
#		+ fracNoise(8.0) * noiseAmount()
	#	+	1.0
		) / 2.0
)
]]></shader>
				</shader>
			</diffuse_albedo>
			<exponent>
				<constant>
					350
				</constant>
			</exponent>
			<bump>
				<shader>
						<shader><![CDATA[
def paramScale() real :
#	global scale
# set this first for your scene.
	4.0

def noiseScale() real :
# additional perturbation's scale
# relative to global scale
	175.0
* paramScale()

def noiseAmount() real :
# additional perturbation's amount. zero = noise off
	0.1
/	paramScale()

def paramRatio() real :
# length ratio.
# Set to its reciprocal for a vertical essence (1.0 / value)
	8.0

def paramIterations1() real :
# number of veins (age)
	8.0

def paramIterations2() real :
# number of sub-veins (veins per veins)
	3.5

def paramTension() real :
# tension (distribution) of veins
# min:				0.0 (flat. Defeats shader)
# max:				5.0 +/- 1
# neutral:	1.0
	1.1

def complexity() int :
# level of intrication of the features
	8

# NOTE:
# For the two following parameters,
# if either is equal to zero
# the material's bump should be switched off
# for performance concerns

def paramBumpRoughness() real :
# wood finish/alteration
# 0.0: no bump (perfect finish)
# 1.0: no finish (rough surface)
# is also multiplier for the bump gain below
	0.15
					
def paramBump() real :
# centimeters. Yes sir, it's bump value.
# again switch bump off if zero
	0.05

#
#		Don't mess with the below, or share results :D
#

def fracNoise(real ratio) real :
	fbm(
		texi() * noiseScale() / ratio,
		texj() * noiseScale(),
		0.0,
		complexity()
	)

def fracNoise2(real ratio) real :
	pow(
		0.5 + fbm(
			(texi() * paramScale()) / ratio,
			texj() * paramScale(),
			fracNoise(ratio) * noiseAmount(),
			complexity()
		) / 2.0,
		paramTension()
	) * 2.0 - 1.0

def essence(real iterations, real ratio) real :
	fract(fracNoise2(ratio) * iterations)

def eval() real :
	clamp(
	(	essence(paramIterations1(), paramRatio())
	+	essence(paramIterations1() * paramIterations2(), paramRatio())
	) - 1.0
,
		- paramBumpRoughness(),
		paramBumpRoughness()
)
*	paramBump()
# to 1 cm
/ 200.
]]></shader>
				</shader>
			</bump>
			<layer>0</layer>
			<fresnel_scale>1</fresnel_scale>
			<ior>1.48</ior>
			<nk_data></nk_data>
		</phong>
	</material>
</scenedata>
