Skip to content

Commit

Permalink
Merge branch 'main' into post-processing-example
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrixyz committed Jun 2, 2022
2 parents 3de0f90 + f487407 commit 6b69e18
Show file tree
Hide file tree
Showing 159 changed files with 5,384 additions and 1,916 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release

# how to trigger: https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
on:
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install cargo-release
run: cargo install cargo-release

- name: Setup release
run: |
git config user.name 'Bevy Auto Releaser'
git config user.email 'bevy@users.noreply.github.com'
# --workspace: updating all crates in the workspace
# --no-publish: do not publish to crates.io
# --execute: not a dry run
# --no-tag: do not push tag for each new version
# --no-push: do not push the update commits
# --exclude: ignore those packages
cargo release minor \
--workspace \
--no-publish \
--execute \
--no-tag \
--no-confirm \
--no-push \
--exclude ci \
--exclude errors \
--exclude bevy-ios-example
- name: Create PR
uses: peter-evans/create-pull-request@v3
with:
delete-branch: true
base: "main"
title: "Preparing Next Release"
body: |
Preparing next release
This PR has been auto-generated
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.8.0-dev"
edition = "2021"
categories = ["game-engines", "graphics", "gui", "rendering"]
description = "A refreshingly simple data-driven game engine and app framework"
exclude = ["assets/**/*", "tools/**/*", ".github/**/*", "crates/**/*"]
exclude = ["assets/", "tools/", ".github/", "crates/", "examples/wasm/assets/"]
homepage = "https://bevyengine.org"
keywords = ["game", "engine", "gamedev", "graphics", "bevy"]
license = "MIT OR Apache-2.0"
Expand Down
4 changes: 2 additions & 2 deletions assets/shaders/animate_shader.wgsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import bevy_pbr::mesh_view_bind_group
#import bevy_pbr::mesh_struct
#import bevy_pbr::mesh_types
#import bevy_pbr::mesh_view_bindings

[[group(1), binding(0)]]
var<uniform> mesh: Mesh;
Expand Down
2 changes: 1 addition & 1 deletion assets/shaders/custom_material_screenspace_texture.wgsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import bevy_pbr::mesh_view_bind_group
#import bevy_pbr::mesh_view_bindings

[[group(1), binding(0)]]
var texture: texture_2d<f32>;
Expand Down
7 changes: 2 additions & 5 deletions assets/shaders/custom_vertex_attribute.wgsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import bevy_pbr::mesh_view_bind_group
#import bevy_pbr::mesh_struct
#import bevy_pbr::mesh_view_bindings
#import bevy_pbr::mesh_bindings

