• 1
  • 3
  • 4
  • 5
  • 6
  • 7
  • 9
 
User avatar
Erio
Topic Author
Posts: 81
Joined: 06 Feb 2013, 17:30
Location: Orléans/France

Re: NoesisGUI Unreal Engine 4 Plugin

25 Oct 2014, 16:26

Thanks for your feedback.

I was feeling that the approach was not correct but could not get what was wrong with it. Now I understand and will try to do with this approach. :)

I discover everything when I work on this plugin. I am grateful for your help there. :)
 
User avatar
Erio
Topic Author
Posts: 81
Joined: 06 Feb 2013, 17:30
Location: Orléans/France

Re: NoesisGUI Unreal Engine 4 Plugin

28 Oct 2014, 08:02

I have been searching for a few hours now and I find no sign of something that would looks like getting the render target in UE4.

So I don't really know. Well I have no idea to be honest. I will try to shout a question on the answerhub..

Something else I did think about was to have a ITexture2D (Noesis) that is getting updated each frame with the GetResolveTexture().

In this, I need to access the uint* (or unint8*) that represents the texture Data.
From there. I could make the uint* of the UTexture2D (UE4) to point on the one from the the Noesis texture, which would result in it being updated too each frame. Normally. I guess.

Could you explain a bit further what you do mean by binding the Texture render Target ?
Could you also explain more specifically which are the commands you're talking about if there are more than the standard process from the integration example.

From what I am seeing. I need in everycases to mess with the pixels array.
There does not seem to be any other method to do it at the moment..

If you can try to be more specific or give me examples that have been used with other engine. I would be thankful as I am really a snake eating his tail for now x.x
 
User avatar
jsantos
Site Admin
Posts: 3919
Joined: 20 Jan 2012, 17:18
Contact:

Re: NoesisGUI Unreal Engine 4 Plugin

28 Oct 2014, 11:36

Could you explain a bit further what you do mean by binding the Texture render Target ?
Yes, bind the render target is just calling OMSetRenderTargets

http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Could you also explain more specifically which are the commands you're talking about if there are more than the standard process from the integration example.
No, this is the standard process as described in the integration document: off-screen commands and direct commands.
From what I am seeing. I need in everycases to mess with the pixels array.
There does not seem to be any other method to do it at the moment..
As told you above, this path is inefficient. Not acceptable at all copying the bits from one surface to another in each frame and using the CPU. There have to be a way to do it efficiently.
If you can try to be more specific or give me examples that have been used with other engine. I would be thankful as I am really a snake eating his tail for now x.x
Could you have a look at the integration done by Coherent? They should have solved this problem.

Thanks!
 
TomSmith
Posts: 15
Joined: 31 Mar 2014, 22:23

Re: NoesisGUI Unreal Engine 4 Plugin

28 Oct 2014, 16:08

Erio,

How are you integrating noesis, have you extended the dx11 RHI to include functions for initialising and drawing noesis?

If so you probably want a UTextureRenderTarget2D in your plugin (outside of the RHI), then use GetRenderTargetTexture to get the RHItexture2d, and pass this to your RHI function.

and inside the Dx11 RHI, you have GetD3D11TextureFromRHITexture(), which returns a FD3d11TextureBase.

Then use FD3d11TextureBase::GetRenderTargetView() to return ID3d11RenderTargetView, which you can use with a call to OMSetRenderTargets.

FSlateD3DRenderer might be worth a browse, it is doing rendering to a RT per viewport.

Please note I haven't tested doing this, its just something I spotted when I was last digging in the RHI code, hope it points you in the right direction.
 
User avatar
Erio
Topic Author
Posts: 81
Joined: 06 Feb 2013, 17:30
Location: Orléans/France

Re: NoesisGUI Unreal Engine 4 Plugin

30 Oct 2014, 05:07

@jsantos:

I took a look at the function that is documented there. It seems very interesting and I am currently investigating it. :)

That's true that it is not. I was not aware that we could bind the RenderTargets this way. I learning everyday! :lol:

I am about to take a loot to CoherentUI's integration. I should be able to see something interesting or that could give me ideas and/or part of the solution. :)

This binding thing is the last thing holding the render to get in UE4. And another problem that came along but I could not pinpoint the moment it appeared. Probably when I updated to UE4.5, It seems that my component is not ticking each frame as it should. But I will investigate this afterward. :)

@TomSmith:

Hi,

At the moment, I integrating noesis by creatign a new module which loads all of the component from Noesis, at the right time it inits the renderSystem by feeding it with the ID3D11Device* coming from GDynamicRHI->GetNativeDevice().

I don't think it's needed to extend those as long as I can get the device or even call D3D11RHI if needed (I never had to yet).

I thank you for the UTextureRenderTarget2D idea as this was exactly what I was seeking for.
Sadly. I have not been able to find this function "GetRenderTargetTexture" or anything else that could approach it to return a RHITexture2D.
From what I have been able to see, the only class that have a function with this name is FRenderTarget.

