Description

Because the Direct3D11 rendering subsystem for OGRE doesn't support Fixed Function Pipeline, it's necessary that you write your own vertex and fragment shaders, even the simplest of materials require shaders, and so, let this serve to you as a starting point for using the Direct3D11 rendering subsystem.

Note: This shader will not work with Direct3D9 or OpenGL.

Shader in Action
ogrehead.mesh With the shader and material applied.

Usage

Just give the material Shader1_HLSL_4_0 to your object/entity.

Shader1_fp_4_0.hlsl

float4 mainFP() : SV_TARGET 
{
		   
	return float4(1.0, 0.7, 0.0, 1.0);
}

Shader1_vp_4_0.hlsl

float4 mainVP(float4 pos : SV_POSITION, uniform float4x4 worldViewProj_m) : SV_Position
{
	// This keeps the object in place by multiplying the world view projection matrix by the position.
	return mul(worldViewProj_m, pos);
}

Shader1_4.0.material

Note: See http://www.ogre3d.org/docs/manual/manual_18.html for a list of profiles, but since the Direct3D11 rendering subsystem is not yet finished, profiles 4.0 and above are not listed.
Note #2: Shader profiles less than 4.0 (vs_4_0, ps_4_0) will not work with Direct3D11, and vice-versa (shader profiles greater than 3.0 (ps_3_0, vs_3_0) will not work with Direct3D9).

vertex_program Shader1_HLSL_vp_4 hlsl
{
	source  Shader1_vp_4_0.hlsl
	entry_point mainVP
	target vs_4_0
	default_params
	{
		param_named_auto worldViewProj_m worldviewproj_matrix
	}
}
 
fragment_program Shader1_HLSL_fp_4 hlsl
{
	source Shader1_fp_4_0.hlsl
	entry_point mainFP
	target ps_4_0
}

material Shader1_HLSL_4_0
{
	technique
	{
		pass
		{
			vertex_program_ref Shader1_HLSL_vp_4
			{
			}
			fragment_program_ref Shader1_HLSL_fp_4
			{
			}
		}
	}
}

Recommendations

To learn more about HLSL (or any shaders), you can read JaJDoo's Shader Guide, which does a very good job at explaining how HLSL (and shaders in general) work.
Since JaJDoo's shader guide is focused on Direct3D9 shader development, you should also read the MSDN article on the semantic updates that came with the new shader model/profile.


Alias: Your_First_Direct3D11_Shader