|
|
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.
|
|
 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).
|
|
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?
|
|
 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.
|
|
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?
|
|
 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;"> { ... } }
|
|
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.
|
|
 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
|
|
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.
|
|
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
|
|
 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.
|
|
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.
|
|
 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
|
|
|
Guest |