I am now heading for FSlateD3DRenderer. I might find interesting things there. :)

EDIT: I am unable to find the class at all in fact o.o

Thanks for your support. ^^

I apologize for taking so long to bring it to life. :/

EDIT2: I found a rather interesting class while investigating the D3D11RHI folder: FD3D11BoundRenderTargets . I think this might be useful ^^

EDIT3: I cannot look at the way Coherent UI did it 's integration to UE4. At least nothing detailled..
 
User avatar
Erio
Topic Author
Posts: 81
Joined: 06 Feb 2013, 17:30
Location: Orléans/France

Re: NoesisGUI Unreal Engine 4 Plugin

30 Oct 2014, 07:58

Hm.
I have to admit, this is way beyond my current knowledge.
I am reading a lot about D3D11 at the moment, navigating the MSDN around OMSetRenderTarget.
Even managed to get something that compiles. But I am missing something about the way it's working yet.

Here is my current code for the binding function. It compiles but the result is not really here yet.
I have to find out the way to create the array of RenderTargetviews..
void UXAMLComponent::bindRenderTarget(UTextureRenderTarget2D *target, Ptr<IRenderTarget2D> source)
{
	ID3D11Device *device = (ID3D11Device *)GDynamicRHI->RHIGetNativeDevice();

	ID3D11Texture2D *depthStencil = NULL;
	ID3D11Texture2D *renderTarget = NULL;

	ID3D11RenderTargetView *rtv = NULL;
	ID3D11DepthStencilView *dsv = NULL;
	ID3D11DeviceContext *context = NULL;

	device->GetImmediateContext(&context);

	FRHITexture *baseTexture = (FRHITexture*)target->Resource->TextureRHI->GetTexture2D();
	FD3D11TextureBase *d3dTexture = GetD3D11TextureFromRHITexture(baseTexture);
	//rtv = d3dTexture->GetRenderTargetView(0, -1);
	//dsv = d3dTexture->GetDepthStencilView(DSAT_Writable);
	
	DX11Texture2D *dx11Texture = (DX11Texture2D*)source->GetResolveTexture();
	renderTarget = dx11Texture->mTexture;

	if (renderTarget)
		if (FAILED(device->CreateRenderTargetView(renderTarget, NULL, &rtv)))
			exit(-1);
	if (depthStencil)
		if (FAILED(device->CreateDepthStencilView(depthStencil, NULL, &dsv)))
			exit(-1);

	context->OMSetRenderTargets(1, &rtv, dsv);

	//delete boundRenderTargets;

	if (dsv)
		dsv->Release();
	if (rtv)
		rtv->Release();
	context->Release();
}
I am also wondering a lot about something:
I don't really understand the way it binds them.. I mean. I have two render targets.. But I don't get how to say that the source view must be used in the target view for example..
I found my ways to get pretty much all the D3D11 COM objects I do need. But I am a bit lost about the "what to do with them" yet. I lack general knowledges about the whole render pipeline. :?

If I bind them. Giving the OMSetRenderTargets function the right array of rendertargetview.. Will it somehow blend them ? Will they be at the same "3D space" ? Will they render on the same surface ? Or maybe will one of them be set as the "target view" and the other will be outprinting there ?

I have absolutely no answers about these and am a bit confused at the moment about it.
I will keep working on it a little bit before going to sleep.

I apologize to require such help and will update the thread before going to sleep with the latest code I have and it's result. :|

EDIT: I can get everything I want from the two render targets but I have no idea of the procedure to bind the two of them correctly. If you could help me with the binding part, I should be able to feed them the correct datas. :) Nothing changed in the code (or at least got reversed to the same point). I am going to sleep. I think I need it. :lol:
 
TomSmith
Posts: 15
Joined: 31 Mar 2014, 22:23

Re: NoesisGUI Unreal Engine 4 Plugin

31 Oct 2014, 04:20

Hi Erio,

Im not sure I understand what you mean by source view and target view.

you have a set of draw calls (generated by noesis when you call its render function), and you want these to end up drawn in a single texture. If you bind a single color rendertarget, your texturerendertarget, and then call the render function, the draw calls will output onto the texture.

Actually you *could* do everything you need without touching directx directly, the RHI has functions that allow you to specify a render context, and bind it. This is how I think it would work:

// create render target view from render target (where NewRenderTarget is the RHITexture2d from UTextureRenderTarget2D)
FRHIRenderTargetView RTV(NewRenderTarget);

// set depth stencil, single render target into an internal RHI buffer
FD3D11DynamicRHI::RHISetRenderTargets(1,&RTV,FTextureRHIParamRef NewDepthStencilTargetRHI,0,Null)
or
FD3D11DynamicRHI::RHISetRenderTargetsAndClear(..) which clears the depth and color buffers too

// the following actually calls OMSetRenderTargets
FD3D11DynamicRHI::CommitRenderTargetsAndUAVs()

