#*****************************************************************************
# Copyright 1986-2002 by mental images GmbH & Co.KG, Fasanenstr. 81, D-10623
# Berlin, Germany. All rights reserved.
#*****************************************************************************
# Author:	Henrik Wann Jensen   (based on specs from Thomas)
# Created:	21.10.1997
# Module:	baseshader
# Purpose:	.mi declarations for built-in Phenomena baseshaders
#
# Exports:
#					texture space mapping
#	mib_texture_vector
#	mib_texture_remap
#	mib_texture_rotate
#	mib_bump_basis
#	mib_bump_map
#	mib_passthrough_bump_map
#					Environments and Compositing
#	mib_lookup_spherical
#	mib_lookup_cube1
#	mib_lookup_cube6
#	mib_lookup_background
#	mib_lookup_cylindrical
#					Textures
#	mib_texture_lookup
#	mib_texture_filter_lookup
#	mib_texture_checkerboard
#	mib_texture_polkadot
#	mib_texture_polkasphere
#	mib_texture_turbulence
#	mib_texture_wave
#					Sample Compositing
#	mib_reflect
#	mib_refract
#	mib_transparency
#	mib_opacity
#	mib_dielectric
#	mib_ray_marcher
#	mib_twosided
#	mib_refraction_index
#					Illumination
#	mib_illum_lambert
#	mib_illum_phong
#	mib_illum_blinn
#	mib_illum_cooktorr
#	mib_illum_ward
#	mib_illum_ward_deriv
#	mib_illum_hair
#					Volume
#	mib_volume
#					Data Conversion
#	mib_color_alpha
#	mib_color_average
#	mib_color_intensity
#	mib_color_interpolate
#	mib_color_mix
#	mib_color_spread
#					Geometry
#	mib_geo_cube
#	mib_geo_sphere
#	mib_geo_cone
#	mib_geo_cylinder
#	mib_geo_square
#	mib_geo_instance
#	mib_geo_instance_mlist
#	mib_geo_add_uv_texsurf
#	mib_geo_torus
#					Photon
#	mib_photon_basic
#					Lightmap
#	mib_lightmap_write
#	mib_lightmap_sample
#					Hair
#
# History:
#	28.10.97 gunter:  added geometry shaders
#	17.11.97 thomas:  added ambience parameter to illuminance base shaders
#	08.12.97 henrik:  renamed mib_twoside to mib_twosided
#	12.01.98 thomas:  added mib_opacity
#	29.01.98 henrik:  added mib_photon_basic
#	26.05.98 thomas:  introduced project in texture_vector and bump_basis
#	16.09.99 steve:	  added color_base in mib_color_mix (now version 2)
#	11.01.00 thomas:  added offset parameter to mib_texture_remap
#	26.01.00 thomas:  added clamp parameter to mib_bump_map*
#	11.01.02 carsten: added mib_illum_hair
#****************************************************************************/

min version "2.0.20"
max version "3.2.99"

#-------------------------------------------- texture space mapping

declare shader
	vector "mib_texture_vector" (
		integer		"select",
		integer		"selspace",
		integer		"vertex",
		integer		"project"
	)
	version 2
	apply texture
end declare

declare shader
	vector "mib_texture_remap" (
		vector		"input",
		transform	"transform",
		vector		"repeat",
		boolean		"alt_x",
		boolean		"alt_y",
		boolean		"alt_z",
		boolean		"torus_x",
		boolean		"torus_y",
		boolean		"torus_z",
		vector		"min",
		vector		"max",
		vector		"offset"
	)
	version 1
	apply texture
end declare

declare shader
	struct {
		vector		"u",
		vector		"v"
	} "mib_texture_rotate" (
		vector		"input",
		scalar		"angle",
		scalar		"min",
		scalar		"max"
	)
	version 1
	apply texture
end declare

declare shader
	struct {
		vector		"u",
		vector		"v"
	} "mib_bump_basis" (
		integer		"project",
		integer		"ntex"
	)
	version 2
	apply texture
end declare

declare shader
	vector "mib_bump_map" (
		vector		"u",
		vector		"v",
		vector		"coord",
		vector		"step",
		scalar		"factor",
		boolean		"torus_u",
		boolean		"torus_v",
		boolean		"alpha",
		color texture	"tex",
		boolean		"clamp"
	)
	version 2
	apply texture
