Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualNickWiggill

Posted 06 July 2012 - 01:50 PM

I'm building my first OpenGL demo to incorporate into the game I'm writing. I wonder if you gentlefolk might help clarify the transformation process for me. I have a basic vertex and fragment shaders up and running already.

Here's what I see as the method for getting 3D objects perspective-transformed to screen:

(pseudocode)


On update:

	 Create the camera matrix: c = camRotation * camTranslation
	 Create the view matrix by inverting the camera matrix: v = c^-1
	 Create the projection matrix using the standard perspective projection matrix terms
	 Create view-projection matrix: vp = p * v

	 For each entity
		  Create a model matrix using entity world position, rotation, and scale values
		  Multiply this specific entity's world transform matrix (the model matrix): mvp = vp * m
		  Set mvp as a uniform for vertex shader
		  glDrawElements(...);

Queries:
  • Please offer your advice on whether or not the above structure is sensible.
  • What options do I have to reduce the number of draw calls? Merging static geometry into a single vertex list using a common texture atlas seems to be the only option?
  • Re the MVP matrix above, why do some sources present the final matrix value as -1, and others as 1? What should I use?
Any other tips, suggestions on this structure welcome.

Primary references:

OpenGL wiki page on viewing and transformations
Joe Groff's tutorial on transformation and projection

#21NickWiggill

Posted 06 July 2012 - 01:05 PM

I'm building my first OpenGL demo to incorporate into the game I'm writing. I wonder if you gentlefolk might help clarify the transformation process for me. I have a basic vertex and fragment shaders up and running already.

Here's what I see as the method for getting 3D objects perspective-transformed to screen:

(pseudocode)


On update:

	 Create the camera matrix: c = camRotation * camTranslation
	 Create the view matrix by inverting the camera matrix: v = c^-1
	 Create the projection matrix using the standard perspective projection matrix terms
	 Create view-projection matrix: vp = v * p

	 For each entity
		  Create a model matrix using entity world position, rotation, and scale values
		  Multiply this specific entity's world transform matrix (the model matrix): mvp = m * vp
		  Set mvp as a uniform for vertex shader
		  glDrawElements(...);

Queries:
  • Please offer your advice on whether or not the above structure is sensible.
  • What options do I have to reduce the number of draw calls? Merging static geometry into a single vertex list using a common texture atlas seems to be the only option?
  • Re the MVP matrix above, why do some sources present the final matrix value as -1, and others as 1? What should I use?
Any other tips, suggestions on this structure welcome.

Primary references:

OpenGL wiki page on viewing and transformations
Joe Groff's tutorial on transformation and projection

#20NickWiggill

Posted 06 July 2012 - 01:05 PM

I'm building my first OpenGL demo to incorporate into the game I'm writing. I wonder if you gentlefolk might help clarify the transformation process for me. I have a basic vertex and fragment shaders up and running already.

Here's what I see as the method for getting 3D objects perspective-transformed to screen:

(pseudocode)


On update:

	 Create the camera matrix: c = camRotation * camTranslation
	 Create the view matrix by inverting the camera matrix: v = c^-1
	 Create the projection matrix using the standard perspective projection matrix terms
	 Create view-projection matrix: vp = v * p

	 For each entity
		  Create a model matrix using entity world position, rotation, and scale values
		  Multiply this specific entity's world transform matrix (the model matrix): mvp = m * vp
		  Set mvp as a uniform for vertex shader
		  glDrawElements(...);

Queries:
  • Please offer your advice on whether or not the above structure is sensible.
  • What options do I have to reduce the number of draw calls? Merging static geometry into a single vertex list using a common texture atlas seems to be the only option?
  • Re the reference link above, why do some sources present the final matrix value as -1, and others as 1? What should I use?
Any other tips, suggestions on this structure welcome.

Primary references:

OpenGL wiki page on viewing and transformations
Joe Groff's tutorial on transformation and projection

#19NickWiggill

Posted 06 July 2012 - 12:59 PM

I'm building my first OpenGL demo to incorporate into the game I'm writing. I wonder if you gentlefolk might help clarify the transformation process for me. I have a basic vertex and fragment shaders up and running already.

Here's what I see as the method for getting 3D objects perspective-transformed to screen:

(pseudocode)


