Sign in to follow this  
ChristOwnsMe

Shader Issue with protected memory

Recommended Posts

I have a chunked LOD system, and I am using noise to generate the height values. This works properly when the planet face hasn't divided yet, but when I divide for the first time, I am getting the exception "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."



m_Vertices[0] = new VertexPositionTexture(vec1, new Vector2(0, 1));
m_Vertices[1] = new VertexPositionTexture(vec2, new Vector2(1 + ps, 1));
m_Vertices[2] = new VertexPositionTexture(vec3, new Vector2(0, 0 - ps));
m_Vertices[3] = new VertexPositionTexture(vec4, new Vector2(1 + ps, 0 - ps));

perlinCombined.Parameters["xNW"].SetValue(vec1); <--------------- THIS LINE THROWS THE EXCEPTION
perlinCombined.Parameters["xNE"].SetValue(vec2);
perlinCombined.Parameters["xSW"].SetValue(vec3);
perlinCombined.Parameters["xSE"].SetValue(vec4);

This line works the first time, but then if I try to change the value again when a child is created, it throws that exception. Any ideas? Thanks.

P.S: I am extremely new to shaders, so sorry if it is something stupidly simple.

Share this post


Link to post
Share on other sites
Effect perlinCombined = CContentManager.Singleton.Content.Load<Effect>("GeometryMap");

The [] operator is built in to the XNA Effect class. My apologies I forgot to mention I was using XNA.

Share this post


Link to post
Share on other sites
Issue Solved: The issue was that certain objects were getting created in Game() instead of LoadContent, so it was causing the effect to get disposed. Here is the resource that helped me.

[url="http://forums.create.msdn.com/forums/p/51107/308920.aspx"]http://forums.create.msdn.com/forums/p/51107/308920.aspx[/url]

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