Jump to content

  • Log In with Google      Sign In   
  • Create Account


If there's more indices loaded - does the shader need to have more bytes?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
20 replies to this topic

#1 SIC Games   Members   -  Reputation: 609

Like
0Likes
Like

Posted 09 August 2012 - 01:33 AM

I noticed, I can import my custom mesh of a box, or a cross and zero problems. However, if I import a custom mesh using more than 2000 indices or around the 1000 range. The mesh won't show up. Currently, the shader's bytewidth is set at 178. Would I have to adjust this?

Thanks for awesome input!

Game Engine's WIP Videos - http://www.youtube.com/sicgames88


Sponsor:

#2 Hodgman   Moderators   -  Reputation: 29551

Like
0Likes
Like

Posted 09 August 2012 - 01:38 AM

Currently, the shader's bytewidth is set at 178. Would I have to adjust this?

Can you clarify what you mean here. What is the bytewidth of a shader?
Do you mean the size of your vertex/index buffers?

#3 SIC Games   Members   -  Reputation: 609

Like
0Likes
Like

Posted 09 August 2012 - 01:47 AM

Sure, the Constant Buffer that has the input element layout for the shader. In the Buffer Description for the Constant Buffer. The ByteWidth is set 178. I looked up on MSDN and it shows that in the Buffer Description that a ByteWidth represents width of bytes returned.

Game Engine's WIP Videos - http://www.youtube.com/sicgames88


#4 Hodgman   Moderators   -  Reputation: 29551

Like
3Likes
Like

Posted 09 August 2012 - 01:54 AM

the Constant Buffer that has the input element layout for the shader

Input layouts are stored in input layout objects, not in constant buffers! An input layout is valid for any number of primitives (if it works for 100 verts, it will also work for 1000 verts).
What are you putting in this constant buffer, and where does the magic number of 178 come from?

in the Buffer Description that a ByteWidth represents width of bytes returned

It's the size of the buffer in bytes. For a constant buffer, this should be the size of the cbuffer structure defined in the HLSL code. For an index or vertex buffer, it's based on the maximum amount of vertices/indices you want to be able to put in the buffer times the size of a vertex/index.

Edited by Hodgman, 09 August 2012 - 02:15 AM.


#5 SIC Games   Members   -  Reputation: 609

Like
0Likes
Like

Posted 09 August 2012 - 05:01 AM

So, the question would still remain that if I can load a simple cube or a simple box....then I should've have a issue importing a heart model than - correct? I created a model valentines heart in Zbrush4 then in Max I converted into OBJ - Triangles. Converted into my custom format with the conversion application...finally, it doesn't show up but a blue screen which just indictates that DX is initialized. The cross and the Cube were made in 3D Studio max and converted and they work.

So, regarless the mesh should load property right?

Game Engine's WIP Videos - http://www.youtube.com/sicgames88


#6 Ripiz   Members   -  Reputation: 529

Like
2Likes
Like

Posted 09 August 2012 - 05:28 AM

It depends on your code whether it is able to load or not. DirectX has no problems with that as long as you tell it what to load and what it is.

Edit:
Maybe you'd like to show how you load that heart model?

Edited by Ripiz, 09 August 2012 - 05:31 AM.


#7 powly k   Members   -  Reputation: 650

Like
1Likes
Like

Posted 09 August 2012 - 05:36 AM

Yes, this sounds more like a problem with your obj-loading code. The bytewidth you should be changing is the one of your vertex and index buffers, not your constant buffer.

Edited by powly k, 09 August 2012 - 05:36 AM.


#8 SIC Games   Members   -  Reputation: 609

Like
-2Likes
Like

Posted 09 August 2012 - 06:13 AM

Made a quick video of what's going on. I show in this video comparison of the demo cross loaded fully and just a simple cone import which failed. I


Game Engine's WIP Videos - http://www.youtube.com/sicgames88


#9 Ripiz   Members   -  Reputation: 529

Like
0Likes
Like

Posted 09 August 2012 - 06:31 AM

The part of code you showed is fine.

But we need to see how you load your .sgm files, or more specifically, code that creates vertex and index buffers for the model.

Edited by Ripiz, 09 August 2012 - 06:31 AM.


#10 SIC Games   Members   -  Reputation: 609

Like
-1Likes
Like

Posted 09 August 2012 - 06:31 AM

So, I get a minus rep point because I showed what the world I was talking about? Dat's messed up. As you can see in the freaking video the GD Cross loads. Nothing wrong with the Custom Mesh importer. It just doesn't like Hearts and cones. FIne, I'll look over the code AGAIN and see what I can come up with. Wow, showing a video - minus rep point! F'ing gay! Ripits said how about show what's happening. So, I did.

