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:
//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);