重构材质系统
This commit is contained in:
@@ -29,6 +29,7 @@ davinci::Scene g_scene;
|
||||
int32_t g_mousePosX = 0;
|
||||
int32_t g_mousePosY = 0;
|
||||
davinci::fVector4 g_mouseColor = davinci::fVector4::BLACK;
|
||||
int32_t g_debugMaterialID = 0;
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
//int main(int argc, char* argv[])
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
#include "scene/dvc_scene_node.h"
|
||||
#include "scene/component/dvc_light_component.h"
|
||||
#include "../adapter/adapter_texture.h"
|
||||
|
||||
#include "standard/dvu_standard_material.h"
|
||||
#include "asset/dvc_material.h"
|
||||
|
||||
SDL_Window* main_window;
|
||||
|
||||
@@ -28,6 +29,10 @@ extern davinci::AntiAliasingTech g_aaTech;
|
||||
extern int32_t g_mousePosX;
|
||||
extern int32_t g_mousePosY;
|
||||
extern davinci::fVector4 g_mouseColor;
|
||||
extern int32_t g_debugMaterialID;
|
||||
|
||||
typedef std::map<std::string, davinci::MaterialPtr> DebugMaterialMap;
|
||||
DebugMaterialMap g_debugMaterialMap;
|
||||
|
||||
bool initMainUI(SDL_Window* window, SDL_GLContext gl_context, const char* glsl_version)
|
||||
{
|
||||
@@ -107,8 +112,19 @@ void drawMainUI()
|
||||
{
|
||||
davinci_utils::export_mesh_to_obj(g_device, g_scene);
|
||||
}
|
||||
const char* aaItem[] = { "None", "MSAA_2X2", "MSAA_4X4"};
|
||||
const char* aaItem[] = { "none", "MSAA_2X2", "MSAA_4X4"};
|
||||
ImGui::Combo("AntiAliasing", (int*)(&g_aaTech), aaItem, IM_ARRAYSIZE(aaItem));
|
||||
|
||||
const char* materialItems[] = {
|
||||
"none",
|
||||
"debug:solid_color",
|
||||
"debug:base_color_texture",
|
||||
"debug:normal_texture",
|
||||
"debug:texture_coordinates_0",
|
||||
"debug:geometry_normal"
|
||||
};
|
||||
ImGui::Combo("DebugMaterial", (int*)(&g_debugMaterialID), materialItems, IM_ARRAYSIZE(materialItems));
|
||||
|
||||
if (ImGui::Button("Render"))
|
||||
{
|
||||
davinci::RenderPipe pipe(g_device);
|
||||
@@ -125,12 +141,36 @@ void drawMainUI()
|
||||
|
||||
pipe.setAntiAliasingTech(g_aaTech);
|
||||
|
||||
if (g_debugMaterialID == 0) {
|
||||
pipe.setDebugMaterial(nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugMaterialMap::iterator it = g_debugMaterialMap.find(materialItems[g_debugMaterialID]);
|
||||
if(it==g_debugMaterialMap.end())
|
||||
{
|
||||
davinci::MaterialPtr debugMaterial = davinci_utils::create_standard_material(&g_device, materialItems[g_debugMaterialID]);
|
||||
if (debugMaterial)
|
||||
{
|
||||
debugMaterial->setupMaterial();
|
||||
|
||||
g_debugMaterialMap[materialItems[g_debugMaterialID]] = debugMaterial;
|
||||
pipe.setDebugMaterial(debugMaterial);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pipe.setDebugMaterial(it->second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
g_scene.buildRenderableQueue(pipe);
|
||||
|
||||
g_renderTarget.clear();
|
||||
pipe.process(g_renderTarget);
|
||||
|
||||
davinci_utils::dump_render_target("d:\\rendertarget", g_renderTarget);
|
||||
//davinci_utils::dump_render_target("d:\\rendertarget", g_renderTarget);
|
||||
}
|
||||
ImGui::Separator();
|
||||
ImVec2 mousePos = ImGui::GetMousePos();
|
||||
|
||||
Reference in New Issue
Block a user