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:
Teejoon
2016-02-07 13:39:13 +01:00
parent ceab837e27
commit 92ab22e779
20 changed files with 971 additions and 309 deletions
+94 -32
View File
@@ -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;
}
};