Commit 74b52177 authored by Kaspar Scharf's avatar Kaspar Scharf

some code cleaning in earth_texture

parent 8c964276
......@@ -3,20 +3,22 @@
//needed for calculation of modified normal-vector; change until you get a good result for normals:
#define SAMPLE_ANGLE__NORMAL_VECTOR 0.0005
float getContinentHeightNoise(vec3 normalizedPosInModelspace) {
return 2*(fbm_3d(normalizedPosInModelspace , 2, 1.25));
}
float getRidgedHeightNoise(vec3 normalizedPosInModelspace) {
return (.75 - abs(fbm_3d( normalizedPosInModelspace , 2, 40.)))/2.;
}
float getDetailHeightNoise(vec3 normalizedPosInModelspace) {
return fbm_3d( normalizedPosInModelspace , 2, 160.)/8.;
}
float getHeightNoise(vec3 normalizedPosInModelspace) {
float noiseContinents = 2*(fbm_3d(normalizedPosInModelspace , 2, 1.25));
float noiseRidged = (.75 - abs(fbm_3d( normalizedPosInModelspace , 2, 40.)))/2.;
float noiseDetails = fbm_3d( normalizedPosInModelspace , 2, 160.)/8.;
// float noise3 = 2*(fbm_3d( normalizedPosInModelspace , 2, 20.) - .5);
// if (noise3 < 0.) {
// noise3 = -noise3;
// }
return (noiseContinents + noiseRidged + noiseDetails) * 2.;
float getHeightNoise(vec3 normalizedPosInModelspace) {
return (getContinentHeightNoise(normalizedPosInModelspace)
+ getRidgedHeightNoise(normalizedPosInModelspace)
+ getDetailHeightNoise(normalizedPosInModelspace))
* 2.;
}
......@@ -35,11 +37,11 @@ vec4 texture_getColor(vec3 texCoord3d, vec3 upVectorNormalized, vec3 normalNorma
float noiseOct5 = 0.;
// if (depth == 1.) {
noiseOct1 = snoise_3d(128.*128. * texCoord3d);
noiseOct2 = snoise_3d(2*128.*128. * texCoord3d);
noiseOct3 = snoise_3d(4*128.*128. * texCoord3d);
noiseOct4 = snoise_3d(8*128.*128. * texCoord3d);
noiseOct5 = snoise_3d(16*128.*128. * texCoord3d);
noiseOct1 = snoise_3d(32.*128. * texCoord3d);
noiseOct2 = snoise_3d(64.*128. * texCoord3d);
noiseOct3 = snoise_3d(128.*128. * texCoord3d);
noiseOct4 = snoise_3d(2*128.*128. * texCoord3d);
noiseOct5 = snoise_3d(4*128.*128. * texCoord3d);
// }
// just some test:
......@@ -47,29 +49,37 @@ vec4 texture_getColor(vec3 texCoord3d, vec3 upVectorNormalized, vec3 normalNorma
// return vec4 (0.,0.,0.,1.);
// }
vec3 distortion = vec3 (.1, .1, .1);
//float noiseVal2 = fbm_3d( texCoord3d, 3, 128.*128.);
float noiseVal2 = 1./2.*noiseOct1 + 1./4.*noiseOct2 + 1./8.*noiseOct3;
//float noiseVal3 = fbm_3d( texCoord3d + distortion, 4, 8*128.*128.);// * 0.05;
float noiseVal3 = 1./2.*noiseOct4 + 1./4.*noiseOct5;
//vec3 distortion = vec3 (.1, .1, .1);
float heightPertubation = 1./2.*noiseOct1 + 1./4.*noiseOct2 + 1./8.*noiseOct3;
vec4 color = vec4(1., 1., 1., 1.);
float height = getHeightNoise(texCoord3d)*.8 + noiseVal2 * .2;
//float ridgedHeight = getRidgedHeightNoise(texCoord3d);
// float height =(
// getContinentHeightNoise(texCoord3d)
// + ridgedHeight
// + getDetailHeightNoise(texCoord3d)
// )*.9 + heightPertubation * .1;
float height =getHeightNoise(texCoord3d)/2.*.9 + heightPertubation * .1;
//testing stuff:
//color = vec4(normalNormalized.x,normalNormalized.y, normalNormalized.z, 1.);
//color = vec4(upVectorNormalized.x,upVectorNormalized.y, upVectorNormalized.z, 1.);
float dt = dot(normalNormalized, upVectorNormalized);
float cs = dt / (length(normalNormalized) * length(upVectorNormalized));
float phi = acos(dt);
float phiNormalized = 2*phi / M_PI; //scale results from [0, M_PI/2] to [0, 1]
//float c = noiseVal1*.3 +.3;
float phiPert = .9*phiNormalized + .1 * noiseVal3;
float phiPertubation = 1./2.*noiseOct4 + 1./4.*noiseOct5;
float phiPert = .9*phiNormalized + .1 * phiPertubation;
if (height> SNOW_LEVEL && phiPert <= ROCK_SLOPE) {
color = vec4(1., 1., 1., 1.);
} else if (height> ROCK_LEVEL || phiPert > ROCK_SLOPE) {
color = vec4(.1, .1, .1, 1.);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment