1
\$\begingroup\$

I got the exercise to create a color map from a heightfield and given normals with alpha blending. Therefore I have to blend 4 textures (deep-flat, deep-steep, high-flat, high-steep) depending on the height and slope.

First I'm calculating the 3 alpha values (lowest layer is fully opaque, does not need to be blended -> gras texture)

//slope:= 1.0f - normal.z at current pixel

void calcAlphas(float height, float slope, float& alpha1, float& alpha2, float& alpha3) {
   alpha1 = (1-height) * slope; //low-steep ->  dirt texture
   alpha2 = height;             //high-flat ->  pebbles texture
   alpha3 = height * slope;     //high-steep -> rock texture
}

After that I'm getting the color at the current pixel of all four textures and calculating the final color:

𝐶3 = 𝛼3 ∗𝑐3 +(1−𝛼3)∗(𝛼2 ∗𝑐2 + 1−𝛼2 ∗(𝛼1∗𝑐1 + 1−𝛼1 ∗𝑐0))

The result looks pretty good but it's very smooth. To compare my result I got a pattern how it should be.

Orignal:

Original

My own color map:

My own color map

\$\endgroup\$
  • 1
    \$\begingroup\$ Your final alpha calculation has some weird characters on it that aren't rendering on my machine. You should also mention what alpha blending mode you're setting things to. \$\endgroup\$ – Jay Lemmon May 10 '15 at 20:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.