06-25-2018, 11:05 AM
I am sorry for the problems with the forum. I will check the spam filter settings again and see if there is anything I can do to improve that.
Now to your question.
From what you have written I think that you should be able to use the texture2D directly as it is on the GPU without copying it to main memory, converting it to GDI+ bitmap, then to WPF bitmap. And from there in DXEngine back to DirectX shader resource view and sending it back to GPU. There is a lot of overhead especially with sending the image from the gpu and back.
To try this use the following code to first create a ShaderResourceView from the texture2D object:
Then you can create a DXEngine material that will use that texture:
You can then use the standardMaterial to create a MeshObjectNode or if you are using WPF 3D objects, you can assign it to WPF Material with:
This will use the standardMaterial whenever the DXEngine will render an object with the diffuseMaterial.
I hope that this code will work for you.
Now to your question.
From what you have written I think that you should be able to use the texture2D directly as it is on the GPU without copying it to main memory, converting it to GDI+ bitmap, then to WPF bitmap. And from there in DXEngine back to DirectX shader resource view and sending it back to GPU. There is a lot of overhead especially with sending the image from the gpu and back.
To try this use the following code to first create a ShaderResourceView from the texture2D object:
Code:
var resourceViewDescription = new ShaderResourceViewDescription
{
Format = [enter format],
Dimension = SharpDX.Direct3D.ShaderResourceViewDimension.Texture2D,
Texture2D = new ShaderResourceViewDescription.Texture2DResource
{
MipLevels = 1,
MostDetailedMip = 0
}
};
var shaderResourceView = new ShaderResourceView(dxViewportView.DXScene.DXDevice.Device, texture2D, resourceViewDescription);
// Do not forget to dispose the shaderResourceView when it is not used any more.
// This can be done with using DisposeList object - for example:
_disposables.Add(shaderResourceView);Then you can create a DXEngine material that will use that texture:
Code:
var standardMaterial = new StandardMaterial()
{
// Set ShaderResourceView into array of diffuse textures
DiffuseTextures = new ShaderResourceView[] { shaderResourceView },
// When showing texture, the DiffuseColor represents a color mask - each color from texture is multiplied with DiffuseColor (White preserves the original color)
DiffuseColor = Colors.White.ToColor3()
};
_disposables.Add(standardMaterial);You can then use the standardMaterial to create a MeshObjectNode or if you are using WPF 3D objects, you can assign it to WPF Material with:
Code:
diffuseMaterial = new DiffuseMaterial();
diffuseMaterial.SetUsedDXMaterial(standardMaterial);This will use the standardMaterial whenever the DXEngine will render an object with the diffuseMaterial.
I hope that this code will work for you.
Andrej Benedik

