0001: // -------------------------------------------------------------
0002: // paraboloid.fx
0003: // 
0004: // Copyright (c) 2004 IMAGIRE Takashi. All rights reserved.
0005: // -------------------------------------------------------------
0006: 
0007: 
0008: // -------------------------------------------------------------
0009: // Transformation for rendering a paraboloid map (放物マップ頂点シェーダプログラム)
0010: // -------------------------------------------------------------
0011: float4 paraboloid( float4 vPosition, float4x4 mWV )
0012: {   
0013:     float4 Out = (float4)0;
0014:     float3 pos;
0015:     float l;
0016:     
0017:     float z_min = 0.1;          // Near plane
0018:     float z_max = 100.0;        // Far plane
0019:     
0020:     // Position in the view space(位置座標)
0021:     pos = mul( vPosition, mWV ).xyz;
0022:     
0023:     l = length( pos );
0024:     
0025:     Out.xy = pos.xy * l * (l-pos.z) / dot( pos.xy, pos.xy );
0026:     
0027:     if( 0 <= pos.z )
0028:     {
0029:         Out.z = (l-z_min)*z_max/(z_max-z_min);
0030:         Out.w = l;
0031:     } else {
0032:         // Fly vertexs in the back to an infinite distant place.
0033:         // (背面にある頂点は無限遠方に飛ばす)
0034:         Out.z = 0;
0035:         Out.w = -0.00001;
0036:     }
0037:     
0038:     return Out;
0039: }
0040: 
0041: 
0042: