-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
rbn42
committed
Oct 30, 2019
1 parent
ae0e703
commit 47f43c5
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
uniform sampler2D tex1; | ||
in mediump vec2 qt_TexCoord0; | ||
out vec4 out_Color; | ||
|
||
float height1(float distanc,float raw_height){ | ||
return raw_height-distanc; | ||
} | ||
|
||
float height2(float distanc,float raw_height){ | ||
return raw_height/(1+distanc*distanc); | ||
} | ||
|
||
float height(float distanc,float raw_height){ | ||
return raw_height*exp(-distanc*distanc*3); | ||
} | ||
|
||
void main() | ||
{ | ||
float px_step=0.0005; | ||
int max_distance=40; | ||
|
||
float h=1-qt_TexCoord0.y; | ||
|
||
out_Color=vec4(0,0,0,0); | ||
float max_nb=0; | ||
for(int i=-max_distance; i<max_distance+1; i++) { | ||
float distanc=abs(i)/1.0/max_distance; | ||
float x=qt_TexCoord0.x+i*px_step; | ||
x=int(x*2000)/2000.0; | ||
|
||
vec4 raw=texture(tex1, vec2(x,0.5)); | ||
float raw_max=(raw.g+raw.r)/2.; | ||
|
||
if(h <=height(distanc,raw_max)) | ||
if(raw_max>max_nb){ | ||
max_nb=raw_max; | ||
out_Color=vec4(getRGB(5*x),1.); | ||
} | ||
} | ||
} |