Dark Bit Factory & Gravity

PROGRAMMING => General coding questions => Topic started by: Pixel_Outlaw on October 17, 2007

Title: Would you recommend learning OpenGL Shading Language?
Post by: Pixel_Outlaw on October 17, 2007
I'm considering buying the second book in the series that discusses OpenGL Shading Language.

I guess I'm looking for some reasons to invest time in learning a new set of commands. Do you use it personally? Is there much demand for learning this?
Title: Re: Would you reccomdend learning OpenGL Shading Language?
Post by: benny! on October 17, 2007
Even if I know very little about shading languages in general - I am really amazed by the
quality of products which use shaders. So, IMHO if you like programming computer graphics
it is worth learning a shader language.

Speaking of the OpenGL Shading language I do not know in which way / how much it differs
to other shading languages (like the one from Microsoft HLSL e.g.). So, if you prefer coding
in OpenGL - why not try its Shading Language.

Hmm ... but I guess there are far more experienced user here to tell you about this topic
more exactly...
Title: Re: Would you recommend learning OpenGL Shading Language?
Post by: Pixel_Outlaw on October 17, 2007

I'm interested in making things that have conditional shading and coloring. I really like graphics programming mostly because of my years of drawing and painting and interest in polyhedra.
Title: Re: Would you recommend learning OpenGL Shading Language?
Post by: frea on October 18, 2007
GLSL came out in one topics i am interested lately - shadows. Shadow mapping can be done faster ( in 2 renderings instead of 3 ) using GLSL.
If you are unsure whether you would like to learn glsl, download ATI's rendermonkey and look at their examples, the amount of code used to produce them and their speed.
If you were interested in glsl i can recomend you the tutorial writen by the guy at typhoon labs.

And after all glsl is not a big language, few types, few functions, c++-like syntax, so not much to learn compared to "normal" languages.


btw. what is "conditional shading" ? Google gave some results about excel ;p
Title: Re: Would you recommend learning OpenGL Shading Language?
Post by: taj on October 18, 2007
Hi PixelOutlaw,

I guess you are asking two questions here. Is it worth learning shaders...if so which type.
Well, is it worth it is hard to say without knowing your personal motivation. I would say shaders are everywhere, games, demos, 3d tools and even embedded devices within a couple of years. Fundamentally you can do stuff that is impossible in fixed pipelines so they are one more tool. Conditional shading (if (normal.z<0.0) colour = black;?? that sort of thing?) may require PS3.0 very quickly, depending on your complexity.

As for langauge. If you intend to do 4k or less I recommend HLSL and directX. If you are an OGL programmer, GLSL and if you don't mind shipping cg.dll everywhere with everything you do, cg is cross platform. GLSL had a late start and has less ready to use stuff than cg currently but its catching up quickly. So cg is easier to learn right now. That said we know GLSL is not going away, we cant say the same for CG.

Lastly, if you go GLSL route, I may be able to help you :-) but not CG.

Chris
Chris
Title: Re: Would you recommend learning OpenGL Shading Language?
Post by: Pixel_Outlaw on October 18, 2007


Ah ok thanks for the info. Yeah by conditional shading I meant evaluating data and changing the way things are drawn and shaded based on that. Something more than "here is my model it has a brick texture, ok now shade it please".
Title: Re: Would you recommend learning OpenGL Shading Language?
Post by: taj on October 18, 2007


Ah ok thanks for the info. Yeah by conditional shading I meant evaluating data and changing the way things are drawn and shaded based on that. Something more than "here is my model it has a brick texture, ok now shade it please".

In that case shaders are your best bet.

Chris
Title: Re: Would you recommend learning OpenGL Shading Language?
Post by: Pixel_Outlaw on October 18, 2007


Also in many modern games you see effects like textboxes converting the images underneath to monotone  colorscales. Is this done with shaders too? Example: the Warning message box in Ikaruga makes everything underneath a pure red hue with no other hues emitted.
Title: Re: Would you recommend learning OpenGL Shading Language?
Post by: taj on October 18, 2007
Thats probably just alpha blending but I cant be sure.
Title: Re: Would you recommend learning OpenGL Shading Language?
Post by: Pixel_Outlaw on October 18, 2007
No I don't think so. I tried to find a pic but basically it takes the region behind the box and strips all hue values, then it just used a pure red hue and keeps the value aspect. I guess a simplified version would be a grayscale region in a color game. Where a square takes the underlying pixels and converts them to grayscale.
Title: Re: Would you recommend learning OpenGL Shading Language?
Post by: taj on October 18, 2007
For this, in normal OGL, I would read the screen as a luminance texture then draw the menu using that texture and no blending. The menu could be any colour using GL_MODULATE mode. Might be slow depending on the card. Can anyone think of a better way? There must be...I still think blending might be able to be used.

In shaders I would read the screen as an RGB texture, and write a shader to read the texture and calculate the luminance and multiply by the colour of the menu. This is defintiely fast on anything supporting non power of two textures.

Chris

Title: Re: Would you recommend learning OpenGL Shading Language?
Post by: stormbringer on December 03, 2007
reading as Luminace is not the best way to do it. Most of the drivers do not convert to RGB to Luminance using a weighted sum, but rather just copy the red channel... pretty ugly. Shaders, shaders and shaders again. Nvidia and ATI manufactures have dropped consistent support of basic OpenGL functionalities, they all focus on shaders.