Caelum 0.4 Shaders in GLSL

Fish

28-06-2009 21:44:40

Here is a zip containing some of the Caelum 0.4 shaders converted to GLSL. It looks like the final 0.4 shaders are a little different from the ones we converted, but they should work anyway. We also had to change two lines of code in SkyDome.cpp to work with the GLSL shaders:

line 150 from:

Ogre::Pass *pass = mMaterial->getTechnique (0)->getPass (0);
if (value) {
pass->setFragmentProgram("CaelumSkyDomeFP");
} else {
pass->setFragmentProgram("CaelumSkyDomeFP_NoHaze");
}
Ogre::GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
params->setIgnoreMissingParams(true);


to:


Ogre::Pass *pass = mMaterial->getTechnique (0)->getPass (0);
if (value) {
pass->setFragmentProgram("CaelumSkyDomeFP_glsl");
} else {
pass->setFragmentProgram("CaelumSkyDomeFP_NoHaze_glsl");
}
Ogre::GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
params->setIgnoreMissingParams(true);
}


I can't guarantee that these converted shaders will work for everyone, but hopefully it will relieve some pain when you try to free yourself from the Cg dependency.

-Fish

[attachment=0]Caelum0_4_GLSL.zip[/attachment]

cdleonard

28-06-2009 23:29:26

This looks awesome; making it work w/o cg is a good thing. But I can't add it to trunk like this because it will no longer work with DirectX. This has to be converted to use unified programs. I've never used them but I don't see why they wouldn't work here.

I'll see if I can convert them later.

Fish

29-06-2009 00:22:03

I figured they wouldn't fit in the trunk which is why I didn't post it to the tracker.

We didn't bother with UnifiedProgs because we're focused solely on OpenGL. Cg was such a nasty pain in our bum that we were happy to delete the Cg shaders. :) That's not to slight the work you have done, what you have done is fabulous. The Cg compiler produces some nasty GLSL code that tends to run slower and is buggy sometimes with odd glitches and random visual artifacts. Switching to native GLSL has solved all but a few that seem to be ATI specific issues.

We also converted the GroundFog shaders but since they are untested (we don't use them) we didn't include them in the zip. But I can post them.

-Fish

cdleonard

15-07-2009 08:15:51

I tried to integrate the glsl but on a closer look it seems the changes are too big; there are non-syntax differences between the glsl and cg versions. There are even some changes to inline constants.

Anyway; the glsl shaders won't go in trunk. If somebody needs them they're welcome to unzip and try to use them; but I don't think it's worth doing. The 'imperfections' in Cg are more manageable than keep two versions shader code in sync.