More linux changes

This commit is contained in:
2023-10-09 17:20:30 +02:00
parent 4aacdce41f
commit a47f17481b
15 changed files with 379 additions and 271 deletions
+1 -1
View File
@@ -1,11 +1,11 @@
import Common;
import BRDF;
import MaterialParameter;
interface IMaterial
{
associatedtype BRDF : IBRDF;
BRDF prepare(MaterialFragmentParameter input);
};
ParameterBlock<IMaterial> gMaterial;
+22
View File
@@ -0,0 +1,22 @@
import VertexData;
struct MaterialParameter
{
float3 worldPosition;
float2 texCoords;
float3 normal;
float3 tangent;
float3 biTangent;
static MaterialParameter create(VertexAttributes attrib)
{
MaterialParameter result;
result.worldPosition = attrib.getWorldPosition().xyz;
result.texCoords = attrib.getTexCoords();
result.normal = attrib.getNormal();
result.tangent = attrib.getTangent();
result.biTangent = attrib.getBiTangent();
return result;
}
}
+24 -7
View File
@@ -4,14 +4,17 @@ import Scene;
struct StaticMeshVertexAttributes : VertexAttributes
{
float4 position: SV_Position;
float4 clipPosition: SV_Position;
float3 worldPosition: POSITION0;
float2 texCoords: TEXCOORD0;
float3 normal: NORMAL0;
float4 getPosition()
float3 tangent: TANGENT0;
float3 biTangent: BITANGENT0;
float3 getWorldPosition()
{
return position;
return worldPosition;
}
float2 getTexCoord()
float2 getTexCoords()
{
return texCoords;
}
@@ -19,6 +22,14 @@ struct StaticMeshVertexAttributes : VertexAttributes
{
return normal;
}
float3 getTangent()
{
return tangent;
}
float3 getBiTangent()
{
return biTangent;
}
}
struct StaticMeshVertexData : VertexData
@@ -26,16 +37,22 @@ struct StaticMeshVertexData : VertexData
StaticMeshVertexAttributes getAttributes(uint index, InstanceData inst)
{
StaticMeshVertexAttributes attr;
float4 worldPos = mul(inst.transformMatrix, positions[index]);
float4 localPos = float4(positions[index], 1);
float4 worldPos = mul(inst.transformMatrix, localPos);
float4 viewPos = mul(viewParams.viewMatrix, worldPos);
float4 clipPos = mul(viewParams.projectionMatrix, viewPos);
attr.position = clipPos;
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;
}
StructuredBuffer<float4> positions;
StructuredBuffer<float3> positions;
StructuredBuffer<float2> texCoords;
StructuredBuffer<float3> normals;
StructuredBuffer<float3> tangents;
StructuredBuffer<float3> biTangents;
}
ParameterBlock<StaticMeshVertexData> vertexData;
+4 -2
View File
@@ -2,9 +2,11 @@ import Scene;
interface VertexAttributes
{
float4 getPosition();
float2 getTexCoord();
float3 getWorldPosition();
float2 getTexCoords();
float3 getNormal();
float3 getTangent();
float3 getBiTangent();
}
interface VertexData