Jump to content

  • Log In with Google      Sign In   
  • Create Account

karwosts

Member Since 15 Sep 2009
Offline Last Active Feb 19 2013 11:51 PM

#4802848 How to draw "lines" in Op

Posted by karwosts on 25 April 2011 - 04:29 PM

I can't think of any blend function that will give you exactly what you want there.

Have you considered that you can probably get a good look without doing any blending? You could only put a cap on lines that have no connecting lines, and otherwise bisect your 'line quads' at the half angle between their intersection. This would ensure that there's no drawing overlap between two lines.

Something like this:lines.JPG


#4802774 Deferred lighting shader issue

Posted by karwosts on 25 April 2011 - 01:14 PM

Are you storing the normals in a floating point texture, or a regular color texture? If you try to stuff a normal value into an RGBA8 texture, it will clamp all negative values to zero. This sounds like it could fit with the problem you're describing (failing positive lights imply negative signed normals could be not working).

A common trick for this would be to normalize your normal, before writing, then scale the values from (-1/1) to (0/1), and then do the reverse operation from reading from the texture.


#4802444 creating vbo data from obj files

Posted by karwosts on 24 April 2011 - 04:48 PM

No, you can't draw the data by separate indexes. You must perform a conversion like you have done to draw obj formatted data in a vertex buffer.

I don't know the particulars of your algorithm, but I would expect loading a medium OBJ file to take on the order of a few seconds, using a well-known importer like Assimp. 45 seconds might not be unusual for one as large as yours.

If you want the ultimate fastest solution, you should not use OBJ directly in your engine. A good idea may be to parse the OBJ into some kind of machine readable opengl-formatted binary data stream in a separate pre-build step, and then load this data at runtime instead of the obj. You could probably cut down the load times by 95% using such a system.


#4801656 translation parallel to camera plane

Posted by karwosts on 22 April 2011 - 10:45 AM

If you want to move an object left/right or up/down in view space, then you just translate it into view space via the modelview matrix, apply the translation, the send that through the projection matrix. Now if you want to figure out the direction of this vector in world space, then you have to multiply it by the inverse of the view matrix.

You'll have to keep the model and view matrices separate if you want to do that, because you need a pure view matrix to get you back to world space from the view space. Otherwise transforming the viewspace direction by the inverse modelview will put your direction in model space, which may or may not be what you want.


#4801460 List vs. Vector?

Posted by karwosts on 21 April 2011 - 09:13 PM

If you want a long description there's 1000s of hits for this common question. Otherwise enjoy this simple chart:

Posted Image


#4801018 Including Normal Data in GLSL Vertex Buffers

Posted by karwosts on 20 April 2011 - 06:32 PM

glEnableClientState(GL_TEXTURE_COORD_ARRAY)?

Don't forget the normals too.


#4800981 Including Normal Data in GLSL Vertex Buffers

Posted by karwosts on 20 April 2011 - 04:58 PM

This is generally a good place to peek for simple questions like this:

http://www.khronos.org/files/opengl-quick-reference-card.pdf

You'll find the list of vertex shader inputs on page 7. The value you're looking for is gl_MultiTexCoord0 through gl_MultiTexCoord7.
Whether you go to slot 0,1,2...7 depends on if you call glClientActiveTexture. The default texcoord is gl_MultiTexCoord0.


#4800943 distorted perspective projection

Posted by karwosts on 20 April 2011 - 03:02 PM

Looks to me like you either don't have depth testing enabled correctly, or you're culling the frontfacing polygons. You can see the lid of the teapot from behind the rim, where its properly obscured in the second image.

Post your render code if you can't figure out how to fix that.


#4800818 GLFrame Up Vectors

Posted by karwosts on 20 April 2011 - 10:03 AM

For a first person camera, you should always first rotate around the Y axis, then around the X. Don't compound matrices across several frames, you always want your Y rotation to be around the global up vector, not the local one.

Also, I realize that if you're talking about constructing a view matrix, you have to do the inverse opposite of that. Otherwise just construct your camera like a regular object and invert the model matrix to get the view matrix.


