Question by
XinYueVR · Aug 08, 2019 at 03:53 AM ·
unityeditorunity remote
Unity Failed in Native API RTVFromRenderBuffer when Get a RenderTexture Handle
C++ Native Code
void RenderAPI_D3D11::SetShaderResourceView(void * textureHandleleft, void * textureHandleright){
mRenderTargetViewLeft = d3d->RTVFromRenderBuffer((UnityRenderBuffer)textureHandleleft);
if (mRenderTargetViewLeft == nullptr)
{
MessageBox(NULL, L" mRenderTargetViewLeft is null", L"SetShaderResourceView RTVFromRenderBuffer", MB_OK);
}
mRenderTargetViewRight = d3d->RTVFromRenderBuffer((UnityRenderBuffer)textureHandleright);
if (mRenderTargetViewRight == nullptr)
{
MessageBox(NULL, L" mRenderTargetViewRight is null", L"SetShaderResourceView RTVFromRenderBuffer", MB_OK);
}
}
C#
ShaderResourceViewLeft = new RenderTexture(2560,1440,24);
ShaderResourceViewRight = new RenderTexture(2560, 1440, 24);
if(LeftEye)
LeftEye.targetTexture = ShaderResourceViewLeft;
if (RightEye)
RightEye.targetTexture = ShaderResourceViewRight;
if (ShaderResourceViewLeft&& ShaderResourceViewRight)
{
Debug.Log("ShaderResourceViewLeft:" + ShaderResourceViewLeft.GetNativeTexturePtr());
Debug.Log("ShaderResourceViewRight:" + ShaderResourceViewRight.GetNativeTexturePtr());
SetShaderResourceView(ShaderResourceViewLeft.GetNativeTexturePtr(), ShaderResourceViewRight.GetNativeTexturePtr());
}
Failed 1: void* texturehandle always 0, it put out the unity GameView Background RenderTargetView not the RenderTexture I set
unitynativerender.png
(75.5 kB)
Comment
Your answer
Follow this Question
Related Questions
Unity Remote 5 Not working 0 Answers
How to connect with another device with hosted unity server app 0 Answers
Unity Works after Reset 0 Answers
Android device is recognized when building but not in editor 0 Answers
Starting new 3D project in unity 0 Answers