PDA

View Full Version : vertex and pixel shader.



icare
02-03-2003, 01:15 AM
is assembly langage the only way to program vertex and pixel shader in opengl 1.4?

Humus
02-03-2003, 03:54 AM
Yes, but it's a "nice" assembler. That is, the code can be very readable since you use variables with names rather than registers like "r0" and so on as you do in Direct3D.

Jan
02-03-2003, 03:58 AM
Yes??? What about Cg?
http://www.cgshaders.com/

Thatīs a way you can program vertex and pixel shader in a C like language, instead of assembly.
Itīs currently quite nVidia specific, so thatīs of course a drawback, but for starting to learn what one can do with shaders, itīs really nice.

Jan.

icare
02-03-2003, 04:40 AM
I heard that cg is not so good at the moment and they have some trouble with their compiler.
In any way i'm not afraid to use assembly http://www.opengl.org/discussion_boards/ubb/smile.gif
where can i find some good code source?

Nutty
02-03-2003, 04:47 AM
nvidia specific? Doesn't Cg work on ATI 9700's if you use ARB_vertex_program and ARB_fragment_program profiles?

IF not why not?

Jan
02-03-2003, 05:43 AM
Yes, it works on a Radeon. But i heard of many people having trouble with some stuff, because nVidia has some profiles for NV only. Thatīs also the reason why i said itīs a little NV specific, but of course not exclusive.

I had no clue of how to use vertex and pixel shaders, at all. I downloaded the Cg Toolkit and played a bit with it. I am not very good at it, cause i have enough other stuff to do at the moment, but i got a good look at what can be done.
Therefore i think Cg is very good, at least to learn to understand what shaders are. If you really want to do supergenius stuff, which runs on all cards, you may want to use assembly.

Jan.

M/\dm/\n
02-03-2003, 06:41 AM
A quick guess - arn't those people who are crying about Cg all the time ATI "die hard" worshipers.
Cg is pretty good right now, of course you can do more in assembly, but why the hell you are using C,C++,Delphi etc. so much? Moreover, think about NV30 huge instruction count, even Carmack said that it's nice field for developers & imagine all that stuff in assembly http://www.opengl.org/discussion_boards/ubb/biggrin.gif

Ostsol
02-03-2003, 07:25 AM
Assembler's not so bad once you get used to it. After a while it becomes second nature. It's certainly alot easier to program with ARB_fragment_program than with ATI_fragment_shader, given that instructions are no longer input via functions. However, I do admit that it can have quite a steeper learning curve, as compared to high level languages.

NitroGL
02-03-2003, 08:53 AM
Originally posted by M/\dm/\n:
A quick guess - arn't those people who are crying about Cg all the time ATI "die hard" worshipers.
Cg is pretty good right now, of course you can do more in assembly, but why the hell you are using C,C++,Delphi etc. so much? Moreover, think about NV30 huge instruction count, even Carmack said that it's nice field for developers & imagine all that stuff in assembly http://www.opengl.org/discussion_boards/ubb/biggrin.gif
I use Cg to only generate chunks of code for something, so it doesn't matter what card I use (I optimize it by hand later). I would never use it in a "professional" application though, as it still could use some reworking on the optimizer.

Just IMO.

Humus
02-03-2003, 06:05 PM
There's nothing terribly wrong with Cg. The problem however is that it's controlled by a single vendor and really doesn't fill any empty slots, at least not given that D3D already has it's HLSL and OpenGL is soon to get one. Todays shaders are short enough to be written in assembler without any real problems at all. Also, I've heard (but don't know if it's true) that the Cg compiler currently generates far from optimal code.

icare
02-03-2003, 11:58 PM
i was wondering if the programmable shader are based only ( or mostly ) on the texture computing?
i mean input, output, variables should be texture as i can see in opengl 2.0 white papers.

Humus
02-04-2003, 06:31 AM
Well, you have textures as input but also texture coordinates and constants of course. You have specific output variables that writes the stuff to your framebuffer.

icare
02-10-2003, 11:20 PM
Is there a way to pass vertex attributes ( like texcoord or color ) from the vertex program to the fragment program to make some computation, using asm?
Or maybe use the output from the vertex program as input for the fragment program?

Humus
02-11-2003, 07:42 AM
Yup. You have certain outputs from the vertex shader, texcoords, position, colors, fogcoord etc. Texcoords/colors etc can be read by the fragment program.