Trying to fix invalid descriptorlayout
This commit is contained in:
@@ -2,17 +2,28 @@ const static float PI = 3.1415926535897932f;
|
||||
const static uint MAX_PARTICLES = 65536;
|
||||
const static uint BLOCK_SIZE = 8;
|
||||
|
||||
cbuffer ScreenToViewParams
|
||||
struct ViewParameter
|
||||
{
|
||||
float4x4 viewMatrix;
|
||||
float4x4 projectionMatrix;
|
||||
float4 cameraPos_WS;
|
||||
}
|
||||
layout(set = 1, binding = 0, std430)
|
||||
ConstantBuffer<ViewParameter> gViewParams;
|
||||
|
||||
struct ScreenToViewParams
|
||||
{
|
||||
float4x4 inverseProjection;
|
||||
float2 screenDimensions;
|
||||
}
|
||||
layout(set = 1, binding = 1, std430)
|
||||
ConstantBuffer<ScreenToViewParams> gScreenToViewParams;
|
||||
|
||||
// Convert clip space coordinates to view space
|
||||
float4 clipToView( float4 clip )
|
||||
{
|
||||
// View space position.
|
||||
float4 view = mul( inverseProjection, clip );
|
||||
float4 view = mul( gScreenToViewParams.inverseProjection, clip );
|
||||
// Perspective projection.
|
||||
view = view / view.w;
|
||||
|
||||
@@ -23,7 +34,7 @@ float4 clipToView( float4 clip )
|
||||
float4 screenToView( float4 screen )
|
||||
{
|
||||
// Convert to normalized texture coordinates
|
||||
float2 texCoord = screen.xy / screenDimensions;
|
||||
float2 texCoord = screen.xy / gScreenToViewParams.screenDimensions;
|
||||
|
||||
// Convert to clip space
|
||||
float4 clip = float4( float2( texCoord.x, -texCoord.y ) * 2.0f - 1.0f, screen.z, screen.w );
|
||||
|
||||
@@ -23,28 +23,27 @@ struct PointLight : ILightEnv
|
||||
{
|
||||
float4 positionWS;
|
||||
float4 positionVS;
|
||||
float3 color;
|
||||
float range;
|
||||
|
||||
float4 colorRange;
|
||||
|
||||
float3 illuminate<B:IBRDF>(MaterialFragmentParameter input, B brdf, float3 viewDir)
|
||||
{
|
||||
float3 lightVec = positionWS.xyz - input.worldPosition;
|
||||
float d = length(lightVec);
|
||||
float3 direction = normalize(lightVec);
|
||||
float illuminance = max(1 - d / range, 0);
|
||||
return illuminance * brdf.evaluate(viewDir, direction, input.worldNormal, input.worldTangent, input.worldBiTangent, color);
|
||||
float illuminance = max(1 - d / colorRange.w, 0);
|
||||
return illuminance * brdf.evaluate(viewDir, direction, input.worldNormal, input.worldTangent, input.worldBiTangent, colorRange.xyz);
|
||||
}
|
||||
|
||||
bool insidePlane(Plane plane)
|
||||
{
|
||||
return dot(plane.n, positionVS.xyz) - plane.d < -range;
|
||||
return dot(plane.n, positionVS.xyz) - plane.d < -colorRange.w;
|
||||
}
|
||||
|
||||
bool insideFrustum(Frustum frustum, float zNear, float zFar)
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
//if(positionVS.z - range > zNear || positionVS.z + range < zFar)
|
||||
//if(positionVS.z - range > zNear || positionVS.z + colorRange.w < zFar)
|
||||
{
|
||||
// result = false;
|
||||
}
|
||||
@@ -69,5 +68,5 @@ struct Lights
|
||||
uint numPointLights;
|
||||
};
|
||||
|
||||
layout(set = 0, binding = 1)
|
||||
layout(set = 0, binding = 0, std430)
|
||||
ConstantBuffer<Lights> gLightEnv;
|
||||
|
||||
@@ -16,3 +16,7 @@ interface IMaterial
|
||||
float getRoughness(MaterialFragmentParameter input);
|
||||
float getSheen(MaterialFragmentParameter input);
|
||||
};
|
||||
|
||||
type_param TMaterial : IMaterial;
|
||||
layout(set = 2, binding = 0, std430)
|
||||
ParameterBlock<TMaterial> gMaterial;
|
||||
|
||||
@@ -44,4 +44,3 @@ struct MaterialFragmentParameter
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -4,16 +4,5 @@ struct PrimitiveSceneData
|
||||
float4x4 worldToLocal;
|
||||
};
|
||||
|
||||
|
||||
struct ViewParameter
|
||||
{
|
||||
float4x4 viewMatrix;
|
||||
float4x4 projectionMatrix;
|
||||
float4 cameraPos_WS;
|
||||
};
|
||||
layout(set = 0)
|
||||
ConstantBuffer<ViewParameter> gViewParams;
|
||||
|
||||
layout(set = 2)
|
||||
layout(set = 3, binding = 0, std430)
|
||||
ConstantBuffer<PrimitiveSceneData> gSceneData;
|
||||
|
||||
|
||||
@@ -1,13 +1,30 @@
|
||||
import Common;
|
||||
import MaterialParameter;
|
||||
import PrimitiveSceneData;
|
||||
|
||||
struct VertexValueCache
|
||||
{
|
||||
float3x3 tangentToLocal;
|
||||
float3x3 tangentToWorld;
|
||||
//This struct is passed between vertex and fragment stage
|
||||
//which means, that it is passed as out mat3x3 in glsl
|
||||
//but Slang for some reason puts a layout(row_major) above
|
||||
//every attribute, including this matrix, but matrix layout
|
||||
//qualifiers are illegal for non-uniform and buffer fields,
|
||||
//leading to a compiler error
|
||||
float3 tangentToLocal[3];
|
||||
float3 tangentToWorld[3];
|
||||
float tangentToWorldSign;
|
||||
float4 color;
|
||||
|
||||
float3x3 getTangentToLocal()
|
||||
{
|
||||
return float3x3(tangentToLocal[0], tangentToLocal[1], tangentToLocal[2]);
|
||||
}
|
||||
|
||||
float3x3 getTangentToWorld()
|
||||
{
|
||||
return float3x3(tangentToWorld[0], tangentToWorld[1], tangentToWorld[2]);
|
||||
}
|
||||
|
||||
#if USE_INSTANCING
|
||||
float4 instanceOrigin;
|
||||
float3 instanceTransform1;
|
||||
@@ -133,9 +150,15 @@ struct VertexShaderInput
|
||||
#endif
|
||||
|
||||
float tangentSign;
|
||||
cache.tangentToLocal = calcTangentToLocal(tangentSign);
|
||||
float3x3 tangentToLocal = calcTangentToLocal(tangentSign);
|
||||
cache.tangentToLocal[0] = tangentToLocal[0];
|
||||
cache.tangentToLocal[1] = tangentToLocal[1];
|
||||
cache.tangentToLocal[2] = tangentToLocal[2];
|
||||
float3x3 localToWorld = float3x3(gSceneData.localToWorld[0].xyz, gSceneData.localToWorld[1].xyz, gSceneData.localToWorld[2].xyz);
|
||||
cache.tangentToWorld = mul(cache.tangentToLocal, localToWorld);
|
||||
float3x3 tangentToWorld = mul(tangentToLocal, localToWorld);
|
||||
cache.tangentToWorld[0] = tangentToWorld[0];
|
||||
cache.tangentToWorld[1] = tangentToWorld[1];
|
||||
cache.tangentToWorld[2] = tangentToWorld[2];
|
||||
cache.tangentToWorldSign = tangentSign;
|
||||
|
||||
return cache;
|
||||
@@ -146,7 +169,7 @@ struct VertexShaderInput
|
||||
MaterialVertexParameter result;
|
||||
result.worldPosition = worldPosition;
|
||||
result.vertexColor = cache.color;
|
||||
result.tangentToWorld = cache.tangentToWorld;
|
||||
result.tangentToWorld = cache.getTangentToWorld();
|
||||
// TODO instancing
|
||||
/*for(int i = 0; i < NUM_MATERIAL_TEXCOORDS-1; i+=2)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user