mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add options to turn off the clouds and to render ugly water
This commit is contained in:
parent
54773b57b6
commit
9d6bf66a32
66
assets/voxygen/shaders/fluid-frag/cheap.glsl
Normal file
66
assets/voxygen/shaders/fluid-frag/cheap.glsl
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
#version 330 core
|
||||||
|
|
||||||
|
#include <globals.glsl>
|
||||||
|
#include <random.glsl>
|
||||||
|
|
||||||
|
in vec3 f_pos;
|
||||||
|
flat in uint f_pos_norm;
|
||||||
|
in vec3 f_col;
|
||||||
|
in float f_light;
|
||||||
|
|
||||||
|
layout (std140)
|
||||||
|
uniform u_locals {
|
||||||
|
vec3 model_offs;
|
||||||
|
float load_time;
|
||||||
|
};
|
||||||
|
|
||||||
|
uniform sampler2D t_waves;
|
||||||
|
|
||||||
|
out vec4 tgt_color;
|
||||||
|
|
||||||
|
#include <sky.glsl>
|
||||||
|
#include <light.glsl>
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
// First 3 normals are negative, next 3 are positive
|
||||||
|
vec3 normals[6] = vec3[]( vec3(-1,0,0), vec3(0,-1,0), vec3(0,0,-1), vec3(1,0,0), vec3(0,1,0), vec3(0,0,1) );
|
||||||
|
|
||||||
|
// TODO: last 3 bits in v_pos_norm should be a number between 0 and 5, rather than 0-2 and a direction.
|
||||||
|
uint norm_axis = (f_pos_norm >> 30) & 0x3u;
|
||||||
|
// Increase array access by 3 to access positive values
|
||||||
|
uint norm_dir = ((f_pos_norm >> 29) & 0x1u) * 3u;
|
||||||
|
// Use an array to avoid conditional branching
|
||||||
|
vec3 f_norm = normals[norm_axis + norm_dir];
|
||||||
|
|
||||||
|
vec3 cam_to_frag = normalize(f_pos - cam_pos.xyz);
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Round the position to the nearest triangular grid cell
|
||||||
|
vec3 hex_pos = f_pos * 2.0;
|
||||||
|
hex_pos = hex_pos + vec3(hex_pos.y * 1.4 / 3.0, hex_pos.y * 0.1, 0);
|
||||||
|
if (fract(hex_pos.x) > fract(hex_pos.y)) {
|
||||||
|
hex_pos += vec3(1.0, 1.0, 0);
|
||||||
|
}
|
||||||
|
hex_pos = floor(hex_pos);
|
||||||
|
*/
|
||||||
|
|
||||||
|
vec3 light, diffuse_light, ambient_light;
|
||||||
|
get_sun_diffuse(f_norm, time_of_day.x, light, diffuse_light, ambient_light, 0.0);
|
||||||
|
float point_shadow = shadow_at(f_pos,f_norm);
|
||||||
|
diffuse_light *= f_light * point_shadow;
|
||||||
|
ambient_light *= f_light, point_shadow;
|
||||||
|
vec3 point_light = light_at(f_pos, f_norm);
|
||||||
|
light += point_light;
|
||||||
|
diffuse_light += point_light;
|
||||||
|
vec3 surf_color = illuminate(srgb_to_linear(vec3(0.2, 0.2, 1.0)), light, diffuse_light, ambient_light);
|
||||||
|
|
||||||
|
float fog_level = fog(f_pos.xyz, focus_pos.xyz, medium.x);
|
||||||
|
vec4 clouds;
|
||||||
|
vec3 fog_color = get_sky_color(normalize(f_pos - cam_pos.xyz), time_of_day.x, cam_pos.xyz, f_pos, 0.25, true, clouds);
|
||||||
|
|
||||||
|
float passthrough = pow(dot(faceforward(f_norm, f_norm, cam_to_frag), -cam_to_frag), 0.5);
|
||||||
|
|
||||||
|
vec4 color = mix(vec4(surf_color, 1.0), vec4(surf_color, 1.0 / (1.0 + diffuse_light * 0.25)), passthrough);
|
||||||
|
|
||||||
|
tgt_color = mix(mix(color, vec4(fog_color, 0.0), fog_level), vec4(clouds.rgb, 0.0), clouds.a);
|
||||||
|
}
|
5
assets/voxygen/shaders/include/cloud/none.glsl
Normal file
5
assets/voxygen/shaders/include/cloud/none.glsl
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
uniform sampler2D t_noise;
|
||||||
|
|
||||||
|
vec4 get_cloud_color(vec3 dir, vec3 origin, float time_of_day, float max_dist, float quality) {
|
||||||
|
return vec4(0.0);
|
||||||
|
}
|
75
assets/voxygen/shaders/include/cloud/regular.glsl
Normal file
75
assets/voxygen/shaders/include/cloud/regular.glsl
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
uniform sampler2D t_noise;
|
||||||
|
|
||||||
|
const float CLOUD_AVG_HEIGHT = 1025.0;
|
||||||
|
const float CLOUD_HEIGHT_MIN = CLOUD_AVG_HEIGHT - 50.0;
|
||||||
|
const float CLOUD_HEIGHT_MAX = CLOUD_AVG_HEIGHT + 50.0;
|
||||||
|
const float CLOUD_THRESHOLD = 0.3;
|
||||||
|
const float CLOUD_SCALE = 5.0;
|
||||||
|
const float CLOUD_DENSITY = 50.0;
|
||||||
|
|
||||||
|
float vsum(vec3 v) {
|
||||||
|
return v.x + v.y + v.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 cloud_at(vec3 pos) {
|
||||||
|
float tick_offs = 0.0
|
||||||
|
+ texture(t_noise, pos.xy * 0.0001 - tick.x * 0.001).x * 0.5
|
||||||
|
+ texture(t_noise, pos.xy * 0.000003).x * 5.0;
|
||||||
|
|
||||||
|
float value = (
|
||||||
|
0.0
|
||||||
|
+ texture(t_noise, pos.xy / CLOUD_SCALE * 0.0003 + tick_offs).x
|
||||||
|
+ texture(t_noise, pos.xy / CLOUD_SCALE * 0.0009 - tick_offs).x * 0.5
|
||||||
|
+ texture(t_noise, pos.xy / CLOUD_SCALE * 0.0025 - tick.x * 0.01).x * 0.25
|
||||||
|
+ texture(t_noise, pos.xy / CLOUD_SCALE * 0.008 + tick.x * 0.02).x * 0.15
|
||||||
|
+ texture(t_noise, pos.xy / CLOUD_SCALE * 0.02 + tick_offs + tick.x * 0.02).x * 0.1
|
||||||
|
) / 3.0;
|
||||||
|
|
||||||
|
float density = max((value - CLOUD_THRESHOLD) - abs(pos.z - CLOUD_AVG_HEIGHT) / 400.0, 0.0) * CLOUD_DENSITY;
|
||||||
|
|
||||||
|
float shade = ((pos.z - CLOUD_AVG_HEIGHT) * 1.8 / (CLOUD_AVG_HEIGHT - CLOUD_HEIGHT_MIN) + 0.5);
|
||||||
|
|
||||||
|
return vec2(shade, density / (1.0 + vsum(abs(pos - cam_pos.xyz)) / 5000));
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 get_cloud_color(vec3 dir, vec3 origin, float time_of_day, float max_dist, float quality) {
|
||||||
|
|
||||||
|
const float INCR = 0.1;
|
||||||
|
|
||||||
|
float mind = (CLOUD_HEIGHT_MIN - origin.z) / dir.z;
|
||||||
|
float maxd = (CLOUD_HEIGHT_MAX - origin.z) / dir.z;
|
||||||
|
|
||||||
|
float start = max(min(mind, maxd), 0.0);
|
||||||
|
float delta = min(abs(mind - maxd), max_dist);
|
||||||
|
|
||||||
|
bool do_cast = true;
|
||||||
|
if (mind < 0.0 && maxd < 0.0) {
|
||||||
|
do_cast = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
float incr = INCR;
|
||||||
|
|
||||||
|
float fuzz = sin(texture(t_noise, dir.xz * 100000.0 + tick.x).x * 100.0) * incr * delta;
|
||||||
|
|
||||||
|
float cloud_shade = 1.0;
|
||||||
|
float passthrough = 1.0;
|
||||||
|
if (do_cast) {
|
||||||
|
for (float d = 0.0; d < 1.0; d += incr) {
|
||||||
|
float dist = start + d * delta;
|
||||||
|
dist += fuzz * pow(maxd - mind, 0.5) * 0.01 * min(pow(dist * 0.005, 2.0), 1.0);
|
||||||
|
|
||||||
|
vec3 pos = origin + dir * min(dist, max_dist);
|
||||||
|
vec2 sample = cloud_at(pos);
|
||||||
|
|
||||||
|
float integral = sample.y * incr;
|
||||||
|
passthrough *= max(1.0 - integral, 0.0);
|
||||||
|
cloud_shade = mix(cloud_shade, sample.x, passthrough * integral);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float total_density = 1.0 - passthrough / (1.0 + delta * 0.0001);
|
||||||
|
|
||||||
|
total_density = max(total_density - 1.0 / pow(max_dist, 0.25), 0.0); // Hack
|
||||||
|
|
||||||
|
return vec4(vec3(cloud_shade), total_density);
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
#include <random.glsl>
|
#include <random.glsl>
|
||||||
|
#include <cloud.glsl>
|
||||||
|
|
||||||
uniform sampler2D t_noise;
|
|
||||||
|
|
||||||
const float PI = 3.141592;
|
const float PI = 3.141592;
|
||||||
|
|
||||||
@ -114,80 +114,6 @@ float is_star_at(vec3 dir) {
|
|||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float CLOUD_AVG_HEIGHT = 1025.0;
|
|
||||||
const float CLOUD_HEIGHT_MIN = CLOUD_AVG_HEIGHT - 50.0;
|
|
||||||
const float CLOUD_HEIGHT_MAX = CLOUD_AVG_HEIGHT + 50.0;
|
|
||||||
const float CLOUD_THRESHOLD = 0.3;
|
|
||||||
const float CLOUD_SCALE = 5.0;
|
|
||||||
const float CLOUD_DENSITY = 50.0;
|
|
||||||
|
|
||||||
float vsum(vec3 v) {
|
|
||||||
return v.x + v.y + v.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
vec2 cloud_at(vec3 pos) {
|
|
||||||
float tick_offs = 0.0
|
|
||||||
+ texture(t_noise, pos.xy * 0.0001 - tick.x * 0.001).x * 0.5
|
|
||||||
+ texture(t_noise, pos.xy * 0.000003).x * 3.0;
|
|
||||||
|
|
||||||
float value = (
|
|
||||||
0.0
|
|
||||||
+ texture(t_noise, pos.xy / CLOUD_SCALE * 0.0003 + tick_offs).x
|
|
||||||
+ texture(t_noise, pos.xy / CLOUD_SCALE * 0.0009 - tick_offs).x * 0.5
|
|
||||||
+ texture(t_noise, pos.xy / CLOUD_SCALE * 0.0025 - tick.x * 0.01).x * 0.25
|
|
||||||
+ texture(t_noise, pos.xy / CLOUD_SCALE * 0.008 + tick.x * 0.02).x * 0.15
|
|
||||||
+ texture(t_noise, pos.xy / CLOUD_SCALE * 0.02 + tick_offs + tick.x * 0.02).x * 0.1
|
|
||||||
) / 3.0;
|
|
||||||
|
|
||||||
float density = max((value - CLOUD_THRESHOLD) - abs(pos.z - CLOUD_AVG_HEIGHT) / 400.0, 0.0) * CLOUD_DENSITY;
|
|
||||||
|
|
||||||
float shade = ((pos.z - CLOUD_AVG_HEIGHT) * 1.5 / (CLOUD_AVG_HEIGHT - CLOUD_HEIGHT_MIN) + 0.5);
|
|
||||||
|
|
||||||
return vec2(shade, density / (1.0 + vsum(abs(pos - cam_pos.xyz)) / 5000));
|
|
||||||
}
|
|
||||||
|
|
||||||
vec4 get_cloud_color(vec3 dir, vec3 origin, float time_of_day, float max_dist, float quality) {
|
|
||||||
|
|
||||||
const float INCR = 0.1;
|
|
||||||
|
|
||||||
float mind = (CLOUD_HEIGHT_MIN - origin.z) / dir.z;
|
|
||||||
float maxd = (CLOUD_HEIGHT_MAX - origin.z) / dir.z;
|
|
||||||
|
|
||||||
float start = max(min(mind, maxd), 0.0);
|
|
||||||
float delta = min(abs(mind - maxd), max_dist);
|
|
||||||
|
|
||||||
bool do_cast = true;
|
|
||||||
if (mind < 0.0 && maxd < 0.0) {
|
|
||||||
do_cast = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
float incr = INCR;
|
|
||||||
|
|
||||||
float fuzz = sin(texture(t_noise, dir.xz * 100000.0 + tick.x).x * 100.0) * incr * delta;
|
|
||||||
|
|
||||||
float cloud_shade = 1.0;
|
|
||||||
float passthrough = 1.0;
|
|
||||||
if (do_cast) {
|
|
||||||
for (float d = 0.0; d < 1.0; d += incr) {
|
|
||||||
float dist = start + d * delta;
|
|
||||||
dist += fuzz * pow(maxd - mind, 0.5) * 0.02 * min(pow(dist * 0.005, 2.0), 1.0);
|
|
||||||
|
|
||||||
vec3 pos = origin + dir * min(dist, max_dist);
|
|
||||||
vec2 sample = cloud_at(pos);
|
|
||||||
|
|
||||||
float integral = sample.y * incr;
|
|
||||||
passthrough *= max(1.0 - integral, 0.0);
|
|
||||||
cloud_shade = mix(cloud_shade, sample.x, passthrough * integral);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float total_density = 1.0 - passthrough / (1.0 + delta * 0.0001);
|
|
||||||
|
|
||||||
total_density = max(total_density - 1.0 / pow(max_dist, 0.25), 0.0); // Hack
|
|
||||||
|
|
||||||
return vec4(vec3(cloud_shade), total_density);
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 get_sky_color(vec3 dir, float time_of_day, vec3 origin, vec3 f_pos, float quality, bool with_stars, out vec4 clouds) {
|
vec3 get_sky_color(vec3 dir, float time_of_day, vec3 origin, vec3 f_pos, float quality, bool with_stars, out vec4 clouds) {
|
||||||
// Sky color
|
// Sky color
|
||||||
vec3 sun_dir = get_sun_dir(time_of_day);
|
vec3 sun_dir = get_sun_dir(time_of_day);
|
||||||
|
@ -36,7 +36,7 @@ use spell::Spell;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ecs::comp as vcomp,
|
ecs::comp as vcomp,
|
||||||
render::{AaMode, Consts, Globals, Renderer},
|
render::{AaMode, CloudMode, Consts, FluidMode, Globals, Renderer},
|
||||||
scene::camera::Camera,
|
scene::camera::Camera,
|
||||||
//settings::ControlSettings,
|
//settings::ControlSettings,
|
||||||
ui::{Graphic, Ingameable, ScaleMode, Ui},
|
ui::{Graphic, Ingameable, ScaleMode, Ui},
|
||||||
@ -205,6 +205,8 @@ pub enum Event {
|
|||||||
ChangeMaxFPS(u32),
|
ChangeMaxFPS(u32),
|
||||||
ChangeFOV(u16),
|
ChangeFOV(u16),
|
||||||
ChangeAaMode(AaMode),
|
ChangeAaMode(AaMode),
|
||||||
|
ChangeCloudMode(CloudMode),
|
||||||
|
ChangeFluidMode(FluidMode),
|
||||||
CrosshairTransp(f32),
|
CrosshairTransp(f32),
|
||||||
ChatTransp(f32),
|
ChatTransp(f32),
|
||||||
CrosshairType(CrosshairType),
|
CrosshairType(CrosshairType),
|
||||||
@ -1771,6 +1773,12 @@ impl Hud {
|
|||||||
settings_window::Event::ChangeAaMode(new_aa_mode) => {
|
settings_window::Event::ChangeAaMode(new_aa_mode) => {
|
||||||
events.push(Event::ChangeAaMode(new_aa_mode));
|
events.push(Event::ChangeAaMode(new_aa_mode));
|
||||||
}
|
}
|
||||||
|
settings_window::Event::ChangeCloudMode(new_cloud_mode) => {
|
||||||
|
events.push(Event::ChangeCloudMode(new_cloud_mode));
|
||||||
|
}
|
||||||
|
settings_window::Event::ChangeFluidMode(new_fluid_mode) => {
|
||||||
|
events.push(Event::ChangeFluidMode(new_fluid_mode));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ use super::{
|
|||||||
TEXT_COLOR,
|
TEXT_COLOR,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
render::AaMode,
|
render::{AaMode, CloudMode, FluidMode},
|
||||||
ui::{ImageSlider, ScaleMode, ToggleButton},
|
ui::{ImageSlider, ScaleMode, ToggleButton},
|
||||||
GlobalState,
|
GlobalState,
|
||||||
};
|
};
|
||||||
@ -87,6 +87,10 @@ widget_ids! {
|
|||||||
fov_value,
|
fov_value,
|
||||||
aa_mode_text,
|
aa_mode_text,
|
||||||
aa_mode_list,
|
aa_mode_list,
|
||||||
|
cloud_mode_text,
|
||||||
|
cloud_mode_list,
|
||||||
|
fluid_mode_text,
|
||||||
|
fluid_mode_list,
|
||||||
audio_volume_slider,
|
audio_volume_slider,
|
||||||
audio_volume_text,
|
audio_volume_text,
|
||||||
sfx_volume_slider,
|
sfx_volume_slider,
|
||||||
@ -188,6 +192,8 @@ pub enum Event {
|
|||||||
AdjustViewDistance(u32),
|
AdjustViewDistance(u32),
|
||||||
AdjustFOV(u16),
|
AdjustFOV(u16),
|
||||||
ChangeAaMode(AaMode),
|
ChangeAaMode(AaMode),
|
||||||
|
ChangeCloudMode(CloudMode),
|
||||||
|
ChangeFluidMode(FluidMode),
|
||||||
AdjustMusicVolume(f32),
|
AdjustMusicVolume(f32),
|
||||||
AdjustSfxVolume(f32),
|
AdjustSfxVolume(f32),
|
||||||
ChangeAudioDevice(String),
|
ChangeAudioDevice(String),
|
||||||
@ -1528,6 +1534,60 @@ impl<'a> Widget for SettingsWindow<'a> {
|
|||||||
{
|
{
|
||||||
events.push(Event::ChangeAaMode(mode_list[clicked]));
|
events.push(Event::ChangeAaMode(mode_list[clicked]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CloudMode
|
||||||
|
Text::new("Cloud Rendering Mode")
|
||||||
|
.down_from(state.ids.aa_mode_list, 8.0)
|
||||||
|
.font_size(14)
|
||||||
|
.font_id(self.fonts.cyri)
|
||||||
|
.color(TEXT_COLOR)
|
||||||
|
.set(state.ids.cloud_mode_text, ui);
|
||||||
|
|
||||||
|
let mode_list = [CloudMode::None, CloudMode::Regular];
|
||||||
|
let mode_label_list = ["None", "Regular"];
|
||||||
|
|
||||||
|
// Get which cloud rendering mode is currently active
|
||||||
|
let selected = mode_list
|
||||||
|
.iter()
|
||||||
|
.position(|x| *x == self.global_state.settings.graphics.cloud_mode);
|
||||||
|
|
||||||
|
if let Some(clicked) = DropDownList::new(&mode_label_list, selected)
|
||||||
|
.w_h(400.0, 22.0)
|
||||||
|
.color(MENU_BG)
|
||||||
|
.label_color(TEXT_COLOR)
|
||||||
|
.label_font_id(self.fonts.cyri)
|
||||||
|
.down_from(state.ids.cloud_mode_text, 8.0)
|
||||||
|
.set(state.ids.cloud_mode_list, ui)
|
||||||
|
{
|
||||||
|
events.push(Event::ChangeCloudMode(mode_list[clicked]));
|
||||||
|
}
|
||||||
|
|
||||||
|
// FluidMode
|
||||||
|
Text::new("Fluid Rendering Mode")
|
||||||
|
.down_from(state.ids.cloud_mode_list, 8.0)
|
||||||
|
.font_size(14)
|
||||||
|
.font_id(self.fonts.cyri)
|
||||||
|
.color(TEXT_COLOR)
|
||||||
|
.set(state.ids.fluid_mode_text, ui);
|
||||||
|
|
||||||
|
let mode_list = [FluidMode::Cheap, FluidMode::Shiny];
|
||||||
|
let mode_label_list = ["Cheap", "Shiny"];
|
||||||
|
|
||||||
|
// Get which fluid rendering mode is currently active
|
||||||
|
let selected = mode_list
|
||||||
|
.iter()
|
||||||
|
.position(|x| *x == self.global_state.settings.graphics.fluid_mode);
|
||||||
|
|
||||||
|
if let Some(clicked) = DropDownList::new(&mode_label_list, selected)
|
||||||
|
.w_h(400.0, 22.0)
|
||||||
|
.color(MENU_BG)
|
||||||
|
.label_color(TEXT_COLOR)
|
||||||
|
.label_font_id(self.fonts.cyri)
|
||||||
|
.down_from(state.ids.fluid_mode_text, 8.0)
|
||||||
|
.set(state.ids.fluid_mode_list, ui)
|
||||||
|
{
|
||||||
|
events.push(Event::ChangeFluidMode(mode_list[clicked]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5) Sound Tab -----------------------------------
|
// 5) Sound Tab -----------------------------------
|
||||||
|
@ -64,3 +64,17 @@ pub enum AaMode {
|
|||||||
MsaaX16,
|
MsaaX16,
|
||||||
SsaaX4,
|
SsaaX4,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Cloud modes
|
||||||
|
#[derive(PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)]
|
||||||
|
pub enum CloudMode {
|
||||||
|
None,
|
||||||
|
Regular,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Fluid modes
|
||||||
|
#[derive(PartialEq, Eq, Clone, Copy, Debug, Serialize, Deserialize)]
|
||||||
|
pub enum FluidMode {
|
||||||
|
Cheap,
|
||||||
|
Shiny,
|
||||||
|
}
|
||||||
|
@ -6,7 +6,7 @@ use super::{
|
|||||||
model::{DynamicModel, Model},
|
model::{DynamicModel, Model},
|
||||||
pipelines::{figure, fluid, postprocess, skybox, sprite, terrain, ui, Globals, Light, Shadow},
|
pipelines::{figure, fluid, postprocess, skybox, sprite, terrain, ui, Globals, Light, Shadow},
|
||||||
texture::Texture,
|
texture::Texture,
|
||||||
AaMode, Pipeline, RenderError,
|
AaMode, CloudMode, FluidMode, Pipeline, RenderError,
|
||||||
};
|
};
|
||||||
use common::assets::{self, watch::ReloadIndicator};
|
use common::assets::{self, watch::ReloadIndicator};
|
||||||
use gfx::{
|
use gfx::{
|
||||||
@ -75,6 +75,8 @@ pub struct Renderer {
|
|||||||
noise_tex: Texture<(gfx::format::R8, gfx::format::Unorm)>,
|
noise_tex: Texture<(gfx::format::R8, gfx::format::Unorm)>,
|
||||||
|
|
||||||
aa_mode: AaMode,
|
aa_mode: AaMode,
|
||||||
|
cloud_mode: CloudMode,
|
||||||
|
fluid_mode: FluidMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Renderer {
|
impl Renderer {
|
||||||
@ -85,6 +87,8 @@ impl Renderer {
|
|||||||
win_color_view: WinColorView,
|
win_color_view: WinColorView,
|
||||||
win_depth_view: WinDepthView,
|
win_depth_view: WinDepthView,
|
||||||
aa_mode: AaMode,
|
aa_mode: AaMode,
|
||||||
|
cloud_mode: CloudMode,
|
||||||
|
fluid_mode: FluidMode,
|
||||||
) -> Result<Self, RenderError> {
|
) -> Result<Self, RenderError> {
|
||||||
let mut shader_reload_indicator = ReloadIndicator::new();
|
let mut shader_reload_indicator = ReloadIndicator::new();
|
||||||
|
|
||||||
@ -96,7 +100,13 @@ impl Renderer {
|
|||||||
sprite_pipeline,
|
sprite_pipeline,
|
||||||
ui_pipeline,
|
ui_pipeline,
|
||||||
postprocess_pipeline,
|
postprocess_pipeline,
|
||||||
) = create_pipelines(&mut factory, aa_mode, &mut shader_reload_indicator)?;
|
) = create_pipelines(
|
||||||
|
&mut factory,
|
||||||
|
aa_mode,
|
||||||
|
cloud_mode,
|
||||||
|
fluid_mode,
|
||||||
|
&mut shader_reload_indicator,
|
||||||
|
)?;
|
||||||
|
|
||||||
let dims = win_color_view.get_dimensions();
|
let dims = win_color_view.get_dimensions();
|
||||||
let (tgt_color_view, tgt_depth_view, tgt_color_res) =
|
let (tgt_color_view, tgt_depth_view, tgt_color_res) =
|
||||||
@ -138,6 +148,8 @@ impl Renderer {
|
|||||||
noise_tex,
|
noise_tex,
|
||||||
|
|
||||||
aa_mode,
|
aa_mode,
|
||||||
|
cloud_mode,
|
||||||
|
fluid_mode,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,6 +190,32 @@ impl Renderer {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Change the cloud rendering mode
|
||||||
|
pub fn set_cloud_mode(&mut self, cloud_mode: CloudMode) -> Result<(), RenderError> {
|
||||||
|
self.cloud_mode = cloud_mode;
|
||||||
|
|
||||||
|
// Recreate render target
|
||||||
|
self.on_resize()?;
|
||||||
|
|
||||||
|
// Recreate pipelines with the new cloud mode
|
||||||
|
self.recreate_pipelines();
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Change the fluid rendering mode
|
||||||
|
pub fn set_fluid_mode(&mut self, fluid_mode: FluidMode) -> Result<(), RenderError> {
|
||||||
|
self.fluid_mode = fluid_mode;
|
||||||
|
|
||||||
|
// Recreate render target
|
||||||
|
self.on_resize()?;
|
||||||
|
|
||||||
|
// Recreate pipelines with the new fluid mode
|
||||||
|
self.recreate_pipelines();
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Resize internal render targets to match window render target dimensions.
|
/// Resize internal render targets to match window render target dimensions.
|
||||||
pub fn on_resize(&mut self) -> Result<(), RenderError> {
|
pub fn on_resize(&mut self) -> Result<(), RenderError> {
|
||||||
let dims = self.win_color_view.get_dimensions();
|
let dims = self.win_color_view.get_dimensions();
|
||||||
@ -278,6 +316,8 @@ impl Renderer {
|
|||||||
match create_pipelines(
|
match create_pipelines(
|
||||||
&mut self.factory,
|
&mut self.factory,
|
||||||
self.aa_mode,
|
self.aa_mode,
|
||||||
|
self.cloud_mode,
|
||||||
|
self.fluid_mode,
|
||||||
&mut self.shader_reload_indicator,
|
&mut self.shader_reload_indicator,
|
||||||
) {
|
) {
|
||||||
Ok((
|
Ok((
|
||||||
@ -658,6 +698,8 @@ struct GfxPipeline<P: gfx::pso::PipelineInit> {
|
|||||||
fn create_pipelines(
|
fn create_pipelines(
|
||||||
factory: &mut gfx_backend::Factory,
|
factory: &mut gfx_backend::Factory,
|
||||||
aa_mode: AaMode,
|
aa_mode: AaMode,
|
||||||
|
cloud_mode: CloudMode,
|
||||||
|
fluid_mode: FluidMode,
|
||||||
shader_reload_indicator: &mut ReloadIndicator,
|
shader_reload_indicator: &mut ReloadIndicator,
|
||||||
) -> Result<
|
) -> Result<
|
||||||
(
|
(
|
||||||
@ -703,6 +745,19 @@ fn create_pipelines(
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
let cloud = assets::load_watched::<String>(
|
||||||
|
&[
|
||||||
|
"voxygen.shaders.include.cloud.",
|
||||||
|
match cloud_mode {
|
||||||
|
CloudMode::None => "none",
|
||||||
|
CloudMode::Regular => "regular",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
.concat(),
|
||||||
|
shader_reload_indicator,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let mut include_ctx = IncludeContext::new();
|
let mut include_ctx = IncludeContext::new();
|
||||||
include_ctx.include("globals.glsl", &globals);
|
include_ctx.include("globals.glsl", &globals);
|
||||||
include_ctx.include("sky.glsl", &sky);
|
include_ctx.include("sky.glsl", &sky);
|
||||||
@ -710,6 +765,7 @@ fn create_pipelines(
|
|||||||
include_ctx.include("srgb.glsl", &srgb);
|
include_ctx.include("srgb.glsl", &srgb);
|
||||||
include_ctx.include("random.glsl", &random);
|
include_ctx.include("random.glsl", &random);
|
||||||
include_ctx.include("anti-aliasing.glsl", &anti_alias);
|
include_ctx.include("anti-aliasing.glsl", &anti_alias);
|
||||||
|
include_ctx.include("cloud.glsl", &cloud);
|
||||||
|
|
||||||
// Construct a pipeline for rendering skyboxes
|
// Construct a pipeline for rendering skyboxes
|
||||||
let skybox_pipeline = create_pipeline(
|
let skybox_pipeline = create_pipeline(
|
||||||
@ -753,8 +809,18 @@ fn create_pipelines(
|
|||||||
fluid::pipe::new(),
|
fluid::pipe::new(),
|
||||||
&assets::load_watched::<String>("voxygen.shaders.fluid-vert", shader_reload_indicator)
|
&assets::load_watched::<String>("voxygen.shaders.fluid-vert", shader_reload_indicator)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
&assets::load_watched::<String>("voxygen.shaders.fluid-frag", shader_reload_indicator)
|
&assets::load_watched::<String>(
|
||||||
.unwrap(),
|
&[
|
||||||
|
"voxygen.shaders.fluid-frag.",
|
||||||
|
match fluid_mode {
|
||||||
|
FluidMode::Cheap => "cheap",
|
||||||
|
FluidMode::Shiny => "shiny",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
.concat(),
|
||||||
|
shader_reload_indicator,
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
&include_ctx,
|
&include_ctx,
|
||||||
gfx::state::CullFace::Nothing,
|
gfx::state::CullFace::Nothing,
|
||||||
)?;
|
)?;
|
||||||
|
@ -540,6 +540,26 @@ impl PlayState for SessionState {
|
|||||||
global_state.settings.graphics.aa_mode = new_aa_mode;
|
global_state.settings.graphics.aa_mode = new_aa_mode;
|
||||||
global_state.settings.save_to_file_warn();
|
global_state.settings.save_to_file_warn();
|
||||||
}
|
}
|
||||||
|
HudEvent::ChangeCloudMode(new_cloud_mode) => {
|
||||||
|
// Do this first so if it crashes the setting isn't saved :)
|
||||||
|
global_state
|
||||||
|
.window
|
||||||
|
.renderer_mut()
|
||||||
|
.set_cloud_mode(new_cloud_mode)
|
||||||
|
.unwrap();
|
||||||
|
global_state.settings.graphics.cloud_mode = new_cloud_mode;
|
||||||
|
global_state.settings.save_to_file_warn();
|
||||||
|
}
|
||||||
|
HudEvent::ChangeFluidMode(new_fluid_mode) => {
|
||||||
|
// Do this first so if it crashes the setting isn't saved :)
|
||||||
|
global_state
|
||||||
|
.window
|
||||||
|
.renderer_mut()
|
||||||
|
.set_fluid_mode(new_fluid_mode)
|
||||||
|
.unwrap();
|
||||||
|
global_state.settings.graphics.fluid_mode = new_fluid_mode;
|
||||||
|
global_state.settings.save_to_file_warn();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
hud::{BarNumbers, CrosshairType, Intro, ShortcutNumbers, XpBar},
|
hud::{BarNumbers, CrosshairType, Intro, ShortcutNumbers, XpBar},
|
||||||
render::AaMode,
|
render::{AaMode, CloudMode, FluidMode},
|
||||||
ui::ScaleMode,
|
ui::ScaleMode,
|
||||||
window::KeyMouse,
|
window::KeyMouse,
|
||||||
};
|
};
|
||||||
@ -182,6 +182,8 @@ pub struct GraphicsSettings {
|
|||||||
pub max_fps: u32,
|
pub max_fps: u32,
|
||||||
pub fov: u16,
|
pub fov: u16,
|
||||||
pub aa_mode: AaMode,
|
pub aa_mode: AaMode,
|
||||||
|
pub cloud_mode: CloudMode,
|
||||||
|
pub fluid_mode: FluidMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for GraphicsSettings {
|
impl Default for GraphicsSettings {
|
||||||
@ -191,6 +193,8 @@ impl Default for GraphicsSettings {
|
|||||||
max_fps: 60,
|
max_fps: 60,
|
||||||
fov: 50,
|
fov: 50,
|
||||||
aa_mode: AaMode::Fxaa,
|
aa_mode: AaMode::Fxaa,
|
||||||
|
cloud_mode: CloudMode::Regular,
|
||||||
|
fluid_mode: FluidMode::Shiny,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -241,6 +241,8 @@ impl Window {
|
|||||||
win_color_view,
|
win_color_view,
|
||||||
win_depth_view,
|
win_depth_view,
|
||||||
settings.graphics.aa_mode,
|
settings.graphics.aa_mode,
|
||||||
|
settings.graphics.cloud_mode,
|
||||||
|
settings.graphics.fluid_mode,
|
||||||
)?,
|
)?,
|
||||||
window,
|
window,
|
||||||
cursor_grabbed: false,
|
cursor_grabbed: false,
|
||||||
|
Loading…
Reference in New Issue
Block a user