On update:

	 Create the camera matrix: c = camRotation * camTranslation
	 Create the view matrix by inverting the camera matrix: v = c^-1
	 Create the projection matrix using the standard perspective projection matrix terms (#1)
	 Create view-projection matrix: vp = v * p

	 For each entity
		  Create a model matrix using entity world position, rotation, and scale values
		  Multiply this specific entity's world transform matrix (the model matrix): mvp = m * vp
		  Set mvp as a uniform for vertex shader
		  glDrawElements(...);

Ref #1 - Perspective projection matrix

Queries:
  • Please offer your advice on whether or not the above structure is sensible.
  • Why is such a complex formula suggested for the NDC-to-window transform? Why not just a basic scaling matrix that counteracts "screen stretch"?
  • What options do I have to reduce the number of draw calls? Merging static geometry into a single vertex list using a common texture atlas seems to be the only option?
  • Re the reference link above, why do some sources present the final matrix value as -1, and others as 1? What should I use?
Any other tips, suggestions on this structure welcome.

Primary references:

OpenGL wiki page on viewing and transformations
Joe Groff's tutorial on transformation and projection

#18NickWiggill

Posted 06 July 2012 - 12:47 PM

I'm building my first OpenGL demo to incorporate into the game I'm writing. I wonder if you gentlefolk might help clarify the transformation process for me. I have a basic vertex and fragment shaders up and running already.

Here's what I see as the method for getting 3D objects perspective-transformed to screen:

(pseudocode)


On update:

	 Create the camera matrix: c = camRotation * camTranslation
	 Create the view matrix by inverting the camera matrix: v = c^-1
	 Create the projection matrix using the standard perspective projection matrix terms (#1)
	 Create view-projection matrix: vp = v * p

	 For each entity
		  Create a model matrix using entity world position, rotation, and scale values
		  Multiply this specific entity's world transform matrix (the model matrix): mvp = m * vp
		  Multiply mvp by window matrix that takes into account the screen's aspect ratio WRT to NDC: wmvp = w * mvp
		  Set mvp as a uniform for vertex shader
		  glDrawElements(...);

Ref #1 - Perspective projection matrix

Queries:
  • Please offer your advice on whether or not the above structure is sensible.
  • Why is such a complex formula suggested for the NDC-to-window transform? Why not just a basic scaling matrix that counteracts "screen stretch"?
  • Is there a way to apply the window matrix BEFORE the model matrix, such that I could just pass in a "wvp" matrix? I guess no, since then the matrix multiplication order would be out of whack...
  • What options do I have to reduce the number of draw calls? Merging static geometry into a single vertex list using a common texture atlas seems to be the only option?
  • Re the reference link above, why do some sources present the final matrix value as -1, and others as 1? What should I use?
Any other tips, suggestions on this structure welcome.

Primary references:

OpenGL wiki page on viewing and transformations
Joe Groff's tutorial on transformation and projection

#17NickWiggill

Posted 06 July 2012 - 12:47 PM

I'm building my first OpenGL demo to incorporate into the game I'm writing. I wonder if you gentlefolk might help clarify the transformation process for me. I have a basic vertex and fragment shaders up and running already.

Here's what I see as the method for getting 3D objects perspective-transformed to screen:

(pseudocode)


On update:

	 Create the camera matrix: c = camRotation * camTranslation
	 Create the view matrix by inverting the camera matrix: v = c^-1
	 Create the projection matrix using the standard perspective projection matrix terms (#1)
	 Create view-projection matrix: vp = v * p

	 For each entity
		  Create a model matrix using entity world position, rotation, and scale values
		  Multiply this specific entity's world transform matrix (the model matrix): mvp = m * vp
		  Multiply mvp by window matrix that takes into account the screen's aspect ratio WRT to NDC: wmvp = w * mvp
		  Set mvp matrix as a uniform for vertex shader
		  glDrawElements(...);

Ref #1 - Perspective projection matrix

Queries:
  • Please offer your advice on whether or not the above structure is sensible.
  • Why is such a complex formula suggested for the NDC-to-window transform? Why not just a basic scaling matrix that counteracts "screen stretch"?
  • Is there a way to apply the window matrix BEFORE the model matrix, such that I could just pass in a "wvp" matrix? I guess no, since then the matrix multiplication order would be out of whack...
  • What options do I have to reduce the number of draw calls? Merging static geometry into a single vertex list using a common texture atlas seems to be the only option?
  • Re the reference link above, why do some sources present the final matrix value as -1, and others as 1? What should I use?
Any other tips, suggestions on this structure welcome.

Primary references:

OpenGL wiki page on viewing and transformations
Joe Groff's tutorial on transformation and projection

PARTNERS