Welcome Guest Search | Active Topics | Members | Log In | Register

Render Targets and Color Depth Options
pha3z
Posted: Friday, March 27, 2009 5:57:33 PM
Rank: Advanced Member

Joined: 1/15/2009
Posts: 174
Points: -1,991
Location: USA
1) Is it possible to render to multiple targets inside a single-pass pixel shader in Nova?

2) Is it possible to declare custom render buffer formats? For example, to have a single buffer to contain color, depth, and normals.

3) Is it possible to create and render 16-bit-per-pixel textures? I realize this may be a GPU/Direct3D limitation. I don't know much about it, so I'm asking.


Either 1 or 2 must be possible to do deferred rendering or complex techniques efficiently. I certainly hope there is a way.

4) For a simple color and depth render that uses Alpha for depth, how would be the best way to render to an RGBA Texture with Nova's current architecture? I would want to sample all four RGBA channels in a post process shader.
Kosh
Posted: Monday, March 30, 2009 8:32:04 AM

Rank: Nova Master

Joined: 4/29/2008
Posts: 719
Points: 2,063
1) No, only DirectX10 allow to render to multiple targets in a single-pass shader
2) Under a shader, you can declare texture with a lot of format (FP16, RGB32, RGB16, etc). So you can use a shader to produce pixel with the semantics you want.
3) Yes it is. The declarative format is A16B16G16R16F
4) Just use a shader that send depth value to alpha. If you declare a postprocess in Nova it can access the backbuffer (which is a ARGB texture).
pha3z
Posted: Wednesday, April 01, 2009 6:41:20 PM
Rank: Advanced Member

Joined: 1/15/2009
Posts: 174
Points: -1,991
Location: USA
Regarding Nova's default backbuffer, the pixel precision is only 8-bit, isn't it?

Kosh
Posted: Wednesday, April 01, 2009 11:02:45 PM

Rank: Nova Master

Joined: 4/29/2008
Posts: 719
Points: 2,063
By default Nova use 8bits per components.

But you can specify your own precision in your shaders.
pha3z
Posted: Thursday, April 02, 2009 10:46:56 PM
Rank: Advanced Member

Joined: 1/15/2009
Posts: 174
Points: -1,991
Location: USA
I wrote some code to try to change Nova's active render target:

Dim bCreateAsRender As Boolean = True
Dim bDepthStencil As Boolean = False
Dim texFormat As NovaFormat = NovaFormat.A16B16G16R16F
Dim bUseQualityLevel As Boolean = False
Dim preRenderTgt As NovaLoadedTexture = NovaEngine.CreateNovaLoadedTexture(1024,1024, bCreateAsRender, bDepthStencil, texFormat, bUseQualityLevel)

preRenderTgt.SetAsRenderTarget(texFormat, bDepthStencil, bUseQualityLevel)



But it doesn't have any effect. If I do this:

