Home Technical Talk

Compile Cgfx for maya with NVIDIA CGC

polycounter lvl 19
Offline / Send Message
Brice Vandemoortele polycounter lvl 19
Hello everyone
When I was working with hlsl I used to compile using fxc via proprietary tools. It helped me figure out the number of instructions, use asm shaders etc.
Nowadays I'm working only in maya so the cgfx plugin was taking care of the compilation. I've been trying to use nvidia cgc (from the CGtoolkit) to produce asm shaders, but i can't get it to work yet.


If i don't manually specify a function to compile (either pixel shader or vertex shader) i get an error on valid semantics (i'm using the -nofx option, which is supposed to avoid cgfx semantics):
technique BasicShader
{
	pass P0
	{
		VertexProgram   = compile arbvp1 vertexFunction();
		FragmentProgram = compile arbfp1 pixelFunction();
	}
}

it gets stuck on the first "{" for no reason :
01_color.cgfx(57) : error C0000: syntax error, unexpected '{' at token "{"

if i don't use -nofx I simply get
(0) : error C3001: no program defined

if I specify manually the function to use (-entry pixelFunction/-entry vertexFunction)
I can only get the vertex shader to compile, the pixel shader outputs:
(0) : error C6014: Required output 'POSITION' not written

which doesn't make any sense since POSITION is output by the vertex shader.

Anyone ever suceed compiling cgfx with cgc? or knows if maya has some sort of temporary asm file somewhere?
Thx

Replies

  • Daaark
    Offline / Send Message
    Daaark polycounter lvl 17
    Is that your whole file? The compiler error says line 57. Are the keywords you are using elsewhere in the script available in arbvp1(as opposed to 2, or 3)?
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 19
    Hi there, somebody helped me and i succeed outputting something from the PS by forcing the profile. Still, I can't get it to load up in maya. I'm confused about the syntax I should use to integrate the asm code in the cgfx.

    the shader i use for testing is very short, so the line 57 is the technique definition already.
  • CrazyButcher
    Offline / Send Message
    CrazyButcher polycounter lvl 20
    I dont think you can easily use precompiled cg code in cgfx.
    if you use the asm style, you probably have to define all parameter bindings and such manually (look at directx .fx files that use precompiled asm for example). However I am not sure if that even works with cgfx at all.
    technique AsmFrag {
       pass {
         FragmentProgram = asm {
          !!FP1.0
          TEX o[COLR], {0}.x, TEX6, 2D;
          END
        };
      }
    }
    

    however there is no hint how you do the parameter binding, I guess it would be something like

    "LOCAL0 = somevar;"

    within the pass defintion, similar to how registers are filled in directx... never tried it so
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 19
    Thanks CB, I'll look into that

    next time I'll hint in the title "this thread is secretly aimed at CB" ;)

    cheers
Sign In or Register to comment.