then call noesis renderer, gXamlRenderer->Render(commands.commands.GetPtr());
since IDX11RenderSystem::SetDevice(..) was called previously with the dx11 device that unreal is using, the resulting draw calls will end up on the render target.


On another note, have you seen vaquole? its a html5 ui plugin that's open source. Its using texture copying to put the UI in, and that isn't great for noesis, but other then that it has all the plumbing necessary to hook in a third party UI (mouse, keyboard, mapping to flat/curved meshes, bluprints etc). you could probably rip out the calls to the webplayer, and have a pretty good starting point for a noesis plugin.
 
User avatar
Erio
Topic Author
Posts: 81
Joined: 06 Feb 2013, 17:30
Location: Orléans/France

Re: NoesisGUI Unreal Engine 4 Plugin

31 Oct 2014, 04:45

Hi TomSmith,

In fact, the plugin is quite "advanced" already and everything is working fine. NoesisGUI is even rendering in it's renderTarget when the component ticks. The "only" thing missing (at least to get a first visual feedback) is the binding. Everything else on the "in-engine" support side is already here. Well ok. Not for 2D. But that will not be an issue once everything is binded. ;)

I will explain then what is the target and the source to me:
UtextureRenderTarget2D *target is the texture on which I need to draw the content coming from NoesisGUI.
Noesis::Core::Ptr<Noesis::Render::IRenderTarget> source is the render target of this XAMLComponent.

If it may bring soem light. I will also explain quickly what a XAMLComponent is, even if the name is pretty speaking for itself.
It is a child class of a UStaticMeshComponent. A class you need to embed into another actor. Why a derive from a static mesh ? It allows me to easily create/modify the current mesh that's represented in this component. I plan on using the mesh given by NoesisGUI in later stages. :)

The thing I don't understand is how to tell the source to draw into the RHITexture2D or even the RHID3D11Texture2D that's contained in the target.

I found and will find how to find the low level D3D11 COM objects if I know which one I need to use.

Also. The function I show earlier does the binding ONLY. The renderTarget has already been created at the time I call it. NoesisGUI had been initialized using the ID3D11Device* used by UE4 so they "share" it.

What I do need is somehow the content of my function to bind or an example of something as:
void bindTargets(UTextureRenderTarget2D *target, Ptr<IRenderTarget> source)
{
    //Instruction to bind a renderTarget to a texture/existing rendertargetview
}
At the moment. I have to manipulate in some way raw D3D11 elements in any cases so..

Also. The render->Render(commands.commands.GetPtr()); is beign called in another function. so that alrght.
The only issue is the binding. Everything else is fine for now. :)

I will try to look at those RHI functions. Thanks. :)

EDIT: I do remember some issues with the FD3D11DynamicRHI... Yes.. It is private. I am not allowed to access it. Thus I am getting an error when using it.. Incomplete class. >.>
 
TomSmith
Posts: 15
Joined: 31 Mar 2014, 22:23

Re: NoesisGUI Unreal Engine 4 Plugin

31 Oct 2014, 15:01

OK, you are thinking the problem is "how do I copy RT x to RT y", but I am thinking the problem is "why render to RT x when you really want the output rendered on RT y". There is no such thing as "binding" two render targets together, the closest thing you can do is make both RTs based on a texture, render stuff with RT x active, then render a textured quad of texture x with RT y active to get the rendered stuff into texture y. This is much more expensive then just rendering to RT y in the first place.

When functions talk of activating multiple render targets, that is drawing once and the output going multiple places, not copying the output of one RT to others.

I don't think you should ever have Ptr<IRenderTarget>, I think you should have a UTextureRenderTarget2D only, owned by the component, and you should activate its render context as the previous post, prior to calling noesis render function. This will leave the noesis output in the unreal texture, and doesn't require any copying etc.

You can then reference this texture in whatever material you are using to draw your "screen"

The directx integration tutorial shows pretty much how I see this working.
 
User avatar
Erio
Topic Author
Posts: 81
Joined: 06 Feb 2013, 17:30
Location: Orléans/France

Re: NoesisGUI Unreal Engine 4 Plugin

31 Oct 2014, 17:47

Thanks for your answer, explanation and the time you're taking to help me to understand how this does work.

To be honest I was not thinking about copying but more about "How to make RTx to render into RT y"
The texture thing is a bad idea and I understand why. It's expensive on a CPU side.


But now that you do explain me. I start to understand. I was thinking that the IRenderTarget was necessary and that we were rendering in it... Then telling that IRenderTarget to render on some other RT.

I do have a better idea of where you were trying to lead me and am grateful. :)

My last question might also be stupid:

Do I need to do this process and get the RTV in your previous post for each frame ?
Also.. How did you get access to FD3D11DynamicRHI. It's a private class that seems to be invisible in the code. I had to copy over the one from the source of UE4. But If you have any better idea (I could not find anything on the net about it. :/ )
  • 1
  • 3
  • 4
  • 5
  • 6
  • 7
  • 9

Who is online

Users browsing this forum: Ahrefs [Bot], Semrush [Bot] and 24 guests