- Viewing Profile: Reputation: Koehler
Community Stats
- Group Members
- Active Posts 22
- Profile Views 637
- Member Title Member
- Age Age Unknown
- Birthday Birthday Unknown
-
Gender
Male
User Tools
Contacts
Koehler hasn't added any contacts yet.
Latest Visitors
No latest visitors to show
#5002402 Stopping my skybox from "Blooming out"
Posted by Koehler
on 19 November 2012 - 11:48 AM
#4995892 OpenGL Not Rendering Models
Posted by Koehler
on 31 October 2012 - 11:41 AM
#4994175 OpenGL 3.3 VBOs and VAOs.. Why do my models not render properly?
Posted by Koehler
on 26 October 2012 - 09:40 AM
So my draw method should look like this, given that m_Program is a compiled, linked, shader program..?
(snip)
That looks correct! Just remember that if you're drawing later on with glPolygonMode(GL_FRONT,GL_FILL), you might as well re-enable GL_CULL_FACE. It should not affect your visual results and should improve performance. When you're ready to add uniforms, you'll pass them in your GLModel::RenderElements() function.
In C++, the choice between matrix[16] and matrix[4][4] comes down to which you like better. matrix[1][1] in the second is the same offset as matrix[4] in the first. The important thing to remember for openGL is that it is column-major in its memory layout (so array element 0 (or [0][0]) is row 0, column 0, but element 1 (or [0][1]) is row 1, column 0. Fortunately, if you want to access your 2D array as matrix[row][column], you can tell OpenGL to transpose it when you pass it in as a uniform (third argument to any of the glUniformMatrix_fv functions).
That said, it's probably easiest to work with a Matrix class so that you can do things like this:
mat4x4 viewProjectionMatrix = projectionMatrix*viewMatrix;.
note that in shader code vectors and matrices are pre-defined types, so code like the above would work.
You may notice that I've referred to "ViewProjection" matrix above, whereas OpenGL has stacks for the "ModelView", and "Projection" matrices. As you move away from using the matrix stack, the easiest way to think of this is as three separate matrices, Model ,View, and Projection. Under the hood, it's effectively doing this:
vec4 finalVertexPos = Projection*View*Model*vertexPos;
For convenience's sake, since the camera doesn't change over the course of a single frame, I like to combine the view and projection matrices together just once, and use the result like this:
vec4 finalVertexPos = viewProjection*Model*vertexPosition;
I'm a bit short on time to explain how to generate view and projection matrices. For a temporary solution you can use glGetFloatv with GL_MODELVIEW_MATRIX or GL_PERSPECTIVE_MATRIX to extract the ones you're already making with the matrix stack (exclude your last glTranslate if you want just your view matrix)
Warning: glGet calls are comparatively slow and you are far better off generating your own, but for comparison's sake this will give you matrices that you can start with.
One step at a time is best.
First focus on getting a shader to compile, using view/projection matrices you copied out of the stack with glGetFloatv, and replacing your glTranslate with a glUniform3f() to move your object around. This will give you a working set of values to verify your shader functions with.
Once that's done, start building (or just download one that already exists) a matrix math library, and work on building full model transforms (translation*rotation*scale) as well as your own view/projection calculations.
That was me not properly referring to VAO's. You've got them already, so this is doneGeneric Attribute Buffers?
#4993455 OpenGL 3.3 VBOs and VAOs.. Why do my models not render properly?
Posted by Koehler
on 24 October 2012 - 09:20 AM
If you just want to get what you have now working without shaders, try using glVertexPointer, glNormalPointer, and glTexCoordPointer in lieu of glVertexAttribPointer, and replace glEnableVertexAttribArray with glEnableClientState (call it 3 times, passing one of GL_NORMAL_ARRAY, GL_TEXTURE_COORD_ARRAY, GL_VERTEX_ARRAY each time)
Not to nitpick, but 3.3 core has deprecated the matrix stack as well. If you want to bring your code completely "up to date", I would recommend handling matrices yourself or with a library, making use of shaders for drawing geometry, and also using generic attribute buffers (glVertexAttribPointer and the like).
#4960964 Any way Render to VBO directly?
Posted by Koehler
on 19 July 2012 - 09:11 AM
#4956495 Transparent geometry in deferred shading (help)
Posted by Koehler
on 06 July 2012 - 04:08 PM
as of 4.0, when using multiple render targets, XNA associates the depth buffer with the render target bound to index 0. (I assume you've got a couple, to represent color/depth/normal).
This is just a guess, but I think you can reuse your depth values by doing the following:
1. Pick a render target you DON'T need for image composition. Set it to preserve contents (or I guess you could bind a "dummy" texture that you won't sample here);
2. Bind this render target to index 0, put your color, specular power, whatever other targets you render to on higher indices.
3. Clear color and depth.
4. Do your G-buffer pass.
5. Disable depth writing
5. Unbind your render targets for now.
6. Do your light pass.
7. Disable depth testing, and rebind the render target you had on index 0 for the G-Buffer pass (once again to index 0)
8. Bind the render target for your final deferred shading output to index 1 (or whichever index you choose that is > 0)
9. Do the image composition pass, writing the final color into the render target on index 1.
10. re-enable depth testing. (Writing should stay OFF if you want consistency in the appearance of your translucent objects)
11. Draw your transparent geometry, outputting the lit color value to index 1
12. Disable depth testing again
13. Bind the render target from index 1 as a texture, and copy it to the backbuffer via a full screen draw. This also gives you an opportunity to post-process your rendered image however you see fit.
..Long list, but I think it'd do the trick.
..Alternatively you could write a light prepass renderer, where your "image composition" pass involves re-drawing your opaque geometry anyway, and just associate the correct depths with your composition render target automatically. The only way to know which would be more efficient in XNA would be to try both (or see if somebody has).
#4956355 rendering as white rectangle + image rotation issue + any advice to improve t...
Posted by Koehler
on 06 July 2012 - 09:53 AM
It sounds like linear interpolation is yielding magenta "fuzz" because it's averaging magenta with zero alpha with whatever your sprite color is, (at 1.0 alpha most likely).
If you call
glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_LESS_EQUAL, f);Where f is a floating-point value between 0 and 1 (you'd have to experiment to see what looks good), your fuzz might clear up. Note that this means any pixels with an alpha value below f will now not be drawn!
#4956349 [Solved] Spritesheet Bleeding
Posted by Koehler
on 06 July 2012 - 09:38 AM
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER,GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER,GL11.GL_NEAREST);When you create your textures, which will use nearest-neighbor sampling instead of mipmapping or linear interpolation for sampling texels that don't line up perfectly with the screen. (so a pixel that's halfway between two texels will be the color of the one it is closest to)
If that doesn't clear up the lines, another option to try (possibly along with the previous one) would be to add 0.5/spriteHeight to your texture coordinates' Y value, and see if that doesn't help.
Failing that, the other solutions I know of involve using shaders, which it doesn't look like you're doing here. LWJGL has some documentation on using them (and VBO's, which are unrelated here but quite useful) on its wiki, which could help you get started.
- Home
- » Viewing Profile: Reputation: Koehler

Find content