It seems it should be perfeclty suited for such a task, but one central point of a deferred renderer is the need of MRTs.
And thats what I cant get to work.
Since I'm planning to render all surfaces diffuse - only not much data is needed. In fact, I only have Color RGB, Normals XY and Emission.
That should fit into two PF_R8G8B8. So I create a mrt
Code: Select all
texture mrt target_width target_height PF_R8G8B8 PF_R8G8B8
Code: Select all
struct PS_IN
{
float2 UV : TEXCOORD0;
float3 Normal: TEXCOORD1;
};
struct PS_OUT
{
float3 rt0 : SV_Target0;
float3 rt1 : SV_Target1;
};
Texture2D Tex;
SamplerState linSample
{
Filter = MIN_MAG_MIP_LINEAR;
AddressU = Wrap;
AddressV = Wrap;
};
float2 encode (float3 n) //Crytec's Spheremap Transform Normal Compression
{
float p = sqrt(n.z*8 + 8);
return float2(n.xy/p + 0.5);
}
PS_OUT test_ps( PS_IN In )
{
PS_OUT MRT;
float4 rawTexture = Tex.Sample(linSample, In.UV);
float3 color = rawTexture.rgb;
float l = rawTexture.a;
float2 n = encode(In.Normal);
MRT.rt0 = color;
MRT.rt1 = float3(n, l);
return MRT;
}
But somehow i can't get it to work, it always crashes when rendering the first image, outputting the following error to the log:
Code: Select all
23:37:34: OGRE EXCEPTION(3:RenderingAPIException): D3D11 device cannot draw indexed
Error Description:ID3D11DeviceContext::DrawIndexed: The Pixel Shader expects a Render Target View bound to slot 0, but none is bound. This is OK, as writes of an unbound Render Target View are discarded. It is also possible the developer knows the data will not be used anyway. This is only a problem if the developer actually intended to bind a Render Target View here.
ID3D11DeviceContext::DrawIndexed: The Pixel Shader expects a Render Target View bound to slot 1, but none is bound. This is OK, as writes of an unbound Render Target View are discarded. It is also possible the developer knows the data will not be used anyway. This is only a problem if the developer actually intended to bind a Render Target View here.
Active OGRE vertex shader name: test_vs
Active OGRE fragment shader name: test_ps in D3D11RenderSystem::_render at ..\..\..\RenderSystems\Direct3D11\src\OgreD3D11RenderSystem.cpp (line 2925)
After all, if I'm not wrong the error is either me not using the compositor system correctly or Ogre not binding the MRT correctly to the shader.
Which wouldn't surprise me since especially that was basically written from scratch and propably isn't complete yet.
But that's at least in my opinion an important functionality that I really need right now - so if my suspicions are true it would be nice to add it to the already great new compositor system
By the way - I tried to do the same by rendering in two passes the data to two render targets - which requires using material schemes controlled by the compositor - which i didn't got working, too.
But I only looked briefly into it