jfdegbo

Members
  • Content count

    63
  • Joined

  • Last visited

Community Reputation

156 Neutral

About jfdegbo

  • Rank
    Member
  1. Render Normals...

    Hi, A texture is an RGB pixel map... A vector is a tuple of 3 floats... Since a texture is composed of three (or four) floats inside HLSL, you can use the three colors to store the 3 vector component of your texture pixel = (normal.x , normal.y, normal.z) but there is one problem with domains... First, you'll have to normalize your normal vector (hence the name -- it's already normalized i assume) But one problem remains, the normal components vary between -1 and 1, and a texture pixel have component between 0 and 1 You'll then just have to divide by two every component of your normal, making it vary between -0.5 and 0.5. You can then add 0.5 to every component to make it vary between 0 and 1 To do the inverse, just multiply by two, and subtract 1...
  2. Well, I think you are right. I've tested this and it works. I finally did some sort of (very optimized) stack of traversal with state restoration, and this seems to work perfectly. thank you both for your advices and time !
  3. Thank you Rick, this works... in a way. OrangyTang : i'm not sure i understand what you mean by "transformation"... But i have another problem. When considering a portal p2 through a portal p1, i do the following : (very standard stuff, too :)) * project p1 vertices according to camera * create the bounding rectangle of the projected 2D vertices * do the same for p2 * clip p2's 2D rectangle inside p1's 2D rectangle if the resulting clip is not a line or a point, then p2 is visible through p1. Now, here's the problem : If room A and B have two adjacent portals 1 & 2 leading to each other, ie A -1-> B -2-> A and B has a single portal 3 to room C A -1- -2- B -3- C If we are in A, we could have the following situation scenario : add A portal 1 not checked add B portal 1 checked, skip portal 2 can be seen through 1 (because 2d overlap), not checked room A already seen, all portals checked, skip portal 3 not visible from 1 (could be like that) portal 2 checked, skip the end we missed portal 3 that was possible to be seen through 2 Is it very wrong to do 2D clipping for portals ? I am missing anything ? Thanks again !
  4. Hello, i've been working on portal culling ; very standard method : I draw the room where the player is. For each drawed rooms, i check all the portals this room has and if a portal is visible across a 2D rectangle, i render the room on the other side of this portal passing the passed rectangle clipped with the portal's rectangle. The rectangle is initially the entire screen. The first problem is obvious : we have to check for loops. Thus we introduce a flag, telling if a room has already been considered, if it is the case, we skip it. The real problem is described by this simple example : As you can see there are some loops possible. Here is what happens with the above method : Player is in A -> A is drawed A's portals : [ 1, 2 ] portal 1 is visible, so let's draw B B's portals : [ 1, 3 ] portal 1 is visible, so let's draw A A has already been seen, skip it portal 3 is visible, let's draw C C's portals : [ 2, 3, 4 ] portal 2 is not visible through 3, skip portal 3 is visible, let's draw B B has already been seen, skip portal 4 is not visible through 3, skip portal 2 is visible, let's draw C C has already been seen, skip the end Fact is that we missed the draw of room D wich is visible !!! I'm looking for a very simple solution, if there's one. This is realtime culling... How does (for example DOOM3) handle this ? Thanks for your time ! [Edited by - jfdegbo on September 19, 2008 7:06:15 AM]
  5. Then why not flip the mesh ... x = -x or something like that
  6. I use GL_BLEND and i guess it is faster, as it is part of the hardware capabilities for quite some time (as opposed to the render to texture approach)
  7. Why don't you do something like this : float4 colorvalue = tex2D(texture_map, Input.Texcoord); float4 coloradd = {0, 0, 0, 0}; colorvalue /= colorvalue.x + colorvalue.y + colorvalue.z + colorvalue.w; coloradd += tex2D(moss_texture, Input.Texcoord * texture_scale[0]) * colorvalue.x; coloradd += tex2D(rock_texture, Input.Texcoord * texture_scale[1]) * colorvalue.y; coloradd += tex2D(grass_texture, Input.Texcoord * texture_scale[2]) * colorvalue.z; coloradd += tex2D(stone_texture, Input.Texcoord * texture_scale[3]) * colorvalue.w; return coloradd;
  8. Quote:Original post by Flimflam I hate to sound like an idiot here (I really am on this subject) but care to elaborate a little further? He means that in your code, you permit a fragment (pixel) to receive multiple layers at the same time (ie if the colorvalue is yellow (red AND green). The problem with that is that RED channel is 1.0 and GREEN channel is 1.0... Now if the texture corresponding to red is (0.7,0.7,0.7) and the one corresponding to green is (0.9,0.9,0.9) (0.7,0.7,0.7) * 1.0 + (0.9,0.9,0.9) * 1.0 = (1.6,1.6,1.6) your resulting texture will be saturated, thus appear white ! You should thus be sure that your input colorvalue respects the following fact : colorvalue.r + colorvalue.g + colorvalue.b + colorvalue.a = 1.0 (EDIT : as i understand, you don't permit colorvalue to be yellow, but take my explanation for RED and ALPHA, and the conclusion is the same)
  9. Using the stencil buffer for masking

    Indeed, nevermind.
  10. Using the stencil buffer for masking

    Quote:Original post by yellowperil What settings beyond glEnable(GL_STENCIL_TEST) are neccessary to setup the stencil buffer? In arguments of the ChoosePixelFormat() function. Don't know anything about SDL and co, i use ogl alone.
  11. Using the stencil buffer for masking

    I think you will want to check your pixel settings when you created your ogl display... Maybe you have a 1bit stencil... Just a thought.
  12. Quote:Original post by Exorcist Create the cube_map just like you would normally. However, when you want to reference an indivual face as a 2d texture, bind the cubemap then specify the face as the texture target via GL_CUBE_MAP_NEG_X etc (or whatever they are, i cant remember off the top of my head) that's interesting, but what about FBO's ? do you know how to specify the cubemap's face to render to ? I'm quite confused because a cube has 6 faces and my hardware is supposed to handle 4 color attachements max (geforce 6600)... So is it or not possible to use one single FBO to render the hole cube map ?
  13. in fact, i didn't play that way with my shaders experience in glsl. I think I should have, but I did't know about multiple sources in link. So i took another direction (wich is globally the same at the end). I made, since the shaders are just plain strings before to be sent to hardware, a kind of #include macro... that way, i generate the shader containing the "main" function at runtime and just includes the files i want (ie a specular effect, a normal map read... etc.) so i don't know what's wrong with your set of shaders.
  14. yes, you don't want that, and that's normal, but did you just try the big fil, just to see if your shader is running right ? (have to know if it's the "linked program" that does work of if the code in itself is already not working...
  15. Ambient shadows in glsl

    Hello, I would add ambient to shadow before multiplying with the material... [edit :] I mean change : shadowShade.g=shadowShade.b=shadowShade.r; shadowShade.a=1.0; with : shadowShade = vec4(ambient_light.r + shadowShade.r, ambient_light.g + shadowShade.r, ambient_light.b + shadowShade.r, 1.0); and do the rest the same way