1// 2//------------------------------------------------------------ 3// Copyright(c) 2009-2010 by Digital Media Professionals Inc. 4// All rights reserved. 5//------------------------------------------------------------ 6// This source code is the confidential and proprietary 7// of Digital Media Professionals Inc. 8//------------------------------------------------------------ 9// 10 11 12// Output registers map 13#define dmp_Position o0 14#define dmp_PMVS_Radii0 o1 15#define dmp_PMVS_Radii1 o2 16#define dmp_PMVS_Radii2 o3 17#define dmp_PMVS_Radii3 o4 18 19#pragma output_map ( position, o0 ) 20#pragma output_map ( generic, o1 ) 21#pragma output_map ( generic, o2 ) 22#pragma output_map ( generic, o3 ) 23#pragma output_map ( generic, o4 ) 24 25// Input registers map 26#pragma bind_symbol(attrCtrPointIndex.x, v0, v0) //expecting only input 0,1,2,3 27 28// Uniform definitions 29#pragma bind_symbol(uProjection, c55, c58) // Projection Matrix 30#pragma bind_symbol(uModelView, c59, c62) // ModelView Matrix 31#pragma bind_symbol(uCenter, c63, c66) // control point positions 32#pragma bind_symbol(uRadii, c71, c74) // radii around each control points 33 34#define uProjection c55 35#define uModelView c59 36#define dmp_PartSys_center c63 // 4*(x,y,z,w) control point positions 37#define dmp_PartSys_radii c71 // 4*(x,y,z,?) box radii around each control points 38 39//internal calculation 40#define CONSTANT c76 //starting register index for constant values 41def CONSTANT[0], 0.0, 1.0, 2.0, 3.0 42 43#define CONST_0 CONSTANT[0].x 44#define CONST_1 CONSTANT[0].y 45#define CONST_2 CONSTANT[0].z 46#define CONST_3 CONSTANT[0].w 47 48main: 49 mova a0.x, v0.x //this is the tricky part. Select the current control point (0..3) 50 mov r1, dmp_PartSys_center[a0.x] 51 m4x4 r0, r1, uModelView //control point position projected in model view space 52 mov r2, dmp_PartSys_radii[a0.x] 53 mul r1.x, r2.x, uModelView[0].x //Projection of the radii in modelview space 54 mul r1.y, r2.x, uModelView[1].x 55 mul r1.z, r2.x, uModelView[2].x 56 dp3 dmp_PMVS_Radii0.x, uProjection[0], r1 //Projection of the radii in camera space 57 dp3 dmp_PMVS_Radii1.x, uProjection[1], r1 //Projection of the radii in camera space 58 dp3 dmp_PMVS_Radii2.x, uProjection[2], r1 //Projection of the radii in camera space 59 dp3 dmp_PMVS_Radii3.x, uProjection[3], r1 //Projection of the radii in camera space 60 mul r1.x, r2.y, uModelView[0].y 61 mul r1.y, r2.y, uModelView[1].y 62 mul r1.z, r2.y, uModelView[2].y 63 dp4 dmp_Position.x, r0, uProjection[0] //control point position output (camera space) (X) 64 dp4 dmp_Position.y, r0, uProjection[1] //control point position output (camera space) (Y) 65 dp3 dmp_PMVS_Radii0.y, uProjection[0], r1 66 dp3 dmp_PMVS_Radii1.y, uProjection[1], r1 67 dp3 dmp_PMVS_Radii2.y, uProjection[2], r1 68 dp3 dmp_PMVS_Radii3.y, uProjection[3], r1 69 mul r1.x, r2.z, uModelView[0].z 70 mul r1.y, r2.z, uModelView[1].z 71 mul r1.z, r2.z, uModelView[2].z 72 dp4 dmp_Position.z, r0, uProjection[2] //control point position output (camera space) (Z) 73 dp4 dmp_Position.w, r0, uProjection[3] //control point position output (camera space) (W) 74 mov dmp_PMVS_Radii0.w, CONST_0 75 mov dmp_PMVS_Radii1.w, CONST_0 76 dp3 dmp_PMVS_Radii0.z, uProjection[0], r1 77 dp3 dmp_PMVS_Radii1.z, uProjection[1], r1 78 dp3 dmp_PMVS_Radii2.z, uProjection[2], r1 79 dp3 dmp_PMVS_Radii3.z, uProjection[3], r1 80 mov dmp_PMVS_Radii2.w, CONST_0 81 mov dmp_PMVS_Radii3.w, CONST_0 82 end 83endmain: 84