MainForm.LogInfo(MainForm.LogInfo(NovaEngine.BackBufferSurface.Format.ToString)

It reports that the format is still A8B8G8R8.

How do I change the backbuffer format to 16 bit?
Kosh
Posted: Friday, April 03, 2009 7:10:01 AM

Rank: Nova Master

Joined: 4/29/2008
Posts: 719
Points: 2,063
You cannot change back buffer like that.

You must use a shader and declare your render target format in it.

The post_glow.fx shader (you can find it on developer.nvidia.com) is a sample that declare differents render targets.

To declare your render texture, just use this code :

texture2D myRenderTexture : RENDERCOLORTARGET <
string Format = "A16R16G16B16" ;
string UIWidget = "None";
>;

To render to it in your pass declaration:

technique Main
{
pass P0 <string Script = "RenderColorTarget=myRenderTexture;">
{
...
}
}
pha3z
Posted: Friday, April 03, 2009 8:28:56 PM
Rank: Advanced Member

Joined: 1/15/2009
Posts: 174
Points: -1,991
Location: USA
So I can do this to create a custom geometry render target.

Then how do I get a post process shader to sample from my geometry render target?


On some of the nvidia samples, It looks like they are doing post process effects as a final pass inside their geometry shaders. I guess you can do this by using a different vertex shader to only process a screen quad during the last pass. This seems fast. But its more confusing. And it means I would not be able to render different shaders and then do my post process on all of it. I'd have to include any post effects as a final pass in any shader I wanted to affect. I'd rather not do it this way for the sake of elegance.
Kosh
Posted: Monday, April 06, 2009 10:50:36 AM

Rank: Nova Master

Joined: 4/29/2008
Posts: 719
Points: 2,063
I think the best solution is :
- Define your own shaders for your objects
- Create a nova custom post process to finalize the scene
pha3z
Posted: Monday, April 06, 2009 6:26:05 PM
Rank: Advanced Member

Joined: 1/15/2009
Posts: 174
Points: -1,991
Location: USA
Ok. That's what I've already done. Except I don't know how to get the post process shader to use my custom render buffer instead of the SceneSampler.

Can you tell me how?

1. Geometry Shader Renders to Custom Buffer

2. Post Process shader samples from custom buffer.

I've completed step 1 as you instructed. I just don't know how to make Post Process Shader read from the custom buffer made in step 1.
pha3z
Posted: Tuesday, April 07, 2009 9:56:44 PM
Rank: Advanced Member

Joined: 1/15/2009
Posts: 174
Points: -1,991
Location: USA
This is what I've concluded:

I have a Geometry Shader that runs on all my geometry first. And I have a Post Process shader that runs second. I have to declare a reference to texture in both of them. Then I instance a NovaLoadedTexture and VB Script and link the parameters of the shaders to the texture I created. A more illustrative example follows:

-- Geometry Shader --

texture myRndrTxt : RENDERCOLORTARGET <annotations>;

texture sampler = sampler_state { Texture = <myRndrTxt>; };

technique Main
{
pass P0 < string Script = "RenderColorTarget=myRndrTxt;>
{ VertexShader = compile vs_2_0 mainVS(); PixelShader = compile ps_2_0 mainPS();}
}

-- Post Process Shader --

texture myBufferTxt : DIFFUSE <annotations>;

texture myBufferSampler = sample_state {Texture = <myBufferTxt>; };

float4 mainPS(VS_OUTPUT IN):COLOR0
{
float4 OutColor = tex2D( myBufferSampler, IN.UV );
//Do stuff here
return OutColor;
}

technique Main
{
pass P0 < string Script = "RenderColorTarget=; >
{ VertexShader = compile vs_2_0 mainVS(); PixelShader = compile ps_2_0 mainPS();}
}


-- Nova Application Visual Basic Pseudocode --

Create a NovaLoadedTexture called "MyGeometryBuffer"

Compile Geometry Shader
Compile PostProcess Shader

// The binding part is what is a question for me.
// If I understand Nova correctly, it is impossible to do this
// through the Nova Explorer Interface.
// You can only do this with VB Script. Am I correct?

Bind "MyGeometryBuffer" to myRndrTxt in Geometry Shader
Bind "MyGeometryBuffer" to myBufferTxt in PostProcess Shader

Affect Geometry Shader to Objects
Affect PostProcess Shader to Camera
Kosh
Posted: Wednesday, April 08, 2009 9:13:28 AM

Rank: Nova Master

Joined: 4/29/2008
Posts: 719
Points: 2,063
Good job. But beware of the term "geometry shader".

A geometry shader is a specific shader under DirectX10 (like vertex shader and pixel shader).

But I do not understand why you need a render texture.

Using yours shaders you can render to the main render target. The postprocess will have direct access to it.
pha3z
Posted: Wednesday, April 08, 2009 9:44:11 PM
Rank: Advanced Member

Joined: 1/15/2009
Posts: 174
Points: -1,991
Location: USA
After reading more about SAS on nvidia, I guess the correct term is "object" shader. And a post process shader is typically a "scene" shader.

Kosh said:
Quote:
But I do not understand why you need a render texture.


Because the default render target is 8bit. I need a 16bit buffer to get enough precision in my depth pass for a tweakable SSAO shader. I believe you told me that Nova's backbuffer can't be changed to 16 bit, so I have to render to an offscreen buffer.
Kosh
Posted: Thursday, April 09, 2009 9:23:23 AM

Rank: Nova Master

Joined: 4/29/2008
Posts: 719
Points: 2,063
Ok I agree
So you have to bind your render target by using a script
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS