Last active
December 18, 2024 01:43
-
-
Save partybusiness/bdcc89213f1aade8684219c65a5a7548 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
shader_type sky; | |
uniform sampler2D skyTexture:source_color; | |
void sky() { | |
COLOR = textureLod(skyTexture, SKY_COORDS, 0.0).rgb; | |
} |
This file contains hidden or 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
shader_type spatial; | |
render_mode unshaded; | |
uniform sampler2D skyTexture:source_color; | |
vec2 view_dir_to_equirectangular(vec3 view_dir) { | |
float y = 0.5 - (atan(view_dir.y, length(view_dir.xz)) / 3.14159); | |
//float y = 0.5-view_dir.y*0.5; | |
float x = -atan(view_dir.x, view_dir.z) / (3.14159 * 2.0) + 0.5; | |
return vec2(x, y); | |
} | |
varying vec3 world_position; | |
void vertex() | |
{ | |
world_position = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz; | |
} | |
void fragment() { | |
vec3 view_dir = normalize(world_position - CAMERA_POSITION_WORLD); | |
vec2 sky_coords = view_dir_to_equirectangular(view_dir); | |
ALBEDO = textureLod(skyTexture, sky_coords, 0.0).rgb; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment