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, 03:26 AM

Posts I've Made

In Topic: no Vsync? why should you

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.


In Topic: Spot the bug quiz.

28 April 2015 - 04:17 AM

11 / 15.

 

I assumed it has to be a bug while one of answers was simply a misplaced semicolon. Didn't expect that.


In Topic: Rendering .obj Model in DirectX 11

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.


In Topic: Rendering .obj Model in DirectX 11

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.


In Topic: Rendering .obj Model in DirectX 11

16 January 2015 - 07:36 AM

Most likely indices are incorrect.

Are you sure you loaded them correctly?

 

Your box (first 4 faces):

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 

should have these indices:

1, 2, 3

3, 4, 1

5, 6, 7

7, 8, 5

 

But array will be indexed from 0, so you need to subtract 1 from each of them:

0, 1, 2

2, 3, 0

4, 5, 6

6, 7, 4

 

But this is assuming you don't need normals and/or texture coordinates.


PARTNERS