Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Bug #483: Shaders creating wrong dimension render surfaces
Product:
TV3D SDK 6.5
Language:
Visual Basic.NET
Current State:
Closed
Resolution:
Fixed
Created On:
October 10th, 2005
Last Modified:
September 3rd, 2006
Reported By:
brimstone
This is long so bear with me:

I'm currently using 3 hlsl shaders that create and us render surfaces. I've noticed that two of the shaders create the RS's with the wrong dimensions, 1 of the shader creates the RS's with the correct dimensions. All of the shaders are from the nVidia sdk.

Here's the way I am setting up the shaders and the render surfaces used for multi-pass effects. I'm only listing one to keep it short, but they are all setup the same way:

code
' Corona settings
shCorona = Scene.CreateShader("corona")
FXFile = Application.StartupPath & "\post_corona.fx"
shCorona.CreateFromEffectFile(FXFile)

rsCoronaObjects = New TVRenderSurface
rsCoronaObjects.SetIndex(shCorona.GetEffectParamTexture("ObjectsMap"))
rsCoronaObjects.SetBackgroundColor(oGlobals.RGBA(0, 0, 0, 0))

rsCoronaBlur = New TVRenderSurface
rsCoronaBlur.SetIndex(shCorona.GetEffectParamTexture("HBlurredMap"))
rsCoronaBlur.SetBackgroundColor(oGlobals.RGBA(0, 0, 0, 0))

rsCoronaGlow = New TVRenderSurface
rsCoronaGlow.SetIndex(shCorona.GetEffectParamTexture("GlowMap"))
rsCoronaGlow.SetBackgroundColor(oGlobals.RGBA(0, 0, 0, 0))
/code

I instantiate a HDRTonemap first. It sets up correctly. The next shader that I set up is a corona shader. I removed the bloom for now. The follow is the debug file, you can see that the first RS created by the shader is the correct dimension (this is the tonemap and an HDR16) the second group of RS's are all setup by the corona and are all A8R8G8B8 and are the wrong dimensions. Also, note the sequence in which the RS's are created.

code
10-07-2005 15:30:57 | SHADER MANAGER : Shader 'ToneMap' successfully created.
10-07-2005 15:30:57 | TEXTURE MANAGER : Successfully created a render surface 1024x702 on slot 9
10-07-2005 15:30:57 | TEXTURE MANAGER : Successfully created a render surface 1024x512 on slot 10
10-07-2005 15:30:57 | TEXTURE MANAGER : Successfully created a render surface 1024x512 on slot 11
10-07-2005 15:30:57 | TEXTURE MANAGER : Successfully created a render surface 1024x512 on slot 12
10-07-2005 15:30:58 | SHADER MANAGER : Shader 'corona' successfully created.
/code

The creation of the RS's when using the nVidia bloom shader behaves in the exact manner. The RS's should be 1024x768.

This behavior is occurs when in fullscreen or windowed modes. 800x600 screen resolution produces the following Render surfaces:

code
10-10-2005 09:37:57 | SHADER MANAGER : Shader 'ToneMap' successfully created.
10-10-2005 09:37:57 | TEXTURE MANAGER : Successfully created a render surface 800x534 on slot 9
10-10-2005 09:37:58 | TEXTURE MANAGER : Successfully created a render surface 512x512 on slot 10
10-10-2005 09:37:58 | TEXTURE MANAGER : Successfully created a render surface 512x512 on slot 11
10-10-2005 09:37:58 | TEXTURE MANAGER : Successfully created a render surface 512x512 on slot 12
10-10-2005 09:37:58 | SHADER MANAGER : Shader 'corona' successfully created.
/code

The bloom shader behaves the same as the corona in this screen resolution.

Between the three shaders the textures are created using completely different methods. In the tonemap.fx just setting up standard textures:

code
texture Image
string ResourceName = "nave.hdr";
string ResourceType = "2D";
string format="A16B16G16R16f";
;
/code

post_corona.fx uses #include "quad.fxh" and DECLARE_QUAD_TEX tyes from the quad.fxh header.

code
DECLARE_QUAD_TEX(ObjectsMap,ObjectsSamp,"A8R8G8B8")
DECLARE_QUAD_TEX(HBlurredMap,HBlurredSamp,"A8R8G8B8")
DECLARE_QUAD_TEX(GlowMap,GlowSampler,"A8R8G8B8")
/code

post_bloom.fx creates the render surfaces using the following:

code
texture SceneMap : RENDERCOLORTARGET

float2 ViewportRatio = { 1.0, 1.0 };
int MIPLEVELS = 1;
string format = "X8R8G8B8";
;
texture DepthMap : RENDERDEPTHSTENCILTARGET

float2 ViewportRatio = { 1.0, 1.0 };
string format = "D24S8";
;
texture DownsampleMap : RENDERCOLORTARGET

float2 ViewportRatio = { 0.25, 0.25 };
int MIPLEVELS = 1;
string format = "A8R8G8B8";
;
/code

I did notice that the quad.fxh and the post_bloom files like to use the texture texturename : RENDERCOLORTARGET approach.

From quad.fxh:
code
// declare exact-sized arbitrary texture
//
// example usage: DECLARE_SIZED_TEX(BlahMap,BlahSampler,"R32F",128,1)
#define DECLARE_SIZED_TEX(Tex,Samp,Fmt,Wd,Ht) texture Tex : RENDERCOLORTARGET \
float2 Dimensions = { Wd, Ht }; \
string Format = Fmt ; \
string UIWidget = "None"; \
int miplevels=1;\
; \
/code

Hope there's enough info there to track it down. The result are squashed full screen shaders.




Comments:

Posted by SylvainTV on October 19th, 2005 at 12:58 AM
i think it's fixed now, i changed it so that it can use non 2^n size for all formats.
and it will use the mainbuffer size if the width/height is not specified. We will see if it solves your issue :)
Posted by brimstone on October 25th, 2005 at 4:24 PM
Thanks sylvain.
Posted by brimstone on November 23rd, 2005 at 4:29 PM
Ok, definately something wierd going on here. I'm using the same bloom.fx file in two different projects. One project is in vb.net and one is in c#.The viewport dimensions are identical between the two applications.

Here's a sample of the debug file showing the dimensions of the RS's created by bloom in C#.
11-23-2005 08:10:21 | TEXTURE MANAGER : Successfully created a render surface 1024x721 on slot 21
11-23-2005 08:10:21 | TEXTURE MANAGER : Successfully created a render surface 256x180 on slot 22
11-23-2005 08:10:21 | TEXTURE MANAGER : Successfully created a render surface 256x180 on slot 23
11-23-2005 08:10:21 | TEXTURE MANAGER : Successfully created a render surface 256x180 on slot 24
11-23-2005 08:10:21 | SHADER MANAGER : Shader 'Bloom' successfully created.
11-23-2005 08:10:21 | TEXTURE MANAGER : Successfully created a render surface 1024x721 on slot 25


Here's the debug showing the RS's created by the same code in VB:
11-23-2005 08:23:55 | TEXTURE MANAGER : Successfully created a render surface 1024x512 on slot 135
11-23-2005 08:23:55 | TEXTURE MANAGER : Successfully created a render surface 256x128 on slot 136
11-23-2005 08:23:55 | TEXTURE MANAGER : Successfully created a render surface 256x128 on slot 137
11-23-2005 08:23:55 | TEXTURE MANAGER : Successfully created a render surface 256x128 on slot 138
11-23-2005 08:23:55 | SHADER MANAGER : Shader 'Bloom' successfully created.
11-23-2005 08:23:55 | TEXTURE MANAGER : Successfully created a render surface 1024x702 on slot 139