View Full Version : Vertex alpha 0.0 - 4.0 ?
02-15-2004, 08:52 AM
Is it possibe to mulitply alpha values with a constant (4)?
The range 0.0 to 1.0 is too small.
In the end alpha values must be clamped 0.0-1.0 (of course).
A vertex program? a fragment shader?
02-15-2004, 10:12 AM
A vertex program or a fragment program, maybe something else. It depends...
A bit more information?
02-15-2004, 01:08 PM
Is the range between 1.0 and 0.0 to small? Are you using floats or doubles or what? By increasing 0.00001 to 0.0 you'll get a decent ( :-) ) range of numbers between 0.0 and 1.0.
Perhaps I dind't get the question. ;-)
02-15-2004, 02:13 PM
Where in the fragment pipe do you want to multiply?
With register combiners, you can scale input values; this can be used to expand given data.
With ARB_fragment_program, multiplication is trivial.
You can use a look-up texture, that takes a value in the range [0,1] and returns whatever you want; for example you could have a Luminance texture where the range [0,0.25] maps to [0,1] and [0.25,1] maps to 1.
You can also pass in data in almost arbitrary ranges as texture coordinates, depending on what you want to do with it.
02-16-2004, 09:00 AM
I want the formula:
If I have two verteces, one with diffuse alpha=1.0 and the other diffuse alpha=0.0.
I want the final alpha to span 0.0-1.0 range almost from one vertex to the other.
02-16-2004, 09:48 AM
All the methods I suggested will achieve that. Including the ramp look-up.
02-16-2004, 10:43 AM
Thank you very much
This "look-up texture" How does it work?
About the other two methods is it possibe to get some examples ? (I am not an advanced programmer)
(I have some old work at "home.bip.net/frl_linder")
02-17-2004, 07:38 AM
Baron3D, I'm still not quite sure what y ou mean by "The range 0.0 to 1.0 is too small."
As for look-up texture, people are talking about dependent texture fetches (I think). Essentially it's the fragment program equivalent of foo[bar[x]] where foo and bar are textures.
02-17-2004, 11:42 AM
In a triangle I have two verteces, one with diffuse alpha=1.0 and the other diffuse alpha=0.0
If I use a texture with alpha values 0.25 to 1.0 :
At the first vert. ALL alpha values should be clamped to 1.0
At the second vert. ALL alpha values should be clamped to 0.0
In between the two verteces alpha values should be in range 0.0 to 1.0
I'm trying to do a more realistic transission between different textures in my landscape.
Using some sort of "texture splatting"
02-17-2004, 11:54 AM
Baron3D, looking at page 403 of the red book (table 9-4), It looks like a base internal format of GL_RGBA with modulate texture function, if you set the vertices in question to (1,1,1,4*a), where a is the alpha you want, you'd get a resultant color of C_t, the texture color, and a resultant alpha of 4*a*A_t, which is what you describe above. It would then be clamped.
Does that sound right?
02-18-2004, 11:30 AM
Yes it does.
Click to: http://biphome.spray.se/frl_linder/img/Image_path.jpg
What I realy want, is some way to make the transissions more soft.
To make "Image_path.jpg" I use alphatest.
02-18-2004, 11:40 AM
maybe you can also use a completely different approach for your splatting (that's how I do it):
Instead of storing the alpha in the vertices, use a GL_ALPHA texture that maps to the terrain. If you make your texture smaller (and thus have to strech it more to get it to cover the entire terrain), your transitions get wider.
The Alpha-Texture approach also helps if you are doing some kind of LOD for your terrain because with vertex-alpha you will reduce your number of "hooks" for the alpha and this will result in changes of color, when the lod changes.
Just my 2 cents
02-18-2004, 12:56 PM
Baron3D, thanks for the screenshot, that's very helpful.
Is this right?: You have a path texture that has an alpha channel corresponding to it's heightfield. Then you modulate that using alpha values at the vertices?
If that's the case, it's not a suprise you get the harsh edges.
If so, you might try exponentiating the alpha channel, rather than depending on clamping. Basicily come up with a function to alter the alpha so that it doesn't suddenily hit zero since that's what is creating the harsh edges.
02-18-2004, 02:57 PM
>Is this right?: You have a path texture that has an alpha channel corresponding to it's heightfield.
>Then you modulate that using alpha values at the vertices?
Yes, I could'n express myslelf better.
>If so, you might try exponentiating the alpha channel
I know what an exponent is, but what do you mean with "exponentiating the alpha channel"?
Must I use a fragmentshader or vertexprogram?
I am using an old gf2.
02-18-2004, 03:12 PM
I could have been more clear. I was thinking of a fragment program, though. I was thinking that alpha^n for n>1 would make a steep dropoff, but not so steep as to create a harsh edge. An exponent may not be the right function, trial and error would be a good approach.
If your target card can't do fragment proograms, then it's harder. Do you just have one big path texture that you want to cut out arbitrary walkways from, or could you make a path out of edges and middles, in which case you could do the blending in photoshop.
02-19-2004, 12:13 PM
The path texure is a tiled texture.
I'm rewriting my old endgine converting from dx6 to ogl.
The landscape is 10x10 miles.
So one big path texture is impossible.
Well, I'm planning to by a cheap 5900XT card before summer.
And about target card, soon every card could do fragment programs.
Now the math is:
if(Texutre_alpha * Diffuse_alpha > 0.5) draw_pixel
What about: (per pixel)
alpha = (Texture_alpha * Diffuse_alpha - 0.5) * 8
Maybe with different constants.
02-19-2004, 02:41 PM
I was thinking per pixel doing
alpha = pow((Texture_alpha * Diffuse_alpha), 3)
You could add constants here or there to that, but that would create a sharp cutoff without any really harsh edges.
However, I think you migt get a better effect (with more effort) by having an "edge of path" texture, and a "path" texture, and carefully combining them so they line up. Then you could draw the grass-path transition, which would look much nicer. It would take effort and thought to make it lilne up nicely, though.
02-20-2004, 02:22 AM
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1.0f);
glTexEnvf(GL_TEXTURE_ENV, GL_ALPHA_SCALE, 4.0f);
... why oh why look at complicated solutions ?
02-20-2004, 10:11 AM
At the first glance this looked realy good.
>glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1.0f);
>glTexEnvf(GL_TEXTURE_ENV, GL_ALPHA_SCALE, 4.0f);
Am I missing something ?
Absolutley NO reaction.
Just these two lines ?
I use them before glBegin .. gl End
02-21-2004, 02:25 PM
I solved it, Tanks for all help.
Texture_alpha is a heightmap (with some noise) in the range 0.15 to 0.65.
Where 0.15 is heigh level and 0.65 is low.
Vertex_alpha is 0.0 and 1.0
And here is the code:
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE , GL_COMBINE_ARB );
glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB , GL_SUBTRACT_ARB );
glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB , GL_PRIMARY_COLOR_ARB);
glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB , GL_TEXTURE );
glTexEnvf( GL_TEXTURE_ENV, GL_ALPHA_SCALE, 4.0f );
And here are the result. Comments? http://biphome.spray.se/frl_linder/img/Image_path_blend.jpg http://biphome.spray.se/frl_linder/img/Image_path_blend2.jpg
02-23-2004, 01:32 AM
My comments :
you'd better use somme corrected alpha channels rather than correcting them by yourself. Take your artist, take a whip, and whip until it gets corrected.
If you are the artist, whip yourself.
Nice to see I beat jwatte on this one http://www.opengl.org/discussion_boards/ubb/tongue.gif
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.