Jump to content
  • Advertisement

Isolier

Member
  • Content Count

    60
  • Joined

  • Last visited

Community Reputation

125 Neutral

About Isolier

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Isolier

    Ruby?

    According to: http://ruby-opengl.rubyforge.org/extensions.html Ruby-OpenGL doesn't support vertex arrays. It seems to me that this is pretty much a deal breaker. JOGL does in fact support vertex arrays which is why I was impressed with its performance when I created a terrain renderer using a heightmap. I just don't see getting comparable results with vertex arrays... Thoughts?
  2. Check this site, which is an awsome resource for doing exactly what you want to do. However, rather than using the heightmap to store your blend factors, I would go with using the vertex color array. This has the added benefit of allowing you to generate the blend factors procedurally, so you may change them on the fly if need be. After pouring over the above article and all of the included resources and source code, if you you still have problems, PM me.
  3. Isolier

    Motion Blur Pixel Shader

    If you go to ATIs website and download RenderMonkey, they have a shader that does motion blur that comes packaged.
  4. Isolier

    designing height maps

    Just google for some heightmaps then use photoshop to gaussian blur them if they are to "jaggedy" or rough.
  5. Isolier

    ASM Books?

    I second the Assembly Language Step By Step book, really a great book.
  6. Ok, so just have a different image as the alpha map for each texture?
  7. Quote:Original post by Rasmadrak is there something similar to GL_SOURCE0_ALPHA_ARB... i.e GL_SOURCE0_RED_ARB or something perhaps? :) No nothing that explicit, although that sure would make it easy :)
  8. A few sources have mentioned using the r, g, b and a components of a texture unit for four different alpha maps. I know how to go about using the alpha channel as an alpha map, but how would I specify using only one channel from the color as an alpha map? For instance glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS) will us all of the colors from the previous texture unit, how would I specify just the red channel for instance?
  9. Ok, well when I get a chance I will have to try that. Thank you.
  10. This is the combining method I am getting but I am not getting any results. The first texture is being rendered normally. gl.glClientActiveTexture(GL.GL_TEXTURE0); gl.glActiveTexture(GL.GL_TEXTURE0); gl.glEnable(GL.GL_TEXTURE_2D); gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY); gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, texCoordBuffer); gl.glBindTexture(GL.GL_TEXTURE_2D, textureObjects[GRASS_TEXTURE_ID]); gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_MODULATE); gl.glClientActiveTexture(GL.GL_TEXTURE1); gl.glActiveTexture(GL.GL_TEXTURE1); gl.glEnable(GL.GL_TEXTURE_2D); gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY); gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, alphaTexCoordBuffer); gl.glBindTexture(GL.GL_TEXTURE_2D, textureObjects[ALPHA_TEXTURE_ID]); gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_COMBINE); gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_COMBINE_RGB, GL.GL_REPLACE); gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_SOURCE0_RGB, GL.GL_PREVIOUS); gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_OPERAND0_RGB, GL.GL_SRC_COLOR); gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_SOURCE1_ALPHA, GL.GL_TEXTURE); gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_OPERAND1_ALPHA, GL.GL_SRC_ALPHA); gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_SOURCE2_RGB, GL.GL_CONSTANT); gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_OPERAND2_RGB, GL.GL_SRC_ALPHA); I have a regular grass type texture in unit 0 and an image with no RGB values but the alpha map in the alpha channel in unit 1. What am I doing wrong here?
  11. Perl is a fun language for that sort of stuff... /shrugs.
  12. Isolier

    [java] simple xml class

    I don't know if you are interested in writing a library yourself, but it isn't too difficult at all. I wrote one based on the way TinyXml, an Xml lib in Cpp, is structered and found that the development went pretty quickly. There's my two cents...
  13. Isolier

    Multitextured Terrain

    Hopefully it will help someone someday. As I said however, I am not quite sure that my procedure is the most effecient.
  14. Isolier

    Multitextured Terrain

    Quote:Original post by AfroFire Is it not possible to use both a display list and a vertex array? Yes, and actually that is what I am currently doing although you lose some of the benifit of using vertx arrays obviously when you do this, that being dynamic geometry. But I am rendering non deformable terrain so I am not worried about it right now.
  15. Isolier

    Multitextured Terrain

    Quote:Original post by Boruki I love it when people reply to their thread with "yeah thanks, figured it out.. byebye". It would make these forums a lot more useful if people actually posted their solutions for others to learn from. I think you could have made that suggestion with a little less sarcasm. It would also make these forums more useful if more people would talk to each other with the same respect that one would afford someone in the real world, without the security blanket of an internet forum. So, here is what I have so far: I am using texture combining and interpolation, however, I am basically just doing what I see best in terms of the method of transitioning between different textures, which, to be honest probably isn't all that great but I am going off my own limited knowlegde as I can't really find much in the way of tutorials or anything that might set me straight. So I have two texture units enabled, texture unit 0 and texture unit 1. Texture unit 0 is sort of the base texture I guess you could call it and texture unit 1 is what gets blended with texture unit 0. What I do is create one large vertex array, then from this vertex array I scan through and create a new vertex array with all the triangles above a certain height. All of the others go into another vertex array that are below this height. Finally, I render the lower vertex array with the texture from texture unit 0 with texture unit 1 trancparency all the way up so that you can't see any of texture unit 1 texture. Then I change the trancparecy of texture unit 1 so that a little of unit 1 texture will be shown on top of unit 0 and render the upper vertex array. Now on to the actual code: This is how I set up texture unit 0 and texture unit 1. Now I am not going to give a full blown explanation on the texture combiner and the interpolation combine methode because there are many resources out on the net that do a much better job at explaining these sorts of things than I can. However, basically what happens is OpenGL takes the color from the texture bound to texture unit 0 as the first argument(GL_PREVIOUS works for this because we are working with texture unit 1 but you can also specify GL_TEXTURE0), then takes the texture from the current texture bound to the current texture unit(which again is texture unit 1, notice we use GL_TEXTURE as the source which tells opengl to use the current texture), and finally we use GL_CONSTANT as the final source with an operand of GL_SRC_ALPHA instead of GL_SRC_COLOR because we want to use the alpha component of the current texture units texture environment, not texture image, read carefully, the current texture units texture environment's alpha channel to interpolate between how much of texture unit 1 gets displayed on top of texture unit 0. We attain this by setting the third source(SOURCE2) to GL_CONSTANT, then we can manipulate the texture environment with calls to glTexEnv(). gl.glClientActiveTexture(GL.GL_TEXTURE0); gl.glActiveTexture(GL.GL_TEXTURE0); gl.glEnable(GL.GL_TEXTURE_2D); gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY); gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, texCoordBuffer); gl.glBindTexture(GL.GL_TEXTURE_2D, textureObjects[DIRT_TEXTURE_ID]); gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_MODULATE); gl.glClientActiveTexture(GL.GL_TEXTURE1); gl.glActiveTexture(GL.GL_TEXTURE1); gl.glEnable(GL.GL_TEXTURE_2D); gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY); gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, texCoordBuffer); gl.glBindTexture(GL.GL_TEXTURE_2D, textureObjects[GRASS_TEXTURE_ID]); gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_COMBINE); gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_COMBINE_RGB, GL.GL_INTERPOLATE); gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_SOURCE0_RGB, GL.GL_PREVIOUS); gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_OPERAND0_RGB, GL.GL_SRC_COLOR); gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_SOURCE1_RGB, GL.GL_TEXTURE); gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_OPERAND1_RGB, GL.GL_SRC_COLOR); gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_SOURCE2_RGB, GL.GL_CONSTANT); gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_OPERAND2_RGB, GL.GL_SRC_ALPHA); This the code that gets the "upper"(grassTris) and "lower"(sandTris) vertex arrays after the main vertex array(vertexList) has been created. for(int i = 0; i < vertexList.length-18; i+=18) { if(vertexList[i+1] < (float)(100.0f/256.0f)*(float)MAX_HEIGHT) { sandTris[sandIndex] = vertexList; sandTris[sandIndex+1] = vertexList[i+1]; sandTris[sandIndex+2] = vertexList[i+2]; sandTris[sandIndex+3] = vertexList[i+3]; sandTris[sandIndex+4] = vertexList[i+4]; sandTris[sandIndex+5] = vertexList[i+5]; sandTris[sandIndex+6] = vertexList[i+6]; sandTris[sandIndex+7] = vertexList[i+7]; sandTris[sandIndex+8] = vertexList[i+8]; sandTris[sandIndex+9] = vertexList[i+9]; sandTris[sandIndex+10] = vertexList[i+10]; sandTris[sandIndex+11] = vertexList[i+11]; sandTris[sandIndex+12] = vertexList[i+12]; sandTris[sandIndex+13] = vertexList[i+13]; sandTris[sandIndex+14] = vertexList[i+14]; sandTris[sandIndex+15] = vertexList[i+15]; sandTris[sandIndex+16] = vertexList[i+16]; sandTris[sandIndex+17] = vertexList[i+17]; sandIndex += 18; } // if else { grassTris[grassIndex] = vertexList; grassTris[grassIndex+1] = vertexList[i+1]; grassTris[grassIndex+2] = vertexList[i+2]; grassTris[grassIndex+3] = vertexList[i+3]; grassTris[grassIndex+4] = vertexList[i+4]; grassTris[grassIndex+5] = vertexList[i+5]; grassTris[grassIndex+6] = vertexList[i+6]; grassTris[grassIndex+7] = vertexList[i+7]; grassTris[grassIndex+8] = vertexList[i+8]; grassTris[grassIndex+9] = vertexList[i+9]; grassTris[grassIndex+10] = vertexList[i+10]; grassTris[grassIndex+11] = vertexList[i+11]; grassTris[grassIndex+12] = vertexList[i+12]; grassTris[grassIndex+13] = vertexList[i+13]; grassTris[grassIndex+14] = vertexList[i+14]; grassTris[grassIndex+15] = vertexList[i+15]; grassTris[grassIndex+16] = vertexList[i+16]; grassTris[grassIndex+17] = vertexList[i+17]; grassIndex += 18; } // else } // for Now I render all this with the following, however notice the use of glTexEnvfv to change the alpha value of texture unit 1 so that more or less of the texture is actually displayed. Also, you will notice I reference grassBuffer and sandBuffer instead of grassTris and sandTris, this is just a "Javaism" where you have to wrap an array into a "buffer" object so that things work nice, same with the gl.gl* calls, just more Java and JOGL quirks, ignore them. gl.glClientActiveTexture(GL.GL_TEXTURE1); gl.glActiveTexture(GL.GL_TEXTURE1); gl.glTexEnvfv(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_COLOR, new float[]{0.0f, 0.0f, 0.0f, 1.0f}); gl.glVertexPointer(3, GL.GL_FLOAT, 0, sandBuffer); gl.glDrawArrays(GL.GL_TRIANGLES, 0, sandIndex/3); gl.glTexEnvfv(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_COLOR, new float[]{0.0f, 0.0f, 0.0f, 0.5f}); gl.glVertexPointer(3, GL.GL_FLOAT, 0, grassBuffer); gl.glDrawArrays(GL.GL_TRIANGLES, 0, grassIndex/3); Now, the problem I am having right now is my texture coordinates are all jacked up, because I obviously can't use the same set of texture coords I was using when I just render the whole scene at once instead of splitting it up into two vertex arrays, but the code for that is: float xStep = WORLD_WIDTH / heightMapWidth; float zStep = WORLD_LENGTH / heightMapLength; texCoordList = new float[(heightMapWidth-1)*(heightMapLength-1)*12]; int listIndex = 0; for(int z = 0; z < heightMapLength - 1; z++) { for(int x = 0; x < heightMapWidth - 1; x++) { texCoordList[listIndex] = (float)x*xStep/textures[0].getWidth(); texCoordList[listIndex+1] =(float)z*zStep/textures[0].getHeight(); texCoordList[listIndex+2] = (float)x*xStep/textures[0].getWidth(); texCoordList[listIndex+3] = (float)(z+1)*zStep/textures[0].getHeight(); texCoordList[listIndex+4] = (float)(x+1)*xStep/textures[0].getWidth(); texCoordList[listIndex+5] = (float)z*zStep/textures[0].getHeight(); texCoordList[listIndex+6] = (float)(x+1)*xStep/textures[0].getWidth(); texCoordList[listIndex+7] = (float)z*zStep/textures[0].getHeight(); texCoordList[listIndex+8] = (float)x*xStep/textures[0].getWidth(); texCoordList[listIndex+9] = (float)(z+1)*zStep/textures[0].getHeight(); texCoordList[listIndex+10] = (float)(x+1)*xStep/textures[0].getWidth(); texCoordList[listIndex+11] = (float)(z+1)*zStep/textures[0].getHeight(); listIndex += 12; } // for } // for Now to finish this off, again my texcoords are all wrong and I don't even know if this is the right way to go about this whole thing, there are probably numerous things I am doing wrong and numerous things that are just flat out stupid, but this was the best I could come up with so far, it works ok but definitely not great because in order to get transitions between the high and low vertex arrays I will need one or two transitional arrays that would have the alpha value of texture unit 1 between 1.0f and 0.5f so that things don't look weird. So there you have it, I don't know if any of it made sense but hopefully it helped someone and hopefully someone will help me because I certainly need it :) Also, I am not going to proof read this so sorry for any gramatical or spelling errors.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!