Sign in to follow this  
GENTS

NVDIA Effect Files & RenderTarget

Recommended Posts

GENTS    158
RENDERCOLORTARGET, RENDERDEPTHSTENCILTARGET, Render-to-Texture Data, etc. How is possible to manage all these parts within an effect file (.fx) and with which source code could I manage them?! THANKS for help ^__^ Byez, [Edited by - GENTS on February 21, 2005 5:23:09 PM]

Share this post


Link to post
Share on other sites
GENTS    158
I'm trying to do something similar to DXSAS code of NVDIA SDK 8.5!

I'm trying to coding in C++ a class to manage al effects, but I've several problems with scene and post effects files 'cause of renderTarget or DepthBufferTarget and similar...

So how could I manage them?!

THANKS ^__^

Share this post


Link to post
Share on other sites
circlesoft    1178
[lol] Rendertargets and such usually aren't dealt with inside effects, because effects should be independent of render targets. They don't care what they render to - all they care about is outputting that pixel, wherever it may be.

In essence, there is a lot more to shaders than just the effect files themselves. You have render states that need to be set, render targets, pre-rendering steps, post-rendering steps, constant setting, ect... You need to develop an abstract class which you can inherit all of your specific shaders from. This way, you have a general interface to each shader, but each shader can do specific things, in turn.

For example:


class IShader
{
private:
ID3DXEffect* effect;

public:

virtual HRESULT BeginShader() = 0;
virtual HRESULT EndShader() = 0;
virtual HRESULT SetupForEntity( IEntity* entityIn ) = 0;
};


The problem in itself is very complicated, and there are many solutions/interpretations of it. Personally, I like doing it this way because I can easily create shaders that require additional processing on the engine-side. For example, a water shader may require additional properties to be calculated and setup.

Share this post


Link to post
Share on other sites
GENTS    158
I've seen that inside NVDIA effects there is this type of code:


technique Glow_9Tap
<
string ScriptClass = "scene";
string ScriptOrder = "postprocess";
string ScriptOutput = "color";
string Script =
"ClearSetColor=ClearColor;"
"ClearSetDepth=ClearDepth;"
"Clear=Color;"
"Clear=Depth;"
"RenderColorTarget0=GlowMap1;"
"RenderDepthStencilTarget=DepthBuffer;"
"ClearSetColor=ClearColor;"
"ClearSetDepth=ClearDepth;"
"Clear=Color;"
"Clear=Depth;"
"ScriptExternal=color;"

"Pass=BlurGlowBuffer_Horz;"

"Pass=BlurGlowBuffer_Vert;"

"Pass=GlowPass;";
>
{
pass BlurGlowBuffer_Horz
<
string Script ="RenderColorTarget0=GlowMap2;"
"Draw=Buffer;";
>
{
cullmode = none;
ZEnable = false;
VertexShader = compile vs_2_0 VS_Quad_Horizontal_9tap();
PixelShader = compile ps_2_0 PS_Blur_Horizontal_9tap();
}
pass BlurGlowBuffer_Vert
<
string Script = "RenderColorTarget0=GlowMap1;"
"Draw=Buffer;";
>
{
cullmode = none;
ZEnable = false;
VertexShader = compile vs_2_0 VS_Quad_Vertical_9tap();
PixelShader = compile ps_2_0 PS_Blur_Vertical_9tap();
}
pass GlowPass
<
string Script= "RenderColorTarget0=;"
"RenderDepthStencilTarget=;"
"ScriptExternal=color;"
"Draw=Buffer;";
>
{
cullmode = none;
ZEnable = false;
ZWriteEnable = false;
AlphaBlendEnable = true;
SrcBlend = one;
DestBlend = one;
VertexShader = compile vs_1_1 VS_Quad();
PixelShader = compile ps_2_0 PS_GlowPass();
}
}


Is it setting RenderTargets, etc, isn't it?!

I know how to made a class with virtual function in it, but I'm trying to setting in general these parameters as "RenderColorTarget0=GlowMap1;" or "RenderDepthStencilTarget=DepthBuffer;"... How is possible to set them?! I'm trying to do it not only within an effect but in general with DirectX... Is there any tutorial or any article on this topic?! How could I set these target?!

THANKS A LOT!

Share this post


Link to post
Share on other sites
circlesoft    1178
AFAIK, all of that script stuff is NVIDIA-indepdent (ie it only is implemented for FX Composer). I couldn't really find anything about those individual tags in the DXSAS reference. If you want to implement something like that, you are probably going to have to parse all of those keys and values manually.

Are you asking how to setup different rendertargets? That is pretty easy - you can either use ID3DXRenderToSurface or IDirect3DDevice9::SetRenderTarget().

Share this post


Link to post
Share on other sites
GENTS    158
I thought that I've to parse these commands if I want to create a sort of NVDIA Effect Framework...
I don't know how to use these commands in DirectX and which are their equivalent functions...

I've seen at C# source code of DXSAS Implementation example of NVDIA SDK 8.5, but I can't get out how to create an equivalent code in C++...

Is it possible?! Which functions should I use?!

THANKS A LOT!!!

Byez,

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Hi,

I think the best way is to parse the semantics.
I think the render targets have a string which says they are a custom render target. The application has to specify when the render target changes.

for example:-



if( bCustomRenderTarget )
{
renderer->saveNormalRenderTarget();
renderer->setNewRenderTarget( shadow_target );
}

// draw calls
// ...

if( bCustomRenderTarget )
{
renderer->restoreNormalRenderTarget();
}






Share this post


Link to post
Share on other sites
GENTS    158
Isn't possible to look at a little piece of complete source code or tutorial on renderTarget and/or NVDIA Scripting and C++ Effect file management implementation?!

TNX!

Share this post


Link to post
Share on other sites
circlesoft    1178
Quote:
Original post by GENTS
no links?!

Gents, DXSAS is new. Nobody has really done anything with it yet, except for Microsoft and Nvidia with their respective SDKs. In all likelihood, you are going to have to take what you can from the samples and documentation. Converting C# code to C++ should not be hard (likewise for converting from C++ to C#). If all else fails, you could simply parse the FX files manually.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this