Page 1 of 1

Question about CG shader language

Posted: Thu Feb 27, 2014 1:30 pm
by AReichl
I just try the Xth. time do get into shader programming.

I won't learn 2 languages (HLSL + GLSL) !!!

CG is fine, but Nvidia itself advises to take something else for future use (and besides, CG is used by Sony for the PlayStation, but it does not run on the XBox).

Maybe use a HLSL -> GLSL "converter" (or the other way around, i don't care) which will be supported in the future (DirectX 11 <-> OpenGL 4) ?

Found some hints here (but still don't know what to do):
http://aras-p.info/blog/2012/10/01/cros ... s-in-2012/

Some time ago there were some interesting university projects (Brook, SH), but development is closed.

It SEEMS to me, that the most economic way right now and for the future would be to learn HLSL (maybe only up to DirectX 9), compile it through CG if you need the written shaders in GLSL, and hope that some company or open source project finds a solution for this mess.

Any ideas or advice ???

Re: Question about CG shader language

Posted: Thu Feb 27, 2014 8:32 pm
by hendu
Learn one language, the cross-platform one (GLSL) ;)

Re: Question about CG shader language

Posted: Fri Feb 28, 2014 9:06 am
by AReichl
Right - specially now where GLSL becomes more important again.

But then you could also say, Irrlicht should only support OpenGL in the future.

If there would be a GLSL -> HLSL converter (there is a project in work), i immediately would say "that's it".

Also you are not alone on this world - i once was asked to help with shaders in HLSL (customer requirement!), so i could not choose.

To sum it up - you are probably right, but i still don't really like the answer.

Re: Question about CG shader language

Posted: Sat Mar 01, 2014 7:00 pm
by Cube_
What about http://en.wikipedia.org/wiki/Shading_la ... g_Language ?
I personally use GLSL but OSL is interesting at the least.

Re: Question about CG shader language

Posted: Sat Sep 16, 2017 8:14 am
by robmar
OSL is interesting, does anyone have any idea how or if that could be integrated into Irrlicht? I looked at the GitHub project page, but there were very little details on integration.

Re: Question about CG shader language

Posted: Sat Sep 16, 2017 12:48 pm
by Foaly
robmar wrote:OSL is interesting, does anyone have any idea how or if that could be integrated into Irrlicht? I looked at the GitHub project page, but there were very little details on integration.
My opinion:

OSL is meant mainly for ray tracing.
E. g. on the github page it says "OSL does not have a separate kind of shader for light sources. Lights are simply surfaces that are emissive, and all lights are area lights."
Things like that really make it unsuitable for real-time rendering.

And you don't compute shadows and all yourself, like you would with glsl, but the rendering system magically does it for you.
So is probably inflexible for real-time, where you don't want accuracy, but instead "fake" many effects.

Although some part of the language could probably be used in a rasterization based renderer.
E. g. that it does not differentiate between varyings and uniforms.
You could maybe create an OSL-like language.

But it would be a huge amount of work and probably not worth it.