EEVEE Next: GI surfels debug display #105802

Merged
Miguel Pozo merged 6 commits from pragma37/blender:pull-eevee-next-surfels into main 2023-03-16 14:14:44 +01:00
4 changed files with 9 additions and 7 deletions
Showing only changes of commit 033b55da2a - Show all commits

View File

@ -17,8 +17,8 @@ void GI::generate_random_surfels()
for (Surfel &surfel : surfels) {
float3 random = rng.get_unit_float3();
surfel.position = float4(random * 3.0f);
surfel.normal = float4(random);
surfel.position = random * 3.0f;
surfel.normal = random;
surfel.color = float4(rng.get_float(), rng.get_float(), rng.get_float(), 1.0f);
}

View File

@ -831,8 +831,10 @@ static inline ShadowTileDataPacked shadow_tile_pack(ShadowTileData tile)
* \{ */
struct Surfel {
pragma37 marked this conversation as resolved Outdated

Rename to DebugSurfel

Rename to `DebugSurfel`

So the idea would be to eventually have a Surfel and a DebugSurfel and make the copy/conversion before rendering the debug visualization?

So the idea would be to eventually have a Surfel and a DebugSurfel and make the copy/conversion before rendering the debug visualization?

Yes. I'm thinking we could reuse it for raytracing debugging.

Yes. I'm thinking we could reuse it for raytracing debugging.
float4 position;
float4 normal;
float3 position;
pragma37 marked this conversation as resolved

Use packed_float3 if you do that.

Use `packed_float3` if you do that.
int _pad0;
float3 normal;
int _pad1;
float4 color;
};
BLI_STATIC_ASSERT_ALIGN(Surfel, 16)

View File

@ -5,7 +5,7 @@ void main()
out_color = surfel.color;
/* Display surfels as circles. */
if (distance(P, surfel.position.xyz) > surfel_radius) {
if (distance(P, surfel.position) > surfel_radius) {
discard;
return;
}

View File

@ -9,14 +9,14 @@ void main()
const vec3 verts[4] = vec3[4](vec3(-1, 1, 0), vec3(-1, -1, 0), vec3(1, 1, 0), vec3(1, -1, 0));
pragma37 marked this conversation as resolved Outdated

Prefer using a switch for compatibility with Metal.

Prefer using a switch for compatibility with Metal.
vec3 lP = verts[gl_VertexID];
vec3 N = surfel.normal.xyz;
vec3 N = surfel.normal;
vec3 T, B;
make_orthonormal_basis(N, T, B);
mat4 model_matrix = mat4(vec4(T * surfel_radius, 0),
vec4(B * surfel_radius, 0),
vec4(N * surfel_radius, 0),
vec4(surfel.position.xyz, 1));
vec4(surfel.position, 1));
P = (model_matrix * vec4(lP, 1)).xyz;