Game Engine's WIP Videos - http://www.youtube.com/sicgames88


#11 Ripiz   Members   -  Reputation: 529

Like
0Likes
Like

Posted 09 August 2012 - 06:38 AM

It wasn't me who downvoted, video is way too long just to show that it's not loading, not to mention you already told that in the first post. Fact that it doesn't load doesn't help to solve it, we need error messages or at least some code.

Your operating system looks like Windows Vista either Windows 7, you could use PIX from DirectX SDK to analyse whether your buffers were created, see how mesh looks like before and after vertex shader, etc.

#12 SIC Games   Members   -  Reputation: 609

Like
0Likes
Like

Posted 09 August 2012 - 06:40 AM

Loads index's and Vertex's
Namespace ModelManger - Class Model. Native Class code MESH. Native Class just has declarations for VertexCount and Indices.

This is part of the Loading Custom Mesh.
    D3D11_BUFFER_DESC indexBufferDesc;
    ZeroMemory( &indexBufferDesc, sizeof(indexBufferDesc) );

    indexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
    indexBufferDesc.ByteWidth = sizeof(unsigned long) * MESH->IndexCount;
    indexBufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
    indexBufferDesc.CPUAccessFlags = 0;
    indexBufferDesc.MiscFlags = 0;

    D3D11_SUBRESOURCE_DATA iinitData;

    iinitData.pSysMem = indices;
    dev->CreateBuffer(&indexBufferDesc, &iinitData, &pIBuffer);

    devcon->IASetIndexBuffer( pIBuffer, DXGI_FORMAT_R32_UINT, 0);


    D3D11_BUFFER_DESC vertexBufferDesc;
    ZeroMemory( &vertexBufferDesc, sizeof(vertexBufferDesc) );

    vertexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
    vertexBufferDesc.ByteWidth = sizeof(Mesh::VERTEX) * MESH->VertexCount;
    vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
    vertexBufferDesc.CPUAccessFlags = 0;
    vertexBufferDesc.MiscFlags = 0;
    D3D11_SUBRESOURCE_DATA vertexBufferData;

    ZeroMemory( &vertexBufferData, sizeof(vertexBufferData) );
    vertexBufferData.pSysMem = OBJVertices;
HR( dev->CreateBuffer( &vertexBufferDesc, &vertexBufferData, &pVBuffer));

   

 D3DX11CreateShaderResourceViewFromFile(dev,	    // the Direct3D device
									   L"Wood.png",    // load Wood.png in the local folder
									   NULL,		   // no additional information
									   NULL,		   // no multithreading
									   &pTexture,	  // address of the shader-resource-view
									   NULL);		  // no multithreading
       

 
this loads the SGM file and sorts through everything. Making sure it's X,Y,Z, Normals, and U, Vs.
bool result;
       

       
        char input;

        char input2;
       
        ifstream fin;
      
        MESH->VertexCount = 0;
        MESH->IndexCount = 0;

    //    VertexIndex *verIndex;
       
        unsigned long * indices;

       
       
        fin.open(filename);
        if(fin.fail() == true) {
            return false;

        }
   
        fin.get(input);

    while(input != ':') {
        fin.get(input);

    }
   
    fin >> MESH->VertexCount;

    MESH->IndexCount = MESH->VertexCount;

    indices = new unsigned long[MESH->IndexCount];


   

    Mesh::VERTEX *OBJVertices;
    OBJVertices  = new Mesh::VERTEX[MESH->VertexCount];

    fin.get(input);
    while(input != ':') {
        fin.get(input);

    }

    fin.get(input);
    fin.get(input);

    for(int i = 0; i<MESH->VertexCount; i++) {
        int normx, normy, normz;

        fin >> OBJVertices[i].x >> OBJVertices[i].y >> OBJVertices[i].z  >> normx >> normy >> normz >> OBJVertices[i].U >> OBJVertices[i].V;
        OBJVertices[i].Normal = D3DXVECTOR3(normx,normy,normz);

        indices[i] = i;

    }
   
   

    fin.close();

INside the converter the program loads the OBJ values and when converting sorts them out through their indices. So, there's no need to worry about figuring out the indices. This is where the Indices[i] come into play because there's no Indices to worry about. Additionally, when converted the SGM model format is already indexed flipped and minutes Z's for texture coord, normals, and vertices.

This is the draw call inside the engine.


