some transparency
This commit is contained in:
@@ -5,6 +5,7 @@ interface IBRDF
|
|||||||
float3 evaluate(float3 viewDir_TS, float3 lightDir_TS, float3 lightColor);
|
float3 evaluate(float3 viewDir_TS, float3 lightDir_TS, float3 lightColor);
|
||||||
float3 evaluateAmbient();
|
float3 evaluateAmbient();
|
||||||
float getAlpha();
|
float getAlpha();
|
||||||
|
float3 getTangentNormal();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Phong : IBRDF
|
struct Phong : IBRDF
|
||||||
@@ -40,6 +41,10 @@ struct Phong : IBRDF
|
|||||||
{
|
{
|
||||||
return alpha;
|
return alpha;
|
||||||
}
|
}
|
||||||
|
float3 getTangentNormal()
|
||||||
|
{
|
||||||
|
return normal;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BlinnPhong : IBRDF
|
struct BlinnPhong : IBRDF
|
||||||
@@ -75,6 +80,10 @@ struct BlinnPhong : IBRDF
|
|||||||
{
|
{
|
||||||
return alpha;
|
return alpha;
|
||||||
}
|
}
|
||||||
|
float3 getTangentNormal()
|
||||||
|
{
|
||||||
|
return normal;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CelShading : IBRDF
|
struct CelShading : IBRDF
|
||||||
@@ -113,6 +122,10 @@ struct CelShading : IBRDF
|
|||||||
{
|
{
|
||||||
return alpha;
|
return alpha;
|
||||||
}
|
}
|
||||||
|
float3 getTangentNormal()
|
||||||
|
{
|
||||||
|
return normal;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// https://learnopengl.com/PBR/Theory
|
// https://learnopengl.com/PBR/Theory
|
||||||
@@ -201,4 +214,8 @@ struct CookTorrance : IBRDF
|
|||||||
{
|
{
|
||||||
return alpha;
|
return alpha;
|
||||||
}
|
}
|
||||||
|
float3 getTangentNormal()
|
||||||
|
{
|
||||||
|
return normal;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -49,6 +49,11 @@ struct FragmentParameter
|
|||||||
result.normal_TS = mul(tbn, normal_WS);
|
result.normal_TS = mul(tbn, normal_WS);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
float3x3 getTangentToWorld()
|
||||||
|
{
|
||||||
|
float3x3 tbn = float3x3(normalize(tangent_WS), normalize(biTangent_WS), normalize(normal_WS));
|
||||||
|
return transpose(tbn);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
static FragmentParameter interpolate(FragmentParameter f0, FragmentParameter f1, FragmentParameter f2, float3 barycentricCoords)
|
static FragmentParameter interpolate(FragmentParameter f0, FragmentParameter f1, FragmentParameter f2, float3 barycentricCoords)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,4 +55,7 @@ void closestHit(inout RayPayload hitValue, in BuiltInTriangleIntersectionAttribu
|
|||||||
result = pow(result, float3(1.0/2.2));
|
result = pow(result, float3(1.0/2.2));
|
||||||
|
|
||||||
hitValue.color = result;
|
hitValue.color = result;
|
||||||
|
hitValue.alpha = brdf.getAlpha();
|
||||||
|
hitValue.intersection_WS = WorldRayOrigin() + RayTCurrent() * WorldRayDirection();
|
||||||
|
hitValue.normal_WS = mul(params.getTangentToWorld(), brdf.getTangentNormal());
|
||||||
}
|
}
|
||||||
@@ -4,4 +4,7 @@ import RayTracingData;
|
|||||||
void miss(inout RayPayload p)
|
void miss(inout RayPayload p)
|
||||||
{
|
{
|
||||||
p.color = float3(0, 1, 0);
|
p.color = float3(0, 1, 0);
|
||||||
|
p.alpha = 1;
|
||||||
|
p.intersection_WS = float3(0, 0, 0);
|
||||||
|
p.normal_WS = float3(0, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -18,9 +18,19 @@ void raygen()
|
|||||||
rayDesc.TMin = 0.001;
|
rayDesc.TMin = 0.001;
|
||||||
rayDesc.TMax = 10000.0;
|
rayDesc.TMax = 10000.0;
|
||||||
|
|
||||||
RayPayload payload;
|
const uint maxRays = 12;
|
||||||
payload.rayDirection = rayDesc.Direction;
|
float3 color = float3(0, 0, 0);
|
||||||
TraceRay(pRayTracingParams.scene, RAY_FLAG_FORCE_OPAQUE, 0xff, 0, 0, 0, rayDesc, payload);
|
float alpha;
|
||||||
|
for(uint i = 0; i < maxRays; ++i) {
|
||||||
|
RayPayload payload;
|
||||||
|
TraceRay(pRayTracingParams.scene, RAY_FLAG_FORCE_OPAQUE, 0xff, 0, 0, 0, rayDesc, payload);
|
||||||
|
color = color.rgb * alpha + payload.color * payload.alpha;
|
||||||
|
alpha = alpha + payload.alpha;
|
||||||
|
rayDesc.Origin = payload.intersection_WS;
|
||||||
|
if(alpha > 0.9){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pRayTracingParams.image[int2(LaunchID.xy)] = float4(payload.color, 1.0);
|
pRayTracingParams.image[int2(LaunchID.xy)] = float4(color, alpha);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ struct CallablePayload
|
|||||||
|
|
||||||
struct RayPayload
|
struct RayPayload
|
||||||
{
|
{
|
||||||
float3 rayDirection;
|
|
||||||
float3 color;
|
float3 color;
|
||||||
|
float alpha;
|
||||||
|
float3 intersection_WS;
|
||||||
|
float3 normal_WS;
|
||||||
};
|
};
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Asset.h"
|
#include "Asset.h"
|
||||||
|
#include "TextureAsset.h"
|
||||||
|
|
||||||
namespace Seele {
|
namespace Seele {
|
||||||
class LevelAsset : public Asset {
|
class LevelAsset : public Asset {
|
||||||
@@ -12,5 +13,6 @@ class LevelAsset : public Asset {
|
|||||||
virtual void load(ArchiveBuffer& buffer) override;
|
virtual void load(ArchiveBuffer& buffer) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Array<OTextureAsset> lightMaps;
|
||||||
};
|
};
|
||||||
} // namespace Seele
|
} // namespace Seele
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
namespace Seele {
|
namespace Seele {
|
||||||
namespace Component {
|
namespace Component {
|
||||||
struct PointLight {
|
struct PointLight {
|
||||||
Vector4 positionWS;
|
// give the lights a radius so that they are not actual points
|
||||||
// Vector4 positionVS;
|
Vector4 positionWSRadius;
|
||||||
Vector4 colorRange;
|
Vector4 colorRange;
|
||||||
};
|
};
|
||||||
} // namespace Component
|
} // namespace Component
|
||||||
|
|||||||
Reference in New Issue
Block a user