surface
AQSIS_V 1.6.0


segment Data

USES 509959

param uniform  float Ka
param uniform  float Kd
param uniform  float Ks
param uniform  float roughness
param uniform  color specularcolor
param uniform  string objname
param uniform  string bakename
varying  color foo
uniform  color black
uniform  string passname
uniform  string bakefilename
uniform  string filename
varying  float bakingpass
varying  color Ct
varying  normal Nf


segment Init
	pushif 1
	pop Ka
	pushif 0.5
	pop Kd
	pushif 0.5
	pop Ks
	pushif 0.1
	pop roughness
	pushif 1
	setfc
	pop specularcolor
	pushis ""
	pop objname
	pushis "bake"
	pop bakename


segment Code
	pushif 0
	pushif 0
	pushif 0
	settc
	pop black
	pushis ""
	pop passname
	pushis ""
	pop bakefilename
	pushis ""
	pop filename
	pushis ".bake"
	pushv bakename
	pushis "."
	pushv objname
	pushif 2
	concat
	pop bakefilename
	pushis ".tex"
	pushv bakename
	pushis "."
	pushv objname
	pushif 2
	concat
	pop filename
	pushis "user:pass"
	option passname
	drop
	pushv passname
	pushis "bake"
	match
	pop bakingpass
	S_CLEAR
	pushif 1
	pushv bakingpass
	eqff
	S_GET
	RS_PUSH
	RS_GET
	RS_JZ 1
	pushv t
	pushif 10
	mulff
	pushv s
	pushif 10
	mulff
	cnoise2
	pop foo
	pushv foo
	pushv t
	pushv s
	pushv bakefilename
	bake_3c
:1
	RS_INVERSE
	RS_JZ 0
	pushv t
	pushv s
	pushif 0
	pushv filename
	pushif 0
	ctexture2
	pop foo
	S_CLEAR
	pushv black
	setcp
	pushv foo
	setcp
	eqpp
	S_GET
	RS_PUSH
	RS_GET
	RS_JZ 2
	pushif 10
	pushv t
	mulff
	pushif 10
	pushv s
	mulff
	cnoise2
	pop foo
:2
	RS_POP
:0
	RS_POP
	pushv foo
	pushv Cs
	mulcc
	pop Ct
	pushv I
	pushv N
	normalize
	faceforward
	pop Nf
	pushv roughness
	pushv I
	normalize
	negp
	pushv Nf
	specular
	pushv Ks
	setfc
	pushv specularcolor
	mulcc
	mulcc
	pushv Nf
	diffuse
	pushv Kd
	mulfc
	ambient
	pushv Ka
	mulfc
	addcc
	pushv Ct
	mulcc
	addcc
	pop Ci
	pushv Os
	pop Oi
	pushv Oi
	pushv Ci
	mulcc
	pop Ci
