When porting pixel shaders from GLSL to OGSFX, in particular shaders found via demo sites, the following tips may be helpful:
See bin\OGSFX
in the Maya installation for the Common.ogsfh
file.
This file contains common shader code that defines the following uniforms and attributes, which you can re-use in your own shader code:
world view projection transformation matrix
screen size
texture co-ordinates
vertex shader input structure
vertex shader output structure
It also includes a default screen quad vertex shader that outputs the position and texture co-ordinates.
>**Note:** Remember to add:
>
>```
>#include "Common.ogsfh"
>```
Instead of using screen co-ordinates as input in your shader code, use UV co-ordinates. This way, your shader can be applied to any geometry: sphere, plane, and so forth.
For example, instead of using gl_FragCoord.xy
, use VSUV
(defined in Common.ogsfh
).
If you are writing a very simple shader, in lieu of writing your own vertex shader, you can re-use the one defined in Common.ogsfh
by specifying it as follows:
VertexShader (in VS_INPUT_ScreenQuad, out VS_TO_PS_ScreenQuad) = VS_ScreenQuad;
If your shader file fails to load, you can refer to errors in the Maya Output Window.