代码: |
struct OutPut{ float4 pos: POSITION; float4 color : COLOR;};OutPut CGMain(float4 posi)//CGMain就是CG的程序入口{ OutPut OUT; OUT.pos = posi; OUT.color = float4(0.0,1.0,0.0,1.0); return OUT;} 只要在CreateProgram中加入这个名字作参数就可以了 CGcontext ctx = CGCreateContext(); CGprogram prog = CGCreateProgram(ctx, CG_SOURCE, mysourcepointer, CG_PROFILE_ARBVP1, "CGMain", NULL); |
代码: |
void C6E3v_particle(float4 pInitial : POSITION, float tInitial : TEXCOORD0, //语义型输入参数 float4 vInitial : TEXCOORD1, out float4 oPosition : POSITION, out float3 color : COLOR, //语义型输出参数 out float pointSize : PSIZE, uniform float time, uniform float4 acceleration, //uniform输入参数 uniform float4x4 modelViewProj){ float t = time - tInitial; float4 pFinal = pInitial +vInitial * t + 0.5 * acceleration * t * t; oPosition = mul(modelViewProj, pFinal); color = float3(t, t, t); pointSize = -8.0 * t * t + 8.0 * t + 0.1 * pFinal.y + 1; if (pointSize < 0) pointSize = 0;} |
http://www.physdev.com/phpbb/files/CG_fragment_compile_tool_130.jpg | ||
描述: |
|
http://www.physdev.com/phpbb/files/CG_vertex_compile_tool_161.jpg | ||
描述: |
|
http://www.physdev.com/phpbb/files/gg_compile_tool_161.jpg | ||
描述: |
|
|
|
|
|
|
|
|
|
|