shader refactors

This commit is contained in:
Turánszki János
2023-06-09 17:26:54 +02:00
parent c48f4a9fe6
commit 3df14532f6
5 changed files with 16 additions and 17 deletions
@@ -593,18 +593,18 @@ struct ShaderMeshInstancePointer
{
data = 0;
}
void Create(uint _instanceIndex, uint frustum_index = 0, float dither = 0)
void Create(uint _instanceIndex, uint camera_index = 0, float dither = 0)
{
data = 0;
data |= _instanceIndex & 0xFFFFFF;
data |= (frustum_index & 0xF) << 24u;
data |= (camera_index & 0xF) << 24u;
data |= (uint(dither * 15.0f) & 0xF) << 28u;
}
uint GetInstanceIndex()
{
return data & 0xFFFFFF;
}
uint GetFrustumIndex()
uint GetCameraIndex()
{
return (data >> 24u) & 0xF;
}
+9 -10
View File
@@ -257,18 +257,17 @@ struct PrimitiveID
#define texture_normal bindless_textures_float2[GetCamera().texture_normal_index]
#define texture_roughness bindless_textures_float[GetCamera().texture_roughness_index]
#define PI 3.14159265358979323846
#define SQRT2 1.41421356237309504880
#define FLT_MAX 3.402823466e+38
#define FLT_EPSILON 1.192092896e-07
#define GOLDEN_RATIO 1.6180339887
static const float PI = 3.14159265358979323846;
static const float SQRT2 = 1.41421356237309504880;
static const float FLT_MAX = 3.402823466e+38;
static const float FLT_EPSILON = 1.192092896e-07;
static const float GOLDEN_RATIO = 1.6180339887;
static const float M_TO_SKY_UNIT = 0.001f; // Engine units are in meters
static const float SKY_UNIT_TO_M = rcp(M_TO_SKY_UNIT);
#define sqr(a) ((a)*(a))
#define sqr(a) ((a)*(a))
#define pow5(x) pow(x, 5)
#define M_TO_SKY_UNIT 0.001f // Engine units are in meters
#define SKY_UNIT_TO_M (1.0 / M_TO_SKY_UNIT)
// attribute computation with barycentric interpolation
// a0 : attribute at triangle corner 0
// a1 : attribute at triangle corner 1
@@ -1358,7 +1357,7 @@ enum class ColorSpace
};
#define NUM_PARALLAX_OCCLUSION_STEPS 32
static const uint NUM_PARALLAX_OCCLUSION_STEPS = 32;
inline void ParallaxOcclusionMapping_Impl(
inout float4 uvsets, // uvsets to modify
in float3 V, // view vector (pointing towards camera)
+2 -2
View File
@@ -361,7 +361,7 @@ PixelInput main(VertexInput input)
#endif // OBJECTSHADER_USE_EMISSIVE
#ifdef OBJECTSHADER_USE_RENDERTARGETARRAYINDEX
const uint frustum_index = input.GetInstancePointer().GetFrustumIndex();
const uint frustum_index = input.GetInstancePointer().GetCameraIndex();
Out.RTIndex = GetCamera(frustum_index).output_index;
#ifndef OBJECTSHADER_USE_NOCAMERA
Out.pos = mul(GetCamera(frustum_index).view_projection, surface.position);
@@ -369,7 +369,7 @@ PixelInput main(VertexInput input)
#endif // OBJECTSHADER_USE_RENDERTARGETARRAYINDEX
#ifdef OBJECTSHADER_USE_VIEWPORTARRAYINDEX
const uint frustum_index = input.GetInstancePointer().GetFrustumIndex();
const uint frustum_index = input.GetInstancePointer().GetCameraIndex();
Out.VPIndex = GetCamera(frustum_index).output_index;
#ifndef OBJECTSHADER_USE_NOCAMERA
Out.pos = mul(GetCamera(frustum_index).view_projection, surface.position);
+1 -1
View File
@@ -33,7 +33,7 @@ VSOut main(VertexInput input)
Out.pos.xyz = (Out.pos.xyz - clipmap.center) / clipmap.voxelSize;
// Project onto dominant axis:
const uint frustum_index = input.GetInstancePointer().GetFrustumIndex();
const uint frustum_index = input.GetInstancePointer().GetCameraIndex();
switch (frustum_index)
{
default:
+1 -1
View File
@@ -9,7 +9,7 @@ namespace wi::version
// minor features, major updates, breaking compatibility changes
const int minor = 71;
// minor bug fixes, alterations, refactors, updates
const int revision = 221;
const int revision = 222;
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);