Sign in to follow this  

Problem with ParallaxMapping

This topic is 3297 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have tried to use the ParallaxMapping effect from coding4fun. But the effect only workt correctly in the FX Composer, in the app i have exactly the same parameters but it looks very different: http://img509.imageshack.us/my.php?image=unbenannt4ri4.jpg Has anybody an idea what could be wrong? Code: create mesh.box set vertax coordinats set vertax elements set effect parameters effect beginn

Share this post


Link to post
Share on other sites
I do not know whether it is right, but a normal bumpmap works.
I initialize the box that way:

boden = Mesh.Box(device, 10.0f, 1.15f, 10.0f);
VertexFormats format = VertexFormats.PositionNormal | VertexFormats.Texture1;

Mesh tempBox = boden.Clone(boden.Options.Value, format, device);
boden.Dispose();
boden = tempBox;

CustomVertex.PositionNormalTextured[] verts2 =(CustomVertex.PositionNormalTextured[])boden.VertexBuffer.Lock(0,typeof(CustomVertex.PositionNormalTextured), LockFlags.None, boden.NumberVertices);

for (int i = 0; i < verts2.Length; ++i)
{
if (i >= 0 && i <= 3)
{
verts2[i].Tv = verts2[i].Y * 0.3f;
verts2[i].Tu = verts2[i].Z * 0.3f;
}
else if (i >= 4 && i <= 7){ ...}

boden.VertexBuffer.Unlock();

VertexElement[] elements = new VertexElement[]
{
new VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0),
new VertexElement(0, 12, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Normal, 0),
new VertexElement(0, 24, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0),
new VertexElement(0, 36, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Tangent, 0),
new VertexElement(0, 48, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.BiNormal, 0),
VertexElement.VertexDeclarationEnd,
};

VertexDeclaration decl = new VertexDeclaration(device, elements);
Mesh tempMesh = boden.Clone(MeshFlags.Managed, elements, device);

boden.Dispose();
boden = tempMesh;

Share this post


Link to post
Share on other sites
Cloning a mesh with new vertex elements will not fill in those elements, they will be empty. You have to fill in the appropriate values for the normal, tangent, and binormal at each vertex. Mesh.ComputeTangentFrame can calculate all 3 for you.

However I feel I should mention that ManagedDX is no longer being developed or supported, so you may want to consider using either the XNA Framework or the community-managed SlimDX.

Share this post


Link to post
Share on other sites

This topic is 3297 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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