xboxscene.org forums

Author Topic: Can Cg Shaders Be Used On The Xdk?  (Read 92 times)

_zlinky

  • Archived User
  • Jr. Member
  • *
  • Posts: 56
Can Cg Shaders Be Used On The Xdk?
« on: July 13, 2007, 03:18:00 AM »

Hey.  I'm writing a game on the PC and I'm using Cg vertex/fragment programs.  Can they be used on the XDK?  Or just the pbkit/OpenXDK?  Thanks.
Logged

openxdkman

  • Archived User
  • Hero Member
  • *
  • Posts: 550
Can Cg Shaders Be Used On The Xdk?
« Reply #1 on: July 19, 2007, 11:43:00 PM »

CODE

    //sets vertex feed configuration
    p=pb_begin();
    pb_push(p++,NV20_TCL_PRIMITIVE_3D_VERTEX_ATTR(0),16);
    for(i=0;i<16;i++) *(p++)=2;    //resets array (nothing goes to v0-v15)
    pb_end(p);
    //declares that 3 floats will go into v0 (3D position) (stride for optional batch processing : +8*4)
    //declares that 3 floats will go into v3 (3D normal) (stride for optional batch processing : +8*4)
    //declares that 2 floats will go into v7 (2D texture coordinates) (stride for optional batch processing : +8*4)
    //(check your intermediate assembler file .vsh to see what ATTR:n is expected)
    //stride 0x20=4*8=4*(3+3+2) is the offset that allows batch processing to find next value in a data stream
    p=pb_begin();
    pb_push1(p,NV20_TCL_PRIMITIVE_3D_VERTEX_ATTR(0),0x2032); p+=2;
    pb_push1(p,NV20_TCL_PRIMITIVE_3D_VERTEX_ATTR(3),0x2032); p+=2;
    pb_push1(p,NV20_TCL_PRIMITIVE_3D_VERTEX_ATTR(7),0x2022); p+=2;
    pb_end(p);

    //read vs.cg for hints about how to create vs.h
    #include "vs.h"
    p=pb_begin();
    p=pb_push_mcode(p,pb_pcode2mcode(g_vs11_main));
    pb_end(p);

    //read ps.cg for hints about how to create ps.h
    #include "ps.h"
    p=pb_begin();
    p=pb_push_mcode(p,pb_pcode2mcode(g_ps11_main));
    pb_end(p);

Logged