Commit 99e5d7ee authored by D-AIRY's avatar D-AIRY

New material system (continue)

parent da3e0459
......@@ -190,6 +190,7 @@
<ClInclude Include="..\..\..\source\mtrl\IXMaterialSystem.h" />
<ClInclude Include="..\..\..\source\mtrl\IXTexture.h" />
<ClInclude Include="..\..\..\source\mtrl\material.h" />
<ClInclude Include="..\..\..\source\mtrl\XMaterialProperty.h" />
<ClInclude Include="..\..\..\source\mtrl\MaterialSystem.h" />
<ClInclude Include="..\..\..\source\mtrl\ml_data.h" />
<ClInclude Include="..\..\..\source\mtrl\reflection.h" />
......
......@@ -83,5 +83,8 @@
<ClInclude Include="..\..\..\source\mtrl\ShaderVariant.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\source\mtrl\XMaterialProperty.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
Subproject commit 04794d7047ef1af9f1cb4799828689fd8d60e9ed
Subproject commit fbe5e2fb6e490683a20689ec7c4d8666d83958ba
......@@ -267,6 +267,8 @@ inline bool operator==(const XGUID &a, const XGUID &b)
#define strdupa(str) strcpy((char*)alloca(sizeof(char) * (strlen(str) + 1)), str)
#define strdups(str) ((str) ? strdup(str) : NULL)
//! Тип функции вывода отладочной информации
typedef void(*report_func) (int iLevel, const char *szLibName, const char *szMessage);
......
......@@ -8,10 +8,11 @@
// {7EC7E7F7-E0BE-4CB7-ABFE-9FC0C10880A5}
#define IXMATERIALSYSTEM_GUID DEFINE_XGUID(0x7ec7e7f7, 0xe0be, 0x4cb7, 0xab, 0xfe, 0x9f, 0xc0, 0xc1, 0x8, 0x80, 0xa5)
#define IXMATERIALSYSTEM_VERSION 1
#define IXMATERIALSYSTEM_VERSION 2
/*! Набор стандартных шейдеров для материала
Если нужно задать макроопределения - используйте варианты IXShaderVariant
@deprecated
*/
struct XSHADER_DEFAULT_DESC
{
......@@ -29,6 +30,8 @@ struct XSHADER_DEFAULT_DESC
Зачем это нужно? Простой пример: Система может рисовать одну и ту же геометрию пообъектно, и инстансингом.
Вершинные шейдеры в этом случае будут различаться, и система должна иметь возможность выбрать, какой вариант
шейдера использовать при конкретной установке материала
@deprecated
*/
class IXShaderVariant: public IXUnknown
{
......@@ -101,10 +104,31 @@ struct XRenderPassOutputElement
};
#define XRENDER_PASS_OUTPUT_LIST_END() {NULL,NULL,GXDECLTYPE_UNUSED,NULL}
#include "XMaterialProperty.h"
struct XVertexFormatHandler {};
struct XRenderPassHandler {};
struct XVertexShaderHandler {};
struct XGeometryShaderHandler {};
struct XMaterialShaderHandler {};
struct XMaterialShaderSampler
{
const char *szKey;
GXSamplerDesc samplerDesc;
};
#define XMATERIAL_SHADER_SAMPLER_LIST_END() {0}
struct XMaterialShaderPass
{
XRenderPassHandler *pRenderPass;
const char *szShaderFile;
const char *szEntryPoint;
GXMacro *pDefines;
XMaterialShaderSampler *pSamplers;
XMaterialProperty *pProperties;
};
#define XMATERIAL_SHADER_PASS_LIST_END() {0}
class IXMaterialSystem: public IXUnknown
{
......@@ -162,6 +186,9 @@ public:
// ["Base color", "vBaseColor", 'GXDECLTYPE_FLOAT4', "float4(1.0f, 0.0f, 0.0f, 0.5f)"],
virtual XRenderPassHandler* XMETHODCALLTYPE registerRenderPass(const char *szName, const char *szShaderFile, XRenderPassTexturesElement *pTextures, XRenderPassSamplersElement *pSamplers, XRenderPassOutputElement *pOutput) = 0;
virtual XRenderPassHandler* XMETHODCALLTYPE getRenderPass(const char *szName) = 0;
virtual XMaterialShaderHandler* XMETHODCALLTYPE registerMaterialShader(const char *szName, XVertexFormatHandler *pVertexFormat, XMaterialShaderPass *pPasses, XMaterialProperty *pGenericProperties) = 0;
virtual XMaterialShaderHandler* XMETHODCALLTYPE getMaterialShader(const char *szName) = 0;
};
#endif
......@@ -398,7 +398,186 @@ XRenderPassHandler* XMETHODCALLTYPE CMaterialSystem::getRenderPass(const char *s
return(NULL);
}
XMaterialShaderHandler* XMETHODCALLTYPE CMaterialSystem::registerMaterialShader(const char *szName, XVertexFormatHandler *pVertexFormat, XMaterialShaderPass *pPasses, XMaterialProperty *pGenericProperties)
{
assert(pVertexFormat);
assert(pPasses);
if(m_mMaterialShaders.KeyExists(szName))
{
LibReport(REPORT_MSG_LEVEL_ERROR, "CMaterialSystem::registerMaterialShader(): shader '%s' has already been registered!\n", szName);
return(NULL);
}
MaterialShader &shader = m_mMaterialShaders[szName];
shader.szName = strdup(szName);
shader.pVertexFormat = (VertexFormatData*)pVertexFormat;
Stack<const char*> stack;
while(pGenericProperties && pGenericProperties->type != XMPT_UNKNOWN)
{
XMaterialProperty tmp = *pGenericProperties;
tmp.szTitle = strdups(tmp.szTitle);
tmp.szKey = strdups(tmp.szKey);
tmp.szDefine = strdups(tmp.szDefine);
if(tmp.type == XMPT_PARAM_GROUP)
{
assert(tmp.szCondition);
tmp.szCondition = strdup(tmp.szCondition);
stack.push(tmp.szCondition);
}
else if(tmp.type == XMPT_PARAM_GROUP_END)
{
assert(stack.count() > 0);
stack.popN(1);
}
else
{
size_t sizeTotal = 0;
for(int i = 0, l = stack.count(); i < l; ++i)
{
sizeTotal += strlen(stack.get(i)) + 1;
}
if(sizeTotal)
{
char *szTemp = (char*)malloc(sizeTotal);
tmp.szCondition = szTemp;
for(int i = 0, l = stack.count(); i < l; ++i)
{
szTemp += sprintf(szTemp, "%s", stack.get(i));
if(i == l - 1)
{
*szTemp = 0;
}
else
{
*szTemp = ',';
}
}
}
else
{
tmp.szCondition = NULL;
}
}
shader.aProperties.push_back(tmp);
++pGenericProperties;
}
assert(stack.count() == 0);
while(pPasses && pPasses->pRenderPass)
{
MaterialShaderPassData *pPass = &shader.aPasses[shader.aPasses.size()];
pPass->pRenderPass = (RenderPass*)pPasses->pRenderPass;
pPass->szShaderFile = strdups(pPasses->szShaderFile);
pPass->szEntryPoint = strdups(pPasses->szEntryPoint);
{
GXMacro *pTmp = pPasses->pDefines;
while(pTmp && pTmp->szName)
{
GXMacro tmp;
tmp.szName = strdup(pTmp->szName);
tmp.szDefinition = strdup(pTmp->szDefinition);
pPass->aDefines.push_back(tmp);
++pTmp;
}
}
{
IGXDevice *pDevice = SGCore_GetDXDevice();
XMaterialShaderSampler *pTmp = pPasses->pSamplers;
while(pTmp && pTmp->szKey)
{
MaterialShaderSamplerData tmp;
tmp.szKey = strdup(pTmp->szKey);
tmp.pSampler = pDevice ? pDevice->createSamplerState(&pTmp->samplerDesc) : NULL;
assert(tmp.pSampler || !pDevice);
pPass->aSamplers.push_back(tmp);
++pTmp;
}
}
{
XMaterialProperty *pTmp = pPasses->pProperties;
while(pTmp && pTmp->type != XMPT_UNKNOWN)
{
XMaterialProperty tmp = *pTmp;
tmp.szTitle = strdups(tmp.szTitle);
tmp.szKey = strdups(tmp.szKey);
tmp.szDefine = strdups(tmp.szDefine);
if(tmp.type == XMPT_PARAM_GROUP)
{
assert(tmp.szCondition);
tmp.szCondition = strdup(tmp.szCondition);
stack.push(tmp.szCondition);
}
else if(tmp.type == XMPT_PARAM_GROUP_END)
{
assert(stack.count() > 0);
stack.popN(1);
}
else
{
size_t sizeTotal = 0;
for(int i = 0, l = stack.count(); i < l; ++i)
{
sizeTotal += strlen(stack.get(i)) + 1;
}
if(sizeTotal)
{
char *szTemp = (char*)malloc(sizeTotal);
tmp.szCondition = szTemp;
for(int i = 0, l = stack.count(); i < l; ++i)
{
szTemp += sprintf(szTemp, "%s", stack.get(i));
if(i == l - 1)
{
*szTemp = 0;
}
else
{
*szTemp = ',';
}
}
}
else
{
tmp.szCondition = NULL;
}
}
pPass->aProperties.push_back(tmp);
++pTmp;
}
assert(stack.count() == 0);
}
++pPasses;
}
return(&shader);
}
XMaterialShaderHandler* XMETHODCALLTYPE CMaterialSystem::getMaterialShader(const char *szName)
{
const AssotiativeArray<String, MaterialShader>::Node *pNode;
if(m_mMaterialShaders.KeyExists(szName, &pNode))
{
return(pNode->Val);
}
return(NULL);
}
void CMaterialSystem::updateReferences()
{
......@@ -464,6 +643,8 @@ void CMaterialSystem::updateReferences()
}
}
}
}
void CMaterialSystem::cleanData()
......@@ -539,6 +720,48 @@ void CMaterialSystem::cleanData()
free((void*)pPass->aOutput[j].szDefault);
}
}
for(AssotiativeArray<String, MaterialShader>::Iterator i = m_mMaterialShaders.begin(); i; i++)
{
MaterialShader *pShader = i.second;
free((void*)pShader->szName);
for(UINT j = 0, jl = pShader->aProperties.size(); j < jl; ++j)
{
free((void*)pShader->aProperties[j].szCondition);
free((void*)pShader->aProperties[j].szDefine);
free((void*)pShader->aProperties[j].szKey);
free((void*)pShader->aProperties[j].szTitle);
}
for(UINT j = 0, jl = pShader->aPasses.size(); j < jl; ++j)
{
MaterialShaderPassData *pPass = &pShader->aPasses[j];
free((void*)pPass->szEntryPoint);
free((void*)pPass->szShaderFile);
for(UINT k = 0, kl = pPass->aDefines.size(); k < kl; ++k)
{
free((void*)pPass->aDefines[k].szName);
free((void*)pPass->aDefines[k].szDefinition);
}
for(UINT k = 0, kl = pPass->aProperties.size(); k < kl; ++k)
{
free((void*)pPass->aProperties[k].szCondition);
free((void*)pPass->aProperties[k].szDefine);
free((void*)pPass->aProperties[k].szKey);
free((void*)pPass->aProperties[k].szTitle);
}
for(UINT k = 0, kl = pPass->aSamplers.size(); k < kl; ++k)
{
free((void*)pPass->aSamplers[k].szKey);
mem_delete(pPass->aSamplers[k].pSampler);
}
}
}
}
//#############################################################################
......
......@@ -104,6 +104,9 @@ public:
XRenderPassHandler* XMETHODCALLTYPE registerRenderPass(const char *szName, const char *szShaderFile, XRenderPassTexturesElement *pTextures, XRenderPassSamplersElement *pSamplers, XRenderPassOutputElement *pOutput) override;
XRenderPassHandler* XMETHODCALLTYPE getRenderPass(const char *szName) override;
XMaterialShaderHandler* XMETHODCALLTYPE registerMaterialShader(const char *szName, XVertexFormatHandler *pVertexFormat, XMaterialShaderPass *pPasses, XMaterialProperty *pGenericProperties) override;
XMaterialShaderHandler* XMETHODCALLTYPE getMaterialShader(const char *szName) override;
void queueTextureUpload(CTexture *pTexture);
void onTextureRelease(CTexture *pTexture);
void update(float fDT);
......@@ -111,8 +114,8 @@ protected:
struct CObjectData
{
SMMATRIX m_mW;
// SMMATRIX m_mWV;
// SMMATRIX m_mWVP;
// SMMATRIX m_mWV;
// SMMATRIX m_mWVP;
} m_objectData;
IGXConstantBuffer *m_pObjectConstantBuffer = NULL;
......@@ -163,6 +166,30 @@ protected:
Array<XRenderPassOutputElement> aOutput;
};
struct MaterialShaderSamplerData
{
const char *szKey;
IGXSamplerState *pSampler;
};
struct MaterialShaderPassData
{
RenderPass *pRenderPass;
const char *szShaderFile;
const char *szEntryPoint;
Array<GXMacro> aDefines;
Array<MaterialShaderSamplerData> aSamplers;
Array<XMaterialProperty> aProperties;
};
struct MaterialShader: public XMaterialShaderHandler
{
const char *szName;
VertexFormatData *pVertexFormat;
Array<MaterialShaderPassData> aPasses;
Array<XMaterialProperty> aProperties;
};
AssotiativeArray<String, VertexFormatData> m_mVertexFormats;
MemAlloc<VertexShaderData> m_poolVSdata;
MemAlloc<GeometryShader> m_poolGSdata;
......@@ -171,6 +198,7 @@ protected:
AssotiativeArray<String, RenderPass> m_mRenderPasses;
AssotiativeArray<String, MaterialShader> m_mMaterialShaders;
VertexShaderData *m_pCurrentVS = NULL;
GeometryShader *m_pCurrentGS = NULL;
......
#ifndef __XMATERIALPROPERTY_H
#define __XMATERIALPROPERTY_H
#include <gdefines.h>
enum XMATERIAL_PROPERTY_TYPE
{
XMPT_UNKNOWN = 0,
XMPT_PARAM_TEXTURE,
XMPT_PARAM_TEXTURE_OPT,
XMPT_PARAM_FLAG,
XMPT_PARAM_GROUP,
XMPT_PARAM_GROUP_END,
XMPT_PARAM_RANGE,
XMPT_PARAM_COLOR,
XMPT_STATIC_PARAM,
XMPT_GLOBAL_FLAG,
XMPT_GLOBAL_PARAM
};
struct XMaterialProperty
{
XMATERIAL_PROPERTY_TYPE type;
const char *szTitle;
const char *szKey;
const char *szDefine;
const char *szCondition;
GXDECLTYPE varType;
float4_t fValue;
};
#define XMATERIAL_PARAM_TEXTURE(szTitle, szKey) {XMPT_PARAM_TEXTURE, szTitle, szKey, NULL, NULL, GXDECLTYPE_UNUSED, float4_t(0.0f, 0.0f, 0.0f, 0.0f)}
#define XMATERIAL_PARAM_TEXTURE_OPT(szTitle, szKey, szDefine) {XMPT_PARAM_TEXTURE_OPT, szTitle, szKey, szDefine, NULL, GXDECLTYPE_UNUSED, float4_t(0.0f, 0.0f, 0.0f, 0.0f)}
#define XMATERIAL_PARAM_FLAG(szTitle, szParam, szDefine) {XMPT_PARAM_FLAG, szTitle, NULL, szDefine, NULL, GXDECLTYPE_UNUSED, float4_t(0.0f, 0.0f, 0.0f, 0.0f)}
#define XMATERIAL_PARAM_GROUP(szTitle, szCondition) {XMPT_PARAM_GROUP, szTitle, NULL, NULL, szCondition, GXDECLTYPE_UNUSED, float4_t(0.0f, 0.0f, 0.0f, 0.0f)}
#define XMATERIAL_PARAM_GROUP_END() {XMPT_PARAM_GROUP_END, NULL, NULL, NULL, NULL, GXDECLTYPE_UNUSED, float4_t(0.0f, 0.0f, 0.0f, 0.0f)}
#define XMATERIAL_PARAM_RANGE(szTitle, szParam, fFrom, fTo, fDefault) {XMPT_PARAM_RANGE, szTitle, szParam, NULL, NULL, GXDECLTYPE_FLOAT1, float4_t(fDefault, fFrom, fTo, 0.0f)}
#define XMATERIAL_PARAM_COLOR(szTitle, szParam, v4Default) {XMPT_PARAM_COLOR, szTitle, szParam, NULL, NULL, GXDECLTYPE_FLOAT4, float4_t(v4Default )}
#define XMATERIAL_STATIC_PARAM(szParam, fValue) {XMPT_STATIC_PARAM, NULL, szParam, NULL, NULL, GXDECLTYPE_UNUSED, float4_t(0.0f, 0.0f, 0.0f, 0.0f)}
#define XMATERIAL_GLOBAL_FLAG(szFlag, szDefine) {XMPT_GLOBAL_FLAG, NULL, szFlag, szDefine, NULL, GXDECLTYPE_UNUSED, float4_t(0.0f, 0.0f, 0.0f, 0.0f)}
#define XMATERIAL_GLOBAL_PARAM(szParam, type) {XMPT_GLOBAL_PARAM, NULL, szParam, NULL, NULL, GXDECLTYPE_UNUSED, float4_t(0.0f, 0.0f, 0.0f, 0.0f)}
#define XMATERIAL_PROPERTY_LIST_END() {XMPT_UNKNOWN, NULL, NULL, NULL, NULL, GXDECLTYPE_UNUSED, float4_t(0.0f, 0.0f, 0.0f, 0.0f)}
#endif
......@@ -26,7 +26,7 @@ CRenderPipeline::CRenderPipeline(IGXDevice *pDevice):
{"vPos", GXDECLTYPE_FLOAT4, GXDECLUSAGE_TEXCOORD2},
XVERTEX_OUTPUT_DECL_END()
};
m_pMaterialSystem->registerVertexFormat("xSceneGeneric", voelGeneric);
XVertexFormatHandler *pVertexFormatSceneGeneric = m_pMaterialSystem->registerVertexFormat("xSceneGeneric", voelGeneric);
XVertexOutputElement voelPostprocess[] = {
{"vPosition", GXDECLTYPE_FLOAT4, GXDECLUSAGE_POSITION},
......@@ -48,6 +48,12 @@ CRenderPipeline::CRenderPipeline(IGXDevice *pDevice):
m_pMaterialSystem->registerVertexShader(pVertexFormatPostprocess, "base/post.vs");
XRenderPassHandler *pRenderPassGBuffer = NULL;
XRenderPassHandler *pRenderPassTransparency = NULL;
XRenderPassHandler *pRenderPassIllumination = NULL;
XRenderPassHandler *pRenderPassPostprocess = NULL;
XRenderPassHandler *pRenderPassShadow = NULL;
{
XRenderPassSamplersElement pSamplers[] = {
{"Scene default", "g_sScene", 0},
......@@ -68,7 +74,7 @@ CRenderPipeline::CRenderPipeline(IGXDevice *pDevice):
XRENDER_PASS_OUTPUT_LIST_END()
};
m_pMaterialSystem->registerRenderPass("xGBuffer", "shaders/material/gbuffer.ps", NULL, pSamplers, pOutput);
pRenderPassGBuffer = m_pMaterialSystem->registerRenderPass("xGBuffer", "shaders/material/gbuffer.ps", NULL, pSamplers, pOutput);
}
{
......@@ -101,7 +107,7 @@ CRenderPipeline::CRenderPipeline(IGXDevice *pDevice):
XRENDER_PASS_OUTPUT_LIST_END()
};
m_pMaterialSystem->registerRenderPass("xTransparency", "shaders/material/transparent.ps", pTextures, pSamplers, pOutput);
pRenderPassTransparency = m_pMaterialSystem->registerRenderPass("xTransparency", "shaders/material/transparent.ps", pTextures, pSamplers, pOutput);
}
{
......@@ -127,7 +133,7 @@ CRenderPipeline::CRenderPipeline(IGXDevice *pDevice):
XRENDER_PASS_OUTPUT_LIST_END()
};
m_pMaterialSystem->registerRenderPass("xIllumination", "shaders/material/illum.ps", pTextures, pSamplers, pOutput);
pRenderPassIllumination = m_pMaterialSystem->registerRenderPass("xIllumination", "shaders/material/illum.ps", pTextures, pSamplers, pOutput);
}
{
......@@ -152,7 +158,7 @@ CRenderPipeline::CRenderPipeline(IGXDevice *pDevice):
XRENDER_PASS_OUTPUT_LIST_END()
};
m_pMaterialSystem->registerRenderPass("xPostprocess", "shaders/material/post.ps", pTextures, pSamplers, pOutput);
pRenderPassPostprocess = m_pMaterialSystem->registerRenderPass("xPostprocess", "shaders/material/post.ps", pTextures, pSamplers, pOutput);
}
{
......@@ -168,11 +174,114 @@ CRenderPipeline::CRenderPipeline(IGXDevice *pDevice):
XRENDER_PASS_OUTPUT_LIST_END()
};
m_pMaterialSystem->registerRenderPass("xShadow", "shaders/material/shadow.ps", NULL, pSamplers, pOutput);
pRenderPassShadow = m_pMaterialSystem->registerRenderPass("xShadow", "shaders/material/shadow.ps", NULL, pSamplers, pOutput);
}
{
XMaterialShaderSampler pSamplers[] = {
{"g_sDefault", GXSamplerDesc()},
XMATERIAL_SHADER_SAMPLER_LIST_END()
};
GXMacro pMacro[] = {
{"DEFINE_1", "value"},
GX_MACRO_END()
};
XMaterialProperty pProperties[] = {
XMATERIAL_PARAM_TEXTURE_OPT("Base texture", "txBase", NULL), // will override generic parameter if supplied
XMATERIAL_PARAM_COLOR("Some color", "vColor"),
XMATERIAL_PARAM_FLAG("Use f0 texture", "has_f0_texture", "HAS_F0MAP"),
XMATERIAL_PARAM_GROUP(NULL, "HAS_F0MAP"),
XMATERIAL_PARAM_TEXTURE("f0 texture", "txF0"),
XMATERIAL_PARAM_FLAG("Use f0 texture", "has_f0_texture", "HAS_F0MAP2"),
XMATERIAL_PARAM_GROUP_END(),
XMATERIAL_PARAM_GROUP(NULL, "!HAS_F0MAP"),
// XMATERIAL_PARAM_FLAG("Use f0 texture", "has_f0_texture", "HAS_F0MAP2"),
XMATERIAL_PARAM_RANGE("f0", "pbr_f0", 0.0f, 1.0f, 0.04f),
XMATERIAL_PARAM_GROUP_END(),
XMATERIAL_PROPERTY_LIST_END()
};
XMaterialShaderPass pPasses[] = {
{pRenderPassGBuffer, "shaders/default/default.ps", "MainGBuffer", pMacro, pSamplers, pProperties},
{pRenderPassIllumination, "shaders/default/default.ps", "MainIllimination", NULL, NULL, NULL},
{pRenderPassShadow, "shaders/default/default.ps", "MainShadow", NULL, NULL, NULL},
XMATERIAL_SHADER_PASS_LIST_END()
};
XMaterialProperty pGenericProperties[] = {
// parameter name, texture name
XMATERIAL_PARAM_TEXTURE("Base texture", "txBase"),
// parameter name, define_if_supplied
XMATERIAL_PARAM_TEXTURE_OPT("Normal map", "txNormals", "HAS_NORMALMAP"),
// parameter name, material parameter name, define_if_set
XMATERIAL_PARAM_FLAG("Use param texture", "has_parameter_texture", "HAS_PARAMMAP"),
// group name (optional), condition (define)
XMATERIAL_PARAM_GROUP(NULL, "HAS_PARAMMAP"),
XMATERIAL_PARAM_TEXTURE("Param texture", "txParameters"),
XMATERIAL_PARAM_GROUP_END(),
XMATERIAL_PARAM_GROUP(NULL, "!HAS_PARAMMAP"),
// name, min, max, material parameter name
XMATERIAL_PARAM_RANGE("Roughness", "pbr_roughness", 0.0f, 1.0f, 0.5f),
XMATERIAL_PARAM_RANGE("Metallic", "pbr_metallic", 0.0f, 1.0f, 0.0f),
XMATERIAL_PARAM_RANGE("Thickness", "pbr_thickness", 0.0f, 1.0f, 1.0f),
XMATERIAL_PARAM_RANGE("AO", "pbr_ao", 0.0f, 1.0f, 1.0f),
XMATERIAL_PARAM_GROUP_END(),
XMATERIAL_PARAM_FLAG("Enable alphatest", "has_alphatest", "HAS_ALPHATEST"),
XMATERIAL_PARAM_GROUP(NULL, "HAS_ALPHATEST"),
XMATERIAL_PARAM_RANGE("Alphatest threshold", "pbr_alphatest_threshold", 0.0f, 1.0f, 0.8f),
XMATERIAL_PARAM_GROUP_END(),
XMATERIAL_PROPERTY_LIST_END()
};
m_pMaterialSystem->registerMaterialShader("Default", pVertexFormatSceneGeneric, pPasses, pGenericProperties);
}
{
XMaterialShaderPass pPasses[] = {
{pRenderPassGBuffer, "shaders/default/transparent.ps", "MainTransparency", NULL, NULL, NULL},
{pRenderPassIllumination, "shaders/default/transparent.ps", "MainIllimination", NULL, NULL, NULL},
{pRenderPassShadow, "shaders/default/transparent.ps", "MainShadow", NULL, NULL, NULL},
XMATERIAL_SHADER_PASS_LIST_END()
};
XMaterialProperty pGenericProperties[] = {
XMATERIAL_STATIC_PARAM("transparent", 1.0f),
// parameter name, texture name
XMATERIAL_PARAM_TEXTURE("Base texture", "txBase"),
// parameter name, define_if_supplied
XMATERIAL_PARAM_TEXTURE_OPT("Normal map", "txNormals", "HAS_NORMALMAP"),
// parameter name, material parameter name, define_if_set
XMATERIAL_PARAM_FLAG("Refraction", "has_refraction", "HAS_REFRACTION"),
XMATERIAL_PARAM_FLAG("Use param texture", "has_parameter_texture", "HAS_PARAMMAP"),
// group name (optional), condition (define)
XMATERIAL_PARAM_GROUP(NULL, "HAS_PARAMMAP"),
XMATERIAL_PARAM_TEXTURE("Param texture", "txParameters"),
XMATERIAL_PARAM_GROUP_END(),
XMATERIAL_PARAM_GROUP(NULL, "!HAS_PARAMMAP"),
// name, min, max, material parameter name
XMATERIAL_PARAM_RANGE("Roughness", "pbr_roughness", 0.0f, 1.0f, 0.5f),
XMATERIAL_PARAM_RANGE("Metallic", "pbr_metallic", 0.0f, 1.0f, 0.0f),
XMATERIAL_PARAM_RANGE("Thickness", "pbr_thickness", 0.0f, 1.0f, 1.0f),
XMATERIAL_PARAM_RANGE("AO", "pbr_ao", 0.0f, 1.0f, 1.0f),
XMATERIAL_PARAM_GROUP_END(),
XMATERIAL_PROPERTY_LIST_END()
};
m_pMaterialSystem->registerMaterialShader("Transparent", pVertexFormatSceneGeneric, pPasses, pGenericProperties);
}
{
XMaterialShaderPass pPasses[] = {
{pRenderPassGBuffer, "shaders/default/postprocess.ps", "MainPostprocess", NULL, NULL, NULL},
XMATERIAL_SHADER_PASS_LIST_END()
};
m_pMaterialSystem->registerMaterialShader("Postprocess", pVertexFormatPostprocess, pPasses, NULL);
}
IXRenderable *pRenderable;
UINT ic = 0;
......
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