Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Zaoshi Kaba

Member Since 04 Nov 2012
Offline Last Active Today, 02:03 PM

#5229418 no Vsync? why should you

Posted by Zaoshi Kaba on 17 May 2015 - 02:36 AM

vlj, it's not small. Problem with VSync is that you get either 60 FPS or 30 FPS (roughly speaking). While 60 FPS usually is fine, 30 FPS has unbearable input lag. I had to turn off VSync on Assassin's Creed Unity because of that (my FPS was roughly 50). Wouldn't even dare to play Action game with that kind of performance.




#5204882 Rendering .obj Model in DirectX 11

Posted by Zaoshi Kaba on 17 January 2015 - 02:23 AM

Your UV coordinates weren't loaded correctly.

 

In .obj file you have:

v  -3.9184 -2.6713 3.3765
v  -3.9184 -2.6713 -3.3765
v  3.9184 -2.6713 -3.3765
v  3.9184 -2.6713 3.3765
v  -3.9184 2.6713 3.3765
v  3.9184 2.6713 3.3765
v  3.9184 2.6713 -3.3765
v  -3.9184 2.6713 -3.3765
# 8 vertices

vn 0.0000 -1.0000 -0.0000
vn 0.0000 1.0000 -0.0000
vn 0.0000 0.0000 1.0000
vn 1.0000 0.0000 -0.0000
vn 0.0000 0.0000 -1.0000
vn -1.0000 0.0000 -0.0000
# 6 vertex normals

vt 1.0000 0.0000 0.0000
vt 1.0000 1.0000 0.0000
vt 0.0000 1.0000 0.0000
vt 0.0000 0.0000 0.0000
# 4 texture coords

which roughly means:

positions = {p0, p1, p2, p3, p4, p5, p6, p7};
normals = {n0, n1, n2, n3, n4, n5};
texcoord = {t0, t1, t2, t3};

Faces in .obj:

f 1/1/1 2/2/1 3/3/1 
f 3/3/1 4/4/1 1/1/1 

tell you to generate these vertices:

vertices = {
	// face 1
	{p0, t0, n0},
	{p1, t1, n0},
	{p2, t2, n0},
	
	// face 2
	{p2, t2, n0},
	{p3, t3, n0},
	{p0, t0, n0}
}

After this you find identical vertices and replace them with index in index buffer.




#5204800 Rendering .obj Model in DirectX 11

Posted by Zaoshi Kaba on 16 January 2015 - 03:51 PM

That's not how index buffer works.

Not sure if I'll be able to explain this correctly though.

 

Currently your buffer contains indexes for position, normal, texture coordinate separately, but all these are properties of vertex and they're impossible to index separately.

 

If you wish to include color your vertex structure might look like this:

struct Vertex {
    float x, y, z; // position
    float nx, ny, nz; // normal
    float tx, ty; // texture coordinates
    float r, g, b, a; // color
};

Now Vertex* vertices = new Vertex[countVertex]; should contain all unique combinations of position/normal/texcoord/color.

 

In cube case there will be 24 unique combinations.

It appears you have 8 different vertices, but no, you have 8 different positions.

Lets take front top right vertex - it'll have same position for all 3 walls (top, right, front), but these walls have different normal vector, which results in these combinations:

(position1, normal1)
(position1, normal2)
(position1, normal3)

And that is 3 vertices in your vertex buffer. If you do same for 7 other vertices you'll have 24 unique vertex combinations. Adding color and texture coordinate won't increase number of vertices in this case.

 

So when you load file:

s 2
f 1/1/1 2/2/1 3/3/1 
f 3/3/1 4/4/1 1/1/1 
s 4
f 5/4/2 6/1/2 7/2/2 
f 7/2/2 8/3/2 5/4/2 

you need to track all unique combinations of faces, generate vertices from position, normal, texcoord indexes, and generate index buffer from these combinations.

Ex.: combination (1/1/1) will have index 0 ( vertices[0] ), which mean you add to your index buffer value 0. If later on you encounter (1/1/1) again, you'll be adding value 0 again.

 

Hopefully I managed to explain it.




#5204497 Rendering .obj Model in DirectX 11

Posted by Zaoshi Kaba on 15 January 2015 - 09:46 AM

After trying to solve the problem for awhile, I can now see the mesh, however I see 2 triangles instead of a box (incomplete box)

 

I guess the problem is with the indices, I have 8 vertices, how do I calculate the indices for the box?

 

Inside ModelLoader.cpp you have:

// Read in the faces.
if(input == 'f') 
{
	fin.get(input);
	if(input == ' ')
	{
		// Read the face data in backwards to convert it to a left hand system from right hand system.
		fin >> faces[faceIndex].vIndex3 >> input2 >> faces[faceIndex].tIndex3 >> input2 >> faces[faceIndex].nIndex3
			>> faces[faceIndex].vIndex2 >> input2 >> faces[faceIndex].tIndex2 >> input2 >> faces[faceIndex].nIndex2
			>> faces[faceIndex].vIndex1 >> input2 >> faces[faceIndex].tIndex1 >> input2 >> faces[faceIndex].nIndex1;
		faceIndex++;
	}
}

