Home > Materials > Textile > Carbon Fiber 1 > View Source

View Source

<?xml version="1.0" encoding="utf-8"?>
<scenedata>
	<material>
		<name>v_fiber_material</name>
		<phong>
			<exponent>
				<constant>
					200
				</constant>
			</exponent>
			<bump>
				<shader>
					<shader><![CDATA[def scale() real:
	0.15

def c() vec2 :
   getTexCoords(0)*scale()

def v_fiber_width() real:
	1.0

def h_fiber_width() real:
	1.0

def v_fiber_section() real:
	50. + 2.0 * noise ( c()*10. )

def h_fiber_section() real:
	50. + 2.0 * noise ( vec2(0.0,0.0) - c()*10. )


def cloth_x() real :
   fract(doti(c() * 100.) + noise ( c() * 8.75) )

def cloth_y() real :
   fract(dotj(c() * 100.) - noise ( c() * 6.35 ))

def eval() real :
		( if (lt ( cloth_x() * 2.0 - 1.0 , 0.0 ) , 1.0 , -1.0 )
		* sin( cloth_y() * 6.283185307 ) * h_fiber_width() / sqrt ( h_fiber_section() )
		 + sqrt ( 
			max ( 0. , v_fiber_section() - pow (
				 (abs (  cloth_x() * 2.0  - 1.0 )  * 2.0 - 1.0 ) / v_fiber_width() , 2.0 
			) ) ) - sqrt ( v_fiber_section() )
		 + fbm (  vec2 ( cloth_x() * 25. , cloth_y() ), 5 ) * 0.1
		 )
		* 0.001 / scale()]]></shader>
				</shader>
			</bump>
			<layer>0</layer>
			<fresnel_scale>1</fresnel_scale>
			<ior>2.2</ior>
			<nk_data></nk_data>
		</phong>
	</material>

	<material>
		<name>h_fiber_material</name>
		<phong>
			<exponent>
				<constant>
					200
				</constant>
			</exponent>
			<bump>
				<shader>
					<shader><![CDATA[def scale() real:
	0.15

def c() vec2 :
   getTexCoords(0)*scale()

def v_fiber_width() real:
	1.0

def h_fiber_width() real:
	1.0

def v_fiber_section() real:
	50. + 2.0 * noise ( c()*10. )

def h_fiber_section() real:
	50. + 2.0 * noise ( vec2(0.0,0.0) - c()*10. )

def cloth_x() real :
   fract(doti(c() * 100.) + noise ( c()*8.75) )

def cloth_y() real :
   fract(dotj(c() * 100.) - noise ( c()*6.35 ))

def eval() real :
		( if (lt ( cloth_y() * 2.0 - 1.0 , 0.0 ) , 1.0 , -1.0 )
		* sin( cloth_x() * 6.283185307 ) * v_fiber_width() / sqrt ( v_fiber_section() )
		 + sqrt ( 
			max ( 0. , h_fiber_section() - pow (
				 (abs (  cloth_y() * 2.0  - 1.0 )  * 2.0 - 1.0 ) / h_fiber_width() , 2.0 
			) ) ) - sqrt ( h_fiber_section() )
		 + fbm (  vec2 ( cloth_x()  , cloth_y()  * 25.), 5 ) * 0.1
		 )
		* 0.001 / scale()]]></shader>
				</shader>
			</bump>
			<layer>0</layer>
			<fresnel_scale>1</fresnel_scale>
			<ior>2.2</ior>
			<nk_data></nk_data>
		</phong>
	</material>

	<material>
		<name>textile_int</name>
		<blend>
			<a_name>v_fiber_material</a_name>
			<b_name>h_fiber_material</b_name>
			<blend>
				<shader>
					<shader><![CDATA[def scale() real:
	0.15

def v_fiber_width() real:
	1.0

def h_fiber_width() real:
	1.0

def c() vec2 :
   getTexCoords(0)*scale()

def cloth_x() real :
   fract( doti( c() * 100.) + noise ( c() * 8.75) )

def cloth_y() real :
   fract( dotj( c() * 100.) - noise ( c() * 6.35 ))

def eval() real :
	if ( lt ( abs ( fract ( cloth_x() * 2.0 + 0.5 ) - 0.5) , (1.0 - v_fiber_width() ) * 0.5 )   , 1.0 ,
	if ( lt ( abs ( fract ( cloth_y() * 2.0 + 0.5 ) - 0.5) , (1.0 - h_fiber_width() ) * 0.5 )    , 0.0 ,
	if( xor ( gt ( cloth_x() , 0.5 ) ,  gt ( cloth_y() , 0.5 ) ) , 0.0 , 1.0 ) ) ) 
]]></shader>
				</shader>
			</blend>
			<step_blend>true</step_blend>
		</blend>
	</material>

</scenedata>