<HTML> <HEAD> <TITLE>fp20</TITLE> <STYLE TYPE="text/css" MEDIA=screen> <!-- BODY { font-family: Arial,Helvetica; } BLOCKQUOTE { margin: 10pt; } H1,A { color: #336699; } /*** Top menu style ****/ .mmenuon { font-family: Arial,Helvetica; font-weight: bold; text-decoration: none; color: #ff6600; font-size: 10pt; } .mmenuoff { font-family: Arial,Helvetica; font-weight: bold; text-decoration: none; color: #ffffff; font-size: 10pt; } .cpyright { font-family: Arial,Helvetica; font-weight: bold; text-decoration: none; color: #ffffff; font-size: xx-small; } .cpyrightText { font-family: Arial,Helvetica; font-weight: bold; text-decoration: none; color: #ffffff; font-size: xx-small; } .sections { font-family: Arial,Helvetica; font-weight: bold; text-decoration: none; color: #336699; font-size: 11pt; } .dsections { font-family: Arial,Helvetica; font-weight: bold; text-decoration: none; color: #336699; font-size: 12pt; } .slink { font-family: Arial,Helvetica; font-weight: normal; text-decoration: none; color: #336699; font-size: 9pt; } .slink2 { font-family: Arial,Helvetica; text-decoration: none; color: #336699; } .maintitle { font-family: Arial,Helvetica; font-weight: bold; text-decoration: none; color: #336699; font-size: 18pt; } .dblArrow { font-family: Arial,Helvetica; font-weight: bold; text-decoration: none; color: #336699; font-size: small; } .menuSec { font-family: Arial,Helvetica; font-weight: bold; text-decoration: none; color: #336699; font-size: small; } .newstext { font-family: Arial,Helvetica; font-size: small; } .linkmenu { font-family: Arial,Helvetica; color: #000000; font-weight: bold; text-decoration: none; } P { font-family: Arial,Helvetica; } PRE { font-family: monospace; white-space: pre; font-color: #333333; font-weight: 100; background-color: #eeeeee; padding: 5px; width: 90%; border-style: solid; border-width: 2px; border-color: #bebebe; } .quote { font-family: Times; text-decoration: none; color: #000000; font-size: 9pt; font-style: italic; } .smstd { font-family: Arial,Helvetica; color: #000000; font-size: x-small; } .std { font-family: Arial,Helvetica; color: #000000; } .meerkatTitle { font-family: sans-serif; font-size: x-small; color: black; } .meerkatDescription { font-family: sans-serif; font-size: 10pt; color: black } .meerkatCategory { font-family: sans-serif; font-size: 9pt; font-weight: bold; font-style: italic; color: brown; } .meerkatChannel { font-family: sans-serif; font-size: 9pt; font-style: italic; color: brown; } .meerkatDate { font-family: sans-serif; font-size: xx-small; color: #336699; } .tocTitle { font-family: Arial,Helvetica; font-weight: bold; text-decoration: none; color: #333333; font-size: 10pt; } .toc-item { font-family: Arial,Helvetica; font-weight: bold; color: #336699; font-size: 10pt; text-decoration: underline; } .perlVersion { font-family: Arial,Helvetica; font-weight: bold; color: #336699; font-size: 10pt; text-decoration: none; } .docTitle { font-family: Arial,Helvetica; font-weight: bold; text-decoration: none; color: #000000; font-size: 10pt; } .dotDot { font-family: Arial,Helvetica; font-weight: bold; color: #000000; font-size: 9pt; } .docSec { font-family: Arial,Helvetica; font-weight: normal; color: #333333; font-size: 9pt; } .docVersion { font-family: Arial,Helvetica; font-weight: bold; text-decoration: none; color: #336699; font-size: 10pt; } .docSecs-on { font-family: Arial,Helvetica; font-weight: normal; text-decoration: none; color: #ff0000; font-size: 10pt; } .docSecs-off { font-family: Arial,Helvetica; font-weight: normal; text-decoration: none; color: #333333; font-size: 10pt; } h3 { font-family: Arial,Helvetica; font-weight: bold; text-decoration: none; color: #336699; font-size: small; } h2 { font-family: Arial,Helvetica; font-weight: bold; text-decoration: none; color: #336699; font-size: medium; } h1 { font-family: Verdana,Arial,Helvetica; font-weight: bold; text-decoration: none; color: #336699; font-size: large; } DL { font-family: Arial,Helvetica; font-weight: normal; text-decoration: none; color: #333333; font-size: 10pt; } UL > LI > A { font-family: Arial,Helvetica; font-weight: bold; color: #336699; font-size: 10pt; } .moduleInfo { font-family: Arial,Helvetica; font-weight: bold; text-decoration: none; color: #333333; font-size: 11pt; } .moduleInfoSec { font-family: Arial,Helvetica; font-weight: bold; text-decoration: none; color: #336699; font-size: 10pt; } .moduleInfoVal { font-family: Arial,Helvetica; font-weight: normal; text-decoration: underline; color: #000000; font-size: 10pt; } .cpanNavTitle { font-family: Arial,Helvetica; font-weight: bold; color: #ffffff; font-size: 10pt; } .cpanNavLetter { font-family: Arial,Helvetica; font-weight: bold; text-decoration: none; color: #333333; font-size: 9pt; } .cpanCat { font-family: Arial,Helvetica; font-weight: bold; text-decoration: none; color: #336699; font-size: 9pt; } --> </STYLE> </HEAD> <BODY> <object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e"> </object> <BLOCKQUOTE> <H1><A NAME="NAME"><A NAME="1">NAME </A></A></H1> <P> <B>fp20</B> - OpenGL fragment profile for NV2x (GeForce3, GeForce4 Ti, Quadro DCC, etc.) </P> <H1><A NAME="SYNOPSIS"><A NAME="2">SYNOPSIS </A></A></H1> <PRE> fp20 </PRE> <H1><A NAME="DESCRIPTION"><A NAME="3">DESCRIPTION </A></A></H1> <P> This OpenGL profile corresponds to the per-fragment functionality introduced by GeForce3. </P> <P> The capabilities of this profile are quite limited. </P> <P> The compiler output for this profile conforms to the <B>nvparse</B> file format for describing <B>NV_register_combiners</B> and <B>NV_texture_shader</B> state configurations. </P> <H1><A NAME="3D_API_DEPENDENCIES"><A NAME="4">3D API DEPENDENCIES </A></A></H1> <P> Requires OpenGL support for <B>NV_texture_shader</B>, <B>NV_texture_shader2</B>, and <B>NV_register_combiners2</B> extensions. These extensions were introduced by GeForce3 and Quadro DCC GPUs. </P> <P> Some standard library functions may require <B>NV_texture_shader3</B>. This extension was introduced by GeForce4 Ti and Quadro4 XGL GPUs. </P> <H2><A NAME="OPENGL_EXTENSION_SPECIFICATIONS"><A NAME="5">OpenGL Extension Specifications </A></A></H2> <PRE> <A HREF="http://www.opengl.org/registry/specs/NV/register_combiners.txt">www.opengl.org/registry/specs/NV/register_combiners.txt</A> <A HREF="http://www.opengl.org/registry/specs/NV/register_combiners2.txt">www.opengl.org/registry/specs/NV/register_combiners2.txt</A> <A HREF="http://www.opengl.org/registry/specs/NV/texture_shader.txt">www.opengl.org/registry/specs/NV/texture_shader.txt</A> <A HREF="http://www.opengl.org/registry/specs/NV/texture_shader2.txt">www.opengl.org/registry/specs/NV/texture_shader2.txt</A> </PRE> <H1><A NAME="PROFILE_OPTIONS"><A NAME="6">PROFILE OPTIONS </A></A></H1> <P> None. </P> <H1><A NAME="DATA_TYPES"><A NAME="7">DATA TYPES </A></A></H1> <DL> <DT><STRONG>fixed </STRONG></DT> <DD> <P> The <B>fixed</B> data type corresponds to a native signed 9-bit integers normalized to the [-1.0,+1.0] range. </P> <DT><STRONG>float </STRONG></DT> <DD> <DT><STRONG>half </STRONG></DT> <DD> <P> In most cases, the <B>float</B> and <B>half</B> data types are mapped to <B>fixed</B> for math operations. </P> <P> Certain built-in standard library functions corresponding to <B>NV_texture_shader</B> operations operate at 32-bit floating-point precision. </P> </DD></DL> <H1><A NAME="SEMANTICS"><A NAME="8">SEMANTICS </A></A></H1> <H2><A NAME="INPUT_SEMANTICS"><A NAME="9">INPUT SEMANTICS </A></A></H2> <P> The varying input semantics in the <B>fp20</B> profile correspond to the respectively named varying output semantics of the <B>vp20</B> profile. </P> <PRE> Binding Semantics Name Corresponding Data COLOR Input primary color COLOR0 COL COL0 COLOR1 Input secondary color COL1 TEX0 Input texture coordinate sets 0 TEXCOORD0 TEX1 Input texture coordinate sets 1 TEXCOORD1 TEX2 Input texture coordinate sets 2 TEXCOORD2 TEX3 Input texture coordinate sets 3 TEXCOORD3 FOGP Input fog color (XYZ) and factor (W) FOG </PRE> <H2><A NAME="OUTPUT_SEMANTICS"><A NAME="10">OUTPUT SEMANTICS </A></A></H2> <PRE> COLOR Output color (float4) COLOR0 COL0 COL DEPTH Output depth (float) DEPR </PRE> <H1><A NAME="STANDARD_LIBRARY_ISSUES"><A NAME="11">STANDARD LIBRARY ISSUES </A></A></H1> <P> There are a lot of standard library issues with this profile. </P> <P> Because the 'fp20' profile has limited capabilities, not all of the Cg standard library functions are supported. The list below presents the Cg standard library functions that are supported by this profile. See the standard library documentation for descriptions of these functions. </P> <PRE> dot(floatN, floatN) lerp(floatN, floatN, floatN) lerp(floatN, floatN, float) tex1D(sampler1D, float) tex1D(sampler1D, float2) tex1Dproj(sampler1D, float2) tex1Dproj(sampler1D, float3) tex2D(sampler2D, float2) tex2D(sampler2D, float3) tex2Dproj(sampler2D, float3) tex2Dproj(sampler2D, float4) texRECT(samplerRECT, float2) texRECT(samplerRECT, float3) texRECTproj(samplerRECT, float3) texRECTproj(samplerRECT, float4) tex3D(sampler3D, float3) tex3Dproj(sampler3D, float4) texCUBE(samplerCUBE, float3) texCUBEproj(samplerCUBE, float4) </PRE><P> Note: The non-projective texture lookup functions are actually done as projective lookups on the underlying hardware. Because of this, the 'w' component of the texture coordinates passed to these functions from the application or vertex program must contain the value 1. </P> <P> Texture coordinate parameters for projective texture lookup functions must have swizzles that match the swizzle done by the generated texture shader instruction. While this may seem burdensome, it is intended to allow 'fp20' profile programs to behave correctly under other pixel shader profiles. The list below shows the swizzles required on the texture coordinate parameter to the projective texture lookup functions. </P> <PRE> Texture lookup function Texture coordinate swizzle tex1Dproj .xw/.ra tex2Dproj .xyw/.rga texRECTproj .xyw/.rga tex3Dproj .xyzw/.rgba texCUBEproj .xyzw/.rgba </PRE> <H2><A NAME="TEXTURE_SHADER_OPERATIONS"><A NAME="12">TEXTURE SHADER OPERATIONS </A></A></H2> <P> In order to take advantage of the more complex hard-wired shader operations provided by <B>NV_texture_shader</B>, a collection of built-in functions implement the various shader operations. </P> <DL> <DT><STRONG>offsettex2D </STRONG></DT> <DD> <DT><STRONG>offsettexRECT </STRONG></DT> <DD> <PRE> offsettex2D(uniform sampler2D tex, float2 st, float4 prevlookup, uniform float4 m) offsettexRECT(uniform samplerRECT tex, float2 st, float4 prevlookup, uniform float4 m) </PRE><P> Performs the following </P> <PRE> float2 newst = st + m.xy * prevlookup.xx + m.zw * prevlookup.yy; return tex2D/RECT(tex, newst); </PRE><P> where 'st' are texture coordinates associated with sampler 'tex', 'prevlookup' is the result of a previous texture operation, and 'm' is the offset texture matrix. This function can be used to generate the 'offset_2d' or 'offset_rectangle' <B>NV_texture_shader</B> instructions. </P> <DT><STRONG>offsettex2DScaleBias </STRONG></DT> <DD> <DT><STRONG>offsettexRECTScaleBias </STRONG></DT> <DD> <PRE> offsettex2DScaleBias(uniform sampler2D tex, float2 st, float4 prevlookup, uniform float4 m, uniform float scale, uniform float bias) offsettexRECTScaleBias(uniform samplerRECT tex, float2 st, float4 prevlookup, uniform float4 m, uniform float scale, uniform float bias) </PRE><P> Performs the following </P> <PRE> float2 newst = st + m.xy * prevlookup.xx + m.zw * prevlookup.yy; float4 result = tex2D/RECT(tex, newst); return result * saturate(prevlookup.z * scale + bias); </PRE><P> where 'st' are texture coordinates associated with sampler 'tex', 'prevlookup' is the result of a previous texture operation, 'm' is the offset texture matrix, 'scale' is the offset texture scale and 'bias' is the offset texture bias. This function can be used to generate the 'offset_2d_scale' or 'offset_rectangle_scale' <B>NV_texture_shader</B> instructions. </P> <DT><STRONG>tex1D_dp3(sampler1D tex, float3 str, float4 prevlookup </STRONG></DT> <DD> <PRE> tex1D_dp3(sampler1D tex, float3 str, float4 prevlookup </PRE><P> Performs the following </P> <PRE> return tex1D(tex, dot(str, prevlookup.xyz)); </PRE><P> where 'str' are texture coordinates associated with sampler 'tex' and 'prevlookup' is the result of a previous texture operation. This function can be used to generate the 'dot_product_1d' <B>NV_texture_shader</B> instruction. </P> <DT><STRONG>tex2D_dp3x2 </STRONG></DT> <DD> <DT><STRONG>texRECT_dp3x2 </STRONG></DT> <DD> <PRE> tex2D_dp3x2(uniform sampler2D tex, float3 str, float4 intermediate_coord, float4 prevlookup) texRECT_dp3x2(uniform samplerRECT tex, float3 str, float4 intermediate_coord, float4 prevlookup) </PRE><P> Performs the following </P> <PRE> float2 newst = float2(dot(intermediate_coord.xyz, prevlookup.xyz), dot(str, prevlookup.xyz)); return tex2D/RECT(tex, newst); </PRE><P> where 'str' are texture coordinates associated with sampler 'tex', 'prevlookup' is the result of a previous texture operation and 'intermediate_coord' are texture coordinates associated with the previous texture unit. This function can be used to generate the 'dot_product_2d' or 'dot_product_rectangle' <B>NV_texture_shader</B> instruction combinations. </P> <DT><STRONG>tex3D_dp3x3 </STRONG></DT> <DD> <DT><STRONG>texCUBE_dp3x3 </STRONG></DT> <DD> <PRE> tex3D_dp3x3(sampler3D tex, float3 str, float4 intermediate_coord1, float4 intermediate_coord2, float4 prevlookup) texCUBE_dp3x3(samplerCUBE tex, float3 str, float4 intermediate_coord1, float4 intermediate_coord2, float4 prevlookup) </PRE><P> Performs the following </P> <PRE> float3 newst = float3(dot(intermediate_coord1.xyz, prevlookup.xyz), dot(intermediate_coord2.xyz, prevlookup.xyz), dot(str, prevlookup.xyz)); return tex3D/CUBE(tex, newst); </PRE><P> where 'str' are texture coordinates associated with sampler 'tex', 'prevlookup' is the result of a previous texture operation, 'intermediate_coord1' are texture coordinates associated with the 'n-2' texture unit and 'intermediate_coord2' are texture coordinates associated with the 'n-1' texture unit. This function can be used to generate the 'dot_product_3d' or 'dot_product_cube_map' <B>NV_texture_shader</B> instruction combinations. </P> <DT><STRONG>texCUBE_reflect_dp3x3 </STRONG></DT> <DD> <PRE> texCUBE_reflect_dp3x3(uniform samplerCUBE tex, float4 strq, float4 intermediate_coord1, float4 intermediate_coord2, float4 prevlookup) </PRE><P> Performs the following </P> <PRE> float3 E = float3(intermediate_coord2.w, intermediate_coord1.w, strq.w); float3 N = float3(dot(intermediate_coord1.xyz, prevlookup.xyz), dot(intermediate_coord2.xyz, prevlookup.xyz), dot(strq.xyz, prevlookup.xyz)); return texCUBE(tex, 2 * dot(N, E) / dot(N, N) * N - E); </PRE><P> where 'strq' are texture coordinates associated with sampler 'tex', 'prevlookup' is the result of a previous texture operation, 'intermediate_coord1' are texture coordinates associated with the 'n-2' texture unit and 'intermediate_coord2' are texture coordinates associated with the 'n-1' texture unit. This function can be used to generate the 'dot_product_reflect_cube_map_eye_from_qs' <B>NV_texture_shader</B> instruction combination. </P> <DT><STRONG>texCUBE_reflect_eye_dp3x3 </STRONG></DT> <DD> <PRE> texCUBE_reflect_eye_dp3x3(uniform samplerCUBE tex, float3 str, float4 intermediate_coord1, float4 intermediate_coord2, float4 prevlookup, uniform float3 eye) </PRE><P> Performs the following </P> <PRE> float3 N = float3(dot(intermediate_coord1.xyz, prevlookup.xyz), dot(intermediate_coord2.xyz, prevlookup.xyz), dot(coords.xyz, prevlookup.xyz)); return texCUBE(tex, 2 * dot(N, E) / dot(N, N) * N - E); </PRE><P> where 'strq' are texture coordinates associated with sampler 'tex', 'prevlookup' is the result of a previous texture operation, 'intermediate_coord1' are texture coordinates associated with the 'n-2' texture unit, 'intermediate_coord2' are texture coordinates associated with the 'n-1' texture unit and 'eye' is the eye-ray vector. This function can be used generate the 'dot_product_reflect_cube_map_const_eye' <B>NV_texture_shader</B> instruction combination. </P> <DT><STRONG>tex_dp3x2_depth </STRONG></DT> <DD> <PRE> tex_dp3x2_depth(float3 str, float4 intermediate_coord, float4 prevlookup) </PRE><P> Performs the following </P> <PRE> float z = dot(intermediate_coord.xyz, prevlookup.xyz); float w = dot(str, prevlookup.xyz); return z / w; </PRE><P> where 'str' are texture coordinates associated with the 'n'th texture unit, 'intermediate_coord' are texture coordinates associated with the 'n-1' texture unit and 'prevlookup' is the result of a previous texture operation. This function can be used in conjunction with the 'DEPTH' varying out semantic to generate the 'dot_product_depth_replace' <B>NV_texture_shader</B> instruction combination. </P> </DD></DL> <H1><A NAME="EXAMPLES"><A NAME="13">EXAMPLES </A></A></H1> <P> The following examples illustrate how a developer can use Cg to achieve <B>NV_texture_shader</B>/<B>NV_register_combiners</B> functionality. </P> <H2><A NAME="EXAMPLE_1"><A NAME="14">Example 1 </A></A></H2> <PRE> struct VertexOut { float4 color : COLOR0; float4 texCoord0 : TEXCOORD0; float4 texCoord1 : TEXCOORD1; }; float4 main(VertexOut IN, uniform sampler2D diffuseMap, uniform sampler2D normalMap) : COLOR { float4 diffuseTexColor = tex2D(diffuseMap, IN.texCoord0.xy); float4 normal = 2 * (tex2D(normalMap, IN.texCoord1.xy) - 0.5); float3 light_vector = 2 * (IN.color.rgb - 0.5); float4 dot_result = saturate(dot(light_vector, normal.xyz).xxxx); return dot_result * diffuseTexColor; } </PRE> <H2><A NAME="EXAMPLE_2"><A NAME="15">Example 2 </A></A></H2> <PRE> struct VertexOut { float4 texCoord0 : TEXCOORD0; float4 texCoord1 : TEXCOORD1; float4 texCoord2 : TEXCOORD2; float4 texCoord3 : TEXCOORD3; }; float4 main(VertexOut IN, uniform sampler2D normalMap, uniform sampler2D intensityMap, uniform sampler2D colorMap) : COLOR { float4 normal = 2 * (tex2D(normalMap, IN.texCoord0.xy) - 0.5); float2 intensCoord = float2(dot(IN.texCoord1.xyz, normal.xyz), dot(IN.texCoord2.xyz, normal.xyz)); float4 intensity = tex2D(intensityMap, intensCoord); float4 color = tex2D(colorMap, IN.texCoord3.xy); return color * intensity; } </PRE> <H1><A NAME="SEE_ALSO"><A NAME="16">SEE ALSO </A></A></H1> <P> <A HREF="vp20.html">vp20</A> </P> </BLOCKQUOTE> </BODY>