end declare

declare shader
	color "mib_passthrough_bump_map" (
		vector		"u",
		vector		"v",
		vector		"coord",
		vector		"step",
		scalar		"factor",
		boolean		"torus_u",
		boolean		"torus_v",
		boolean		"alpha",
		color texture	"tex",
		boolean		"clamp"
	)
	version 2
	apply texture
end declare

#-------------------------------------------- Environments and Compositing

declare shader
	color "mib_lookup_spherical" (
		vector		"dir",
		scalar		"rotate",
		color texture   "tex"
	)
	version 1
	apply environment
end declare

declare shader
	color "mib_lookup_cube1" (
		vector		"point",
		vector		"dir",
		vector		"size",
		color texture   "tex"
	)
	version 1
	apply environment
end declare

declare shader
	color "mib_lookup_cube6" (
		vector		"point",
		vector		"dir",
		vector		"size",
		color texture   "tex_mx",
		color texture   "tex_px",
		color texture   "tex_my",
		color texture   "tex_py",
		color texture   "tex_mz",
		color texture   "tex_pz"
	)
	version 1
	apply environment
end declare

declare shader
	color "mib_lookup_background" (
		vector		"zoom",
		vector		"pan",
		boolean		"torus_u",
		boolean		"torus_v",
		color texture   "tex"
	)
	version 1
	apply texture, environment, lens
end declare

declare shader
	color "mib_lookup_cylindrical" (
		transform	"xform",
		scalar		"begin",
		scalar		"end",
		color texture	"tex"
	)
	version 1
	apply environment
end declare

#-------------------------------------------- Textures

declare shader
	color "mib_texture_lookup" (
		color texture	"tex",
		vector		"coord"
	)
	version 1
	apply texture
end declare

declare shader
	color "mib_texture_filter_lookup" (
		color texture	"tex",
		vector		"coord",
		scalar		"eccmax",
		scalar		"maxminor",
		scalar		"disc_r",
		boolean		"bilinear",
		integer		"space",
		shader		"remap"
	)
	version 3
	apply texture
end declare

declare shader
	color "mib_texture_checkerboard" (
		vector		"coord",
		scalar		"xsize",
		scalar		"ysize",
		scalar		"zsize",
		color		"color000",
		color		"color001",
		color		"color010",
		color		"color011",
		color		"color100",
		color		"color101",
		color		"color110",
		color		"color111"
	)
	version 1
	apply texture
end declare

declare shader
	color "mib_texture_polkadot" (
		vector		"coord",
		scalar		"radius",
		color		"fgcolor",
		color		"bgcolor"
	)
	version 1
	apply texture
end declare

declare shader
	color "mib_texture_polkasphere" (
		vector		"coord",
		scalar		"radius",
		color		"fgcolor",
		color		"bgcolor"
	)
	version 1
	apply texture
end declare

declare shader
	scalar "mib_texture_turbulence" (
		vector		"coord",
		scalar		"spacing",
		scalar		"strength",
		scalar		"power",
		integer		"iteration",
		integer		"polar_dim"
	)
	version 1
end declare

declare shader
	color "mib_texture_wave" (
		vector		"coord",
		scalar		"amplitude_x",
		scalar		"amplitude_y",
		scalar		"amplitude_z",
		scalar		"offset"
	)
	version 1
end declare

#-------------------------------------------- Sample Compositing

declare shader
	color "mib_reflect" (
		color		"input",
		color		"reflect",
		boolean		"notrace"
	)
	version 2
end declare

declare shader
	color "mib_refract" (
		color		"input",
		color		"refract",
		scalar		"ior"
	)
	version 2
end declare

declare shader
	color "mib_transparency" (
		color		"input",
		color		"transp"
	)
	version 2
end declare

declare shader
	color "mib_opacity" (
		color		"input",
		color		"opacity"
	)
	version 2
end declare

declare shader
	color "mib_twosided" (
		color		"front",
		color		"back"
	)
	version 1
end declare

declare shader
	struct {
		scalar		"ior",
		boolean		"enter"
	} "mib_refraction_index" (
		scalar		"mtl_ior"
	)
	version 1
