its running i think
This commit is contained in:
@@ -14,9 +14,8 @@ struct LightCullingData
|
||||
ParameterBlock<LightCullingData> pLightCullingData;
|
||||
|
||||
[shader("pixel")]
|
||||
void pixelMain(in VertexAttributes attribs, out float4 baseColor)
|
||||
void pixelMain(in MaterialParameter params : PARAMETER, out float4 baseColor)
|
||||
{
|
||||
MaterialParameter params = attribs.create();
|
||||
BRDF brdf = pMaterial.prepare(params);
|
||||
float3 result = float3(0, 0, 0);
|
||||
for(int i = 0; i < pLightEnv.numDirectionalLights; ++i)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import VertexData;
|
||||
import MaterialParameter;
|
||||
|
||||
struct InstanceData
|
||||
{
|
||||
@@ -13,11 +14,11 @@ struct Scene
|
||||
ParameterBlock<Scene> pScene;
|
||||
|
||||
[shader("vertex")]
|
||||
IVertexAttributes vertexMain(
|
||||
VertexAttributes vertexMain(
|
||||
uint vertexId: SV_VertexID,
|
||||
uint instanceId: SV_InstanceID,
|
||||
){
|
||||
InstanceData inst = pScene.instances[instanceId];
|
||||
IVertexAttributes attr = pVertexData.getAttributes(vertexId, inst.transformMatrix);
|
||||
VertexAttributes attr = pVertexData.getAttributes(vertexId, inst.transformMatrix);
|
||||
return attr;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ void taskMain(
|
||||
DispatchMesh(head, 1, 1, p);
|
||||
}
|
||||
|
||||
groupshared IVertexAttributes gs_vertices[MAX_VERTICES];
|
||||
groupshared VertexAttributes gs_vertices[MAX_VERTICES];
|
||||
groupshared uint3 gs_indices[MAX_PRIMITIVES];
|
||||
groupshared uint gs_numVertices;
|
||||
groupshared uint gs_numPrimitives;
|
||||
@@ -78,7 +78,7 @@ void meshMain(
|
||||
in uint threadID: SV_GroupIndex,
|
||||
in uint groupID: SV_GroupID,
|
||||
in payload MeshPayload meshPayload,
|
||||
out Vertices<IVertexAttributes, MAX_VERTICES> vertices,
|
||||
out Vertices<VertexAttributes, MAX_VERTICES> vertices,
|
||||
out Indices<uint3, MAX_PRIMITIVES> indices
|
||||
){
|
||||
InstanceData inst = pScene.instances[meshPayload.instanceId[groupID]];
|
||||
|
||||
@@ -9,3 +9,8 @@ struct MaterialParameter
|
||||
float3 viewDir_TS;
|
||||
}
|
||||
|
||||
struct VertexAttributes
|
||||
{
|
||||
MaterialParameter parameter : PARAMETER;
|
||||
float4 clipPosition: SV_POSITION;
|
||||
};
|
||||
|
||||
@@ -2,36 +2,6 @@ import VertexData;
|
||||
import Common;
|
||||
import Scene;
|
||||
|
||||
struct SkinnedMeshVertexAttributes : VertexAttributes
|
||||
{
|
||||
float4 clipPosition: SV_Position;
|
||||
float3 worldPosition: POSITION0;
|
||||
float2 texCoords: TEXCOORD0;
|
||||
float3 normal: NORMAL0;
|
||||
float3 tangent: TANGENT0;
|
||||
float3 biTangent: BITANGENT0;
|
||||
float3 getWorldPosition()
|
||||
{
|
||||
return worldPosition;
|
||||
}
|
||||
float2 getTexCoords()
|
||||
{
|
||||
return texCoords;
|
||||
}
|
||||
float3 getNormal()
|
||||
{
|
||||
return normal;
|
||||
}
|
||||
float3 getTangent()
|
||||
{
|
||||
return tangent;
|
||||
}
|
||||
float3 getBiTangent()
|
||||
{
|
||||
return biTangent;
|
||||
}
|
||||
}
|
||||
|
||||
struct SkinnedMeshVertexData : VertexData
|
||||
{
|
||||
SkinnedMeshVertexAttributes getAttributes(uint index, float4x4 transform)
|
||||
|
||||
@@ -2,45 +2,24 @@ import Common;
|
||||
import VertexData;
|
||||
import MaterialParameter;
|
||||
|
||||
struct StaticMeshVertexAttributes : IVertexAttributes
|
||||
{
|
||||
float4 clipPosition: SV_Position;
|
||||
float3 worldPosition: POSITION0;
|
||||
float2 texCoords: TEXCOORD0;
|
||||
float3 normal: NORMAL0;
|
||||
float3 tangent: TANGENT0;
|
||||
float3 biTangent: BITANGENT0;
|
||||
|
||||
MaterialParameter create()
|
||||
{
|
||||
MaterialParameter result;
|
||||
result.worldPosition = worldPosition;
|
||||
result.texCoords = texCoords;
|
||||
result.normal = normal;
|
||||
result.tangent = tangent;
|
||||
result.biTangent = biTangent;
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct StaticMeshVertexData : IVertexData
|
||||
{
|
||||
typedef StaticMeshVertexAttributes VertexAttributes;
|
||||
StaticMeshVertexAttributes getAttributes(uint index, float4x4 transform)
|
||||
VertexAttributes getAttributes(uint index, float4x4 transform)
|
||||
{
|
||||
StaticMeshVertexAttributes attr;
|
||||
VertexAttributes attributes;
|
||||
MaterialParameter params;
|
||||
float4 localPos = float4(positions[index], 1);
|
||||
float4 worldPos = mul(transform, localPos);
|
||||
float4 viewPos = mul(pViewParams.viewMatrix, worldPos);
|
||||
float4 clipPos = mul(pViewParams.projectionMatrix, viewPos);
|
||||
attr.clipPosition = clipPos;
|
||||
attr.worldPosition = worldPos.xyz;
|
||||
attr.texCoords = texCoords[index];
|
||||
attr.normal = normals[index];
|
||||
attr.tangent = tangents[index];
|
||||
attr.biTangent = biTangents[index];
|
||||
return attr;
|
||||
params.worldPosition = worldPos.xyz;
|
||||
params.texCoords = texCoords[index];
|
||||
params.normal = normals[index];
|
||||
params.tangent = tangents[index];
|
||||
params.biTangent = biTangents[index];
|
||||
attributes.parameter = params;
|
||||
attributes.clipPosition = clipPos;
|
||||
return attributes;
|
||||
}
|
||||
StructuredBuffer<float3> positions;
|
||||
StructuredBuffer<float2> texCoords;
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
import MaterialParameter;
|
||||
|
||||
interface IVertexAttributes
|
||||
{
|
||||
MaterialParameter create();
|
||||
};
|
||||
|
||||
interface IVertexData
|
||||
{
|
||||
associatedtype VertexAttributes : IVertexAttributes;
|
||||
VertexAttributes getAttributes(uint index, float4x4 transform);
|
||||
};
|
||||
ParameterBlock<IVertexData> pVertexData;
|
||||
Reference in New Issue
Block a user