Skip to content

Commit

Permalink
submits
Browse files Browse the repository at this point in the history
  • Loading branch information
kingofthebongo2008 committed Mar 1, 2016
1 parent 95366cc commit 6b41d99
Show file tree
Hide file tree
Showing 170 changed files with 8,657 additions and 487 deletions.
Binary file added msm/Externals/AntTweakBar/lib/AntTweakBar64.lib
Binary file not shown.
Binary file added msm/Externals/d3dcompiler_46.dll
Binary file not shown.
Binary file added msm/Shadows/AntTweakBar64.dll
Binary file not shown.
5 changes: 5 additions & 0 deletions msm/Shadows/SampleFramework11/ShaderCompilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ static ID3DBlob* CompileShader(const wchar* path, const char* functionName, cons

ID3DBlob* compiledShader;
ID3DBlobPtr errorMessages;
wchar_t buffer[256];

wsprintf(buffer, L"%s\n", path);

OutputDebugString(buffer);
HRESULT hr = D3DCompileFromFile(path, defines, D3D_COMPILE_STANDARD_FILE_INCLUDE, functionName,
profile, flags, 0, &compiledShader, &errorMessages);

Expand Down
Binary file added msm/Shadows/SettingsCompiler.exe
Binary file not shown.
Binary file added msm/Shadows/SettingsCompilerAttributes.dll
Binary file not shown.
Binary file added msm/Shadows/Shadows.exe
Binary file not shown.
Binary file added msm/test.7z
Binary file not shown.
Binary file added msm/test/Content/Models/Columns/Columns.sdkmesh
Binary file not shown.
Binary file added msm/test/Content/Models/Columns/default.dds
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/command_a.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/con_edge.dds
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/crn_pan_a.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/crn_pan_c.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/crn_pan_d.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/crn_pan_e.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/crn_pan_f.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/crn_pan_g.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/crn_pan_i.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/ele_bot.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/ele_floor.dds
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/fan_blde.dds
Binary file not shown.
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/fan_hub.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/gr_trans_b.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/gravel_a.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/gravel_c.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/grt_sm_a.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/grt_sm_b.dds
Binary file not shown.
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/hz_a.dds
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/mav_b_lit.dds
Binary file not shown.
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/pad_big_b.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/pad_pan_a.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/pipe_a.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/pipe_b.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/pipe_d.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/pipe_e.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/rail.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/re_bar_a.dds
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/ring_a.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/road_end.dds
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/road_st_a.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/sm_pan_a.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/tank_side.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/tank_top.dds
Binary file not shown.
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/tow_rib_ a.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/tow_rib_c.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/trench_b.dds
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/truss_a.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/truss_end.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/tw_tex_a.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Powerplant/walkway_a.dds
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added msm/test/Content/Models/Soldier/Soldier.sdkmesh
Binary file not shown.
Binary file not shown.
Binary file added msm/test/Content/Models/Soldier/head_diff.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Soldier/head_norm.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Soldier/jacket_diff.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Soldier/jacket_norm.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Soldier/pants_diff.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Soldier/pants_norm.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Soldier/upBody_diff.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Soldier/upbody_norm.dds
Binary file not shown.
Binary file added msm/test/Content/Models/Tower/Tower.sdkmesh
Binary file not shown.
Binary file added msm/test/Content/Models/Tower/blackDirty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added msm/test/Content/Models/Tower/cementDiffuse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added msm/test/Content/Models/Tower/redDirty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added msm/test/Content/Models/Tower/road_2k_diff_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added msm/test/Content/Models/Tower/woodDirty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added msm/test/Content/Textures/Default.dds
Binary file not shown.
Binary file added msm/test/Shadows/AntTweakBar64.dll
Binary file not shown.
76 changes: 76 additions & 0 deletions msm/test/Shadows/AppSettings.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
cbuffer AppSettings : register(b7)
{
float3 LightDirection;
float3 LightColor;
bool EnableAlbedoMap;
int ShadowMapSize;
float FilterSize;
bool StabilizeCascades;
int NumDiscSamples;
bool AutoComputeDepthBounds;
float MinCascadeDistance;
float MaxCascadeDistance;
int PartitionMode;
float SplitDistance0;
float SplitDistance1;
float SplitDistance2;
float SplitDistance3;
float PSSMLambda;
float Bias;
float VSMBias;
float OffsetScale;
int SMFormat;
float PositiveExponent;
float NegativeExponent;
float LightBleedingReduction;
float MSMDepthBias;
float MSMMomentBias;
float BloomThreshold;
float BloomMagnitude;
float BloomBlurSigma;
float KeyValue;
float AdaptationRate;
}

static const int Scene_PowerPlant = 0;
static const int Scene_Tower = 1;
static const int Scene_Columns = 2;

static const int ShadowMode_FixedSizePCF = 0;
static const int ShadowMode_GridPCF = 1;
static const int ShadowMode_RandomDiscPCF = 2;
static const int ShadowMode_OptimizedPCF = 3;
static const int ShadowMode_VSM = 4;
static const int ShadowMode_EVSM2 = 5;
static const int ShadowMode_EVSM4 = 6;
static const int ShadowMode_MSMHamburger = 7;
static const int ShadowMode_MSMHausdorff = 8;

static const int ShadowMapSize_SMSize512 = 0;
static const int ShadowMapSize_SMSize1024 = 1;
static const int ShadowMapSize_SMSize2048 = 2;

static const int FixedFilterSize_Filter2x2 = 0;
static const int FixedFilterSize_Filter3x3 = 1;
static const int FixedFilterSize_Filter5x5 = 2;
static const int FixedFilterSize_Filter7x7 = 3;
static const int FixedFilterSize_Filter9x9 = 4;

static const int PartitionMode_Manual = 0;
static const int PartitionMode_Logarithmic = 1;
static const int PartitionMode_PSSM = 2;

static const int ShadowMSAA_MSAANone = 0;
static const int ShadowMSAA_MSAA2x = 1;
static const int ShadowMSAA_MSAA4x = 2;
static const int ShadowMSAA_MSAA8x = 3;

static const int SMFormat_SM16Bit = 0;
static const int SMFormat_SM32Bit = 1;

static const int ShadowAnisotropy_Anisotropy1x = 0;
static const int ShadowAnisotropy_Anisotropy2x = 1;
static const int ShadowAnisotropy_Anisotropy4x = 2;
static const int ShadowAnisotropy_Anisotropy8x = 3;
static const int ShadowAnisotropy_Anisotropy16x = 4;

27 changes: 27 additions & 0 deletions msm/test/Shadows/DepthOnly.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//=================================================================================================
//
// Shadows Sample
// by MJP
// http://mynameismjp.wordpress.com/
//
// All code and content licensed under Microsoft Public License (Ms-PL)
//
//=================================================================================================

// ================================================================================================
// Constant buffers
// ================================================================================================
cbuffer VSConstants : register(b0)
{
float4x4 World;
float4x4 ViewProjection;
}

// ================================================================================================
// Vertex Shader
// ================================================================================================
float4 VS(in float3 PositionOS : POSITION) : SV_Position
{
float3 positionWS = mul(float4(PositionOS, 1.0f), World).xyz;
return mul(float4(positionWS, 1.0f), ViewProjection);
}
238 changes: 238 additions & 0 deletions msm/test/Shadows/DepthReduction.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
//=================================================================================================
//
// Shadows Sample
// by MJP
// http://mynameismjp.wordpress.com/
//
// All code and content licensed under Microsoft Public License (Ms-PL)
//
//=================================================================================================

//=================================================================================================
// Includes
//=================================================================================================
#include "SharedConstants.h"

//=================================================================================================
// Constants
//=================================================================================================
#define MSAA_ 1
static const uint NumThreads = ReductionTGSize * ReductionTGSize;

//=================================================================================================
// Resources
//=================================================================================================
#if MSAA_
Texture2DMS<float> DepthMap : register(t0);
#else
Texture2D<float> DepthMap : register(t0);
#endif

Texture2D<float2> ReductionMap : register(t0);

SamplerState LinearClampSampler : register(s0);

RWTexture2D<float2> OutputMap : register(u0);

cbuffer ReductionConstants : register(b0)
{
float4x4 Projection;
float NearClip;
float FarClip;
}

#if CS_
// -- shared memory
groupshared float2 depthSamples[NumThreads];
#endif

// ------------------------------------------------------------------------------------------------
// Returns the min of 4 values
// ------------------------------------------------------------------------------------------------
float Min4(in float4 values)
{
return min(min(values.x, values.y), min(values.z, values.w));
}

// ------------------------------------------------------------------------------------------------
// Returns the max of 4 values
// ------------------------------------------------------------------------------------------------
float Max4(in float4 values)
{
return max(max(values.x, values.y), max(values.z, values.w));
}

// First pass of the depth reduction
float2 DepthReductionInitialPS(in float4 PositionSS : SV_Position,
in float2 TexCoord : TEXCOORD0) : SV_Target0
{
float minDepth = 1.0f;
float maxDepth = 0.0f;

#if MSAA_
uint w, h, numSamples;
DepthMap.GetDimensions(w, h, numSamples);

for(uint sIdx = 0; sIdx < numSamples; ++sIdx)
{
[unroll]
for(uint y = 0; y < 2; ++y)
{
[unroll]
for(uint x = 0; x < 2; ++x)
{
uint2 samplePos = min(uint2(PositionSS.xy) * 2 + uint2(x, y), uint2(w - 1, h - 1));
float depthSample = DepthMap.Load(samplePos, sIdx);

if(depthSample < 1.0f)
{
// Convert to linear Z
depthSample = Projection._43 / (depthSample - Projection._33);
depthSample = saturate((depthSample - NearClip) / (FarClip - NearClip));
minDepth = min(minDepth, depthSample);
maxDepth = max(maxDepth, depthSample);
}
}
}
}
#else
float4 depthSamples = DepthMap.GatherRed(LinearClampSampler, TexCoord);
depthSamples = Projection._43 / (depthSamples - Projection._33);
depthSamples = saturate((depthSamples - NearClip) / (FarClip - NearClip));
float minDepth = Min4(depthSamples);
float maxDepth = Max4(depthSamples);
#endif

return float2(minDepth, maxDepth);
}

// Subsequent passes of the depth reduction
float2 DepthReductionPS(in float4 PositionSS : SV_Position,
in float2 TexCoord : TEXCOORD0) : SV_Target0
{
float4 minSamples = ReductionMap.GatherRed(LinearClampSampler, TexCoord);
float4 maxSamples = ReductionMap.GatherGreen(LinearClampSampler, TexCoord);
float minDepth = Min4(minSamples);
float maxDepth = Max4(maxSamples);

return float2(minDepth, maxDepth);
}

#if CS_

// First pass of the depth reduction
[numthreads(ReductionTGSize, ReductionTGSize, 1)]
void DepthReductionInitialCS(in uint3 GroupID : SV_GroupID,
in uint3 GroupThreadID : SV_GroupThreadID,
uint ThreadIndex : SV_GroupIndex)
{
float minDepth = 1.0f;
float maxDepth = 0.0f;

#if MSAA_
uint2 textureSize;
uint numSamples;
DepthMap.GetDimensions(textureSize.x, textureSize.y, numSamples);
#else
uint2 textureSize;
DepthMap.GetDimensions(textureSize.x, textureSize.y);
#endif

uint2 samplePos = GroupID.xy * ReductionTGSize + GroupThreadID.xy;
samplePos = min(samplePos, textureSize - 1);

#if MSAA_
for(uint sIdx = 0; sIdx < numSamples; ++sIdx)
{
float depthSample = DepthMap.Load(samplePos, sIdx);

if(depthSample < 1.0f)
{
// Convert to linear Z
depthSample = Projection._43 / (depthSample - Projection._33);
depthSample = saturate((depthSample - NearClip) / (FarClip - NearClip));
minDepth = min(minDepth, depthSample);
maxDepth = max(maxDepth, depthSample);
}
}
#else
float depthSample = DepthMap[samplePos];

if(depthSample < 1.0f)
{
// Convert to linear Z
depthSample = Projection._43 / (depthSample - Projection._33);
depthSample = saturate((depthSample - NearClip) / (FarClip - NearClip));
minDepth = min(minDepth, depthSample);
maxDepth = max(maxDepth, depthSample);
}
#endif

// Store in shared memory
depthSamples[ThreadIndex] = float2(minDepth, maxDepth);
GroupMemoryBarrierWithGroupSync();

// Reduce
[unroll]
for(uint s = NumThreads / 2; s > 0; s >>= 1)
{
if(ThreadIndex < s)
{
depthSamples[ThreadIndex].x = min(depthSamples[ThreadIndex].x, depthSamples[ThreadIndex + s].x);
depthSamples[ThreadIndex].y = max(depthSamples[ThreadIndex].y, depthSamples[ThreadIndex + s].y);
}

GroupMemoryBarrierWithGroupSync();
}

if(ThreadIndex == 0)
{
minDepth = depthSamples[0].x;
maxDepth = depthSamples[0].y;
OutputMap[GroupID.xy] = float2(minDepth, maxDepth);
}
}

// Subsequent passes of the depth reduction
[numthreads(ReductionTGSize, ReductionTGSize, 1)]
void DepthReductionCS(in uint3 GroupID : SV_GroupID, in uint3 GroupThreadID : SV_GroupThreadID,
in uint ThreadIndex : SV_GroupIndex)
{
uint2 textureSize;
ReductionMap.GetDimensions(textureSize.x, textureSize.y);

uint2 samplePos = GroupID.xy * ReductionTGSize + GroupThreadID.xy;
samplePos = min(samplePos, textureSize - 1);

float minDepth = ReductionMap[samplePos].x;
float maxDepth = ReductionMap[samplePos].y;

if(minDepth == 0.0f)
minDepth = 1.0f;

// Store in shared memory
depthSamples[ThreadIndex] = float2(minDepth, maxDepth);
GroupMemoryBarrierWithGroupSync();

// Reduce
[unroll]
for(uint s = NumThreads / 2; s > 0; s >>= 1)
{
if(ThreadIndex < s)
{
depthSamples[ThreadIndex].x = min(depthSamples[ThreadIndex].x, depthSamples[ThreadIndex + s].x);
depthSamples[ThreadIndex].y = max(depthSamples[ThreadIndex].y, depthSamples[ThreadIndex + s].y);
}

GroupMemoryBarrierWithGroupSync();
}

if(ThreadIndex == 0)
{
minDepth = depthSamples[0].x;
maxDepth = depthSamples[0].y;
OutputMap[GroupID.xy] = float2(minDepth, maxDepth);
}
}

#endif // CS_
Loading

0 comments on commit 6b41d99

Please sign in to comment.