outdoor beautifullyizing

That code is quite Delphi specific, no wonder you don’t understand it.

The coverage factors are nothing but layer opacities for the detail texture layers. How you calculate them depends on the result you want to achieve. For total control, you can just paint them in a paint program, or alternatively you can generate them procedurally using vertex height and slope.

What this code does, is that if you have specified an explicit coverage map, it just reads it to the coverage factors. The coverages are encoded in an image with different coverages being in different color components.

If the coverage map isn’t there, the values are calculated procedurally. For this, there’s a look-up table (another image) which has, in a way, height as x-axis and slope as y. So when you get the color at point (height, slope), you get the appropriate coverage values. For slope, you can use the y-component of the vertex normal.

-Ilkka

Clearification : Whilst nVidia doenst support the crossbar extension, it supports the functionallity of it in most ways, the only thing stopping them to expose this extension in the extensionlist is the behaivor of an unbound texture unit. So it you use it to access only TMUs with bounded textures you can rely on nvidias driver to work.
When the function was moved into the core the result if querying an unbound units value is specifyed as undefined and therefor works well. All this is in the openglExtensionSpec.pdf from nVidia


the problem was not that the code is delphi (i can code in delphi, too) specific, the problem was, that i dont know what to use here :
glcolor4f(x,x,x,y);
if i want to set x to 40% and y to 60%

(a few google searches later)

i got the formula…
but…
i never see my second detail texture…
at the top of my mountains is no detail texture, and the bottom there is ONLY my detail texture…

i tried some values (formula :
coltex1 = 0.6f,
coltex3 = 0.4f,
cov1=coltex1/(1-coltex3),
cov2=1-coltex3;
cov1 = coltex1/(1-coltex3);
cov2 = 1-coltex3;
glColor4f(cov1,cov1,cov1,cov2);
)

but i can only control the factors of the main texture and the second detail texture…

just solved the problem !

coverage factor 3 at 0,5f means texture 2 is automatically at 1-cov factor 3

Good for you. Hey, how about some screenshot, after all this it’d be nice to see what you’ve got together.

-Ilkka

i’ll upload one in 6 hours…

screenshots available at :
ftp://hamsterdevelopment.homeftp.org -> public (thats my computer^^, so not on 24h/day)

the highter the number the newer the shot

here you find a demo-shot : http://de.geocities.com/vegankatze/screenshot10.jpg

-> screenshot is uploaded, but the server seems to be ****ty. geocities = bad, right ?

anyone has webspace for me ?

[This message has been edited by HamsterofDeath (edited 01-22-2003).]

[This message has been edited by HamsterofDeath (edited 01-22-2003).]

So that’s a plasma-morphing sun… No, it looks good, keep it up!

A little advice on those trees though, if you don’t mind. You’re on the right track, especially with those tall trees, but you have to take care of a couple of things to make the illusion perfect.

First, you should never be able to see a straight polygon edge in a tree. It’s easy to fix this, just extrude each such edge to a polygon and texture it to create a better silhouette.

The slightly harder problem are the polygons that are viewed from steep angles. You can’t totally get rid of these, but you do have a pretty good control over which directions they are seen from. In an 1st person kind of game, which you seem to be creating, the trees are typically viewed from the same level or a little bit below. So then you construct the trees so that the polygons become “buggy” mostly when viewed from above.

You can look at the trees in my grass demo to see how I managed these things. The trees are normal polygon meshes, aroung 50 faces each.

-Ilkka

I have written a demo that uses three textures blended together. I have my server down right now, but I will post the link later so that you can download it.

Miguel Castillo.

mhh grrmrmorf hate
my coverage factors are stupid ! they hide my third texture. i can interpolate between 2 but the third simply dissapears.

why can’t there be a simple function in the article calculating them ?

[This message has been edited by HamsterofDeath (edited 01-23-2003).]

i got 3 factors, one of them is always 0.
how to get a1 and a2 ?

[This message has been edited by HamsterofDeath (edited 01-23-2003).]

