Emissive planet system upgrades / Indexed vertices for planets

This commit is contained in:
Anuken
2025-05-28 21:21:21 -04:00
parent fcb5b42d58
commit 43fb2e7cdc
15 changed files with 193 additions and 82 deletions

View File

@@ -1,6 +1,7 @@
attribute vec4 a_position;
attribute vec3 a_normal;
attribute vec4 a_color;
attribute vec4 a_emissive;
uniform mat4 u_proj;
uniform mat4 u_trans;
@@ -8,6 +9,7 @@ uniform vec3 u_lightdir;
uniform vec3 u_camdir;
uniform vec3 u_campos;
uniform vec3 u_ambientColor;
uniform float u_emissive;
varying vec4 v_col;
@@ -20,8 +22,8 @@ void main(){
vec3 lightReflect = normalize(reflect(a_normal, u_lightdir));
vec3 vertexEye = normalize(u_campos - (u_trans * a_position).xyz);
float albedo = a_color.a > 0.5 ? 0.0 : min(a_color.a * 2.0, 1.0);
float emissive = a_color.a < 0.5 ? 0.0 : 1.0 - (a_color.a - 0.5) * 2.0;
float albedo = 1.0 - a_color.a;
float emissive = a_emissive.a * u_emissive;
float specularFactor = dot(vertexEye, lightReflect);
if(specularFactor > 0.0){
@@ -30,6 +32,6 @@ void main(){
vec3 norc = (u_ambientColor + specular) * (diffuse + vec3(clamp((dot(a_normal, u_lightdir) + 1.0) / 2.0, 0.0, 1.0)));
v_col = vec4(a_color.rgb, 1.0) * vec4(mix(norc, vec3(1.0), emissive), 1.0);
v_col = vec4(mix(a_color.rgb, a_emissive.rgb, vec3(1.0 - norc)), 1.0) * vec4(mix(norc, vec3(1.0), emissive), 1.0);
gl_Position = u_proj * u_trans * a_position;
}