Vertex / pixel shader development: frustrating

Hello there people,

I’m currently trying - accompanied by a LOT of frustration :mad: - to get a pixel shader (fragment program) and / or vertex shader (vertex program) to run with OpenGL. I have bought nVidia’s “The Cg Tutorial” book with all kinds of examples that should work, but not a single person seems interested in telling you how you can actually COMPILE such a program by means of a practical example; I have tried compiling a simple, example pixel shader from the book using nVidia’s CGC command line compiler (CGC FragmentProgram.Txt). Nothing. The thing doesn’t seem to have a command line help switch and / or documentation, so I’m stuck.

I have also tried nVidia’s development IDE (FX Composer or whatever it is called) but it is WAY to cluttered with options to get up and running as far as the compilation of a simple pixel shader is concerned. I simply want to COMPILE a SINGLE PIXEL SHADER (a plain text file, nothing more) into an arbfp1 profile (or higher) compatible pixel shader program and I want to load this shader from within my application, is this really too much to ask (loading a precompiled (example) shader and using it in my application is no problem) :confused: ? I’m not interested in complete CgFX-projects with a plethora of vertex / pixel shaders and all kinds of additional assets that nVidia’s development environment wants to put me through.

I have also downloaded ATI’s RenderMonkey IDE (I’m currently using a Radeon 9800) but the current version isn’t able to compile shaders to an OpenGL profile: only DirectX profiles are supported, OpenGL support is planned ("…Support for DX8, DX9 (today) and OpenGL shader models (future)…"; :mad: way to go, ATI).

After that, I tried some third party tools like ShaderWorks: cluttered IDE, complete projects, no simple, single pixel / vertex shader compilation possible ( :confused: WHY?).

I’m starting to think about giving up. As a Computer Science student majoring in computer graphics I have enjoyed programming in OpenGL for quite some years now, but annoying and frustrating things like this just take the fun out of graphics programming. If someone out there can tell me what I am supposed to do to get a simple pixel shader (programmed in Cg / HLSL / GLSL; I am told the languages are compatible (although it seems that Cg-types like “float4” are not recognized by (at least) HLSL)) like the one below compiled using the arbfp1 profile, please let me know. Any Help would be greatly appreciated. Thanks in advance.

The program:

struct C2E2f_Output {
float4 color : COLOR;
};

C2E2f_Output C2E2f_Passthrough(float4 color : COLOR)
{
C2E2f_Output OUT;
OUT.color = color;
return OUT;
}

GRTZ,

(Sn)Ik.

P.S.

Im currently trying - as a last desperate attempt :frowning: - to get my Visual Studio .Net environment to source highlight Cg / HLSL / GLSL shaders and / or compile them to an OpenGL / DirectX profile…

cgc -profile arbfp1 input.cg -o output.txt

:slight_smile: Thanks a lot, I’ll try it right away.

GRTZ,

(Sn)Ik.

Too bad, it doesn’t seem to work :frowning: :

“(0) : error C3001: no program defined
10 lines, 1 errors.”

The content of my input.cg file is exactly as follows:

struct C2E2f_Output {
float4 color : COLOR;
};

C2E2f_Output C2E2f_Passthrough(float4 color : COLOR)
{
C2E2f_Output OUT;
OUT.color = color;
return OUT;
}

No idea what I’m doing wrong…

GRTZ,

(Sn)Ik.

I dont really work with cg but it was my understanding that every program requires a main function.

You’ll need to add “-entry C2E2f_Passthrough” to tell the compiler the name of your entry function.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.