hm looks like i got the solution, just by randomly trying out everything.
bruteforce always wins. it’s only a matter of time.

[This message has been edited by HamsterofDeath (edited 01-23-2003).]

ok, here is my hopeyfully last problem :
if i want to draw only the first texture (the lowest) glcolor has to be 1,1,1,0 right ?
for the second, it has to be 0,0,0,1, and for the last 0,0,0,0.

right ? (ignore the order - are the values correct for only displaying a single texture ?)

the problem is that one of the textures is nearly invisible…no matter wich of the 3 settings i try…

[This message has been edited by HamsterofDeath (edited 01-23-2003).]

can anyone help me ? i’m dying.

[This message has been edited by HamsterofDeath (edited 01-23-2003).]

HEEEEEEEEEEEEEEELP

the coverage factors aren’t calculated anywhere in the code !!

the article is lying !

[This message has been edited by HamsterofDeath (edited 01-23-2003).]

that s how to calculate the coverage factors :


So, how do you compute alpha and beta for a vertex from its texture weights? With some math you get that alpha = c0/(1-c2), beta = 1-c2 if c2<1 and beta = 0 and for alpha you can choose any value if c2=1. Isn’t it cool?

as i expected, i don’t understand the most important sentence.

alpha = c0/(1-c2), beta = 1-c2 if c2<1 and beta = 0 and for alpha you can choose any value if c2=1.

so beta is 1-c2 and beta is 0 ?
???

i just want a function that need 3 floats (c0,c1,c2) and gives me 2 floats (rgb,alpha)

is there nobody who got one ?

code: for (int x =0;x<size;x++)
{
for (int y = 0;y<size;y++)
{
if (map[x+sizey] <=128)
{
float percentB = (float)(map[x+size
y])/128f;
System.out.println(map[x+sizey]);
float percentC = 0;
float percentA = 1-percentB;
float[] cov = calculateCoverage(percentA,percentB,percentC);
Color color = new Color(cov[0],cov[1],0);
covertex.setRGB(x,size-1-y,color.getRGB());
} else
{
float percentA = 0;
float percentC = (float)(map[x+size
y]-128f)/128f;
float percentB = 1-percentC;
float[] cov = calculateCoverage(percentA,percentB,percentC);
Color color = new Color(cov[0],cov[1],0);
covertex.setRGB(x,size-y-1,color.getRGB());
}
}
}

the code is java, but it’s easy to guess what it’s doing. i tried to fill in 0,0,1 / 0,1,0 and 1,0,0 for percenta->c, and everything worked fine. i saw the textures i wanted to see.

so, the bug must be in my weight-calculation. but where ?
map[…] is my heightmap. the lowest point is 0, the highest is 256.

so for every point below or equal 128, i use height / 128 as the percentB-weight, and 1-percentB = percentA

for every point highter than 128, i subtract 128, then divide by 128 to get the percentC-weight. percentB then is 1-percentB.

where is the error ?

here is my coverage-calculaton :

private float[] calculateCoverage(float c1,float c2,float c3)
{
	if (c1+c2+c3 != 1 | | c1 &lt; 0 | | c2 &lt; 0 | | c3 &lt; 0 | | c1 &gt; 1 | | c2 &gt; 2 | | c3 &gt; 1)
	{
		return null;
	} else
	{
		float[] cov= new float[2];
		cov[0] = c1/(1-c3);
		cov[1] = 1-c3;
		return cov;
	}
 }

[This message has been edited by HamsterofDeath (edited 01-24-2003).]

Sorry, I didn’t take the effort to go through all the code you posted, I think the functions you need are:

alpha = c3
rgb = c2/(c1+c2)

That is assuming you use the combiner setup you posted earlier. If c1+c2=0, rgb doesn’t matter, just set it to some value like 1.

-Ilkka

I LOVE YOU !
it works

how to change the gltexenvi-commands to make the texture be completely transparent at alpha 0 and completely opaque at alpha 1 ?