end declare

declare shader
	color "mib_dielectric" (
		color		"input",
		color		"absorb",
		scalar		"refract",
		scalar		"ior"
	)
	version 1
end declare

declare shader
	color "mib_ray_marcher" (
		shader		"shader",
		scalar		"distance",
		integer		"num",
		integer		"subdiv",
		color		"contrast"
	)
	version 1
end declare

#-------------------------------------------- Illumination

declare shader
	color "mib_illum_lambert" (
		color		"ambience",
		color		"ambient",
		color 		"diffuse",
		integer		"mode",      # light selection mode 0..2
		array light	"lights"
	)
	version 2
end declare

declare shader
	color "mib_illum_phong" (
		color		"ambience",
		color		"ambient",
		color 		"diffuse",
		color 		"specular",
		scalar		"exponent",  # phong exponent
		integer		"mode",      # light selection mode 0..2
		array light	"lights"
	)
	version 2
end declare

declare shader
	color "mib_illum_ward" (
		color		"ambience",
		color		"ambient",
		color 		"diffuse",
		color 		"glossy",
		scalar		"shiny_u",   # shinyness in u direction
		scalar		"shiny_v",   # shinyness in v direction
		vector		"u",         # u direction
		vector		"v",         # v direction
		integer		"mode",      # light selection mode 0..2
		array light	"lights"
	)
	version 1
end declare

declare shader
	color "mib_illum_ward_deriv" (
		color		"ambience",
		color		"ambient",
		color 		"diffuse",
		color 		"glossy",
		scalar		"shiny_u",   # shinyness in u direction
		scalar		"shiny_v",   # shinyness in v direction
		integer		"mode",      # light selection mode 0..2
		array light	"lights"
	)
	version 1
	derivative 1 	# requires surface derivatives	
end declare

declare shader
	color "mib_illum_blinn" (
		color		"ambience",
		color		"ambient",
		color 		"diffuse",
		color 		"specular",
		scalar		"roughness", # average microfacet slope
		scalar          "ior",       # rel. ior
		integer		"mode",      # light selection mode 0..2
		array light	"lights"
	)
	version 2
end declare

declare shader
	color "mib_illum_cooktorr" (
		color		"ambience",
		color		"ambient",
		color 		"diffuse",
		color 		"specular",
		scalar		"roughness", # average microfacet slope
		color           "ior",       # rel. ior for three wavelengths
		integer		"mode",      # light selection mode 0..2
		array light	"lights"
	)
	version 2
end declare

declare shader
	color "mib_illum_hair" (
		color		"ambience",
		color		"ambient",
		color		"diffuse",
		color		"specular",
		scalar		"exponent",
		integer		"mode",
		array light	"lights"
	)
	version 1
end declare


#-------------------------------------------- Volume

declare shader
	color "mib_volume" (
		color		"color",
		scalar		"max",
		boolean		"lightrays"
	)
	version 1
end declare


#-------------------------------------------- Data Conversion

declare shader
	color "mib_color_alpha" (
		color		"input",
		scalar		"factor"
	)
	version 2
end declare

declare shader
	color "mib_color_average" (
		color		"input",
		scalar		"factor"
	)
	version 2
end declare

declare shader
	color "mib_color_intensity" (
		color		"input",
		scalar		"factor"
	)
	version 2
end declare

declare shader
	color "mib_color_interpolate" (
		scalar		"input",
		integer		"num",
		scalar		"weight_1",
		scalar		"weight_2",
		scalar		"weight_3",
		scalar		"weight_4",
		scalar		"weight_5",
		scalar		"weight_6",
		color		"color_0",
		color		"color_1",
		color		"color_2",
		color		"color_3",
		color		"color_4",
		color		"color_5",
		color		"color_6",
		color		"color_7"
	)
	version 1
end declare

