Splatmapping now working.
Rendering pipleline now support 3 different types of Material: Basic: a material with a single color on every property (diffuse, specular, ect). SingleTextures: a material with a single texture in all or any property. Have a single color on the rest. SplatMapping: has a SplatMap and 0 to 5 different textures to every property. Properties with o texture uses a single color insted. All materials with a texture has a UVRepeat, telling how many time to till in U and in V. modelJobs now uses ShadeID, ModelID and TextureID for the Hash insted of only Texture MayaExported exports 3 differnt types of material, the same as the piplen now supports.
This commit is contained in:
@@ -53,6 +53,7 @@ private:
|
||||
|
||||
ShaderProgram* m_ForwardPlusProgram;
|
||||
ShaderProgram* m_ExplosionEffectProgram;
|
||||
ShaderProgram* m_ForwardPlusSplatMapProgram;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
struct ExplosionEffectJob : ModelJob
|
||||
{
|
||||
ExplosionEffectJob(ComponentWrapper explosionEffectComponent, ::Model* model, Camera* camera, glm::mat4 matrix, ::RawModel::MaterialGroup matGroup, ComponentWrapper modelComponent, ::World* world, glm::vec4 fillColor, float fillPercentage)
|
||||
ExplosionEffectJob(ComponentWrapper explosionEffectComponent, ::Model* model, Camera* camera, glm::mat4 matrix, ::RawModel::MaterialProperties matGroup, ComponentWrapper modelComponent, ::World* world, glm::vec4 fillColor, float fillPercentage)
|
||||
: ModelJob(model, camera, matrix, matGroup, modelComponent, world, fillColor, fillPercentage)
|
||||
{
|
||||
ExplosionOrigin = (glm::vec3)explosionEffectComponent["ExplosionOrigin"];
|
||||
|
||||
@@ -14,7 +14,7 @@ private:
|
||||
|
||||
public:
|
||||
~Model();
|
||||
const std::vector<RawModel::MaterialGroup>& MaterialGroups() const { return m_RawModel->MaterialGroups; }
|
||||
const std::vector<RawModel::MaterialProperties>& MaterialGroups() const { return m_RawModel->m_Materials; }
|
||||
const glm::mat4& Matrix() const { return m_RawModel->m_Matrix; }
|
||||
const RawModel::Vertex* Vertices() const { return m_RawModel->Vertices(); }
|
||||
unsigned int NumberOfVertices() const { return m_RawModel->NumVertices(); }
|
||||
|
||||
@@ -14,39 +14,98 @@
|
||||
#include "../Core/World.h"
|
||||
#include "../Core/Transform.h"
|
||||
#include "Skeleton.h"
|
||||
#include "ShaderProgram.h"
|
||||
|
||||
struct ModelJob : RenderJob
|
||||
{
|
||||
ModelJob(Model* model, Camera* camera, glm::mat4 matrix, ::RawModel::MaterialGroup matGroup, ComponentWrapper modelComponent, World* world, glm::vec4 fillColor, float fillPercentage)
|
||||
ModelJob(Model* model, Camera* camera, glm::mat4 matrix, ::RawModel::MaterialProperties matProp, ComponentWrapper modelComponent, World* world, glm::vec4 fillColor, float fillPercentage)
|
||||
: RenderJob()
|
||||
{
|
||||
Model = model;
|
||||
TextureID = (matGroup.Texture) ? matGroup.Texture->ResourceID : 0;
|
||||
if (modelComponent["DiffuseTexture"]) {
|
||||
DiffuseTexture = matGroup.Texture.get();
|
||||
} else {
|
||||
DiffuseTexture = nullptr;
|
||||
}
|
||||
if (modelComponent["NormalMap"]) {
|
||||
NormalTexture = matGroup.NormalMap.get();
|
||||
} else {
|
||||
NormalTexture = nullptr;
|
||||
}
|
||||
if (modelComponent["SpecularMap"]) {
|
||||
SpecularTexture = matGroup.SpecularMap.get();
|
||||
} else {
|
||||
SpecularTexture = nullptr;
|
||||
}
|
||||
if (modelComponent["GlowMap"]) {
|
||||
IncandescenceTexture = matGroup.IncandescenceMap.get();
|
||||
} else {
|
||||
IncandescenceTexture = nullptr;
|
||||
}
|
||||
DiffuseColor = matGroup.DiffuseColor;
|
||||
SpecularColor = matGroup.SpecularColor;
|
||||
IncandescenceColor = matGroup.IncandescenceColor;
|
||||
StartIndex = matGroup.StartIndex;
|
||||
EndIndex = matGroup.EndIndex;
|
||||
ModelID = model->ResourceID;
|
||||
Type = matProp.type;
|
||||
::RawModel::MaterialBasic* matGroup = matProp.material;
|
||||
switch(matProp.type){
|
||||
case ::RawModel::MaterialType::Basic:
|
||||
if (Model->isSkined()) {
|
||||
ShaderID = ResourceManager::Load<ShaderProgram>("#ForwardPlusProgram")->ResourceID;
|
||||
}
|
||||
else {
|
||||
//JOHAN TODO: Add Non-skined shader
|
||||
}
|
||||
TextureID = 0;
|
||||
break;
|
||||
case ::RawModel::MaterialType::SingleTextures:
|
||||
{
|
||||
if (Model->isSkined()) {
|
||||
ShaderID = ResourceManager::Load<ShaderProgram>("#ForwardPlusProgram")->ResourceID;
|
||||
}
|
||||
else {
|
||||
//JOHAN TODO: Add Non-skined shader
|
||||
}
|
||||
::RawModel::MaterialSingleTextures* singleTextures = static_cast<::RawModel::MaterialSingleTextures*>(matProp.material);
|
||||
TextureID = (singleTextures->ColorMap.Texture) ? singleTextures->ColorMap.Texture->ResourceID : 0;
|
||||
if (modelComponent["DiffuseTexture"]) {
|
||||
DiffuseTexture.push_back(singleTextures->ColorMap.Texture.get());
|
||||
}
|
||||
|
||||
if (modelComponent["NormalMap"]) {
|
||||
NormalTexture.push_back(singleTextures->NormalMap.Texture.get());
|
||||
}
|
||||
|
||||
if (modelComponent["SpecularMap"]) {
|
||||
SpecularTexture.push_back(singleTextures->SpecularMap.Texture.get());
|
||||
}
|
||||
|
||||
if (modelComponent["GlowMap"]) {
|
||||
IncandescenceTexture.push_back(singleTextures->IncandescenceMap.Texture.get());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ::RawModel::MaterialType::SplatMapping:
|
||||
{
|
||||
if (Model->isSkined()) {
|
||||
ShaderID = ResourceManager::Load<ShaderProgram>("#ForwardPlusSplatMapProgram")->ResourceID;
|
||||
}
|
||||
else {
|
||||
//JOHAN TODO: Add Non-skinned shader
|
||||
}
|
||||
::RawModel::MaterialSplatMapping* SplatTextures = static_cast<::RawModel::MaterialSplatMapping*>(matProp.material);
|
||||
|
||||
SplatMap = SplatTextures->SplatMap.Texture.get();
|
||||
|
||||
TextureID = (SplatTextures->ColorMaps[0].Texture) ? SplatTextures->ColorMaps[0].Texture->ResourceID : 0;
|
||||
if (modelComponent["DiffuseTexture"]) {
|
||||
for (auto texture : SplatTextures->ColorMaps) {
|
||||
DiffuseTexture.push_back(texture.Texture.get());
|
||||
}
|
||||
}
|
||||
|
||||
if (modelComponent["NormalMap"]) {
|
||||
for (auto texture : SplatTextures->NormalMaps) {
|
||||
NormalTexture.push_back(texture.Texture.get());
|
||||
}
|
||||
}
|
||||
|
||||
if (modelComponent["SpecularMap"]) {
|
||||
for (auto texture : SplatTextures->SpecularMaps) {
|
||||
SpecularTexture.push_back(texture.Texture.get());
|
||||
}
|
||||
}
|
||||
|
||||
if (modelComponent["GlowMap"]) {
|
||||
for (auto texture : SplatTextures->IncandescenceMaps) {
|
||||
IncandescenceTexture.push_back(texture.Texture.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
DiffuseColor = matGroup->DiffuseColor;
|
||||
SpecularColor = matGroup->SpecularColor;
|
||||
IncandescenceColor = matGroup->IncandescenceColor;
|
||||
StartIndex = matGroup->StartIndex;
|
||||
EndIndex = matGroup->EndIndex;
|
||||
Matrix = matrix;
|
||||
Color = modelComponent["Color"];
|
||||
Entity = modelComponent.EntityID;
|
||||
@@ -68,13 +127,16 @@ struct ModelJob : RenderJob
|
||||
|
||||
unsigned int TextureID;
|
||||
unsigned int ShaderID;
|
||||
unsigned int ModelID;
|
||||
|
||||
::RawModel::MaterialType Type;
|
||||
EntityID Entity;
|
||||
glm::mat4 Matrix;
|
||||
const Texture* DiffuseTexture;
|
||||
const Texture* NormalTexture;
|
||||
const Texture* SpecularTexture;
|
||||
const Texture* IncandescenceTexture;
|
||||
const Texture* SplatMap;
|
||||
std::vector<const Texture*> DiffuseTexture;
|
||||
std::vector<const Texture*> NormalTexture;
|
||||
std::vector<const Texture*> SpecularTexture;
|
||||
std::vector<const Texture*> IncandescenceTexture;
|
||||
float Shininess = 0.f;
|
||||
glm::vec4 Color;
|
||||
const ::Model* Model = nullptr;
|
||||
@@ -95,7 +157,7 @@ struct ModelJob : RenderJob
|
||||
|
||||
void CalculateHash() override
|
||||
{
|
||||
Hash = TextureID;
|
||||
Hash = TextureID + ModelID << 10 + ShaderID << 20;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -76,10 +76,10 @@ public:
|
||||
|
||||
struct MaterialSingleTextures : public MaterialBasic
|
||||
{
|
||||
TextureProperties ColorMaps;
|
||||
TextureProperties NormalMaps;
|
||||
TextureProperties SpecularMaps;
|
||||
TextureProperties IncandescenceMaps;
|
||||
TextureProperties ColorMap;
|
||||
TextureProperties NormalMap;
|
||||
TextureProperties SpecularMap;
|
||||
TextureProperties IncandescenceMap;
|
||||
};
|
||||
|
||||
enum class MaterialType { Basic = 1, SplatMapping, SingleTextures };
|
||||
@@ -136,10 +136,10 @@ private:
|
||||
void ReadMaterialFile(std::string filePath);
|
||||
void ReadMaterials(std::size_t& offset, char* fileData, const unsigned int& fileByteSize);
|
||||
void ReadMaterialSingle(std::size_t& offset, char* fileData, const unsigned int& fileByteSize);
|
||||
void ReadMaterialBasic(MaterialBasic* Material, unsigned int &offset, char* fileData, unsigned int& fileByteSize);
|
||||
void ReadMaterialSingleTexture(MaterialSingleTextures* Material, unsigned int &offset, char* fileData, unsigned int& fileByteSize);
|
||||
void ReadMaterialSplatMapping(MaterialSplatMapping* Material, unsigned int &offset, char* fileData, unsigned int& fileByteSize);
|
||||
void ReadMaterialTextureProperties(TextureProperties& texture, unsigned int &offset, char* fileData, unsigned int& fileByteSize);
|
||||
void ReadMaterialBasic(MaterialBasic* Material, std::size_t& offset, char* fileData, const unsigned int& fileByteSize);
|
||||
void ReadMaterialSingleTexture(MaterialSingleTextures* Material, std::size_t& offset, char* fileData, const unsigned int& fileByteSize);
|
||||
void ReadMaterialSplatMapping(MaterialSplatMapping* Material, std::size_t& offset, char* fileData, const unsigned int& fileByteSize);
|
||||
void ReadMaterialTextureProperties(TextureProperties& texture, std::size_t& offset, char* fileData, const unsigned int& fileByteSize);
|
||||
|
||||
void ReadAnimationFile(std::string filePath);
|
||||
void ReadAnimationBindPoses(std::size_t& offset, char* fileData, const unsigned int& fileByteSize);
|
||||
|
||||
@@ -47,7 +47,6 @@ private:
|
||||
void fillLight(std::list<std::shared_ptr<RenderJob>>& jobs);
|
||||
bool isChildOfACamera(EntityWrapper entity);
|
||||
bool isChildOfCurrentCamera(EntityWrapper entity);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user