fix entities shading
This commit is contained in:
+11
-14
@@ -1,17 +1,17 @@
|
||||
in float a_distance;
|
||||
in vec4 a_color;
|
||||
in vec2 a_texCoord;
|
||||
in vec3 a_position;
|
||||
in vec3 a_dir;
|
||||
in vec3 a_normal;
|
||||
in vec3 a_realnormal;
|
||||
in vec4 a_modelpos;
|
||||
in float a_fog;
|
||||
|
||||
layout (location = 0) out vec4 f_color;
|
||||
layout (location = 1) out vec4 f_position;
|
||||
layout (location = 2) out vec4 f_normal;
|
||||
|
||||
in float a_distance;
|
||||
in float a_fog;
|
||||
in vec2 a_texCoord;
|
||||
in vec3 a_dir;
|
||||
in vec3 a_normal;
|
||||
in vec3 a_position;
|
||||
in vec3 a_realnormal;
|
||||
in vec4 a_color;
|
||||
in vec4 a_modelpos;
|
||||
|
||||
uniform sampler2D u_texture0;
|
||||
uniform samplerCube u_skybox;
|
||||
uniform vec3 u_fogColor;
|
||||
@@ -20,8 +20,6 @@ uniform float u_fogCurve;
|
||||
uniform bool u_alphaClip;
|
||||
uniform vec3 u_sunDir;
|
||||
|
||||
uniform bool u_enableShadows;
|
||||
|
||||
#include <shadows>
|
||||
|
||||
void main() {
|
||||
@@ -33,8 +31,7 @@ void main() {
|
||||
if (alpha < (u_alphaClip ? 0.5f : 0.15f)) {
|
||||
discard;
|
||||
}
|
||||
f_color = a_color * tex_color;
|
||||
f_color.rgb *= shadow;
|
||||
f_color = a_color * tex_color * shadow;
|
||||
f_color = mix(f_color, vec4(fogColor, 1.0), a_fog);
|
||||
f_color.a = alpha;
|
||||
f_position = vec4(a_position, 1.0);
|
||||
|
||||
@@ -4,6 +4,7 @@ layout (location = 0) in vec3 v_position;
|
||||
layout (location = 1) in vec2 v_texCoord;
|
||||
layout (location = 2) in vec3 v_color;
|
||||
layout (location = 3) in vec4 v_light;
|
||||
layout (location = 4) in vec4 v_normal;
|
||||
|
||||
out float a_distance;
|
||||
out float a_fog;
|
||||
@@ -34,8 +35,8 @@ void main() {
|
||||
vec3 pos3d = a_modelpos.xyz - u_cameraPos;
|
||||
a_modelpos.xyz = apply_planet_curvature(a_modelpos.xyz, pos3d);
|
||||
|
||||
a_normal = vec3(0.0, 1.0, 0.0);//v_normal.xyz * 2.0 - 1.0;
|
||||
a_realnormal = a_normal;
|
||||
a_realnormal = v_normal.xyz * 2.0 - 1.0;
|
||||
a_normal = calc_screen_normal(a_realnormal);
|
||||
|
||||
vec3 light = v_light.rgb;
|
||||
float torchlight = calc_torch_light(a_realnormal, a_modelpos.xyz);
|
||||
|
||||
@@ -8,7 +8,8 @@ uniform float u_weatherFogDencity;
|
||||
uniform float u_weatherFogCurve;
|
||||
|
||||
float calc_torch_light(vec3 normal, vec3 modelpos) {
|
||||
return max(0.0, 1.0 - distance(u_cameraPos, modelpos) / u_torchlightDistance) * max(0.0, -dot(normal, normalize(modelpos - u_cameraPos)));
|
||||
return max(0.0, 1.0 - distance(u_cameraPos, modelpos) / u_torchlightDistance)
|
||||
* max(0.0, -dot(normal, normalize(modelpos - u_cameraPos)));
|
||||
}
|
||||
|
||||
vec3 calc_screen_normal(vec3 normal) {
|
||||
|
||||
@@ -3,15 +3,15 @@ layout (location = 1) out vec4 f_position;
|
||||
layout (location = 2) out vec4 f_normal;
|
||||
|
||||
in float a_distance;
|
||||
in vec4 a_torchLight;
|
||||
in vec3 a_skyLight;
|
||||
in vec2 a_texCoord;
|
||||
in float a_fog;
|
||||
in vec3 a_position;
|
||||
in vec2 a_texCoord;
|
||||
in vec3 a_dir;
|
||||
in vec3 a_normal;
|
||||
in vec3 a_position;
|
||||
in vec3 a_realnormal;
|
||||
in vec3 a_skyLight;
|
||||
in vec4 a_modelpos;
|
||||
in vec4 a_torchLight;
|
||||
|
||||
uniform sampler2D u_texture0;
|
||||
uniform samplerCube u_skybox;
|
||||
@@ -21,7 +21,6 @@ uniform vec3 u_sunDir;
|
||||
uniform bool u_alphaClip;
|
||||
uniform bool u_debugLights;
|
||||
uniform bool u_debugNormals;
|
||||
uniform bool u_enableShadows;
|
||||
|
||||
#include <shadows>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user