declare shader
	color "mib_color_mix" (
		integer		"num",
		integer		"mode_0",
		integer		"mode_1",
		integer		"mode_2",
		integer		"mode_3",
		integer		"mode_4",
		integer		"mode_5",
		integer		"mode_6",
		integer		"mode_7",
		scalar		"weight_0",
		scalar		"weight_1",
		scalar		"weight_2",
		scalar		"weight_3",
		scalar		"weight_4",
		scalar		"weight_5",
		scalar		"weight_6",
		scalar		"weight_7",
		color		"color_0",
		color		"color_1",
		color		"color_2",
		color		"color_3",
		color		"color_4",
		color		"color_5",
		color		"color_6",
		color		"color_7",
		color		"color_base"
	)
	version 2
end declare

declare shader
	struct {
		color		"out_0",
		color		"out_1",
		color		"out_2",
		color		"out_3",
		color		"out_4",
		color		"out_5",
		color		"out_6",
		color		"out_7"
	} "mib_color_spread" (
		color		"input",
		integer		"num",
		integer		"mode_0",
		integer		"mode_1",
		integer		"mode_2",
		integer		"mode_3",
		integer		"mode_4",
		integer		"mode_5",
		integer		"mode_6",
		integer		"mode_7",
		color		"weight_0",
		color		"weight_1",
		color		"weight_2",
		color		"weight_3",
		color		"weight_4",
		color		"weight_5",
		color		"weight_6",
		color		"weight_7"
	)
	version 1
end declare

#-------------------------------------------- Geometry

declare shader
	geometry "mib_geo_cube" (
	)
	version 1
end declare

declare shader
	geometry "mib_geo_torus" (
		scalar 		"radius",
		scalar		"thickness",
		integer		"uSpans",
		integer		"vSpans"
	)
	version 1
end declare

declare shader
	geometry "mib_geo_sphere" (
		integer		"u_subdiv",
		integer		"v_subdiv"
	)
	version 1
end declare

declare shader
	geometry "mib_geo_cone" (
		integer		"u_subdiv",
		integer		"v_subdiv",
		boolean		"capped"
	)
	version 1
end declare

declare shader
	geometry "mib_geo_cylinder" (
		integer		"u_subdiv",
		integer		"v_subdiv",
		boolean		"bottom_capped",
		boolean		"top_capped"
	)
	version 1
end declare

declare shader
	geometry "mib_geo_square" (
	)
	version 1
end declare

declare shader
	geometry "mib_geo_instance" (
		geometry	"object",
		transform	"matrix",
		shader		"material"
	)
	version 1
end declare

declare shader
	geometry "mib_geo_instance_mlist" (
		geometry	"object",
		transform	"matrix",
		array material	"material"
	)
	version 1
end declare

declare shader
	geometry "mib_geo_add_uv_texsurf" (
		geometry	"object"
	)
	version 1
end declare

#-------------------------------------------- Photon

declare shader
	color "mib_photon_basic" (
		color		"diffuse",
		color		"specular",
		color		"transp",
		scalar		"ior_frac"
	)
	version 1
end declare

#-------------------------------------------- Lights

declare shader
	color "mib_light_infinite" (
		color		"color",
		boolean		"shadow",
		scalar		"factor"
	)
	version 1
	apply light
end declare

declare shader
	color "mib_light_point" (
		color		"color",
		boolean		"shadow",
		scalar		"factor",
		boolean		"atten",
		scalar		"start",
		scalar		"stop"
	)
	version 1
	apply light
end declare

declare shader
	color "mib_light_spot" (
		color		"color",
		boolean		"shadow",
		scalar		"factor",
		boolean		"atten",
		scalar		"start",
		scalar		"stop",
		scalar		"cone"
	)
	version 1
	apply light
end declare

#-------------------------------------------- Shadow

declare shader
	color "mib_shadow_transparency" (
		color		"color",
		color		"transp",
		integer		"mode",
		array light	"light"
	)
	version 1
	apply shadow
end declare

#-------------------------------------------- Lightmap

declare shader
	struct {
		vector 		"point",
		vector 		"normal",
		vector 		"tex"
	}
	"mib_lightmap_write" (
		color texture 	"texture",	#output texture
		vector texture	"coord",	#texture coords to use
		color texture	"input"		#to evaluate the texture output
	)
	version 1
end declare

declare shader
	color "mib_lightmap_sample" (
		boolean 	"indirect",	#use indirect illumination?
		integer		"flip",		#0=no, 1=yes , 2=both
		array light 	"lights"	#direct illumination
	)
	version 1
end declare

