Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have been trying to use an existing library that automatically generates shaders (Hydrax plugin for Ogre3D). These shaders are used to render water and somewhat involved, but are not extremely complicated. However there seems to be some differences in how the cg shaders are handled by OpenGL and DirectX, more specifically, I am pretty sure that the author of the library only has debugged all the shaders for DirectX, and they work flawlessly there, but not so in OpenGL. There are no compiler errors, but the result just doesn't look the same. (And I have to run the library in OpenGL.) Isn't cg supposed to be a language that can freely use the exact same code for both platforms? Are there any specific known caveats one should know about when using the same code for them? Are there any fast ways to find what parts of the code work differently?

(I am pretty sure that the shaders are the problem. Otherwise Ogre3D has great support for both frameworks, and everything is abstracted away nicely. Other shaders work in OpenGL, etc...)

share|improve this question
    
Does seem a bit odd, but it might help in getting to the bottom of it if you posted the shader code. At least the relevant parts. Also, what seems different between the two? –  Ray Dey Jun 4 '12 at 23:24
    
I've actually done more testing and to my great surprise (have very limited shader language knowledge) could localize (at least one of) the problem(s): the function tex1D(x): works correctly in DX, but always returns black in GL. If I use tex2D(x,x) with the same texture, both work correctly. I've been testing on an ATI card (the word is that cg compiler has a lot of problems with ATI), will test more on Nvidia. But even if you have more generic tips of what usually differs in cg in GL/DX and how to troubleshoot, please tell. –  Cray Jun 5 '12 at 0:15
    
Re: the tex1D vs tex2D thing, you might check if the engine is correctly binding the 1D texture in OpenGL, using glEnable(GL_TEXTURE_1D), glTexImage1D, etc. OpenGL is quite picky about this: a one-pixel-tall texture bound as 2D is not the same thing as a 1D texture, to it. –  Nathan Reed Jun 5 '12 at 0:42
    
Tested with NVIDIA as well, got same results. You are probably right, it's possible that Ogre3D does not think of those textures as different, while OpenGL expects it. –  Cray Jun 5 '12 at 0:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.