Created Cg shaders (markdown)

Themaister 2013-04-30 02:17:04 -07:00
parent c9c115a5a3
commit 91ffba40e1
1 changed files with 34 additions and 0 deletions

34
Cg-shaders.md Normal file

@ -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