Jump to content
  • Advertisement
Sign in to follow this  
ChristOwnsMe

Pixel Shader Iteration Issue

This topic is 2225 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

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]

[background=rgb(244, 247, 245)]SHADER:[/background]

[/font]

[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 by ShadowMan777

Share this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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;

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!