detail texture blend-out
Could someone please tell me how to "blend in" detail texture of terrain. I''ve tried using blendig and multitexturing with no luck. I just can''t get it to blend out. I treid using GL_COMBINE_EXT(or GL_COMBINE4_NV) & GL_ADD_SIGNED_EXT with no luck. I have "sternght" of detail texture stored in alpha component of color calculated per vertex (calculated on per frame basis for all patches of terrain in range)
So basicly this should work:
ADD_SIGNED_EXT Arg0 * Arg1 + Arg2 * Arg3 - 0.5
Arg0 = main texture
Arg1 = color -> RGB
Arg2 = detail texture
Arg3 = color -> alpha
but for some wierd reason it doesn''t...
Any ideas?
You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
Weird. That should do the trick.
What kind of results do you see ?
Did you get the latest drivers ?
I should ask you if you are sure that your graphics card support the GL_NV_texture_env_combine4 extension, but I''m pretty sure the GeForce4 Ti supports it
What kind of results do you see ?
Did you get the latest drivers ?
I should ask you if you are sure that your graphics card support the GL_NV_texture_env_combine4 extension, but I''m pretty sure the GeForce4 Ti supports it

I''m still doing it on TNT2 but this extension is supported and yes, I have "the latest" drivers (it''s kinda funny saying this with nVida card since they are new only few days).
And the result: The edge of patch using detail texture is clearly seen. Like there is no blend off.
You should never let your fears become the boundaries of your dreams.
And the result: The edge of patch using detail texture is clearly seen. Like there is no blend off.
You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
It seems like your Arg3 (alpha channel) is constant, or is not containing the value you need around your edges.
What is ''alpha'' in your object ? and do you have lighting ?
What is ''alpha'' in your object ? and do you have lighting ?
Arg0 * Arg1 + Arg2 * Arg3 - 0.5
not gonna work
say
Arg0 * Arg1 = 0.5
Arg2 * Arg3 = 1
0.5 + 1 - 0.5 = 1 which is want u want i assume
Arg0 * Arg1 = 0.5
Arg2 * Arg3 = 0
0.5 + 0 - 0.5 = 0 but u want 0.5
i think what u want is impossible on a tnt2 in one pass, one way of doing it in one pass on a tnt2 (not the best way but is used in quite a few commericial games) store different alpha values in the detailmaps texture. ie when u construct the detail maps for highest detail use alpha 1 and for the 1x1 sized texture use alpha 0 (alternativly dont use alpha but change the details textures colours from 256x256 original -> 1x1 colour(0.5,0.5,0.5)
the mipmaps btw will fade out depending on distance (+ angle problem) from the camera
http://uk.geocities.com/sloppyturds/gotterdammerung.html
not gonna work
say
Arg0 * Arg1 = 0.5
Arg2 * Arg3 = 1
0.5 + 1 - 0.5 = 1 which is want u want i assume
Arg0 * Arg1 = 0.5
Arg2 * Arg3 = 0
0.5 + 0 - 0.5 = 0 but u want 0.5
i think what u want is impossible on a tnt2 in one pass, one way of doing it in one pass on a tnt2 (not the best way but is used in quite a few commericial games) store different alpha values in the detailmaps texture. ie when u construct the detail maps for highest detail use alpha 1 and for the 1x1 sized texture use alpha 0 (alternativly dont use alpha but change the details textures colours from 256x256 original -> 1x1 colour(0.5,0.5,0.5)
the mipmaps btw will fade out depending on distance (+ angle problem) from the camera
http://uk.geocities.com/sloppyturds/gotterdammerung.html
Another technique that would work would be : trilinear filtering !
If you use LINEAR_MIPMAP_LINEAR (or NEAREST_MIPMAP_LINEAR) on your detail texture, and the mipmap level 0 contains the detail texture and other mipmap levels contain a ''neutral'' texture (maybe grey), then OpenGL will fade your detail texture automatically.
That has some advantages and disadvantages as well.
Main Advantages...
- Easy-to-use, automatic method : just set the mipmap levels and OpenGL blends them for you.
- OpenGL compliant : no need for [exotic] extensions such as texture_env_combine4
Main Disadvantages...
- Texture-intensive work : need some extra memory for storing mipmaps, and need some extra fillrate for trilinear filtering.
- Uncontrollable blending limit : sometimes you would like to know where the detail texture has completely disappeared, so that you can apply single-texturing instead of multi-texturing for [far] polygons. The trilinear method makes that limit very difficult to compute.
If you use LINEAR_MIPMAP_LINEAR (or NEAREST_MIPMAP_LINEAR) on your detail texture, and the mipmap level 0 contains the detail texture and other mipmap levels contain a ''neutral'' texture (maybe grey), then OpenGL will fade your detail texture automatically.
That has some advantages and disadvantages as well.
Main Advantages...
- Easy-to-use, automatic method : just set the mipmap levels and OpenGL blends them for you.
- OpenGL compliant : no need for [exotic] extensions such as texture_env_combine4
Main Disadvantages...
- Texture-intensive work : need some extra memory for storing mipmaps, and need some extra fillrate for trilinear filtering.
- Uncontrollable blending limit : sometimes you would like to know where the detail texture has completely disappeared, so that you can apply single-texturing instead of multi-texturing for [far] polygons. The trilinear method makes that limit very difficult to compute.
eek, zedzeek you just replied while I was replying !
Anyway, I think that DarkWing''s method is quite good assuming that he does want to use detail textures to darken as well as brightening the original texture. That''s why it''s necessary to use signed values. Am I wrong ?
Anyway, I think that DarkWing''s method is quite good assuming that he does want to use detail textures to darken as well as brightening the original texture. That''s why it''s necessary to use signed values. Am I wrong ?
Alpha component is right since I tried rendering only detail texture(no base) and it gives me a smooth fade off. And opengl lighting is disabled since I do my own. (stored in color.RGB)
zedzeek: Thanks for that. I found out the just same thing by testing with differenet alpha values... The problem was that just about in every info I found about it they was using this method.
Your solution(s) looks quite nice but I realy don''t know how to control the distance and strenght of detail texture then. I don''t even know how to construct texture with different textures at each mimmap level. And the slopes would be quite the problem I think.
vincoof: Yes, GL_ADD_SIGNED_EXT was used to both darken and brighten texture (It looks wierd if I just brighter or darken it...)
Why am I always trying to do something with my card that just doesn''t go...
How about a multipass. How do I do it in multipass. The only way I found in my search was (GL_DST_COLOR, GL_SRC_COLOR). Looks nice, but again no fade off. A must somehow include color.alpha to this blending but I just can''t see how.
zedzeek: how do you do it in "gotterdammerung"? (and what does that mean?)
You should never let your fears become the boundaries of your dreams.
zedzeek: Thanks for that. I found out the just same thing by testing with differenet alpha values... The problem was that just about in every info I found about it they was using this method.
Your solution(s) looks quite nice but I realy don''t know how to control the distance and strenght of detail texture then. I don''t even know how to construct texture with different textures at each mimmap level. And the slopes would be quite the problem I think.
vincoof: Yes, GL_ADD_SIGNED_EXT was used to both darken and brighten texture (It looks wierd if I just brighter or darken it...)
Why am I always trying to do something with my card that just doesn''t go...

How about a multipass. How do I do it in multipass. The only way I found in my search was (GL_DST_COLOR, GL_SRC_COLOR). Looks nice, but again no fade off. A must somehow include color.alpha to this blending but I just can''t see how.
zedzeek: how do you do it in "gotterdammerung"? (and what does that mean?)
You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
Defining mipmap levels is a kid-game.
0x80 is neutral with GL_ADD_SIGNED, but other values may be neutral if you use something else than signed additions.
In multipass, the easiest way is (IMO) to do one pass for ''brightening'' and one pass for ''darkening'' because it removes alot of problems to add and subtract in separate passes.
GLint internal_format = ...; // Set the internal format of the detail textureGLsizei width = ...; // Set the width of the detail textureGLsizei height = ...; // Set the height of the detail textureGLenum format = ...; // Set the format of the detail textureGLenum type = ...; // Set the type of the detail textureconst GLvoid* pixels = ...; // Set the pixel array of the detail textureGLubyte* mipmap_pixels;glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, format, type, pixels);mipmap_pixels = new GLubyte[(width*height)/4];memset(mipmap_pixels, 0x80, (sizeof(GLubyte)*width*height)/4));// fill the mipmap with the neutral value 0x80for ( GLint mipmap_level = 1, GLsizei mipmap_width = width/2, GLsizei mipmap_height = height/2 ; (mipmap_width > 0) && (mipmap_height > 0) ; mipmap_level++, mipmap_width /= 2, mipmap_height /= 2 ){ glTexImage2D(GL_TEXTURE_2D, mipmap_level, GL_RGB, mipmap_width, mipmap_height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, mipmap_pixels); // or maybe you need alpha too : glTexImage2D(GL_TEXTURE_2D, mipmap_level, GL_RGBA, mipmap_width, mipmap_height, 0, GL_INTENSITY, GL_UNSIGNED_BYTE, mipmap_pixels);}delete[] mipmap_pixels;
0x80 is neutral with GL_ADD_SIGNED, but other values may be neutral if you use something else than signed additions.
In multipass, the easiest way is (IMO) to do one pass for ''brightening'' and one pass for ''darkening'' because it removes alot of problems to add and subtract in separate passes.
vincoof : Thanks for code. I''ll try it when I get home. About that multipass. I know about doing it in 2 passes. First brighten and then darken it to make nice looking details. But thats gonna have huge impact on fillrate. Well.. I''m gonna have to wait for gf4 to do this then...(but not in multipass I hope
)
On the simmilar note. Did anyone try using bumpmapping insted detail map?
You should never let your fears become the boundaries of your dreams.

On the simmilar note. Did anyone try using bumpmapping insted detail map?
You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement