diff --git a/Cg-shaders.md b/Cg-shaders.md new file mode 100644 index 0000000..82a4f75 --- /dev/null +++ b/Cg-shaders.md @@ -0,0 +1,34 @@ +## Purpose +Cg shaders is a spec from nVidia. It has the great advantage that shaders written in Cg are compatible with both OpenGL and Direct3D. It is also compatible with PlayStation 3 as well. They are also compatible with basic HLSL if some considerations are taken into account. They can even be automatically be compiled into [[GLSL shaders]], which makes Cg shaders a true "write once, run everywhere" shader format. + +### Example Cg shader + void main_vertex + ( + float4 position : POSITION, + out float4 oPosition : POSITION, + uniform float4x4 modelViewProj, + float2 tex : TEXCOORD, + out float2 oTex : TEXCOORD + ) + { + oPosition = mul(modelViewProj, position); + oTex = tex; + } + + float4 main_fragment (float2 tex : TEXCOORD, uniform sampler2D s0 : TEXUNIT0) : COLOR + { + return tex2D(s0, tex); + } + +## Specification +The Cg shader spec used in RetroArch is documented [here](https://github.com/Themaister/Emulator-Shader-Pack/blob/master/Cg/README). It defines single-pass Cg shaders as well as multi-pass shaders using a custom Cg preset format (.cgp). + +### Example Cg preset + shaders = 2 + shader0 = 4xBR-v3.9.cg + scale_type0 = source + scale0 = 4.0 + filter_linear0 = false + shader1 = dummy.cg + filter_linear1 = true +