struct Vertex {
[[location(0)]] position: vec3<f32>;
Expand All @@ -12,9 +12,6 @@ struct CustomMaterial {
[[group(1), binding(0)]]
var<uniform> material: CustomMaterial;

[[group(2), binding(0)]]
var<uniform> mesh: Mesh;

struct VertexOutput {
[[builtin(position)]] clip_position: vec4<f32>;
[[location(0)]] blend_color: vec4<f32>;
Expand Down
4 changes: 2 additions & 2 deletions assets/shaders/instancing.wgsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import bevy_pbr::mesh_view_bind_group
#import bevy_pbr::mesh_struct
#import bevy_pbr::mesh_types
#import bevy_pbr::mesh_view_bindings

[[group(1), binding(0)]]
var<uniform> mesh: Mesh;
Expand Down
6 changes: 3 additions & 3 deletions assets/shaders/shader_defs.wgsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import bevy_pbr::mesh_view_bind_group
#import bevy_pbr::mesh_struct
#import bevy_pbr::mesh_types
#import bevy_pbr::mesh_view_bindings

[[group(1), binding(0)]]
var<uniform> mesh: Mesh;
Expand All @@ -26,7 +26,7 @@ fn vertex(vertex: Vertex) -> VertexOutput {
[[stage(fragment)]]
fn fragment() -> [[location(0)]] vec4<f32> {
var color = vec4<f32>(0.0, 0.0, 1.0, 1.0);
# ifdef IS_RED
# ifdef IS_RED
color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
# endif
return color;
Expand Down
5 changes: 5 additions & 0 deletions crates/bevy_core_pipeline/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ trace = []
# bevy
bevy_app = { path = "../bevy_app", version = "0.8.0-dev" }
bevy_asset = { path = "../bevy_asset", version = "0.8.0-dev" }
bevy_derive = { path = "../bevy_derive", version = "0.8.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.8.0-dev" }
bevy_reflect = { path = "../bevy_reflect", version = "0.8.0-dev" }
bevy_render = { path = "../bevy_render", version = "0.8.0-dev" }
bevy_transform = { path = "../bevy_transform", version = "0.8.0-dev" }
bevy_utils = { path = "../bevy_utils", version = "0.8.0-dev" }

serde = { version = "1", features = ["derive"] }

32 changes: 32 additions & 0 deletions crates/bevy_core_pipeline/src/clear_color.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use bevy_derive::{Deref, DerefMut};
use bevy_ecs::prelude::*;
use bevy_reflect::{Reflect, ReflectDeserialize};
use bevy_render::{color::Color, extract_resource::ExtractResource};
use serde::{Deserialize, Serialize};

#[derive(Reflect, Serialize, Deserialize, Clone, Debug)]
#[reflect_value(Serialize, Deserialize)]
pub enum ClearColorConfig {
Default,
Custom(Color),
None,
}

impl Default for ClearColorConfig {
fn default() -> Self {
ClearColorConfig::Default
}
}

/// When used as a resource, sets the color that is used to clear the screen between frames.
///
/// This color appears as the "background" color for simple apps, when
/// there are portions of the screen with nothing rendered.
#[derive(Component, Clone, Debug, Deref, DerefMut, ExtractResource)]
pub struct ClearColor(pub Color);

impl Default for ClearColor {
fn default() -> Self {
Self(Color::rgb(0.4, 0.4, 0.4))
}
}
128 changes: 0 additions & 128 deletions crates/bevy_core_pipeline/src/clear_pass.rs

This file was deleted.

20 changes: 0 additions & 20 deletions crates/bevy_core_pipeline/src/clear_pass_driver.rs

This file was deleted.

82 changes: 82 additions & 0 deletions crates/bevy_core_pipeline/src/core_2d/camera_2d.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
use crate::clear_color::ClearColorConfig;
use bevy_ecs::{prelude::*, query::QueryItem};
use bevy_reflect::Reflect;
use bevy_render::{
camera::{
Camera, CameraProjection, CameraRenderGraph, DepthCalculation, OrthographicProjection,
},
extract_component::ExtractComponent,
primitives::Frustum,
view::VisibleEntities,
};
use bevy_transform::prelude::{GlobalTransform, Transform};

#[derive(Component, Default, Reflect, Clone)]
#[reflect(Component)]
pub struct Camera2d {
pub clear_color: ClearColorConfig,
}

impl ExtractComponent for Camera2d {
type Query = &'static Self;
type Filter = With<Camera>;

fn extract_component(item: QueryItem<Self::Query>) -> Self {
item.clone()
}
}

#[derive(Bundle)]
pub struct Camera2dBundle {
pub camera: Camera,
pub camera_render_graph: CameraRenderGraph,
pub projection: OrthographicProjection,
pub visible_entities: VisibleEntities,
pub frustum: Frustum,
pub transform: Transform,
pub global_transform: GlobalTransform,
pub camera_2d: Camera2d,
}

impl Default for Camera2dBundle {
fn default() -> Self {
Self::new_with_far(1000.0)
}
}

impl Camera2dBundle {
/// Create an orthographic projection camera with a custom Z position.
///
/// The camera is placed at `Z=far-0.1`, looking toward the world origin `(0,0,0)`.
/// Its orthographic projection extends from `0.0` to `-far` in camera view space,
/// corresponding to `Z=far-0.1` (closest to camera) to `Z=-0.1` (furthest away from
/// camera) in world space.
pub fn new_with_far(far: f32) -> Self {
// we want 0 to be "closest" and +far to be "farthest" in 2d, so we offset
// the camera's translation by far and use a right handed coordinate system
let projection = OrthographicProjection {
far,
depth_calculation: DepthCalculation::ZDifference,
..Default::default()
};
let transform = Transform::from_xyz(0.0, 0.0, far - 0.1);
let view_projection =
projection.get_projection_matrix() * transform.compute_matrix().inverse();
let frustum = Frustum::from_view_projection(
&view_projection,
&transform.translation,
&transform.back(),
projection.far(),
);
Self {
camera_render_graph: CameraRenderGraph::new(crate::core_2d::graph::NAME),
projection,
visible_entities: VisibleEntities::default(),
frustum,
transform,
global_transform: Default::default(),
camera: Camera::default(),
camera_2d: Camera2d::default(),
}
}
}
Loading

0 comments on commit 6b69e18

Please sign in to comment.