#4800579 Including Normal Data in GLSL Vertex Buffers

Posted by karwosts on 19 April 2011 - 07:25 PM

I'm not really sure what's confusing you, maybe you can post your own code so we can see what you're doing. Stride is pretty clearly listed as a parameter to glVertexAttribPointer.

For your VertexPositionNormalTexture, it would just be something like this (threw in normals and texcoords so you can see how to do it);

int vertexIndex = glGetAttribLocation(program, "inputPosition");
int normalIndex = glGetAttribLocation(program, "inputNormal");
int texcoordIndex = glGetAttribLocation(program, "inputTexcoord");

glVertexAttribPointer(vertexIndex, 3, GL_FLOAT, GL_FALSE, sizeof(VertexPositionNormalTexture), 0);
glVertexAttribPointer(normalIndex, 3, GL_FLOAT, GL_FALSE, sizeof(VertexPositionNormalTexture), 3*sizeof(float));
glVertexAttribPointer(texcoordIndex, 2, GL_FLOAT, GL_FALSE, sizeof(VertexPositionNormalTexture), 6*sizeof(float));

(My shader also might be somewhat wrong in how it handles a 12-byte input. It seems to work, but my transformations don't apply unless I add another vect4(0.0, 0.0, 0.0, 1.0). If it's obviously wrong in some way shape or form, that would be good to know.)


I don't think I really understand what you're saying here, but I think you need to post your opengl client code.


#4799308 iOS Shaders compile (even though they shouldn't)

Posted by karwosts on 16 April 2011 - 05:34 PM

glGetProgramiv(shaderHandle, GL_COMPILE_STATUS, &compileSuccess);

GL_COMPILE_STATUS is not a valid argument to glGetProgramiv. You probably mean glGetShaderiv here.

glGetShaderiv
glGetProgramiv

This is why you need to call glGetError, it would be throwing errors that you're using the glGetProgramiv incorrectly.


#4798039 A question on Property of 3 positive numbers

Posted by karwosts on 13 April 2011 - 11:41 AM

You should be able to figure this out with even a trivial test case.....

1 < 500 < 501

(1 + 501) > 2*500
502 > 1000

false.


#4798017 Nothing showing up on screen?

Posted by karwosts on 13 April 2011 - 11:04 AM

Couple thoughts:

1) You call LoadIdentity in the beginning of render on an unspecified matrix stack. Does this clear the projection matrix on the first pass, as that stack is still bound when you exit the setup function?

2) What color is your quad supposed to be? Why is texturing enabled?

3) Your quad is lying on the near plane, not sure how the clipping calculations work exactly but I'm not positive if things exactly on the near plane get clipped or not.


#4797743 Simple GLSL Image Processing

Posted by karwosts on 12 April 2011 - 07:33 PM

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

This is a problem if you don't build mipmaps. If you're not using them, you have to set the minfilter to not use mipmapping (GL_LINEAR for example), otherwise it won't sample the texture.

http://www.opengl.org/wiki/Common_Mistakes#Creating_a_Texture


Also this:
glGenFramebuffers(1, &fbo_id);
glBindFramebuffer(GL_FRAMEBUFFER, 1);

You probably meant to bind fbo_id, not "1". It may work but it is prone to breaking.

Is depth test enabled by default? I thought I would have to explicitly enable it with glEnable(GL_DEPTH_TEST). If I'm not doing that, should I have to worry about it?


You're right, its disabled by default. You should be fine.


#4797598 very beginer

Posted by karwosts on 12 April 2011 - 11:58 AM

@jyk: When I stated row-major, I was refering to the fact that each row in a rotation matrix represents the direction vector of the rotated axes in terms of original reference coordinates, which is the case for pre-multiplication type of transformation matrices as opposed to the post-multiplication type where each column represted the rotated axes vectors. I was not talking about the layout of matrix in memory, which I honestly do not have much understanding in that area. I think I may have used the wrong term to express my intended meaning. Is there a more technically correct term for that?


I believe the correct term is 'row vectors' vs 'column vectors'.




PARTNERS