Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 28 Nov 2010
Offline Last Active Jan 28 2015 12:59 AM

Posts I've Made

In Topic: Mesh Picking Accuracy Problem

05 December 2012 - 01:32 AM

Found the problem, although i don't really understand why it was a problem.

Basically i deleted the line : rayDir = Vector3.Normalize(rayDir)

So i don't normalized the ray direction at all anymore.

Now it works perfectly. Go figure.

In Topic: World Space to Screen Space Conversions

04 December 2012 - 05:24 PM

Well to anyone who was interested, I figured out what the problem was. I just needed to make a minor adjustment to my translate vertex code (see below). The problem was that i had not taken into account that the origin of the NDC system is the centre of the viewport. Since the NDC system ranges from -1 to 1, i just had to add/subtract one in the vertex translation code.

// translate vertex
position.x += spNDC.x + 1;
position.y += spNDC.y - 1;

In Topic: Hardware Instancing - Optimization Query

16 November 2012 - 10:04 PM

Thanks guys. Yeah I had a think about it last night and it seems logical to just have a base beam mesh and pass the actual cross section geometry parameters to the shader, and let the shader do the work. Saves me having to create a mesh for each beam size, and also recreate the meshes each frame.

@kuana - yes I realize that's where the performance problems are steming from, as I mentioned in my earlier post. Thanks for the response.

In Topic: Hardware Instancing - Optimization Query

15 November 2012 - 09:47 PM

I'm not very familar with skinning, i don't use it in my application. I think i know what your saying though. I am thinking an integer vertex attribute that can be either 0,1 or 2. 0 indicating that all vertices are effected by scaling, 1 indicating that only relevant web vertices are effected by scaling, and 2 indicating that only relevant flange vertices are effected by scaling. I would then have to pass two matrices as part of my instance data. One matrix being the 'global' scaling matrix, and the other being the 'local' scaling matrix. The shader will apply the global scaling matrix to all vertices flagged as 0. I can then make the local transformation matrix only contain a scaling in the x and y direction. So my shader will apply the x scaling component to my vertices flagged as 1 (web), and apply the y scaling component to my vertices flagged as 2 (flange).

Is that essentially what your saying?

I've attached a pic below showing the scaling operations. I'm a bit reluctant to post code, but i dont think the code will tell you anything anyway. I'm just passing a transformation matrix to my shader at the moment, on a per-instance basis.

Posted Image

In Topic: Hardware Instancing - Optimization Query

15 November 2012 - 08:28 PM

Thanks for the reply Jason.

I think i understand what your saying, although it may be hard to implement in my case. Basically every vertex has to be scaled. Every type of I-section has different depths, widths, flange thinkness, and web thicknesses. Scaling the height, width and length of the mesh can be done easily with a scaling matrix, its more the flange and web thicknesses that i am struggling with.

So really i would have to do something like this:
1. Scale mesh with a scaling matrix to give correct height, width and length.
2. Flag all vertices save for a few to not be affected by further scaling.
3. Apply additional vertical scale to adjust flange thickness
4. Flag all vertices save for a few to not be affected by further scaling.
3. Apply additional horizontal scaling matrix that will adjust web thickness.

Is this possible with your suggestion?