1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE book PUBLIC
"-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
3 "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">
4 <refentry id=
"refract">
9 <holder>Khronos Group
</holder>
12 <refentrytitle>refract
</refentrytitle>
13 <manvolnum>3G
</manvolnum>
16 <refname>refract
</refname>
17 <refpurpose>calculate the refraction direction for an incident vector
</refpurpose>
19 <refsynopsisdiv><title>Declaration
</title>
22 <funcdef>genType
<function>refract
</function></funcdef>
23 <paramdef>genType
<parameter>I
</parameter></paramdef>
24 <paramdef>genType
<parameter>N
</parameter></paramdef>
25 <paramdef>float
<parameter>eta
</parameter></paramdef>
28 <funcdef>genDType
<function>refract
</function></funcdef>
29 <paramdef>genDType
<parameter>I
</parameter></paramdef>
30 <paramdef>genDType
<parameter>N
</parameter></paramdef>
31 <paramdef>float
<parameter>eta
</parameter></paramdef>
35 <refsect1 id=
"parameters"><title>Parameters
</title>
38 <term><parameter>I
</parameter></term>
41 Specifies the incident vector.
46 <term><parameter>N
</parameter></term>
49 Specifies the normal vector.
54 <term><parameter>eta
</parameter></term>
57 Specifies the ratio of indices of refraction.
63 <refsect1 id=
"description"><title>Description
</title>
65 For a given incident vector
<parameter>I
</parameter>, surface normal
<parameter>N
</parameter> and ratio of
66 indices of refraction,
<parameter>eta
</parameter>,
<function>refract
</function> returns the refraction vector,
67 <parameter>R
</parameter>.
70 <parameter>R
</parameter> is calculated as:
73 <programlisting><![CDATA[ k =
1.0 - eta * eta * (
1.0 - dot(N, I) * dot(N, I));
75 R = genType(
0.0); // or genDType(
0.0)
77 R = eta * I - (eta * dot(N, I) + sqrt(k)) * N;]]
></programlisting>
80 The input parameters
<parameter>I
</parameter> and
<parameter>N
</parameter> should be normalized in order to achieve the desired result.
83 <refsect1 id=
"versions"><title>Version Support
</title>
84 <informaltable frame=
"topbot">
89 <entry>refract (genType)
</entry>#newin11#
92 <entry>refract (genDType)
</entry>#newin40#
98 <refsect1 id=
"seealso"><title>See Also
</title>
100 <citerefentry><refentrytitle>dot
</refentrytitle></citerefentry>,
101 <citerefentry><refentrytitle>reflect
</refentrytitle></citerefentry>
104 <refsect1 id=
"Copyright"><title>Copyright
</title>
106 Copyright
<trademark class=
"copyright"></trademark> 2011 Khronos Group.
107 This material may be distributed subject to the terms and conditions set forth in
108 the Open Publication License, v
1.0,
8 June
1999.
109 <ulink url=
"http://opencontent.org/openpub/">http://opencontent.org/openpub/
</ulink>.