Blend!
This commit is contained in:
parent
dff5745652
commit
cd96691c35
|
|
@ -3,11 +3,12 @@ use std::{collections::HashSet, time::Instant};
|
|||
use glam::{mat4, vec2, vec3, vec4, Mat4, Quat, Vec2, Vec3};
|
||||
use glium::{
|
||||
backend::{glutin::SimpleWindowBuilder, Facade},
|
||||
glutin::config::ConfigTemplateBuilder,
|
||||
implement_vertex,
|
||||
index::PrimitiveType,
|
||||
uniform,
|
||||
winit::event::{Event, WindowEvent},
|
||||
Program, Surface, VertexBuffer,
|
||||
DrawParameters, Program, Surface, VertexBuffer,
|
||||
};
|
||||
use winit::{
|
||||
event::ElementState,
|
||||
|
|
@ -99,7 +100,9 @@ fn prepare_scene(display: &impl Facade) -> Vec<Wireframe> {
|
|||
|
||||
fn main() {
|
||||
let event_loop = EventLoop::builder().build().unwrap();
|
||||
let cfg = ConfigTemplateBuilder::new().with_multisampling(8);
|
||||
let (window, display) = SimpleWindowBuilder::new()
|
||||
.with_config_template_builder(cfg)
|
||||
.with_title("Refraction: Wireframe")
|
||||
.build(&event_loop);
|
||||
|
||||
|
|
@ -178,7 +181,7 @@ fn main() {
|
|||
* Mat4::from_translation(-cam_pos);
|
||||
|
||||
let mut target = display.draw();
|
||||
target.clear_color(0.0, 0.0, 0.2, 1.0);
|
||||
target.clear_color(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
let mvp = proj * view;
|
||||
let uniforms = uniform! {
|
||||
|
|
@ -194,6 +197,22 @@ fn main() {
|
|||
&Default::default(),
|
||||
)
|
||||
.unwrap();
|
||||
let params = DrawParameters {
|
||||
blend: glium::Blend {
|
||||
color: glium::BlendingFunction::Addition {
|
||||
source: glium::LinearBlendingFactor::One,
|
||||
destination: glium::LinearBlendingFactor::OneMinusSourceAlpha,
|
||||
},
|
||||
alpha: glium::BlendingFunction::Addition {
|
||||
source: glium::LinearBlendingFactor::One,
|
||||
destination: glium::LinearBlendingFactor::OneMinusSourceAlpha,
|
||||
},
|
||||
constant_value: (0., 0., 0., 0.),
|
||||
},
|
||||
line_width: Some(3.),
|
||||
smooth: Some(glium::Smooth::Nicest),
|
||||
..Default::default()
|
||||
};
|
||||
for mesh in &scene {
|
||||
let uniforms = uniform! {
|
||||
mvp: mvp.to_cols_array_2d(),
|
||||
|
|
@ -201,13 +220,7 @@ fn main() {
|
|||
};
|
||||
let indices = glium::index::NoIndices(mesh.mode);
|
||||
target
|
||||
.draw(
|
||||
&mesh.data,
|
||||
&indices,
|
||||
&program,
|
||||
&uniforms,
|
||||
&Default::default(),
|
||||
)
|
||||
.draw(&mesh.data, &indices, &program, &uniforms, ¶ms)
|
||||
.unwrap();
|
||||
}
|
||||
target.finish().unwrap();
|
||||
|
|
|
|||
|
|
@ -5,5 +5,6 @@ in vec3 vertex_color;
|
|||
out vec4 color;
|
||||
|
||||
void main() {
|
||||
color = vec4(vertex_color, 1.0);
|
||||
float opacity = pow(0.5 - 0.5 * gl_FragCoord.z, 0.25);
|
||||
color = opacity * vec4(vertex_color, 1.0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user