Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

gunslinger77

OpenGL opengl fragment shaders...

This topic is 5420 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi everybody, i am just seeking a little hint. I have been studing the per vertex and per fragment programs for a month now, and i think i am beginning to understand the whole thing a little more now. Now that i have a little understanding on the argument i would like to know what kind of shader language should be the most useful to learn. For what i can see i have 2 choices (and half). Should I learn assembly like programs used with GL_*_PROGRAM_ARB, or the c like OGSL shaders? The half choice should ne NVidia''s CG, but as for now i''d prefer a cross platform language, so i won''t consider studing a card specific shading method. Does someone knows what shading language will use OpenGL 2? It would be nice to study something that WON''T get obsolete in the next few months... thanks for the help, the Gunslinger...

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by gunslinger77
The half choice should ne NVidia''s CG, but as for now i''d prefer a cross platform language, so i won''t consider studing a card specific shading method.



CG isn''t card specific. Where did you get it from? CG works on every card that supports ARB_fragement_program and is croos-platform.



"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"

Share this post


Link to post
Share on other sites
probably is just a wrong guess from mine...
Anyway since it lost the contest for opengl 2 shading language i think that it would be more useful concentrating on more supported per fragment tecniques.

trivial discussion, my simple shader isn''t just working
it is just displayng blank screen :|
Hope to hear from you soon, bye!

Share this post


Link to post
Share on other sites
quote:
Original post by gunslinger77
probably is just a wrong guess from mine...
Anyway since it lost the contest for opengl 2 shading language i think that it would be more useful concentrating on more supported per fragment tecniques.

trivial discussion, my simple shader isn''t just working
it is just displayng blank screen :|
Hope to hear from you soon, bye!


Maybe some code would help. What shader? CG shader? I had some difficulties setting CG up, but my CG shaders work on my Radeon9600 Pro. I''m switching to OGSL soon anyway >_<.



"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"

Share this post


Link to post
Share on other sites
no cg, sorry, i am fling low in assembler, as for now.
i am using 2 simple programs, my vertex program is working fine (at least if i enable just that one my OpenGL app displays the right things.
The fragment program on the other hand isn''t working at all, if it is enabled, it just clears the window to a depressing BLACK.

the fragment program code is:

!!ARBfp1.0

# Fragment inputs
ATTRIB inTexCoord = fragment.texcoord; # First set of texture coordinates
ATTRIB inColor = fragment.color.primary; # Diffuse interpolated color

# Fragment outputs
OUTPUT outColor = result.color;

TEMP texelColor;
TXP texelColor, inTexCoord, texture, 2D;

MUL outColor, texelColor, inColor; # Modulate texel color with vertex color
#ADD outColor, texelColor, inColor; # Add texel color to vertex color

END

Actually i am using no texture, but everybody told me that i have to specify TexCoords anyway (i think they are used to calculate the fragment interpoled color).
Hear from you soon,
Gunslinger

Share this post


Link to post
Share on other sites
Um I have never written low level assembly shaders, so I can''t help..



"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by gunslinger77
MUL outColor, texelColor, inColor; # Modulate texel color with vertex color



quote:

Actually i am using no texture, but everybody told me that i have to specify TexCoords anyway (i think they are used to calculate the fragment interpoled color).



Well, they told you wrong. And this is also where your problem lies: you are multiplying the vertex colour with the *texture* colour in your FP. If you don''t bind a texture, then the result will obviously be black.

Try this instead of the MUL: MOV outColor, inColor;

Oh yes, and you do realize, that you are actually doing a *projected* texture access ? I don''t think this is what you want. You would want to use TEX instead of TXP, assuming a valid texture is bound. Yep, those are the little problems when simply copy''n''pasting sample code from the specs without thoroughfully understanding it..

Share this post


Link to post
Share on other sites
thank you anonymous
post after post i am seeing the light after all...

can you (or anybody else) explain what difference there is between tecture coordinates and projected texture coordinates? (TEX vs TXP...)
thx gunslinger

Share this post


Link to post
Share on other sites
It''s all in the spec. . .

http://oss.sgi.com/projects/ogl-sample/registry/ARB/fragment_program.txt

TXP divides the x, y, and z components of the texture coordinate by the w component before sampling the texture. This is used for projective textures.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!