• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By isu diss
      How do I fill the gap between sky and terrain? Scaling the terrain or procedural terrain rendering?

    • By Jiraya
      For a 2D game, does using a float2 for position increases performance in any way?
      I know that in the end the vertex shader will have to return a float4 anyway, but does using a float2 decreases the amount of data that will have to be sent from the CPU to the GPU?
       
    • By ucfchuck
      I am feeding in 16 bit unsigned integer data to process in a compute shader and i need to get a standard deviation.
      So I read in a series of samples and push them into float arrays
      float vals1[9], vals2[9], vals3[9], vals4[9]; int x = 0,y=0; for ( x = 0; x < 3; x++) { for (y = 0; y < 3; y++) { vals1[3 * x + y] = (float) (asuint(Input1[threadID.xy + int2(x - 1, y - 1)].x)); vals2[3 * x + y] = (float) (asuint(Input2[threadID.xy + int2(x - 1, y - 1)].x)); vals3[3 * x + y] = (float) (asuint(Input3[threadID.xy + int2(x - 1, y - 1)].x)); vals4[3 * x + y] = (float) (asuint(Input4[threadID.xy + int2(x - 1, y - 1)].x)); } } I can send these values out directly and the data is as expected

                             
      Output1[threadID.xy] = (uint) (vals1[4] ); Output2[threadID.xy] = (uint) (vals2[4] ); Output3[threadID.xy] = (uint) (vals3[4] ); Output4[threadID.xy] = (uint) (vals4[4] ); however if i do anything to that data it is destroyed.
      If i add a
      vals1[4] = vals1[4]/2; 
      or a
      vals1[4] = vals[1]-vals[4];
      the data is gone and everything comes back 0.
       
       
      How does one go about converting a uint to a float and performing operations on it and then converting back to a rounded uint?
    • By fs1
      I have been trying to see how the ID3DInclude, and how its methods Open and Close work.
      I would like to add a custom path for the D3DCompile function to search for some of my includes.
      I have not found any working example. Could someone point me on how to implement these functions? I would like D3DCompile to look at a custom C:\Folder path for some of the include files.
      Thanks
    • By stale
      I'm continuing to learn more about terrain rendering, and so far I've managed to load in a heightmap and render it as a tessellated wireframe (following Frank Luna's DX11 book). However, I'm getting some really weird behavior where a large section of the wireframe is being rendered with a yellow color, even though my pixel shader is hard coded to output white. 

      The parts of the mesh that are discolored changes as well, as pictured below (mesh is being clipped by far plane).

      Here is my pixel shader. As mentioned, I simply hard code it to output white:
      float PS(DOUT pin) : SV_Target { return float4(1.0f, 1.0f, 1.0f, 1.0f); } I'm completely lost on what could be causing this, so any help in the right direction would be greatly appreciated. If I can help by providing more information please let me know.
  • Advertisement
  • Advertisement
Sign in to follow this  

DX11 Sphere Drawing with SlimDx using vertex n index buffers ( trianglelist primitive dx11)

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

I changed it using two angles and still not drawing properly...


public bool Initialize(ref Device device) {

/* vertex and index count will be calculated using radious & tesselation properties later
I will make this class simple so that one who does not know much about it will also be able to Draw a sphere
using this class */

BufferDescription vertexBuffDesc, indexBuffDesc;

// Radious won't be used here , it will play role in just x = r * Cos(90); something like this ....

vertexCount = ((int)tesselation + 1) * 12;
indexCount = vertexCount*4*3*2;

VertexPositionColor [] vertices = new VertexPositionColor[vertexCount];
int[] indices = new int[indexCount];

/*
using mathematics rules , radious & tesselation I will fill the arrays here with data;
*/
// compute our step around each circle
float step = ((float)System.Math.PI*2) / tesselation;
// used to track the index into our vertex array
int index = 0;
//create the loop on the XY plane first

for (float theta = -90f; theta < 90f; theta += 45f)
{
for (float phi = 0f; phi < 360; phi += 45f)
{

vertices[index++] = new VertexPositionColor(new Vector3((float)System.Math.Cos(phi) * (float)System.Math.Sin(theta) * radious, (float)System.Math.Sin(phi) * (float)System.Math.Sin(theta) * radious, 0f), new Vector4(0f, 1f, 0f, 0f));
vertices[index++] = new VertexPositionColor(new Vector3((float)System.Math.Cos(phi+theta) * (float)System.Math.Sin(theta+phi) * radious, (float)System.Math.Sin(phi+theta) * (float)System.Math.Sin(theta+phi) * radious, 0f), new Vector4(0f, 0f, 1f, 0f));
}
}
//next on the XZ plane
for (float theta = -90f; theta < 90; theta += 45)
{
for (float phi = 0f; phi < 360; phi += 45)
{
vertices[index++] = new VertexPositionColor(new Vector3((float)System.Math.Cos(phi) * (float)System.Math.Sin(theta) * radious, 0f, (float)System.Math.Cos(theta)), new Vector4(1f, 0f, 0f, 0f));
vertices[index++] = new VertexPositionColor(new Vector3((float)System.Math.Cos(phi+theta) * (float)System.Math.Sin(theta+phi) * radious, 0f, (float)System.Math.Cos(theta+phi)), new Vector4(0f, 0f, 1f, 1f));
}
}
//finally on the YZ plane
for (float theta = -90f; theta < 90; theta += 45)
{
for (float phi = 0f; phi < 360; phi += 45)
{
vertices[index++] = new VertexPositionColor(new Vector3(0f, (float)System.Math.Sin(phi) * (float)System.Math.Sin(theta) * radious, (float)System.Math.Cos(theta) ), new Vector4(0f, 0f, 0f, 1f));
vertices[index++] = new VertexPositionColor(new Vector3(0f, (float)System.Math.Sin(phi+theta) * (float)System.Math.Sin(theta+phi) * radious, (float)System.Math.Cos(theta+phi)), new Vector4(1f, 1f, 0f, 0f));
}
}


/*
* keeping tesselation 10 get's me 10 points on each XY,YZ,XZ plan and now I would like to use Index Buffer's help
to get better performance and reuse these

*/


int ind = 0;
for (int i = 0; i < 192; i++)
{
indices[ind++] = i;
indices[ind++] = i+1;
indices[ind++] = 64+i;

indices[ind++] = 64+i+1;
indices[ind++] = 128+i;
indices[ind++] = i;
}

//int six = 0;
//float slices = (float)192/3;
//float stacks = (float)3;



//for (ushort slice = 0; slice < slices; ++slice)
//{
// for (float stack = 0; stack < stacks; ++stack)
// {
// int v = (ushort)(slice * (stacks + 1) + stack);
// indices[six++] = v;
// indices[six++] = (int)(v + 1);
// indices[six++] = (int)(v + (stacks + 1));
// indices[six++] = (int)(v + (stacks + 1));
// indices[six++] = (int)(v + 1);
// indices[six++] = (int)(v + (stacks + 1) + 1);
// }
//}


// I will make streams of these arrays here

DataStream vertexDataStream = new DataStream(vertices, true, true);
vertexDataStream.Position = 0;
DataStream indexDataStream = new DataStream(indices, true, true);
indexDataStream.Position = 0;
/*
these streams will create buffers
*/

// vertex buffer initialization

vertexBuffDesc = new BufferDescription
{
Usage = ResourceUsage.Default,
SizeInBytes = System.Runtime.InteropServices.Marshal.SizeOf(typeof(VertexPositionColor)) * vertexCount,
BindFlags = BindFlags.VertexBuffer,
CpuAccessFlags = CpuAccessFlags.None,
StructureByteStride = 0,
OptionFlags = 0
};
vertexBuffer = new Buffer(device, vertexDataStream, vertexBuffDesc);

// index buffer initialization
indexBuffDesc = new BufferDescription {
Usage = ResourceUsage.Default,
SizeInBytes = sizeof(int) * indexCount,
BindFlags = BindFlags.IndexBuffer,
CpuAccessFlags = CpuAccessFlags.None,
StructureByteStride = 0

};
indexBuffer = new Buffer(device, indexDataStream, indexBuffDesc);

return true;
}


Previous POST : http://www.gamedev.n...th-slimdx-dx11/

Share this post


Link to post
Share on other sites
Advertisement
Please use the "code" tags if you're going to post source code, especially that much of it.

Share this post


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

  • Advertisement