I previously had a class that could perform basic 2d rendering operations against a RenderTarget, which is my UI solution, however I no longer have the fixed function pipeline to use. (DX11, hlsl 4_0, WinRT) So I need to create shaders to do my UI drawing.
Fortunately the vertex and fragment programs should be simple. (Although I have to admit my programs could likely be unusable )
Vertex Shader: Basically I think it should just pass through the vertices and not do translation. Would like to be able to test this..
Code: Select all
//-----------------------------------------------------------------------------
// Function Name: main
// Function Desc: Vertex Program Entry point
//-----------------------------------------------------------------------------
void main
(
in float2 inPos : POSITION,
in float4 inColor : SV_Target,
in float2 inTexcoord2 : TEXCOORD0,
out float2 outPos : SV_Position,
out float4 outColor : SV_Target,
out float2 outTexcoord2 : TEXCOORD0
)
{
outPos = inPos;
outColor = inColor;
outTexcoord2 = inTexcoord2;
}
Code: Select all
//-----------------------------------------------------------------------------
// GLOBAL PARAMETERS
//-----------------------------------------------------------------------------
Texture2D gTextureSampler0 : register(t0);
SamplerState gTextureSamplerState0 : register(s0);
//-----------------------------------------------------------------------------
// Function Name: main
// Function Desc: Pixel Program Entry point
//-----------------------------------------------------------------------------
void main
(
in float4 inColor : SV_Target,
in float2 inTexcoord2 : TEXCOORD0,
out float4 outColor : SV_Target
)
{
return gTextureSampler0.Sample(gTextureSamplerState0, inTexcoord2) * inColor;
}
My Renderer2D class manually sets up the render system, and so I don't use the material system, and I don't know how the RTSS would come into play here. (I believe it is also material related) I want to manually setup the render system using the RenderSystem::bindGpuProgram method, however I need a GpuProgramPtr instance. So how to go from a string, which contains the Vertex Shader code above, to a GpuProgramPtr? I tried using the GpuProgramManager::loadFromString method, however I get the following exception:
Code: Select all
void D3D11GpuProgram::loadFromSource(void)
{
String message = "AIZ:D3D11 dosn't support assembly shaders. Shader name:" + mName + "\n" ;
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, message,
"D3D11GpuProgram::loadFromSource");
}
Code: Select all
mVertexProgram = mgr->loadFromString(gVertexProgramName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, gVertexProgram, Ogre::GpuProgramType::GPT_VERTEX_PROGRAM, Ogre::String("vs_4_0"));
Also, will I need to call bindGpuParameters? These shaders are very simple in what they do, I just want to be able to draw lines, rectangles, and images on the screen!
Please help. I want to get back to writing my game.