Cg + openGL question

Started by
1 comment, last by kRogue 19 years ago
Hi all, as I browse the Cg documentation, I am left wondering the following questions: 1) for a vertex program, what is the maximum number of varying paramters it can have (say for the vp30 vertex shader profile)? according to the docs there are bindings for 16 default paramaters (which can be nemed GENERIC_ATTR#, or go by names like POSITION, NORMAL, TEXCOORD#, ect)...but if I use cgEnableClientState (and calls like it) can I get more than 16 paramaters? 2) is there a way to pass half's and fixed to vertex shaders, i.e. from C, to create an array of floats (or float3's, float4's) perform a low level operation so that an array of float4's say 100 floats in size, I can create an array of say just bytes, which repreent say half's then send them as arrays to Cg and then unpack the half data into float in Cg (i.e. this would be a bit of a hack to get more paramaters, but losing precision) 3) lastly, I do doubt this is false, but I can hope... during triangle rasterization, the GPU probably keeps track of the 2 previous vertices that make up a given triangle.... is it possible to somehow read these back (in the fragment shader)? the reason is that I am doing skinning oo the GPU, and I'd like to get the normal, and tangent vectors... there might me a very cheasy way to get this from within the fragment shader, if I hold onto the Projection matrix and use the ddx() and ddy() functions [but I am not so sure if I can] Best Regards
Close this Gamedev account, I have outgrown Gamedev.
Advertisement
1) There's no way to get extra varying parameters. There's a minimum of 96 uniform parameters (though this number may vary depending on the profile; I only use arbvp1/arbfp1) that are set for every vertex. What are you doing that requires more than 16 varying parameters?

2) Half is supported by some profiles, but not all. Fixed is supported in fragment programs, but not vertex. Int is supported in some profiles, but is usually converted to a float. Not that it matters, as there's no easy way to "unpack" the data (no bitshifts, bitmasks, etc).

3) Pixel shaders are limited to color and texture inputs and the uniform parameters, and that's it. If there's something extra you need to pass (like the normal), then pass it through the extra texture coordinates (output from the vertex shader).
Hi,

Your answer is exaclty what I thought and what I was afraid of.. damn... I think I probabaly only need at most 10 paramerts to go to the vertex shader... I am doing the skining of MD5 models on GPU, and their mentality is a touch different frm the usual skining (i.e. usual=each vertex is influenced by a set of transofrmation each weighted) while MD5 has the mentality that each vertex is a convex combination of distinct points each of which is infuenced by a transofrmation). 10 paramters--> max of 8 distinct points per vertex.... maybe that will be good enought fore most MD5's out there...

Best Regards

Close this Gamedev account, I have outgrown Gamedev.

This topic is closed to new replies.

Advertisement