Commit e52dfc97 by Kai Westerkamp

Non textures Materials

parent 5b57cf19
......@@ -279,17 +279,9 @@ UMaterialInterface *AProceduralEntity::GetMaterialForIndex(unsigned int index,
aiMaterial* AMat = scene->mMaterials[index];
aiColor3D color(0.f, 0.f, 0.f);
if (AI_SUCCESS == AMat->Get(AI_MATKEY_COLOR_DIFFUSE, color)) {
UE_LOG(GLTF, Warning, TEXT("Material Property: %s, %d %d %d not Implemented"), TEXT("AI_MATKEY_COLOR_DIFFUSE"), color.r, color.g, color.b);
}
if (AMat->GetTextureCount(aiTextureType_DIFFUSE) > 0) {
aiString Path;
if (AMat->GetTexture(aiTextureType_DIFFUSE, 0, &Path, NULL, NULL, NULL, NULL, NULL) == AI_SUCCESS) {
FString fileName = FString(Path.C_Str());
......@@ -309,9 +301,9 @@ UMaterialInterface *AProceduralEntity::GetMaterialForIndex(unsigned int index,
bool isValid;
int32 width, height;
diffTexture = LoadTexture2D((uint8*)aiTexture->pcData, aiTexture->mWidth, format, isValid, width, height);
UTexture2D* diffTexture = LoadTexture2D((uint8*)aiTexture->pcData, aiTexture->mWidth, format, isValid, width, height);
//if (isValid)
if (isValid)
newMaterial->SetTextureParameterValue(FName("DiffuseTexture"), diffTexture);
}
......@@ -337,16 +329,43 @@ UMaterialInterface *AProceduralEntity::GetMaterialForIndex(unsigned int index,
bool isValid;
int32 width, height;
diffTexture = LoadTexture2D_FromFile(dirPath + "\\" + fileName, isValid, width, height);
UTexture2D* diffTexture = LoadTexture2D_FromFile(dirPath + "\\" + fileName, isValid, width, height);
//if (isValid)
if (isValid)
newMaterial->SetTextureParameterValue(FName("DiffuseTexture"), diffTexture);
}
}
}
else {
newMaterial = UMaterialInstanceDynamic::Create(UniformMaterialRef, this);
MaterialMap.Add(index, newMaterial);
aiColor3D color(0.f, 0.f, 0.f);
if (AI_SUCCESS == AMat->Get(AI_MATKEY_COLOR_DIFFUSE, color)) {
//UE_LOG(GLTF, Warning, TEXT("Material Property : %s, %f %f %f"), TEXT("AI_MATKEY_COLOR_DIFFUSE"), color.r, color.g, color.b);
FLinearColor Fcolor = FLinearColor(color.r, color.g, color.b);
newMaterial->SetVectorParameterValue(FName("Diffuse"), Fcolor);
}
}
aiColor3D color(0.f, 0.f, 0.f);
if (AI_SUCCESS == AMat->Get(AI_MATKEY_COLOR_SPECULAR, color)) {
//UE_LOG(GLTF, Warning, TEXT("Material Property: %s, %f %f %f"), TEXT("AI_MATKEY_COLOR_SPECULAR"), color.r, color.g, color.b);
FLinearColor Fcolor = FLinearColor(color.r, color.g, color.b);
newMaterial->SetVectorParameterValue(FName("Specular"), Fcolor);
}
//TODO
//float shininess;
//if (AI_SUCCESS == AMat->Get(AI_MATKEY_SHININESS, shininess)) {
//UE_LOG(GLTF, Warning, TEXT("Material Property: %s, %f"), TEXT("AI_MATKEY_SHININESS"), shininess);
//newMaterial->SetVectorParameterValue(FName("Specular"), Fcolor);
//}
MaterialMap.Add(index, newMaterial);
return newMaterial;
}
}
......
......@@ -29,6 +29,9 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Materials")
UMaterialInterface * MasterMaterialRef;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Materials")
UMaterialInterface * UniformMaterialRef;
// Sets default values for this actor's properties
AProceduralEntity();
......@@ -46,8 +49,8 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Materials")
TMap<int32, UMaterialInterface *> MaterialMap;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Materials")
UTexture2D* diffTexture;
//UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Materials")
//UTexture2D* diffTexture;
private:
int32 _selectedVertex;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment