Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic materials scene renderer proj #428

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions projects/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ project(projects)
if (!PPX_ANDROID)
add_subdirectory(sample_00_ppx_info)
endif ()

add_subdirectory(sample_01_triangle)
add_subdirectory(sample_02_triangle_spinning)
add_subdirectory(sample_03_square_textured)
Expand Down Expand Up @@ -45,6 +46,7 @@ add_subdirectory(push_descriptors)
add_subdirectory(mipmap_demo)
add_subdirectory(gltf)
add_subdirectory(dynamic_rendering)
add_subdirectory(gltf_basic_materials)
add_subdirectory(alloc)
add_subdirectory(fishtornado)
add_subdirectory(fluid_simulation)
Expand Down
30 changes: 30 additions & 0 deletions projects/gltf_basic_materials/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2023 Google LLC
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2024

#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)

project(31_gltf_basic_materials)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove 31_


add_samples_for_all_apis(
NAME ${PROJECT_NAME}
SOURCES
"GltfBasicMaterials.h"
"GltfBasicMaterials.cpp"
"main.cpp"
SHADER_DEPENDENCIES
"shader_scene_renderer_vertex_material_vertex"
"shader_scene_renderer_material_error"
"shader_scene_renderer_material_debug"
"shader_scene_renderer_material_unlit"
"shader_scene_renderer_material_standard"
)
339 changes: 339 additions & 0 deletions projects/gltf_basic_materials/GltfBasicMaterials.cpp

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions projects/gltf_basic_materials/GltfBasicMaterials.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef GLTF_BASIC_MATERIALS_H
#define GLTF_BASIC_MATERIALS_H

#include "ppx/ppx.h"
#include "ppx/scene/scene_material.h"
#include "ppx/scene/scene_mesh.h"
#include "ppx/scene/scene_pipeline_args.h"

#include <unordered_map>

class GltfBasicMaterialsApp
: public ppx::Application
{
public:
virtual void Config(ppx::ApplicationSettings& settings) override;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: virtual is implied by override and can be removed

virtual void Setup() override;
virtual void Shutdown() override;
virtual void Render() override;

private:
struct PerFrame
{
ppx::grfx::CommandBufferPtr cmd;
ppx::grfx::SemaphorePtr imageAcquiredSemaphore;
ppx::grfx::FencePtr imageAcquiredFence;
ppx::grfx::SemaphorePtr renderCompleteSemaphore;
ppx::grfx::FencePtr renderCompleteFence;
};

std::vector<PerFrame> mPerFrame;
ppx::grfx::ShaderModulePtr mVS;
ppx::grfx::ShaderModulePtr mPS;
ppx::grfx::PipelineInterfacePtr mPipelineInterface;
ppx::grfx::GraphicsPipelinePtr mStandardMaterialPipeline = nullptr;
ppx::grfx::GraphicsPipelinePtr mUnlitMaterialPipeline = nullptr;
ppx::grfx::GraphicsPipelinePtr mErrorMaterialPipeline = nullptr;

ppx::scene::Scene* mScene = nullptr;
ppx::scene::MaterialPipelineArgs* mPipelineArgs = nullptr;

std::unordered_map<const ppx::scene::Material*, uint32_t> mMaterialIndexMap;
std::unordered_map<const ppx::scene::Material*, ppx::grfx::GraphicsPipeline*> mMaterialPipelineMap;

ppx::grfx::TexturePtr mIBLIrrMap;
ppx::grfx::TexturePtr mIBLEnvMap;
};

#endif // GLTF_BASIC_MATERIALS_H
17 changes: 17 additions & 0 deletions projects/gltf_basic_materials/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2023 Google LLC
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2024

//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "GltfBasicMaterials.h"

SETUP_APPLICATION(GltfBasicMaterialsApp)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"abandoned_workshop_02_4k_irr.hdr" "abandoned_workshop_02_4k_env.hdr" 4096 2048 7
Binary file not shown.
Loading
Loading