updated voxel radiance compute

This commit is contained in:
turanszkij
2017-02-26 19:45:12 +01:00
parent bc6798ae6d
commit 428943ac4c
3 changed files with 56 additions and 5 deletions
+40 -2
View File
@@ -5,14 +5,52 @@ RWTEXTURE3D(output, float4, 0);
groupshared float4 accumulation[4 * 4 * 4];
static const float3 SAMPLES[16] = {
float3(0.355512, -0.709318, -0.102371),
float3(0.534186, 0.71511, -0.115167),
float3(-0.87866, 0.157139, -0.115167),
float3(0.140679, -0.475516, -0.0639818),
float3(-0.0796121, 0.158842, -0.677075),
float3(-0.0759516, -0.101676, -0.483625),
float3(0.12493, -0.0223423, -0.483625),
float3(-0.0720074, 0.243395, -0.967251),
float3(-0.207641, 0.414286, 0.187755),
float3(-0.277332, -0.371262, 0.187755),
float3(0.63864, -0.114214, 0.262857),
float3(-0.184051, 0.622119, 0.262857),
float3(0.110007, -0.219486, 0.435574),
float3(0.235085, 0.314707, 0.696918),
float3(-0.290012, 0.0518654, 0.522688),
float3(0.0975089, -0.329594, 0.609803)
};
[numthreads(4, 4, 4)]
void main( uint3 DTid : SV_DispatchThreadID, uint GroupIndex : SV_GroupIndex )
{
// TODO!
float4 current = input[DTid];
float3 dim;
input.GetDimensions(dim.x, dim.y, dim.z);
float3 uvw = DTid / dim;
output[DTid] = current;
float occ = 0;
uint count = 0;
for (uint i = 0; i < 16; ++i)
{
for (uint j = 1; j < 6; ++j)
{
float3 tex = uvw + j * SAMPLES[i] / dim;
occ += input.SampleLevel(sampler_linear_clamp, tex, 0).a;
count++;
}
}
output[DTid] = float4(input[DTid].rgb, occ / count);
//float4 current = input[DTid];
//output[DTid] = current;
//accumulation[GroupIndex] = current;
+1
View File
@@ -248,6 +248,7 @@ enum RSTYPES
RSTYPE_SHADOW_DOUBLESIDED,
RSTYPE_OCCLUDEE,
RSTYPE_VOXELIZE,
RSTYPE_SKY,
RSTYPE_LAST
};
// depth-stencil states
+15 -3
View File
@@ -1013,6 +1013,18 @@ void wiRenderer::SetUpStates()
rs.AntialiasedLineEnable = false;
GetDevice()->CreateRasterizerState(&rs, rasterizers[RSTYPE_VOXELIZE]);
rs.FillMode = FILL_SOLID;
rs.CullMode = CULL_FRONT;
rs.FrontCounterClockwise = true;
rs.DepthBias = 0;
rs.DepthBiasClamp = 0;
rs.SlopeScaledDepthBias = 0;
rs.DepthClipEnable = false;
rs.ScissorEnable = false;
rs.MultisampleEnable = false;
rs.AntialiasedLineEnable = false;
GetDevice()->CreateRasterizerState(&rs, rasterizers[RSTYPE_SKY]);
for (int i = 0; i < DSSTYPE_LAST; ++i)
{
depthStencils[i] = new DepthStencilState;
@@ -3707,7 +3719,7 @@ void wiRenderer::DrawSky(GRAPHICSTHREAD threadID)
GetDevice()->EventBegin("DrawSky", threadID);
GetDevice()->BindPrimitiveTopology(TRIANGLELIST,threadID);
GetDevice()->BindRasterizerState(rasterizers[RSTYPE_BACK],threadID);
GetDevice()->BindRasterizerState(rasterizers[RSTYPE_SKY],threadID);
GetDevice()->BindDepthStencilState(depthStencils[DSSTYPE_DEPTHREAD],STENCILREF_SKY,threadID);
GetDevice()->BindBlendState(blendStates[BSTYPE_OPAQUE],threadID);
@@ -3727,7 +3739,7 @@ void wiRenderer::DrawSun(GRAPHICSTHREAD threadID)
GetDevice()->EventBegin("DrawSun", threadID);
GetDevice()->BindPrimitiveTopology(TRIANGLELIST, threadID);
GetDevice()->BindRasterizerState(rasterizers[RSTYPE_BACK], threadID);
GetDevice()->BindRasterizerState(rasterizers[RSTYPE_SKY], threadID);
GetDevice()->BindDepthStencilState(depthStencils[DSSTYPE_DEPTHREAD], STENCILREF_SKY, threadID);
GetDevice()->BindBlendState(blendStates[BSTYPE_ADDITIVE], threadID);
@@ -3865,7 +3877,7 @@ void wiRenderer::RefreshEnvProbes(GRAPHICSTHREAD threadID)
// sky
{
GetDevice()->BindPrimitiveTopology(TRIANGLELIST, threadID);
GetDevice()->BindRasterizerState(rasterizers[RSTYPE_BACK], threadID);
GetDevice()->BindRasterizerState(rasterizers[RSTYPE_SKY], threadID);
GetDevice()->BindDepthStencilState(depthStencils[DSSTYPE_DEPTHREAD], STENCILREF_SKY, threadID);
GetDevice()->BindBlendState(blendStates[BSTYPE_OPAQUE], threadID);