Sign in to follow this  
przem

R2VB in MDX (c#)

Recommended Posts

hi guys, well im new here in the forum as well im new in mdx. right now im working on a project for geometry refinment and i wanted to play around with the ati's r2vb workaround. but unfortunately i cant get it work in MDX - in the ati sdk are few examples and documentation how to use it but only for c++. since the enviroment in mdx is littl bit different, i dont know how to set it up. i found in the forum the post from acid2 but the sources he's pointig to are not available. could some one help me to set it up in c#?
device->SetTexture(D3DDMAPSAMPLER, renderTaget);

how can i express it in c#? SetTexture accepts only int as the first parameter, how can i know the id for D3DDMAPSAMPLER or i.e. D3DVERTEXTEXTURESAMPLER[n] ? [Edited by - przem on November 10, 2006 2:17:54 PM]

Share this post


Link to post
Share on other sites
no one can help me?

finally i figured out, how to set up all the bindings in c# - i.e. D3DDMAPSEMPLER is 256 - (int)DisplacementMap.Sampler. all the other setting too.

but it doesnt work - the vertex buffer isnt binded and it renders only one pixel, probably the one form the dummy vertex buffer with 4byte, since if i switch off the r2vb stuff, the pixel is still there.

the vertex declaration is set to float4 since i store the vb in a A32B32G32R32F texture in homogenus coords.

some code:

// 1.
device.SetRenderState(RenderStates.PointSize, ati.R2VB.r2vbGlbEnable_Set(1));
// 2.
// 3.
device.SetTexture((int)DisplacementMap.Sampler, buffer1);
device.SetRenderState(RenderStates.PointSize, R2VB.r2vbVStrm2SmpMap_Set(2, R2VB.R2VB_VSMP_OVR_DMAP));

device.VertexDeclaration = vertexDecl2;
device.SetStreamSource(2, vbdummy, 0);
// 4. draw
device.DrawPrimitives(PrimitiveType.TriangleFan, 0, 1);
// 5.
device.SetRenderState(RenderStates.PointSize, R2VB.r2vbVStrm2SmpMap_Set(2, R2VB.R2VB_VSMP_OVR_DIS));

device.SetTexture((int)DisplacementMap.Sampler, null);
// 6.
device.SetRenderState(RenderStates.PointSize, R2VB.r2vbGlbEnable_Set(0));



the vertex declaration:

VertexElement[] elements2 = new VertexElement[]
{
new VertexElement(2, 0, DeclarationType.Float4,
DeclarationMethod.Default,
DeclarationUsage.Position, 0),
VertexElement.VertexDeclarationEnd
};

// dummy vertex buffer
vbdummy = new VertexBuffer(e.Device, 4*sizeof(float), Usage.None, CustomVertex.PositionOnly.Format, Pool.Default);




has someone any ideas??

Share this post


Link to post
Share on other sites
I'd suggest that you e-mail acid2. His e-mail is in his profile. If he gets the archive back up, it'd help anyone interested in this stuff.

Share this post


Link to post
Share on other sites
I had a chat with Ollie/Acid2 about this a few weeks ago, but he didn't have the sources himself anymore either. He sent me the sources as a demo a while ago though and that seems to be quite complete (download it here). It's in MDX 2.0, so it will take some tinkering, but it should help you on your way.

Share this post


Link to post
Share on other sites
ok, got it. thanx very much.
it was - as asumed - one small thing... the only problem was my dummy vertex buffer, which had to be declared with Usage-flag WriteOnly. intresting.


vbdummy = new VertexBuffer(e.Device, 4 * 4 * sizeof(float), Usage.WriteOnly, (CustomVertex.Transformed.Format), Pool.Default);



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