There is a memory leak

This commit is contained in:
Dynamitos
2023-11-30 11:51:53 +01:00
parent d1475d506e
commit 1493627ceb
20 changed files with 91 additions and 102 deletions
+10 -17
View File
@@ -2,7 +2,6 @@ import Common;
struct MaterialParameter
{
float3 position_TS;
float3 position_WS;
float2 texCoords;
float3 vertexColor;
@@ -11,18 +10,16 @@ struct MaterialParameter
// data used by light environment
struct LightingParameter
{
// world to tangent space
float3x3 tbn;
float3 position_TS;
float3 viewDir_TS;
float3 position_WS;
float3 viewDir_WS;
};
// data passed to fragment shader
struct FragmentParameter
{
float4 position_CS : SV_Position;
float3 position_TS : POSITION0;
float3 viewDir_TS : POSITION1;
float3 viewDir_WS : POSITION1;
float3 normal_WS : NORMAL0;
float3 tangent_WS : TANGENT0;
float3 biTangent_WS : TANGENT1;
@@ -32,7 +29,6 @@ struct FragmentParameter
MaterialParameter getMaterialParameter()
{
MaterialParameter result;
result.position_TS = position_TS;
result.position_WS = position_WS;
result.texCoords = texCoords;
result.vertexColor = vertexColor;
@@ -41,9 +37,9 @@ struct FragmentParameter
LightingParameter getLightingParameter()
{
LightingParameter result;
result.tbn = transpose(float3x3(normalize(tangent_WS), normalize(biTangent_WS), normalize(normal_WS)));
result.position_TS = position_TS;
result.viewDir_TS = viewDir_TS;
result.tbn = float3x3(normalize(tangent_WS), normalize(biTangent_WS), normalize(normal_WS));
result.position_WS = position_WS;
result.viewDir_WS = viewDir_WS;
return result;
}
};
@@ -63,14 +59,11 @@ struct VertexAttributes
float4 worldPos = mul(transformMatrix, modelPos);
float4 viewPos = mul(pViewParams.viewMatrix, worldPos);
float4 clipPos = mul(pViewParams.projectionMatrix, viewPos);
float3 tangent_WS = mul(transformMatrix, float4(normalize(tangent_MS), 0)).xyz;
float3 biTangent_WS = mul(transformMatrix, float4(normalize(biTangent_MS), 0)).xyz;
float3 normal_WS = mul(transformMatrix, float4(normalize(normal_MS), 0)).xyz;
// Transforms from world space into tangent space
float3x3 tbn = transpose(float3x3(tangent_WS, biTangent_WS, normal_WS));
float3 tangent_WS = mul(float3x3(transformMatrix), normalize(tangent_MS));
float3 biTangent_WS = mul(float3x3(transformMatrix), normalize(biTangent_MS));
float3 normal_WS = mul(float3x3(transformMatrix), normalize(normal_MS));
FragmentParameter result;
result.position_TS = mul(tbn, worldPos.xyz);
result.viewDir_TS = mul(tbn, pViewParams.cameraPos_WS.xyz - worldPos.xyz);
result.viewDir_WS = pViewParams.cameraPos_WS.xyz - worldPos.xyz;
result.normal_WS = normal_WS;
result.tangent_WS = tangent_WS;
result.biTangent_WS = biTangent_WS;