[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: Cg, GLSL and uniform parameters



Hey Steve,



On Sat, 22 May 2004 19:18:13 -0500, Steve Baker <sjbaker1@airmail.net> escreveu:

> De: Steve Baker <sjbaker1@airmail.net>
> Data: Sat, 22 May 2004 19:18:13 -0500
> Para: linuxgames@sunsite.dk
> Assunto: Re: Cg, GLSL and uniform parameters



First of all, thank you for your time.


(...)


>  > For what I have seen until now, most uniform parameters defined in shaders correspond to OpenGL
>  > states anyway....
> 
> Not in most of my shaders!


Well, I'm having some trouble with that issue also. I mean, for an initial implementation, I'm relying on GL state for accessing matrices (modelview, projection and texture), material properties and lights. I understand that without reference to GL states one can define new material models, new light properties, etc, and implement them exclusively with programmable shaders. But then again, I'm not really feeling the need to completely abandon some of OpenGL's standard models, since I also want to support the traditional fixed-function pipeline. It would seem proper to "share" properties between standard OpenGL models and other alternative ones. That's why I made the above statement. Do you think this is reasonable?


> > ...so I could save some trouble by working directly with GLSL or exclusively with versions (present
>  > and future) of ARB_vertex_program and ARB_fragment_program.
> 
> We are in an ugly little corner right now where Cg is a mess - and GLSL isn't here yet.   I'm planning
> to support *BOTH* Cg-with-ARB-profiles *AND* GLSL - and *NOT* support Cg-with-nVidia-profiles.
> 
> It seems reasonably possible to write shaders that work with both GLSL and Cg-with-ARB-profiles with
> a minimum of '#define/#ifdef' stuff.
> 
> That seems to be a reasonably do-able thing...but it's a pain.  We really needed GLSL to come out a
> year ago.


Yes, that indeed seems to be painful :P.


> > Do you think it would be worth working with Cg and allowing a little more flexibility, though having
>  > some more trouble coding management for generic uniform parameters, or should I stick with options
>  > that allow direct access to OpenGL states (GLSL and ARB_vertex/fragment_program) and save myself some
>  > trouble?
> 
> I think you should consider quite carefully whether you truly need access to the classical OpenGL
> states.   I've found that being free of that mess is the best thing that ever happened to OpenGL.
> There are a few OpenGL states that can usefully be passed through as Uniforms - but you certainly
> don't need all of them.


I agree we don't need all of them, of course. My approach is to use as much of the most common GL states for my shaders, which doesn't mean that I won't be able to implement more sophisticated shaders that rely on more "application dependent" states (as opposed to traditional OpenGL states).

Could you please give me some examples of uniform parameters that are used in vertex and fragment shaders? I'm only beginning to explore the subject, so it would help a bunch to have some more clarification on this. I have the feeling I'm missing some important points regarding uniforms that will probably affect my design in a not very good way.



Again, thanks for your attention,
Miguel A. Osorio.