meta4d-me / CatDogEngine

A cross-platform game engine/editor written in modern C++ (WIP)
GNU General Public License v2.0
161 stars 17 forks source link

Use texture switch #440

Closed roeas closed 11 months ago

roeas commented 11 months ago

Snipaste_2023-12-22_16-01-00 Snipaste_2023-12-22_16-01-04

Properties that do not use textures display "No Resources". Also removes the warning about no textures in ECWorldConsumer::AddMaterial.

roeas commented 11 months ago

Heres a bug:

ImGuiUtils::ImGuiBoolProperty("Use texture", pPropertyGroup->useTexture);

if (pPropertyGroup->useTexture)
{
    pMaterialComponent->ActivateShaderFeature(engine::MaterialTextureTypeToShaderFeature.at(textureType));
}
else
{
    pMaterialComponent->DeactivateShaderFeature(engine::MaterialTextureTypeToShaderFeature.at(textureType));
}

Due to the different granularity of the useTexture of ORM PropertyGroup and the ShaderFeature of ORM, it is difficult to control the switching of the ORM ShaderFeature with the useTexture checkbox on UI. Given that we've already implemented the lazy and hot reloading of shaders, perhaps we could split the ShaderFeature::ORM?

T-rvw commented 11 months ago

Heres a bug:

ImGuiUtils::ImGuiBoolProperty("Use texture", pPropertyGroup->useTexture);

if (pPropertyGroup->useTexture)
{
  pMaterialComponent->ActivateShaderFeature(engine::MaterialTextureTypeToShaderFeature.at(textureType));
}
else
{
  pMaterialComponent->DeactivateShaderFeature(engine::MaterialTextureTypeToShaderFeature.at(textureType));
}

Due to the different granularity of the useTexture of ORM PropertyGroup and the ShaderFeature of ORM, it is difficult to control the switching of the ORM ShaderFeature with the useTexture checkbox on UI. Given that we've already implemented the lazy and hot reloading of shaders, perhaps we could split the ShaderFeature::ORM?

ORM is a project logic which will be removed in the editor/engine finally. The correct way is to write a MaterialGraph. Then PBR material node exports Occulsion, Roughness, Metalness float values to user. User can choose Texture node's R/G/B/A to output to the input of PBR material node. Reference to Maya/Blender/Unreal's material graph design is OK.

And logics about BaseColor/Normal/... will also be removed in the future. A good design is to transfer these settings to a material type metadata file. Editor/Engine codes only care about very generic settings : parameters(CBuffer), resources(2d/3d/procedural/... textures), samplers(how to use texture), render states(blend/alpha/...)