[2.1, 2.2] Using dynamic textures with PBS

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

[2.1, 2.2] Using dynamic textures with PBS

Post by al2950 »

I have dynamic textures that I use with PBS materials, which are updated via its own RTT compositor. In 2.1 only 2D Array textures are allowed. (I understand why PBS uses 2d Arrays). However, at least for Dx11, it still seems to work fine if you use a basic 2D texture, apart from an assert that happens. Rendering into a 2D array also for seems impossible for 2.1

Now I have been looking over the source for 2.2, with the hope it may solve my issues. Although it appears the PBS will not assert anymore, the shader code still only supports 2d Arrays. It also appears that you still can not use a 2d Array texture as a render target, although it looks much closer to doing so than 2.1!

Is there anything I have got wrong, and how much effort would it be to allow using 2d Arrays as rendertargets?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5298
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1279
Contact:

Re: [2.1, 2.2] Using dynamic textures with PBS

Post by dark_sylinc »

PBS only supporting array textures is probably not gonna change.

However 2.2 was designed to use 2D arrays as render targets (now that you mention... I don't think I tested this :P).

You can use the "2d_array" keyword in scripts to create a 2D Array instead of a regular texture.
The member RenderPassTargetBase::slice (and RenderPassTargetBase::resolveSlice for MSAA) are used to render to a specific slice of the 2D array.

You'll have to create an RTV manually in the scripts:

Code: Select all

texture myTex width height num_slices PFG_RGBA8_UNORM_SRGB 2d_array

rtv myTex5
{
	//Render to slice[5] (starts from 0)
	colour myTex slice 5
}

//You can also edit the already, default-created rtv "myTex" which was created alongside the texture
rtv myTex
{
	colour myTex slice 1
}

target myTex5
{
	//....
}
Probably MSAA will need testing, as usually MSAA doesn't support arrays; so slice must be 1, while resolveSlice must contain what slice usually would. We need a way to automatically fix that without having you to write two different script definitions just for the MSAA path and another for the non-MSAA path (if I didn't take care of that already?).

Note: If you are just using arrays with num_arrays = 1; then you only need to add the keyword "2d_array" and you're basically done; because by default we render to slice 0.
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

Re: [2.1, 2.2] Using dynamic textures with PBS

Post by al2950 »

Interesting. I assume renderSystem::_setRenderTarget is not used any more then. Ill start looking at upgrading to 2.2... I think the time has finally come.... it make the jump easier if reflections probes where pixel based, instead of object based :P
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

Re: [2.1, 2.2] Using dynamic textures with PBS

Post by xrgo »

al2950 wrote: Fri Jun 01, 2018 3:32 pm if reflections probes where pixel based, instead of object based :P
Yes please!
Post Reply