void Draw() {

cBuffer.LightVector = D3DXVECTOR4(1.0f, 4.0f, -2.0f,0.0f);
    cBuffer.LightColor = D3DXCOLOR(0.5f, 0.5f, 0.5f, 1.0f);
    cBuffer.AmbientColor = D3DXCOLOR(0.2f, 0.2f, 0.2f, 1.0f);
 
	
// select which vertex buffer to display
	    UINT stride = sizeof(Mesh::VERTEX);
	    UINT offset = 0;
	    devcon->IASetVertexBuffers(0, 1, &pVBuffer, &stride, &offset);
	    devcon->IASetIndexBuffer(pIBuffer, DXGI_FORMAT_R32_UINT, 0);
	    // select which primtive type we are using
	    devcon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
	    // draw the Hypercraft
	    devcon->UpdateSubresource(pCBuffer, 0, 0, &cBuffer, 0, 0);
	    devcon->PSSetShaderResources(0, 1, &pTexture);
	    devcon->DrawIndexed(MESH->VertexCount, 0, 0);
}


This function updates the matrixes.

void update_Matrixes() {
                //--- Let's see if we need to move camera anywehere important.
    MESH->worldMatrix = MESH->rotation_Matrix * MESH->translation_Matrix;
    cBuffer.final = MESH->worldMatrix * viewMatrix * projectionMatrix;
    cBuffer.Rotation = MESH->rotation_Matrix;
    }

   

The position and rotations are both set in the editor.

I didn't mean to get all hasty but minus a point for trying to show a video on what I'm talking about. Just doesn't make sense.

Game Engine's WIP Videos - http://www.youtube.com/sicgames88


#13 SIC Games   Members   -  Reputation: 609

Like
0Likes
Like

Posted 09 August 2012 - 06:42 AM

Is tehre anything more information I can provide?

Game Engine's WIP Videos - http://www.youtube.com/sicgames88


#14 Ripiz   Members   -  Reputation: 529

Like
1Likes
Like

Posted 09 August 2012 - 06:48 AM

I can't see any mistake there. Are you sure your mesh isn't simply too small or too big to see it?
As I mentioned in the last reply, you could try to use PIX to see if GPU has correct data to work with.

#15 SIC Games   Members   -  Reputation: 609

Like
0Likes
Like

Posted 09 August 2012 - 06:51 AM

I thought about it being too big or too small - so it's good to hear that as well. I'm checking into it now and will report shortly. Thanks Ripiz and everyone.

Game Engine's WIP Videos - http://www.youtube.com/sicgames88


#16 Ripiz   Members   -  Reputation: 529

Like
1Likes
Like

Posted 09 August 2012 - 06:58 AM

I just checked video again, Cross and Cone coordinates aren't much different, they should be about same size.

At this point I'd say PIX is the only your chance (unless I missed something).

#17 Hodgman   Moderators   -  Reputation: 29551

Like
2Likes
Like

Posted 09 August 2012 - 07:08 AM

Some general debugging advice:
* Every D3D function that returns a HRESULT expects you to capture that return value and check for success. There's a lot of missing error checking in your code, where if something is going wrong, you'll continue on anyway and silently ignore the error.
* Whenever something unknown/weird is happening in D3D, change your device creation code to add in the debug-device flag -- this will print out error messages if you're doing anything suss with the API.
* If the above don't catch an error, then launch PIX and use it to capture a frame from your game. You can then inspect what's happening during the offending draw-call, such as whether there's actually any vertices in your vertex buffer, or if pixels are being rejected by back-face culling, etc...

#18 SIC Games   Members   -  Reputation: 609

Like
0Likes
Like

Posted 09 August 2012 - 08:44 AM

I tried to use PIX and it said Failure Creation Progress. What I did notice is that in the drawing topology when I chose to use TriangleStrip it would draw it but a stretched out triangle effect would happen. If I did TriangleList_Adj it would draw the cap part - believe of the cone. At least it's something but I'll investigate further. As of now I'm trying to get PIX working and seeing why it's saying Failure Creating Process.

Game Engine's WIP Videos - http://www.youtube.com/sicgames88


#19 SIC Games   Members   -  Reputation: 609

Like
0Likes
Like

Posted 09 August 2012 - 09:00 AM

Hodgeman I'll look into more of the device creation as well

Game Engine's WIP Videos - http://www.youtube.com/sicgames88


#20 SIC Games   Members   -  Reputation: 609

Like
1Likes
Like

Posted 09 August 2012 - 09:33 AM

Inside where it gathers the SGM values - I temporary stored the Normals X Y Z as a Integer! ROFL! Talk about up all night programming tireness. Now it draws a sphere! Additionally, Ripiz I have to move the camera back some to actually see it! :) Thanks everyone!

Game Engine's WIP Videos - http://www.youtube.com/sicgames88





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS