Back to main page

Shader

Each type of shader have a header inside the engine with some version specific declarations. When compiling an HLSL file, the header is concatunated before the shader's code for version compability.

Shaders loaded with compilation errors will be marked as not compiled and treated as NULL but remembering the filename so that you don't get redundant error messages.

You can assign a not compiled shader to an item to see your default material shader but you can not use an invalid default material shader since it can't be replaced by itself.

Headers for HLSL is not supported by the engine because the checksum for knowing if a shader file has changed will not know about changes in headers.

int Shader_LoadAsMaterial_InSB(void);

The string buffer must contain a valid extensionless filename with less than 255 characters to an HLSL shader in ANSI encoding. It must contain a vertex shader called VS and a pixel shader called PS.

The ID to a new or reused shader that can be assigned to model parts.

Loads and compiles the shader if it haven't been loaded yet and locks it from being deleted by the engine.

int Shader_LoadAsPostEffect_InSB(void);

The string buffer must contain a valid extensionless filename with less than 255 characters to an HLSL shader in ANSI encoding. It must contain a pixel shader called PS.

The ID to a new or reused shader that can be used with the post effect methods.

Loads and compiles the shader if it haven't been loaded yet.

int Shader_LoadAsDrawShader_InSB(void);

The string buffer must contain a valid extensionless filename with less than 255 characters to an HLSL shader in ANSI encoding. It must contain a pixel shader called PS.

The ID to a new or reused shader that can be used with the draw shader methods.

Loads and compiles the shader if it haven't been loaded yet.

void Shader_Unlock(int Shader);

Unlocking is affecting the use of Engine_RemoveUnusedResources.

Shader is a valid and locked shader.

Unlocks the shader to tell the garbage collection that you aren't using it and the engine can delete it when nothing else is using it.

void Shader_UseAsDefaultMaterialShader(int MaterialShader);

The default material shader is used instead of a warning when a part of a model is rendered without a shader in the used shader channel.

It is not used for shader channel 1 because not using a depth only shader means that the part's material will not cast shadows.

MaterialShader is a valid, compiled and locked shader loaded as a material or 0 for not using a default material shader.

MaterialShader is used as the default material shader. Giving 0 will set the default material shader to NULL so that you will get warnings again when rendering without a shader. Any previous default material shader is replaced.

void Shader_GetFilename_OutSB(int Shader);

Shader is a valid shader.

Writes Shader's extensionless filename to the string buffer. If you for example loaded "Material_MyShader.hlsl", "Material_MyShader" will be returned to the string buffer.

void Shader_SetGlobalTime(float NewValue);

The global time is available to both vertex and pixel shaders for both materials and post effects. It is called "GlobalTime" in HLSL whenever you need it.

Sets the global time to NewValue.

float Shader_GetGlobalTime(void);

Returns the global time (the value that was assigned the last time you called Shader_SetGlobalTime).