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

## Recommended Posts

So I am creating a geometry map using a pixel shader. I iterate over the texture coordinates using the pixel shader and calculate noise, then output this final noise value. This is for a chunked lod planet system. The noise works fine with the first patch, however when you zoom in and it tries to generate a new heightmap, ALL texture coordinates x and y in the pixel shader are the same.

My main question is what would cause all the pixel shader texture coordinates to be the same for every pixel when it runs this a second time. The vertices and texture coordinates never change, so I don't understand why the pixel shader doesn't return the same values.

Here is the code.I am using c# and XNA.

[color=#526569][font=Verdana, Arial, Helvetica, sans-serif]

### float4 PS_INoise(float2 inTexCoords : TEXCOORD0) : COLOR0 { float land0 = (float)0; // Get the direction, from the origin (top-left) to the end vector (bottom-right) float3 xDirection = xNE - xNW; float3 zDirection = xSW - xNW; // Scale the distance by the texture coordinate (which is between 0 and 1) xDirection *= inTexCoords.x; zDirection *= 1 - inTexCoords.y; // Lerp outward from the originSY (top-left) in the direction of the end vector (bottom-right) float3 lerpedWorldPos = xNW + xDirection + zDirection; land0 = inoise(lerpedWorldPos); land0 = inTexCoords.y; return land0; } APPLICATION:[/font] //pre-transformed quad m_Vertices[0] = new VertexPositionTexture(new Vector3(-1, 1, 0f), new Vector2(0, 1)); m_Vertices[1] = new VertexPositionTexture(new Vector3(1, 1, 0f), new Vector2(1 , 1)); m_Vertices[2] = new VertexPositionTexture(new Vector3(-1, -1, 0f), new Vector2(0, 0)); m_Vertices[3] = new VertexPositionTexture(new Vector3(1, -1, 0f), new Vector2(1 , 0 )); perlinCombined.Parameters["xNW"].SetValue(new Vector3(-1, 1, 0f)); perlinCombined.Parameters["xNE"].SetValue(new Vector3(1, 1, 0f)); perlinCombined.Parameters["xSW"].SetValue(new Vector3(-1, -1, 0f)); perlinCombined.Parameters["xSE"].SetValue(new Vector3(1, -1, 0f)); CRenderManager.Singleton.GetGD().SetRenderTarget(RenderTarget); CRenderManager.Singleton.GetGD().BlendState = BlendState.Opaque; foreach (EffectPass pass in perlinCombined.CurrentTechnique.Passes) { pass.Apply(); CRenderManager.Singleton.GetGD().DrawUserPrimitives(PrimitiveType.TriangleStrip, m_Vertices, 0,2); } CRenderManager.Singleton.GetGD().SetRenderTarget(null); Edited June 13, 2012 by ShadowMan777

##### Share on other sites
I have still been unable to fix this. Forgot to add also, anytime I zoom int o the planet and it starts creating children and calling the pixel shader more, the ENTIRE SCREEN is purple, like the clearing color switched somehow. It goes way when I disable setting a render target.
Any help would be appreciated. Thanks. Edited by ShadowMan777

##### Share on other sites
Somewhat solved. For some reason, by setting the RasterizationState(), it is making all future pixel shader calls not iterate.

RasterizerState rs = new RasterizerState();

rs.FillMode = FillMode.WireFrame;
rs.CullMode = CullMode.CullClockwiseFace;
GraphicsDevice.RasterizerState = rs;

1. 1
2. 2
Rutin
24
3. 3
JoeJ
19
4. 4
5. 5

• 17
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631730
• Total Posts
3001917
×