BluffTitler stores its effects in CFX files. The format has been introduced by Outerspace Software at the release of BluffTitler version 12 as replacement for the deprecated DirectX 9 FX format.
This page is only meant for software engineers. You do not have to understand anything on this page in order to use effects. Click here to learn how to use effects
It comes in 2 versions:
BFX | a text format containing the HLSL source code |
CFX | a binary format containing compiled shaders (bytecode) |
The consumer editions of BluffTitler can only load CFX files. You can compile BFX to CFX with the developer edition. The developer edition is currently not for sale.
An effect contains:
A BFX file header looks like this:
BFX 1.0 DESCRIPTION "This effect does this and that and also..."
Up to 5 textures can be used:
0 | defined by effect |
1 | defined by effect |
2 | defined by effect |
3 | depth buffer |
4 | stencil buffer |
Textures are defined like this:
TEXTURE 0 COLOUR MIP * * TEXTURE 1 DISPLACEMENT MIP * * TEXTURE 2 CUBE MIP * *
1st string is always TEXTURE
2nd string is the texture index [0,4]
3rd string is the texture type {COLOUR, REFLECTION, CUBE, NORMAL, DEPTH, STENCIL, VOXEL, SKETCH, CARTOON, ALPHA, TONALART, DISPLACEMENT, FUR}
4th string sets mipmapping {*,MIP,LIN}. * means that the effect must not make adjustments.
5th string sets horizontal texture mode {*,CLAMP,WRAP,MIRROR}
6th string sets vertical texture mode {*,CLAMP,WRAP,MIRROR}
Textures can be accessed like this:
float4 c=MyTexture0.Sample(MySampler0, input.tex); float4 c=MyTexture0.SampleLevel(MySampler0, input.tex, 0);
An effect file can add 16 extra properties to a layer by using the following annotations:
UIName | The property name as it must appear in the GUI |
UIMin | The minimum value |
UIMax | The maximum value |
UIDefault | The default value |
UISliders | Number of sliders {1,2,3} |
UIScale | Scale to GUI factor |
UIInteger | Set to true for integer variables |
UIWidget | Widget |
The 16 extra properties can be defined this way:
float4 Prop0 < string UIName="My very own variable"; float UIMin=0; float UIMax=10; float3 UIDefault=float3(2,0,0); int UISliders=1; float UIScale=1; bool UIInteger=true; int UIWidget=0; >
Every property has a widget:
0 | default |
1 | angle |
2 | colour |
A pass contains render states, links to HLSL code and other properties. A pass is defined like this:
PASS BLENDING ADDITIVE ZREAD Y ZWRITE Y RGBAWRITE 7 CULL BACK SOLID Y CLEARTARGET Y VS vs_4_0 VS1 HS hs_4_0 HS1 DS ds_4_0 DS1 GS gs_4_0 GS1 PS ps_4_0 PS1
All render states are booleans {Y,N} except the following:
BLENDING can be {NONE, ALPHA, ADDITIVE, SUBTRACTIVE}
RGBAWRITE can be [0,15]. Y is accepted as 15 and N as 0.
CULL can be {FRONT, BACK, NONE}
The next pass in the same effect takes over the renderstates of the previous pass. The next effect resets the renderstates.
Every pass must have a vertex (VS) and pixel shader (PS). Hull (HS), domain (DS) and geometry shaders (GS) are optional.
The CLEARTARGET state is only used in the 2nd pass of a postprocessing effect.
If an effect is applied to the camera layer, the 1st texture contains the render output. This way it can be used as a post processing effect.
If the effect has 2 passes, the output of the 1st pass is used as the input for the 2nd pass. This can be used to optimize effects, like for example a bilinear blur. Note that this convention makes normal 2 pass effects useless for the camera layer.
The render target is cleared by default. For some effects, like for example a bloom, you don't want this. It can be prevented by setting the CLEARTARGET pass property to N:
CLEARTARGET N
BluffTitler uses the following vertex format:
struct | VS_INPUT{ | |
float4 | pos: | POSITION; |
float4 | normal: | NORMAL; |
float4 | col: | COLOR; |
float2 | tex: | TEXCOORD0; |
float4 | tangent: | TANGENT; |
}; |
Meshes created with the Tubular square, Tubular round, Wireframe, Light discs, Light bulbs and Comb text layer styles abuse the tangent field to store special info: (bulb/bulbs, contour, contours)
All matrices are 4x4 homogeneous transformation matrices in row major format.
World | model to world space |
WorldA | text layer: model(character) to text space |
WorldB | text layer: text to world space. (World = WorldA x WorldB) |
View | world to view space |
Projection | view to projection(screen) space |
WorldView | World x View |
ViewProjection | View x Projection |
WorldViewProjection | World x View x Projection |
WorldNormal | normals to world space |
WorldNormalA | text layer: normals from model to text space. |
WorldNormalB | text layer: normals from text to world space. (WorldNormal = WorldNormalA * WorldNormalB) |
InverseMirrorNormal | mirrored reflection to non mirrored world space |
InverseView | The inverse view matrix |
InverseProjection | The inverse projection matrix |
InverseViewProjection | InverseProjection x InverseView |
All vectors are 4D floats.
EyePos | X | Y | Z | W |
TextureResolution[5] | width | height | depth | aspect ratio (width/height) |
Material | R | G | B | A |
Power | specular power | alpha test mirror | fog range start | fog range full |
AmbientCol | R | G | B | 1 |
Lights | number of lights | fog colour R | fog colour G | fog colour B |
DiffuseCol[4] | R | G | B | 1 |
SpecularCol[4] | R | G | B | 1 |
LightPos[4] | X | Y | Z | 1 |
Time | show time in seconds | particle time in seconds | particle lifetime in seconds | alpha test |
LocalTime | hours | minutes | seconds | milliseconds |
ModelRepeat | picture layer: model repeat prop X text and scroller layer: word index voxel layer: tissue density prop X | picture layer: model repeat prop Y text and scroller layer: words voxel layer: tissue density prop Y | picture layer: model repeat prop Z | quality {0,1,2} |
TextureRepeat | picture and mirror layers: texture repeat prop X | picture and mirror layers: texture repeat prop Y | - | - |
CharacterIndex | text and scroller layer: character index picture layer when using model repeat prop: tile | text and scroller layer: characters picture layer when using model repeat prop: tiles | text and scroller layer: Unicode value | submodel |
PivotPoint | X | Y | Z | 1 |
Mirror | mirror exists (1 means yes) | mirror specularity | mirror gradient | clip (1 means yes) |
MirrorPlane | X normal | Y normal | Z normal | dot product normal and pos |
Amplitude[5] | audio amplitudes are stored in 20 floats: [0] contains all, [1] contains lowest frequency, [19] contains highest frequency. | |||
Prop[16] | the effect specific variables. The w component is always 1. | |||
WaterHeader | waves | steepness | - | - |
WaterData[120] | frequency | amplitude | heading | phase |
The HLSL source code (vertex, hull, domain, geometry and pixel shaders) follows after the HLSL tag:
HLSL
The compiled bytecode follows after the COMPILED tag:
COMPILED VS 0 2708
2nd string is the shader type {VS,HS,DS,GS,PS}
3rd string is the pass
4th string is the size in bytes
Shaders can be shared between passes like this:
COMPILED VS 0,1,2,3,4 2708