// //------------------------------------------------------------ // Copyright(c) 2009-2010 by Digital Media Professionals Inc. // All rights reserved. //------------------------------------------------------------ // This source code is the confidential and proprietary // of Digital Media Professionals Inc. //------------------------------------------------------------ // #include "Commonasm.h" // Input registers map #define aPosition v0 #define aNormal v1 #define aTexCoord v2 // Output registers map #define vPosition o0 #define vQuaternion o1 #define vView o2 #define vTexCoord0 o3 #pragma bind_symbol( aPosition.xyzw, v0, v0 ) #pragma bind_symbol( aNormal.xyz, v1, v1 ) #pragma bind_symbol( aTexCoord.xy, v2, v2 ) #pragma bind_symbol( uProjection, c0, c3 ) #pragma bind_symbol( uModelView, c4, c7 ) #pragma output_map ( position, o0 ) #pragma output_map ( quaternion, o1 ) #pragma output_map ( view, o2 ) #pragma output_map ( texture0, o3.xy ) l_position_view_quaternion: m4x4 TEMP_VIEW, dmp_position, dmp_local_to_view_matrix // Generate the model view matrix. mov dmp_lrView, -TEMP_VIEW // Outputs view vector. m3x3 TEMP_NORM.xyz, dmp_normal, dmp_local_to_view_matrix // Inner product of normal and view. m4x4 gl_Position, TEMP_VIEW, dmp_projection_matrix // Model view projection. // Quaternion. add r4, TEMP_NORM.z, CONST_1 mul r4, r4, CONST_HALF mov dmp_lrQuat.w, CONST_0 rsq r4, r4.x mul r5, TEMP_NORM, CONST_HALF cmp EQ, EQ, TEMP_NORM.z, -CONST_1 ifc 0, 1, COND_MODE_STA0 rcp dmp_lrQuat.z, r4.x mul dmp_lrQuat.xy, r5, r4 else mov dmp_lrQuat.xyz, CONST_1_0 endif nop ret nop main: call l_position_view_quaternion mov gl_TexCoord0, aTexCoord end endmain: