/* 

VEX hair shader 
arno_hair_far_field
																													
parametric far field hair / fiber shader:

- physically based (full implementation of Marschner et al. plus some additional corrections of the formulae)
- for hair with circular cross section
- distant viewer & distant light sources == far-field scattering	
- includes three scattering components: 

R:   direct backward reflection (white)
TT:  one time forward transmitted (colored, very strong when there is a light source from behind)
TRT: backward transmitted-internal reflected-transmitted (colored)

Note:

All parameters passed to the shaders are local ("per vertex" + interpolation) parameters unlike the standard VEX hair shader.
Please let me know if you need a  per hair ("per primitive") version of this shader with tip / root parameter sets. 

history:	 
-------														

version 0.1 (3.01.05)
	first build 
version 1.0 (17.01.05)
	fixed: a_caustic: float -> vector
	fixed: caustic intensity estimation 
version 1.1 (21.01.05)
	fixed: opacity hack: theta_r -> abs(theta_r)
	fixed: opacity hack: linear interpolation instead of smooth(), opacity_offset 
version 1.2 (21.01.05)
	fixed: 1/theta_d instead of 1/_theta_d2 
	fixed: test if circular -> use dPds as major_axis vector
	problem: too bright spots in the R-component (from fresnel!)
version 1.3 (9.02.05)
	fixed: ambient illumination
	fixed: history :)
version 1.4 (14.03.05)
	fixed: removed n_TRT = set (0.,0.,0.)
	fixed: fresnel cos_theta = 0 -> return 1.
	fixed: opacity for each color component
	fixed: floating point consistency !!!!!!
version 1.4a (29.03.05)
	other opacity formula
version 1.5 (21.11.05)
	"circular symmetric version"
	n_per_2
	new opacity formula


copyright:
----------

All copyrights (c) 2004,05 Arno Zinke


contact:
--------

If you need support, or other sophisticated (simplified & ultra fast, more accurate, near field: for close-ups & light hair)
fiber shaders, parameter settings or if you have any comments feel free to contact me... 

www.gfar.de
zinke@gfar.de

 

external parameters:
--------------------


matrial properties
------------------


//shifts of the modes with respect to specular cone
longitudinal_shift_R
longitudinal_shift_TT
longitudinal_shift_TRT

// width of the modes
// to be more precise: 0.5/(width*width)
longitudinal_width_R			
longitudinal_width_TT			
longitudinal_width_TRT			

// glint scale factor
glint_scale					

// azimutal width of the caustic
azimutal_caustic_width		

// fade range of the caustic
fade_range_caustic_merge		

// intensity limit of the caustic
caustic_intensity_limit		

// to scale the intensity of each mode independently
// these factors could be used for normalization purposes widht respect to the widths (for the Gaussians: 1/(sqrt(2*PI)*width))
scale_R
scale_TT					
scale_TRT					

// absolute absorption coefficients per unit length (for: red, green, blue)
float absorption_coefficient_r		
float absorption_coefficient_g		
float absorption_coefficient_b		

// diffuse color
// could be set with respect to absorption coefficients: exp(-1.5*absorption*radius)
diffuse_color

// diffuse intensity
diffuse_intensity			

// ambient color
// could be set with respect to absorption coefficients: exp(-2.*absorption*radius)
ambient_color

//ambient intensity
ambient_intensity

// the ratio between index of refractions inside the hair and sourounding medium (ior_inside/ior_outside)
index_of_refraction_ratio

// factor for opacity correction
opacity_factor

// offset for opacity correction
opacity_offset

geometrical properties
----------------------

// fiber cross section radius
radius
			

 																															 																					
