• Content count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About vbbartlett

  • Rank
  1. I know this has been asked and beaten to death but I saw this a couple of months ago and I don't know where and hoping some one can fill in the blanks for me. So the standard way to "compress normal maps" using DXT5 is to use the Green and Alpha channels and compute the z. What I remember seeing is a way to use a partial derivative if that is what I remember. So you store -Nx/Nz and -Ny/Nz. What this accomplishes is the previous shader code looks like this, half3 norm = tex2D(NormalSampler, IN.TexCoord.xy).agb; norm.xy = 2.f* (norm.xy - .5f); norm.z = sqrt(1.0f - norm.x*norm.x - norm.y*norm.y); norm = normalize(norm); with the derivatives it would look like this half3 norm = half3(-tex2D(NormalSampler, IN.TexCoord.xy).ag,1); norm = normalize(norm); So basically X,Y,Z become X/Z, Y/Z, Z/Z = X/Z,Y/Z,1 which can be normalized back to the original vector. This reduces the number of instructions in the shader. I found some of this described in the following site http://www.gamasutra.com/features/20030903/crespo_02.shtml but what Im missing is what happens to values where Nx is larger than Nz, my assumption was that for most maps, Nx and Ny were less than Nz and I map the result of 0 - 1 to 0 to 255, but this doesn't work in this case. Second benefit is I can add multiple Normal maps directly and and then normalize at the end half3 norm1 = half3(-tex2D(NormalSampler1, IN.TexCoord1.xy).ag,1); half3 norm2 = half3(-tex2D(NormalSampler2, IN.TexCoord2.xy).ag,1); half3 norm = normalize(norm1 + norm2); Thoughts? Anyone know what I am talking about, why are the values neg? Is there anything I am missing?
  2. Stencil effects on Extensions

    I found a chunk of code at http://www.xmission.com/~nate/siggraph97/notes/pixlfrmt.htm which allowed me to print out the allowed formats, and the one I am choosing is available... so why would it not be accelerated by the driver? Is there a way to find out which are accelerated?
  3. I was tinkering with extensions and attempting to find out what my card supported. I found that if I had the stencil depth in the pixel format set to anything but 0, that all the extensions but 3, were not returned via the glGetString. I was wondering if anyone else had experienced this problem and if so what the the foundations for this occurring? Is there something I can do if i want both a stencil buffer and some of the implemented extensions?
  4. Specifically does the selection in Opengl respect the stencil buffer? If so is there a specific way to make this occur? I have the stencil buffer working in that it limits the drawing of a basic scene (it has 3 lines, 1 fully enclose in the stencil, 1 partially enclosed, and 1 outside the stencil) This then displays 3 lines when the stencil is off and 2 lines, one a full line and the second a partial when the stencil is active. Now I use the select mode but am returned all three lines' ids...
  5. Simply, is it better to have a lot of small lists or one large one where size is described by the number of operations in the list? Larger right? By how much? Secondly can anyone suggest a setup that will display a polygon under the following set of criteria Polygon has a color Polygon MAY be filled (fill with color)/(outline with color) Polygon MAY have edge color (diff than fill color and only overrides if filled) Polygon MAY be highlighed (overrides all outline/edge coloring) Once i have created the polygon, i would like to store the pg in a display list, and the options don't require the polygon to be recreated. These options can be changed dynamically. In addition to drawing the PG, a GL_LINE_LOOP is drawn around the border of the PG (and interior holes) The provides viewability when looking at the pg edge on. My thoughts create two lists one for the PG and one for the border... or combine them and draw them multiple times depending on the current setting basically overdrawing the edge if needed...
  6. Before I can begin programming, I need to understand some concepts about sprite movement and collision in a 2D side view environment. The sprite's position would be generally described by a speed and angle for a previous position along surface. The concept I am having the most difficulty with is if the surface is uneven, it has hills, valleys, stairs, anything that is not horizontal. So here are my first thoughts for good movement: I would use a pixel-perfect collision detection between the sprite's body bitmask and a bitmask of the surface. This should give an idea of whether the sprite can move in that direction. Now if it passes that test (has hit a wall) it next tests for angle of movement. Say the sprite can travel up inclines from 0-45°, so how do i detect what the angle based on the origin and ... well some position where the sprite is on top of the surface? Consider a tank sprite, it actually has two points of contact with the surface, and given a center point as its position, Im looking for thoughts on how to determine the sprite's new position. The only thing I can come up with is to determing the center position of the sprite for its last angle and position, then do two vertical search in the bitmask of the surface to find pixels on which the contact points will reside. Once found locate the new center and determine the angle of movement. This just seems like there is a better way that im missing... On top of all of this is the fact that the surface image/bitmask can be altered during play by events such as explosions. (Emiminates prepocessing the surface and determining a vector based line... at least I think it does.) So thoughts on what type of steps I would need to take... thx in advance.
  7. OpenGL 24-bit bitmap partial transparency help.

    im not sure if it would work but I would investigate glColorMask()...
  8. I have a image rendering ortho view setup to view images without used of the drawpixel function. I have added the image data to a set of tiled textures, 0ing the areas outside the image in the alpha channel. This works quite well, however, now i need to clip the images based on a polygon. To do this I decided to use the stencil buffer. This also worked well initially however when I rotated the view, the image began to have areas of the texture disappear. The question is WHY? I hav changed the stencil peice to become visible, and it draws, however it becomes visible under the image as if the stencil test isn't working correctly or there is rounding problems... here is the piece of code any thoughts? Code: glEnable(GL_STENCIL_TEST); glClear(GL_STENCIL_BUFFER_BIT); glStencilFunc(GL_ALWAYS, 0x1,0x1); glStencilOp(GL_REPLACE,GL_REPLACE,GL_REPLACE); glEnable(GL_COLOR_LOGIC_OP); glLogicOp(GL_XOR); // create a stencil from the files extrema glColor4d(1,0,0,0); glBegin(GL_POLYGON); glVertex3d(ext[0].x*mx,ext[0].y*mx,0); glVertex3d(ext[1].x*mx,ext[0].y*mx,0); glVertex3d(ext[1].x*mx,ext[1].y*mx,0); glVertex3d(ext[0].x*mx,ext[1].y*mx,0); glEnd(); glDisable(GL_COLOR_LOGIC_OP); glEnable(GL_ALPHA_TEST); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glEnable(GL_TEXTURE_2D); glStencilFunc(GL_NOTEQUAL,0x0,0x1); glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); dx = tsize.x; dy = tsize.y; for(y = 0; y < theight; y++) for(x = 0; x < twidth; x++) { glBindTexture (GL_TEXTURE_2D,tiles[y*twidth+x]); glBegin(GL_QUADS); glTexCoord2d(0,0);glVertex3f((pts[0].x + x*dx)/dpi[0]*mx, (pts[0].y + (y)*dy)/dpi[0]*mx,0); glTexCoord2d(1,0);glVertex3f((pts[0].x + dx*(x+1))/dpi[0]*mx,(pts[0].y + (y)*dy)/dpi[0]*mx,0); glTexCoord2d(1,1);glVertex3f((pts[0].x + dx*(x+1))/dpi[0]*mx,(pts[0].y + (y+1)*dy)/dpi[0]*mx,0); glTexCoord2d(0,1);glVertex3f((pts[0].x + dx*x)/dpi[0]*mx, (pts[0].y + (y+1)*dy)/dpi[0]*mx,0); glEnd(); } glDisable(GL_TEXTURE_2D); glDisable(GL_ALPHA_TEST); glDisable(GL_STENCIL_TEST); glPopMatrix();
  9. Textures and alpha channel

    Even when i specify the format as GL_ALPHA and only pass enough data for the alpha channel?
  10. why are you using 4 vertexs?
  11. I have a concern about displaying an image as a texture where a specific color in the image is treated as transparent. If I create the texture as GL_RGBA and then subtexture it with alpha values, with this create areas of transparency? the calls would look like this // create a texture from a 24bit chunk of data glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size, size, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, data[i,0]); // add alpha values to the texture glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, size, size, GL_ALPHA, GL_UNSIGNED_BYTE, adata[i,0]); the variable data, is a 2 dimenstional array that contains 24 bit color data in the BGR format. adata is a 2 dim array of single bytes. I have read through the data array populating the adata array based on the color in the data array, setting the adata to 255 or 0 depending on the color. However when i put the glTexSubImage2D call in, the entire texture disappears. My question is, is the concept correct and im just messing up the actual image memory? OR is the concept incorrect? What can I do to transfer a BGR image to texture and add an alpha value without actually resizing the BGR data into RGBA?
  12. OpenGL glDrawPixels Problem

    how do i detect the extentions and is there any good tutorial or information about using those extentions?
  13. trying to render a scene that has vector data ie lines and polygons then render a picture, and then render some more vector data. The problem is that the picture isn't a 2^n size, Thus I can't use textures... (at least that is my understanding) My solution is to glReadPixels into a hbitmap, blit the picture onto the hbitmap, then glDrawPixels and then continue drawing. However the process lags everyonce in a while. most of the time it can draw do the glDrawPixels pretty fast but every once in a while it takes about 2 secs for it to render and I was wondering if anyone as a solution for either this or how to render a picture in opengl when the size is not 2^n*2^m? If there is a better algorithm please suggest it! basically im drawing glLines and then want to render a jpg on top of those lines and then draw some more lines on top of the picture...
  14. Where to find textures

    Im looking for any place to get textures from. Im building a space game for kicks and would like some decent textures for planets. Anyone have any ideas where I could find images that could be used as textures for planets? I have visited the NASA site and have most if not all of the planets in our solar system but 9(+moons)... yeah I would like some more textures than that... Any ideas would be appreciated.
  15. Background: I have created a view to display a scene. And am trapping the mouse moves and button events. The project is a solar system rendering. However because of the scale of the objects, I want to be able to move the view around to look in different direction other than direactly at the sun and only the near planets. I would like the effect of "turning my head" and looking to the right /left/up down and planets that may be far to the left and right... The problems is I haven't been able to determine the angle to rotate based on the two mouse points. On top of that at present was only able to think of a solution for the down and up events. I would also like solution that would dynamically change the view rotation as I moved the mouse... Any and All help is much appreciated!!!