mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add skybox
This commit is contained in:
parent
b486048d0c
commit
9da50b3f4d
@ -12,4 +12,4 @@ tracy-world-server = "-Zunstable-options run --bin veloren-server-cli --features
|
||||
test-voxygen = "run --bin veloren-voxygen --no-default-features --features gl,simd"
|
||||
tracy-voxygen = "-Zunstable-options run --bin veloren-voxygen --no-default-features --features tracy,gl,simd --profile no_overflow"
|
||||
server = "run --bin veloren-server-cli"
|
||||
|
||||
dbg-voxygen = "run --bin veloren-voxygen -Zunstable-options --profile debuginfo"
|
||||
|
@ -42,16 +42,9 @@ uniform u_locals {
|
||||
|
||||
layout(location = 0) out vec4 tgt_color;
|
||||
|
||||
float depth_at(vec2 uv) {
|
||||
float buf_depth = texture(sampler2D(t_src_depth, s_src_depth), uv).x;
|
||||
vec4 clip_space = vec4(uv * 2.0 - 1.0, buf_depth, 1.0);
|
||||
vec4 view_space = proj_mat_inv * clip_space;
|
||||
view_space /= view_space.w;
|
||||
return -view_space.z;
|
||||
}
|
||||
|
||||
vec3 wpos_at(vec2 uv) {
|
||||
float buf_depth = texture(sampler2D(t_src_depth, s_src_depth), uv).x * 2.0 - 1.0;
|
||||
float buf_depth = texture(sampler2D(t_src_depth, s_src_depth), uv).x;
|
||||
mat4 inv = view_mat_inv * proj_mat_inv;//inverse(all_mat);
|
||||
vec4 clip_space = vec4((uv * 2.0 - 1.0) * vec2(1, -1), buf_depth, 1.0);
|
||||
vec4 view_space = inv * clip_space;
|
||||
|
@ -149,30 +149,6 @@ vec3 _illuminate(float max_light, vec3 view_dir, /*vec3 max_light, */vec3 emitte
|
||||
// return /*srgb_to_linear*/(/*0.5*//*0.125 * */vec3(pow(color.x, gamma), pow(color.y, gamma), pow(color.z, gamma)));
|
||||
}
|
||||
|
||||
/*
|
||||
float depth_at(vec2 uv) {
|
||||
float buf_depth = texture(src_depth, uv).x;
|
||||
vec4 clip_space = vec4(uv * 2.0 - 1.0, buf_depth, 1.0);
|
||||
vec4 view_space = proj_mat_inv * clip_space;
|
||||
view_space /= view_space.w;
|
||||
return -view_space.z;
|
||||
}
|
||||
|
||||
vec3 wpos_at(vec2 uv) {
|
||||
float buf_depth = texture(src_depth, uv).x * 2.0 - 1.0;
|
||||
mat4 inv = view_mat_inv * proj_mat_inv;//inverse(all_mat);
|
||||
vec4 clip_space = vec4(uv * 2.0 - 1.0, buf_depth, 1.0);
|
||||
vec4 view_space = inv * clip_space;
|
||||
view_space /= view_space.w;
|
||||
if (buf_depth == 1.0) {
|
||||
vec3 direction = normalize(view_space.xyz);
|
||||
return direction.xyz * 100000.0 + cam_pos.xyz;
|
||||
} else {
|
||||
return view_space.xyz;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void main() {
|
||||
// TODO: precompute in the vertex shader?
|
||||
vec2 uv = (f_pos + 1.0) * 0.5;
|
||||
|
@ -23,19 +23,13 @@ layout(location = 0) in vec3 v_pos;
|
||||
layout(location = 0) out vec3 f_pos;
|
||||
|
||||
void main() {
|
||||
/* vec3 v_pos = v_pos;
|
||||
v_pos.y = -v_pos.y; */
|
||||
f_pos = v_pos;
|
||||
|
||||
// TODO: is this todo below still valid? is cam_pos jittery
|
||||
// TODO: Make this position-independent to avoid rounding error jittering
|
||||
gl_Position =
|
||||
/* proj_mat *
|
||||
view_mat * */
|
||||
all_mat *
|
||||
/* proj_mat *
|
||||
view_mat * */
|
||||
vec4(/*100000 * */v_pos + cam_pos.xyz, 1);
|
||||
// vec4(v_pos * (100000.0/* + 0.5*/) + cam_pos.xyz, 1);
|
||||
vec4(v_pos + cam_pos.xyz, 1);
|
||||
// gl_Position = vec4(gl_Position.xy, sign(gl_Position.z) * gl_Position.w, gl_Position.w);
|
||||
gl_Position.z = gl_Position.w;
|
||||
// gl_Position.z = gl_Position.w - 0.000001;//0.0;
|
||||
|
@ -5,7 +5,7 @@ use super::{
|
||||
instances::Instances,
|
||||
model::{DynamicModel, Model, SubModel},
|
||||
pipelines::{
|
||||
clouds, figure, fluid, particle, postprocess, sprite, terrain, ui, ColLights,
|
||||
clouds, figure, fluid, particle, postprocess, skybox, sprite, terrain, ui, ColLights,
|
||||
GlobalsBindGroup, Light, Shadow,
|
||||
},
|
||||
},
|
||||
@ -137,18 +137,12 @@ pub struct FirstPassDrawer<'a> {
|
||||
}
|
||||
|
||||
impl<'a> FirstPassDrawer<'a> {
|
||||
/*pub fn draw_skybox<'b: 'a>(
|
||||
&mut self,
|
||||
model: &'b Model,
|
||||
globals: &'b Consts<Globals>,
|
||||
verts: Range<u32>,
|
||||
) {
|
||||
pub fn draw_skybox<'b: 'a>(&mut self, model: &'b Model<skybox::Vertex>) {
|
||||
self.render_pass
|
||||
.set_pipeline(&self.renderer.skybox_pipeline.pipeline);
|
||||
self.render_pass.set_bind_group(0, &globals.bind_group, &[]);
|
||||
self.render_pass.set_vertex_buffer(0, &model.vbuf, 0, 0);
|
||||
self.render_pass.draw(verts, 0..1);
|
||||
}*/
|
||||
self.render_pass.set_vertex_buffer(0, model.buf().slice(..));
|
||||
self.render_pass.draw(0..model.len() as u32, 0..1);
|
||||
}
|
||||
|
||||
pub fn draw_figure<'b: 'a>(
|
||||
&mut self,
|
||||
|
@ -140,7 +140,7 @@ impl Camera {
|
||||
self.dependents.proj_mat_inv = self.dependents.proj_mat.inverted();
|
||||
|
||||
// TODO: Make this more efficient.
|
||||
self.dependents.cam_pos = Vec3::from(self.dependents.view_mat.inverted() * Vec4::unit_w());
|
||||
self.dependents.cam_pos = Vec3::from(self.dependents.view_mat_inv * Vec4::unit_w());
|
||||
self.frustum = Frustum::from_modelview_projection(
|
||||
(self.dependents.proj_mat
|
||||
* self.dependents.view_mat
|
||||
@ -148,7 +148,7 @@ impl Camera {
|
||||
.into_col_arrays(),
|
||||
);
|
||||
|
||||
self.dependents.cam_dir = Vec3::from(self.dependents.view_mat.inverted() * -Vec4::unit_z());
|
||||
self.dependents.cam_dir = Vec3::from(self.dependents.view_mat_inv * -Vec4::unit_z());
|
||||
}
|
||||
|
||||
pub fn frustum(&self) -> &Frustum<f32> { &self.frustum }
|
||||
|
@ -1034,7 +1034,7 @@ impl Scene {
|
||||
self.lod.render(renderer, global);*/
|
||||
|
||||
// Render the skybox.
|
||||
// TODO: renderer.render_skybox(&self.skybox.model, global, lod);
|
||||
drawer.draw_skybox(&self.skybox.model);
|
||||
|
||||
/*self.terrain.render_translucent(
|
||||
renderer,
|
||||
|
@ -353,6 +353,10 @@ impl Scene {
|
||||
body: Option<humanoid::Body>,
|
||||
inventory: Option<&Inventory>,
|
||||
) {
|
||||
// TODO: can probably be drawn last but it crashes when drawn first and we
|
||||
// should figure that out
|
||||
// drawer.draw_skybox(&self.skybox.model);
|
||||
|
||||
if let Some(body) = body {
|
||||
let model = &self.figure_model_cache.get_model(
|
||||
&self.col_lights,
|
||||
|
Loading…
Reference in New Issue
Block a user