Which assumes 3 vertices per face, aka. triangle, however in your .obj file:

g Box001
usemtl Material__26
s 2
f 1/1/1 2/2/1 3/3/1 4/4/1 
s 4
f 5/4/2 6/1/2 7/2/2 8/3/2 
s 8
f 1/4/3 4/1/3 6/2/3 5/3/3 
s 16
f 4/4/4 3/1/4 7/2/4 6/3/4 
s 32
f 3/4/5 2/1/5 8/2/5 7/3/5 
s 64
f 2/4/6 1/1/6 5/2/6 8/3/6 
# 6 polygons

each face (polygon) contains 4 vertices.

 

You have 2 choices here:

  1. load correct number of vertices for each face / polygon and triangulate them;
  2. when you export .obj file there should be an option to triangulate meshes / faces / polygons, use it to generate triangles instead of arbitrary polygons.



#5204296 Rendering .obj Model in DirectX 11

Posted by Zaoshi Kaba on 14 January 2015 - 02:43 PM

You removed most of temp files from your project, I'll give you that. Usually people are unable to do even that.

 

I am unable to compile your project because I don't have D3DX, but there is something I have noticed:

  1. you aren't doing any transformations in your vertex shader, meaning it's not being transformed into the screen;
  2. your box is relatively far from (0, 0, 0) point, it won't be visible with 'default' camera transform.



#5202559 whats wrong with my directx 11 project?

Posted by Zaoshi Kaba on 07 January 2015 - 05:23 AM

Debugger does give a certain answer.

Your program seems to get stuck inside this loop (ModelClass.cpp):

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

However I am unable to compile your code so there's no way for me to provide further help.




#5202556 Compile Error C2065: 'identifier' : undeclared identifier, C++ Scope...

Posted by Zaoshi Kaba on 07 January 2015 - 04:58 AM

As vstrakh pointed out there's a mismatch between line numbers, so I'll just ignore that.

 

According to first error unique_ptr is undefined. According to C++ reference it's defined in <memory> header which I don't see you including. That could be source of your problem.




#5199979 [DX11] writing RWTexture2DArray in pixel shader

Posted by Zaoshi Kaba on 25 December 2014 - 12:46 PM

It's ID3D11DeviceContext::OMSetRenderTargetsAndUnorderedAccessViews method: 

For pixel shaders, UAVStartSlot should be equal to the number of render-target views being bound.



#5199386 How was my operator overload working when I forgot to return *this

Posted by Zaoshi Kaba on 21 December 2014 - 04:06 AM


Some bugs have a mysterious way to sense release date and crash the software just before that.

Schrodinger's bug.




#5196233 Win 10 Tech Preview Visual Studio 2015 and Direct2D tutorial

Posted by Zaoshi Kaba on 04 December 2014 - 06:21 AM

There's no attachment so I'll just list typical problems:

  1. DirectX SDK comes with Windows SDK, which comes with Visual Studio. This means you don't need to install SDK separately. Visual Studio is all you need to use DirectX. If you have old SDK you will have to remove it;
  2. Microsoft got rid of D3DX, which had texture loading, meshes, and a lot of other stuff. Therefore you have to implement these yourself and old samples don't work anymore. There's DirectX Tool Kit but I think you'll still have to make some changes to make D3DX code work;
  3. DXUT is gone as well, which heavily relied on D3DX and been used in a lot code samples;
  4. Math API has been updated, so old D3DX math functions don't work. See DirectXMath.h include and MSDN.



#5186753 normal map generating

Posted by Zaoshi Kaba on 13 October 2014 - 02:02 PM


This is very possible.

 

This has been discussed in some other topic.

It is possible but it won't be real normal map. You'll just end up with some fake effect which most likely be on a scale from bad to terrible.




#5186738 normal map generating

Posted by Zaoshi Kaba on 13 October 2014 - 12:23 PM

You cannot make normal map like that.




#5185959 Formula for Exponential Growth

Posted by Zaoshi Kaba on 09 October 2014 - 05:02 AM

Looks about correct:

untitled.png

 

Formula:

y = 10 ^ (2 ^ ((x - 1900) / 2 / 28) * (70 / 12) - 10)

Where x is 1900 to 2100.




#5185929 Formula for Exponential Growth

Posted by Zaoshi Kaba on 09 October 2014 - 02:55 AM

It's exponent with certain scaling on both axes.

Red dots represent computing power which follows Moore's Law (x2 every 2 years).

e^x also has similar shape.

 

I think you're overcomplicating problem by trying to create function based on data instead of making a guess based on visual information.

Not to mention you have no accurate data to begin with.




#5185114 Two Questions about DirectX 11 (XMVECTOR & Creating Input Layouts)

Posted by Zaoshi Kaba on 05 October 2014 - 07:16 AM

If you pass pointer you'll have to load value from memory by pointer, however if you pass your vector by value there's a good chance it will be passed in register and you won't need to access memory, which is way more faster and efficient.






PARTNERS