LargeScreen/common/shader/inc/curvature.gdshaderinc
shurongsen b8d780b2a2 3d
接口添加
2025-01-03 14:02:17 +08:00

21 lines
607 B
Plaintext

global uniform bool is_curvature;
global uniform float curvature_radius;
global uniform vec3 player_position;
float get_depth(float dist){
return sqrt(dist*dist + curvature_radius * curvature_radius) - curvature_radius ;
}
vec3 curvature_vertex(mat4 model_matrix ,vec3 vertex ) {
if (is_curvature ){
vec3 vertex_world =(model_matrix * vec4(vertex, 1.0)).xyz ;
vec3 dist = vertex_world -player_position;
float depth = get_depth(length(dist.xz));
vertex_world.y -= depth;
vec3 vertex_local = (inverse(model_matrix) * vec4(vertex_world, 1.0)).xyz;
vertex = vertex_local;
}
return vertex;
}