store emittance flood texture as r16g16
This commit is contained in:
parent
fd0501c700
commit
210242b6d6
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
ConstantBuffer<struct sh_flood_constants> g_constants : register(b0);
|
ConstantBuffer<struct sh_flood_constants> g_constants : register(b0);
|
||||||
Texture2D<float4> g_emittance_textures[] : register(t0, space0);
|
Texture2D<float4> g_emittance_textures[] : register(t0, space0);
|
||||||
RWTexture2D<uint> g_flood_textures[]: register(u0, space1);
|
RWTexture2D<uint2> g_flood_textures[]: register(u0, space1);
|
||||||
|
|
||||||
SamplerState g_sampler : register(s0);
|
SamplerState g_sampler : register(s0);
|
||||||
|
|
||||||
@ -44,9 +44,9 @@ SH_ENTRY(ROOTSIG) void cs(struct cs_input input)
|
|||||||
if (step_len == -1) {
|
if (step_len == -1) {
|
||||||
/* Seed */
|
/* Seed */
|
||||||
float4 emittance = g_emittance_textures[g_constants.emittance_tex_urid][id];
|
float4 emittance = g_emittance_textures[g_constants.emittance_tex_urid][id];
|
||||||
uint seed = 0xFFFFFFFF;
|
uint2 seed = uint2(0xFFFF, 0xFFFF);
|
||||||
if (emittance.a > 0) {
|
if (emittance.a > 0) {
|
||||||
seed = (id.x << 16) | id.y;
|
seed = id;
|
||||||
}
|
}
|
||||||
g_flood_textures[g_constants.write_flood_tex_urid][id] = seed;
|
g_flood_textures[g_constants.write_flood_tex_urid][id] = seed;
|
||||||
} else {
|
} else {
|
||||||
@ -62,14 +62,13 @@ SH_ENTRY(ROOTSIG) void cs(struct cs_input input)
|
|||||||
(int2)id + int2(0 , +step_len), /* bottom center */
|
(int2)id + int2(0 , +step_len), /* bottom center */
|
||||||
(int2)id + int2(+step_len, +step_len) /* bottom right */
|
(int2)id + int2(+step_len, +step_len) /* bottom right */
|
||||||
};
|
};
|
||||||
uint closest_seed = 0xFFFFFFFF;
|
uint2 closest_seed = uint2(0xFFFF, 0xFFFF);
|
||||||
uint closest_seed_len_sq = 0xFFFFFFFF;
|
uint closest_seed_len_sq = 0xFFFFFFFF;
|
||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
int2 coord = read_coords[i];
|
int2 coord = read_coords[i];
|
||||||
if (coord.x >= 0 && coord.x < (int)tex_size.x && coord.y >= 0 && coord.y < (int)tex_size.y) {
|
if (coord.x >= 0 && coord.x < (int)tex_size.x && coord.y >= 0 && coord.y < (int)tex_size.y) {
|
||||||
uint seed = g_flood_textures[g_constants.read_flood_tex_urid][coord];
|
uint2 seed = g_flood_textures[g_constants.read_flood_tex_urid][coord];
|
||||||
int2 seed_coord = int2((seed >> 16) & 0xFFFF, seed & 0xFFFF);
|
int2 dist_vec = (int2)id - (int2)seed;
|
||||||
int2 dist_vec = (int2)id - seed_coord;
|
|
||||||
uint dist_len_sq = dot(dist_vec, dist_vec);
|
uint dist_len_sq = dot(dist_vec, dist_vec);
|
||||||
if (dist_len_sq < closest_seed_len_sq) {
|
if (dist_len_sq < closest_seed_len_sq) {
|
||||||
closest_seed = seed;
|
closest_seed = seed;
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
ConstantBuffer<struct sh_shade_constants> g_constants : register(b0);
|
ConstantBuffer<struct sh_shade_constants> g_constants : register(b0);
|
||||||
Texture2D<float4> g_gbuff_textures[] : register(t0, space0);
|
Texture2D<float4> g_gbuff_textures[] : register(t0, space0);
|
||||||
Texture2D<uint> g_emittance_flood_textures[] : register(t0, space1);
|
Texture2D<uint2> g_emittance_flood_textures[] : register(t0, space1);
|
||||||
RWTexture2D<float4> g_write_textures[]: register(u0, space2);
|
RWTexture2D<float4> g_write_textures[]: register(u0, space2);
|
||||||
|
|
||||||
SamplerState g_sampler : register(s0);
|
SamplerState g_sampler : register(s0);
|
||||||
@ -44,9 +44,8 @@ SH_ENTRY(ROOTSIG) void cs(struct cs_input input)
|
|||||||
float4 albedo = g_gbuff_textures[g_constants.albedo_tex_urid][id];
|
float4 albedo = g_gbuff_textures[g_constants.albedo_tex_urid][id];
|
||||||
float4 emittance = g_gbuff_textures[g_constants.emittance_tex_urid][id];
|
float4 emittance = g_gbuff_textures[g_constants.emittance_tex_urid][id];
|
||||||
|
|
||||||
uint emittance_flood_packed = g_emittance_flood_textures[g_constants.emittance_flood_tex_urid][id];
|
uint2 emittance_flood = g_emittance_flood_textures[g_constants.emittance_flood_tex_urid][id];
|
||||||
uint2 emittance_flood = uint2(emittance_flood_packed >> 16, emittance_flood_packed & 0xFFFF);
|
emittance_flood *= (emittance_flood.x < 0xFFFF && emittance_flood.y < 0xFFFF);
|
||||||
emittance_flood *= emittance_flood_packed < 0xFFFFFFFF;
|
|
||||||
|
|
||||||
float4 final_color = old_color + albedo + float4(float(emittance_flood.x) / float(g_constants.tex_width), float(emittance_flood.y) / float(g_constants.tex_height), 0, 1);
|
float4 final_color = old_color + albedo + float4(float(emittance_flood.x) / float(g_constants.tex_width), float(emittance_flood.y) / float(g_constants.tex_height), 0, 1);
|
||||||
|
|
||||||
|
|||||||
@ -2672,8 +2672,8 @@ void gp_run(struct gp_run_params params)
|
|||||||
/* Alloc buffers */
|
/* Alloc buffers */
|
||||||
sig->albedo = gbuff_alloc(DXGI_FORMAT_R8G8B8A8_UNORM, final_target_size, D3D12_RESOURCE_STATE_RENDER_TARGET);
|
sig->albedo = gbuff_alloc(DXGI_FORMAT_R8G8B8A8_UNORM, final_target_size, D3D12_RESOURCE_STATE_RENDER_TARGET);
|
||||||
sig->emittance = gbuff_alloc(DXGI_FORMAT_R8G8B8A8_UNORM, final_target_size, D3D12_RESOURCE_STATE_RENDER_TARGET);
|
sig->emittance = gbuff_alloc(DXGI_FORMAT_R8G8B8A8_UNORM, final_target_size, D3D12_RESOURCE_STATE_RENDER_TARGET);
|
||||||
sig->emittance_flood_a = gbuff_alloc(DXGI_FORMAT_R32_UINT, final_target_size, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
sig->emittance_flood_a = gbuff_alloc(DXGI_FORMAT_R16G16_UINT, final_target_size, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||||
sig->emittance_flood_b = gbuff_alloc(DXGI_FORMAT_R32_UINT, final_target_size, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
sig->emittance_flood_b = gbuff_alloc(DXGI_FORMAT_R16G16_UINT, final_target_size, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sprite_scope *sprite_scope = sprite_scope_begin();
|
struct sprite_scope *sprite_scope = sprite_scope_begin();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user