Shader Issue with protected memory

Started by
2 comments, last by ChristOwnsMe 11 years, 10 months ago
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.
Advertisement
Check your implementation of the [] operator. I don't think, that this has anything to do with shaders.
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.
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.

http://forums.create.msdn.com/forums/p/51107/308920.aspx

This topic is closed to new replies.

Advertisement