mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Reduced size of terrain sprite vertices
This commit is contained in:
parent
c05f4fe009
commit
37301706d4
@ -4,9 +4,8 @@
|
||||
#include <srgb.glsl>
|
||||
|
||||
in vec3 v_pos;
|
||||
in vec3 v_norm;
|
||||
in vec3 v_col;
|
||||
in float v_ao;
|
||||
in uint v_col;
|
||||
in uint v_norm_ao;
|
||||
in vec4 inst_mat0;
|
||||
in vec4 inst_mat1;
|
||||
in vec4 inst_mat2;
|
||||
@ -41,10 +40,13 @@ void main() {
|
||||
0.0
|
||||
) * pow(abs(v_pos.z) * SCALE, 1.3) * 0.2;
|
||||
|
||||
f_norm = (inst_mat * vec4(v_norm, 0)).xyz;
|
||||
// First 3 normals are negative, next 3 are positive
|
||||
vec3 normals[6] = vec3[](vec3(-1,0,0), vec3(1,0,0), vec3(0,-1,0), vec3(0,1,0), vec3(0,0,-1), vec3(0,0,1));
|
||||
f_norm = (inst_mat * vec4(normals[(v_norm_ao >> 0) & 0x7u], 0)).xyz;
|
||||
|
||||
f_col = srgb_to_linear(v_col) * srgb_to_linear(inst_col);
|
||||
f_ao = v_ao;
|
||||
vec3 col = vec3((uvec3(v_col) >> uvec3(0, 8, 16)) & uvec3(0xFFu)) / 255.0;
|
||||
f_col = srgb_to_linear(col) * srgb_to_linear(inst_col);
|
||||
f_ao = float((v_norm_ao >> 3) & 0x3u) / 4.0;
|
||||
|
||||
// Select glowing
|
||||
if (select_pos.w > 0 && select_pos.xyz == floor(sprite_pos)) {
|
||||
|
@ -12,9 +12,12 @@ use vek::*;
|
||||
gfx_defines! {
|
||||
vertex Vertex {
|
||||
pos: [f32; 3] = "v_pos",
|
||||
norm: [f32; 3] = "v_norm",
|
||||
col: [f32; 3] = "v_col",
|
||||
ao: f32 = "v_ao",
|
||||
// ____BBBBBBBBGGGGGGGGRRRRRRRR
|
||||
col: u32 = "v_col",
|
||||
// ...AANNN
|
||||
// A = AO
|
||||
// N = Normal
|
||||
norm_ao: u32 = "v_norm_ao",
|
||||
}
|
||||
|
||||
vertex Instance {
|
||||
@ -43,11 +46,18 @@ gfx_defines! {
|
||||
|
||||
impl Vertex {
|
||||
pub fn new(pos: Vec3<f32>, norm: Vec3<f32>, col: Rgb<f32>, ao: f32) -> Self {
|
||||
let norm_bits = if norm.x != 0.0 {
|
||||
if norm.x < 0.0 { 0 } else { 1 }
|
||||
} else if norm.y != 0.0 {
|
||||
if norm.y < 0.0 { 2 } else { 3 }
|
||||
} else {
|
||||
if norm.z < 0.0 { 4 } else { 5 }
|
||||
};
|
||||
|
||||
Self {
|
||||
pos: pos.into_array(),
|
||||
col: col.into_array(),
|
||||
norm: norm.into_array(),
|
||||
ao,
|
||||
col: col.map2(Rgb::new(0, 8, 16), |e, shift| ((e * 255.0) as u32) << shift).reduce_bitor(),
|
||||
norm_ao: norm_bits | (((ao * 3.9999) as u32) << 3),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -569,7 +569,8 @@ impl PlayState for SessionState {
|
||||
global_state.settings.save_to_file_warn();
|
||||
},
|
||||
HudEvent::AdjustSpriteRenderDistance(sprite_render_distance) => {
|
||||
global_state.settings.graphics.sprite_render_distance = sprite_render_distance;
|
||||
global_state.settings.graphics.sprite_render_distance =
|
||||
sprite_render_distance;
|
||||
global_state.settings.save_to_file_warn();
|
||||
},
|
||||
HudEvent::CrosshairTransp(crosshair_transp) => {
|
||||
@ -714,7 +715,8 @@ impl PlayState for SessionState {
|
||||
thread_pool: client.thread_pool(),
|
||||
gamma: global_state.settings.graphics.gamma,
|
||||
mouse_smoothing: global_state.settings.gameplay.smooth_pan_enable,
|
||||
sprite_render_distance: global_state.settings.graphics.sprite_render_distance as f32,
|
||||
sprite_render_distance: global_state.settings.graphics.sprite_render_distance
|
||||
as f32,
|
||||
};
|
||||
|
||||
// Runs if either in a multiplayer server or the singleplayer server is unpaused
|
||||
@ -732,7 +734,13 @@ impl PlayState for SessionState {
|
||||
// Clear the screen
|
||||
renderer.clear();
|
||||
// Render the screen using the global renderer
|
||||
self.scene.render(renderer, client.state(), client.entity(), client.get_tick(), &scene_data);
|
||||
self.scene.render(
|
||||
renderer,
|
||||
client.state(),
|
||||
client.entity(),
|
||||
client.get_tick(),
|
||||
&scene_data,
|
||||
);
|
||||
// Draw the UI to the screen
|
||||
self.hud.render(renderer, self.scene.globals());
|
||||
// Finish the frame
|
||||
|
Loading…
Reference in New Issue
Block a user