Managing superposition of celestial objects in passing over each other
This commit is contained in:
parent
4e94507ac0
commit
d91b9ea126
2 changed files with 25 additions and 24 deletions
|
@ -32,11 +32,11 @@ shader_param/ground_color = Color(0.1, 0.07, 0.034, 1)
|
||||||
shader_param/exposure = 0.1
|
shader_param/exposure = 0.1
|
||||||
shader_param/dither_strength = 1.0
|
shader_param/dither_strength = 1.0
|
||||||
shader_param/samayun_arc = 50.0
|
shader_param/samayun_arc = 50.0
|
||||||
shader_param/samayun_position = Vector3(2.038, 0.584, -0.995)
|
shader_param/samayun_position = Vector3(2.038, 0.695, -0.296)
|
||||||
shader_param/zabr_arc = 15.0
|
shader_param/zabr_arc = 15.0
|
||||||
shader_param/zabr_position = Vector3(0.6, 0.03, -0.342)
|
shader_param/zabr_position = Vector3(1.755, 0.627, 0.768)
|
||||||
shader_param/stigi_arc = null
|
shader_param/stigi_arc = 8.381
|
||||||
shader_param/stigi_position = Vector3(0.688, 0.03, -0.342)
|
shader_param/stigi_position = Vector3(0.925, 0.277, 0.17)
|
||||||
shader_param/samayun = ExtResource( "1_thm7k" )
|
shader_param/samayun = ExtResource( "1_thm7k" )
|
||||||
shader_param/zabr = ExtResource( "3_bgghj" )
|
shader_param/zabr = ExtResource( "3_bgghj" )
|
||||||
shader_param/stigi = ExtResource( "3_jqgsm" )
|
shader_param/stigi = ExtResource( "3_jqgsm" )
|
||||||
|
|
|
@ -58,8 +58,8 @@ vec2 place_object(vec3 position, vec3 eyedir){
|
||||||
vec3 n1 = normalize(cross(position,vec3(0.0,1.0,0.0))) ;
|
vec3 n1 = normalize(cross(position,vec3(0.0,1.0,0.0))) ;
|
||||||
vec3 n2 = normalize(cross(position,n1)) ;
|
vec3 n2 = normalize(cross(position,n1)) ;
|
||||||
//We project EYEDIR on this plane with an approximate correction for projection
|
//We project EYEDIR on this plane with an approximate correction for projection
|
||||||
float x = dot(eyedir,n1) * 0.89 ;
|
float x = dot(eyedir,n1) * 0.9 ;
|
||||||
float y = dot(eyedir,n2) * 0.89 ;
|
float y = dot(eyedir,n2) * 0.9 ;
|
||||||
return vec2(x, y);
|
return vec2(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,28 +127,29 @@ void sky() {
|
||||||
vec2 zabr_uv = place_object(zabr_position, EYEDIR) ;
|
vec2 zabr_uv = place_object(zabr_position, EYEDIR) ;
|
||||||
vec2 stigi_uv = place_object(stigi_position, EYEDIR) ;
|
vec2 stigi_uv = place_object(stigi_position, EYEDIR) ;
|
||||||
|
|
||||||
// Adding Samayun
|
// Adding the celestial objects from the nearest to the farest
|
||||||
|
// Adding stigi
|
||||||
|
if (length(EYEDIR - normalize(stigi_position)) < stigi_scale / 2.0){ // we are in the area of the sky where stigi is placed
|
||||||
|
COLOR += texture(stigi, stigi_uv / stigi_scale + vec2(0.5)).rgb * texture(stigi, stigi_uv / stigi_scale + vec2(0.5)).a;
|
||||||
|
}
|
||||||
|
// Adding samayun
|
||||||
if (length(EYEDIR - normalize(samayun_position)) < samayun_scale / 2.0) { // we are in the area of the sky where samayun is placed
|
if (length(EYEDIR - normalize(samayun_position)) < samayun_scale / 2.0) { // we are in the area of the sky where samayun is placed
|
||||||
// If zabr is nearer at this place, do nothing
|
if (length(EYEDIR - normalize(stigi_position)) < stigi_scale / 2.0){ // if stigi is in front of samayun, don’t draw where stigi alpha is > 0
|
||||||
if (length(EYEDIR - normalize(zabr_position)) < zabr_scale / 2.0 && length(zabr_position) < length(samayun_position)){
|
COLOR += texture(samayun, samayun_uv / samayun_scale + vec2(0.5)).rgb * max((texture(samayun, samayun_uv / samayun_scale + vec2(0.5)).a - texture(stigi, stigi_uv / stigi_scale + vec2(0.5)).a), 0.0) ;
|
||||||
} else { // // Add samayun to the sky
|
} else {
|
||||||
COLOR += texture(samayun, samayun_uv / samayun_scale + vec2(0.5)).rgb * texture(samayun, samayun_uv / samayun_scale + vec2(0.5)).a;
|
COLOR += texture(samayun, samayun_uv / samayun_scale + vec2(0.5)).rgb * texture(samayun, samayun_uv / samayun_scale + vec2(0.5)).a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Adding zabr
|
// Adding zabr
|
||||||
if (length(EYEDIR - normalize(zabr_position)) < zabr_scale / 2.0) { // we are in the area of the sky where zabr is placed
|
if (length(EYEDIR - normalize(zabr_position)) < zabr_scale / 2.0) { // we are in the area of the sky where zabr is placed
|
||||||
// If samayun is nearer at this place, do nothing
|
if (length(EYEDIR - normalize(samayun_position)) < samayun_scale / 2.0){ // if samayun is in front of zabr, don’t draw where samayun alpha is > 0
|
||||||
if (length(EYEDIR - normalize(samayun_position)) < samayun_scale / 2.0 && length(samayun_position) < length(zabr_position)){
|
COLOR += texture(zabr, zabr_uv / zabr_scale + vec2(0.5)).rgb * max((texture(zabr, zabr_uv / zabr_scale + vec2(0.5)).a - texture(samayun, samayun_uv / samayun_scale + vec2(0.5)).a), 0.0);
|
||||||
} else { // Add zabr to the sky
|
} else {
|
||||||
|
if (length(EYEDIR - normalize(stigi_position)) < stigi_scale / 2.0){ // if stigi is in front of zabr, don’t draw where its alpha is > 0
|
||||||
|
COLOR += texture(zabr, zabr_uv / zabr_scale + vec2(0.5)).rgb * (texture(zabr, zabr_uv / zabr_scale + vec2(0.5)).a - texture(stigi, stigi_uv / stigi_scale + vec2(0.5)).a);
|
||||||
|
} else {
|
||||||
COLOR += texture(zabr, zabr_uv / zabr_scale + vec2(0.5)).rgb * texture(zabr, zabr_uv / zabr_scale + vec2(0.5)).a;
|
COLOR += texture(zabr, zabr_uv / zabr_scale + vec2(0.5)).rgb * texture(zabr, zabr_uv / zabr_scale + vec2(0.5)).a;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Adding stigi
|
|
||||||
if (length(EYEDIR - normalize(stigi_position)) < stigi_scale / 2.0) { // we are in the area of the sky where stigi is placed
|
|
||||||
// If samayun is nearer at this place, do nothing
|
|
||||||
if (length(EYEDIR - normalize(samayun_position)) < samayun_scale / 2.0 && length(samayun_position) < length(stigi_position)){
|
|
||||||
} else { // Add stigi to the sky
|
|
||||||
COLOR += texture(stigi, stigi_uv / stigi_scale + vec2(0.5)).rgb * texture(stigi, stigi_uv / stigi_scale + vec2(0.5)).a;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue