update main shader
This commit is contained in:
parent
35cf07b0f0
commit
8dfc948fe3
@ -1,20 +1,18 @@
|
|||||||
in vec4 a_color;
|
in vec4 a_color;
|
||||||
in vec2 a_texCoord;
|
in vec2 a_texCoord;
|
||||||
in float a_distance;
|
in float a_distance;
|
||||||
|
in float a_fog;
|
||||||
in vec3 a_dir;
|
in vec3 a_dir;
|
||||||
out vec4 f_color;
|
out vec4 f_color;
|
||||||
|
|
||||||
uniform sampler2D u_texture0;
|
uniform sampler2D u_texture0;
|
||||||
uniform samplerCube u_cubemap;
|
uniform samplerCube u_cubemap;
|
||||||
uniform vec3 u_fogColor;
|
uniform vec3 u_fogColor;
|
||||||
uniform float u_fogFactor;
|
|
||||||
uniform float u_fogCurve;
|
|
||||||
uniform bool u_alphaClip;
|
uniform bool u_alphaClip;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec3 fogColor = texture(u_cubemap, a_dir).rgb;
|
vec3 fogColor = texture(u_cubemap, a_dir).rgb;
|
||||||
vec4 tex_color = texture(u_texture0, a_texCoord);
|
vec4 tex_color = texture(u_texture0, a_texCoord);
|
||||||
float depth = (a_distance/256.0);
|
|
||||||
float alpha = a_color.a * tex_color.a;
|
float alpha = a_color.a * tex_color.a;
|
||||||
if (u_alphaClip) {
|
if (u_alphaClip) {
|
||||||
if (alpha < 0.2f)
|
if (alpha < 0.2f)
|
||||||
@ -24,7 +22,6 @@ void main() {
|
|||||||
if (alpha < 0.002f)
|
if (alpha < 0.002f)
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
f_color = mix(a_color * tex_color, vec4(fogColor,1.0),
|
f_color = mix(a_color * tex_color, vec4(fogColor,1.0), a_fog);
|
||||||
min(1.0, pow(depth*u_fogFactor, u_fogCurve)));
|
|
||||||
f_color.a = alpha;
|
f_color.a = alpha;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ layout (location = 2) in float v_light;
|
|||||||
out vec4 a_color;
|
out vec4 a_color;
|
||||||
out vec2 a_texCoord;
|
out vec2 a_texCoord;
|
||||||
out float a_distance;
|
out float a_distance;
|
||||||
|
out float a_fog;
|
||||||
out vec3 a_dir;
|
out vec3 a_dir;
|
||||||
|
|
||||||
uniform mat4 u_model;
|
uniform mat4 u_model;
|
||||||
@ -14,6 +15,10 @@ uniform mat4 u_proj;
|
|||||||
uniform mat4 u_view;
|
uniform mat4 u_view;
|
||||||
uniform vec3 u_cameraPos;
|
uniform vec3 u_cameraPos;
|
||||||
uniform float u_gamma;
|
uniform float u_gamma;
|
||||||
|
uniform float u_fogFactor;
|
||||||
|
uniform float u_fogCurve;
|
||||||
|
uniform float u_weatherFogOpacity;
|
||||||
|
uniform float u_weatherFogDencity;
|
||||||
uniform samplerCube u_cubemap;
|
uniform samplerCube u_cubemap;
|
||||||
|
|
||||||
uniform vec3 u_torchlightColor;
|
uniform vec3 u_torchlightColor;
|
||||||
@ -35,6 +40,10 @@ void main() {
|
|||||||
a_dir = modelpos.xyz - u_cameraPos;
|
a_dir = modelpos.xyz - u_cameraPos;
|
||||||
vec3 skyLightColor = pick_sky_color(u_cubemap);
|
vec3 skyLightColor = pick_sky_color(u_cubemap);
|
||||||
a_color.rgb = max(a_color.rgb, skyLightColor.rgb*decomp_light.a);
|
a_color.rgb = max(a_color.rgb, skyLightColor.rgb*decomp_light.a);
|
||||||
|
|
||||||
a_distance = length(u_view * u_model * vec4(pos3d * FOG_POS_SCALE, 0.0));
|
a_distance = length(u_view * u_model * vec4(pos3d * FOG_POS_SCALE, 0.0));
|
||||||
|
float depth = (a_distance / 256.0);
|
||||||
|
a_fog = min(1.0, max(pow(depth * u_fogFactor, u_fogCurve),
|
||||||
|
min(depth * u_weatherFogDencity, u_weatherFogOpacity)));
|
||||||
gl_Position = u_proj * u_view * modelpos;
|
gl_Position = u_proj * u_view * modelpos;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -97,6 +97,7 @@ void PrecipitationRenderer::render(const Camera& camera, float delta) {
|
|||||||
|
|
||||||
WeatherPreset weather {};
|
WeatherPreset weather {};
|
||||||
auto& fall = weather.fall;
|
auto& fall = weather.fall;
|
||||||
|
fall.vspeed = 2.0f;
|
||||||
fall.texture = "misc/rain";
|
fall.texture = "misc/rain";
|
||||||
|
|
||||||
const int radius = 6;
|
const int radius = 6;
|
||||||
|
|||||||
@ -119,6 +119,8 @@ void WorldRenderer::setupWorldShader(
|
|||||||
shader.uniform1f("u_gamma", settings.graphics.gamma.get());
|
shader.uniform1f("u_gamma", settings.graphics.gamma.get());
|
||||||
shader.uniform1f("u_fogFactor", fogFactor);
|
shader.uniform1f("u_fogFactor", fogFactor);
|
||||||
shader.uniform1f("u_fogCurve", settings.graphics.fogCurve.get());
|
shader.uniform1f("u_fogCurve", settings.graphics.fogCurve.get());
|
||||||
|
shader.uniform1f("u_weatherFogOpacity", 0.8f);
|
||||||
|
shader.uniform1f("u_weatherFogDencity", 2.0f);
|
||||||
shader.uniform1f("u_dayTime", level.getWorld()->getInfo().daytime);
|
shader.uniform1f("u_dayTime", level.getWorld()->getInfo().daytime);
|
||||||
shader.uniform2f("u_lightDir", skybox->getLightDir());
|
shader.uniform2f("u_lightDir", skybox->getLightDir());
|
||||||
shader.uniform3f("u_cameraPos", camera.position);
|
shader.uniform3f("u_cameraPos", camera.position);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user