added material rendering
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"shader": "funny_basic_pbr",
|
||||
"AlbedoTexture": "game/core/textures/bricks.png"
|
||||
"AlbedoTexture": "game/core/textures/cat.png",
|
||||
"AlbedoMultiplier": [1,1,1,1]
|
||||
}
|
||||
|
||||
@@ -10,13 +10,21 @@ COMMON {
|
||||
float4x4 g_matViewProjection;
|
||||
float4 g_vViewPosition;
|
||||
};
|
||||
struct PerModelData
|
||||
|
||||
struct MaterialData_t
|
||||
{
|
||||
float4 m_vAlbedoColor;
|
||||
uint32_t m_uAlbedo;
|
||||
};
|
||||
|
||||
struct PerModelData_t
|
||||
{
|
||||
float4x4 m_matTranslation;
|
||||
float4x4 m_matRotation;
|
||||
uint32_t m_uAlbedo;
|
||||
MaterialData_t m_material;
|
||||
}
|
||||
StructuredBuffer<PerModelData> g_modelData;
|
||||
|
||||
StructuredBuffer<PerModelData_t> g_modelData;
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 m_vScreenPosition: SV_POSITION;
|
||||
@@ -80,8 +88,18 @@ PS
|
||||
PS_OUTPUT psMain( PS_INPUT input )
|
||||
{
|
||||
PS_OUTPUT output = {};
|
||||
PerModelData data = g_modelData[input.m_uInstance];
|
||||
output.m_vAlbedo = g_textures[data.m_uAlbedo].Sample(g_textureSampler, input.m_vTexCoord.xy);
|
||||
PerModelData_t data = g_modelData[input.m_uInstance];
|
||||
if ( data.m_material.m_uAlbedo != -1 )
|
||||
{
|
||||
output.m_vAlbedo = g_textures[data.m_material.m_uAlbedo]
|
||||
.Sample(g_textureSampler, input.m_vTexCoord.xy)
|
||||
* data.m_material.m_vAlbedoColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
output.m_vAlbedo = data.m_material.m_vAlbedoColor;
|
||||
|
||||
}
|
||||
output.m_vWorldPosition = input.m_vWorldPosition;
|
||||
output.m_vNormal = input.m_vNormal;
|
||||
return output;
|
||||
|
||||
BIN
funnyassets/textures/cat.png
Normal file
BIN
funnyassets/textures/cat.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 142 KiB |
Reference in New Issue
Block a user