now i’m have some problems with black screen instead mixed frame
I create for each world namedRT texture and add it to cache manualy
void World::CreateNamedRT(String worldName)
{
Graphics* g = context->GetSubsystem<Graphics>();
int w = g->GetWidth();
int h = g->GetHeight();
renderTexture = SharedPtr<Texture2D>(new Texture2D(context));
if (renderTexture)
{
renderTexture->SetSize(w, h, Graphics::GetRGBFormat(), TEXTURE_RENDERTARGET);
renderTexture->SetFilterMode(FILTER_BILINEAR);
renderTexture->SetName(worldName);
RenderSurface* surface = renderTexture->GetRenderSurface();
surface->SetViewport(0, camera.vp);
ResourceCache* cache = context->GetSubsystem<ResourceCache>();
cache->AddManualResource(renderTexture);
}
}
// usial worlds
worlds[WORLD_A].InitScene(context_, "WorldA.xml", WORLD_A);
worlds[WORLD_A].SetupPlayer();
worlds[WORLD_A].CreateNamedRT("WorldA");
worlds[WORLD_B].InitScene(context_, "WorldB.xml", WORLD_B);
worlds[WORLD_B].SetupPlayer();
worlds[WORLD_B].CreateNamedRT("WorldB");
// world with portal mesh
worlds[WORLD_P].InitScene(context_, "WorldP.xml", WORLD_P);
worlds[WORLD_P].SetupPlayer();
worlds[WORLD_P].CreateNamedRT("WorldP");
only for test i’m append to active visible viewport a part with new RenderPath
worlds[WORLD_A].SetCurrent();
// add PrenderPath
rp = SharedPtr<RenderPath>((worlds[WORLD_A].camera.vp->GetRenderPath()->Clone()));
rp->Append(cache->GetResource<XMLFile>("PostProcess/Portal.xml"));
worlds[WORLD_A].camera.vp->SetRenderPath(rp);
where is portal.xml
<renderpath>
<command type="quad" vs="Portal" ps="Portal" output="viewport" >
<texture unit="0" name="WorldA" />
<texture unit="1" name="WorldP" />
<texture unit="2" name="WorldB" />
</command>
</renderpath>
and his shader portal.hlsl
#include "Uniforms.hlsl"
#include "Samplers.hlsl"
#include "Transform.hlsl"
#include "ScreenPos.hlsl"
#include "Lighting.hlsl"
void VS(float4 iPos : POSITION,
out float2 oScreenPos : TEXCOORD0,
out float4 oPos : OUTPOSITION)
{
float4x3 modelMatrix = iModelMatrix;
float3 worldPos = GetWorldPos(modelMatrix);
oPos = GetClipPos(worldPos);
oScreenPos = GetScreenPosPreDiv(oPos);
}
void PS(float2 iScreenPos : TEXCOORD0,
out float4 oColor : OUTCOLOR0)
{
// DiffMap - WorldA = tex unit 0
// NormalMap - WorldP = tex unit 1
// SpecMap - WorldB = tex unit 2
float3 MaskRgb = Sample2D(NormalMap, iScreenPos).rgb;
float MaskIntensity = GetIntensity(MaskRgb);
float3 Wa = Sample2D(DiffMap, iScreenPos).rgb;
float3 Wb = Sample2D(SpecMap, iScreenPos).rgb;
oColor = float4(lerp(Wa, Wb, MaskIntensity), 1.0);
}
in the log i’m don’t see any of shaders error, i mean that all loading is ok
also I checkout for all worlds RT (make screenshots) and only one - first have a fully black color
but why is black? any ideas ?
ps. if I change shader with output line like this
oColor = float4(1.0, 1.0, 1.0, 1.0); the screen will be - white.
but if I make changes like:
oColor = float4(MaskRgb, 1.0); or oColor = float4(Wa, 1.0); or oColor = float4(Wb, 1.0);
it still will be fully black