This commit is contained in:
AndresTraks 2016-10-10 06:10:44 +03:00
Родитель e7908d8ca9
Коммит 91746d8c45
23 изменённых файлов: 246 добавлений и 1996 удалений

Просмотреть файл

@ -16,7 +16,7 @@ namespace DemoFramework.OpenTK
public Color Color;
}
public class ShapeData : System.IDisposable
public class ShapeData : IDisposable
{
public int VertexCount;
public int ElementCount;

Просмотреть файл

@ -1,120 +0,0 @@
using System;
using System.Globalization;
using SharpDX;
using SharpDX.Direct3D;
using SharpDX.Direct3D10;
using SharpDX.DXGI;
using Device = SharpDX.Direct3D10.Device;
namespace DemoFramework.SharpDX
{
public class InfoText : IDisposable
{
Device device;
Font font;
Color4 color = new Color4(1, 0, 0, 1);
Color4 clearColor = new Color4(1, 0, 0, 0);
float fps = -1;
string textString = "";
Rectangle rect = new Rectangle(0, 0, 256, 256);
CultureInfo culture = CultureInfo.InvariantCulture;
Texture2D renderTexture;
RenderTargetView renderTextureView;
RenderTargetView[] renderViews;
OutputMergerStage outputMerger;
bool _isEnabled = true;
public bool IsEnabled
{
get { return _isEnabled; }
set { _isEnabled = value; }
}
string _text = "";
public string Text
{
get { return _text; }
set
{
_text = value;
textString = string.Format("FPS: {0}\n{1}", fps.ToString("0.00", culture), value);
}
}
public ShaderResourceView OverlayBufferRes;
public float Width {
get { return rect.Width; }
}
public float Height
{
get { return rect.Height; }
}
public InfoText(Device device)
{
this.device = device;
outputMerger = device.OutputMerger;
font = new Font(device, 20, 0, FontWeight.Normal, 0, false, FontCharacterSet.Default,
FontPrecision.Default, FontQuality.ClearTypeNatural, FontPitchAndFamily.DontCare, "tahoma");
renderTexture = new Texture2D(device, new Texture2DDescription()
{
ArraySize = 1,
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
CpuAccessFlags = CpuAccessFlags.None,
Format = Format.R8G8B8A8_UNorm,
Height = rect.Height,
Width = rect.Width,
MipLevels = 1,
OptionFlags = ResourceOptionFlags.None,
SampleDescription = new SampleDescription(1, 0),
Usage = ResourceUsage.Default
});
renderTextureView = new RenderTargetView(device, renderTexture);
renderViews = new[] { renderTextureView };
OverlayBufferRes = new ShaderResourceView(device, renderTexture, new ShaderResourceViewDescription()
{
Format = Format.R8G8B8A8_UNorm,
Dimension = ShaderResourceViewDimension.Texture2D,
Texture2D = new ShaderResourceViewDescription.Texture2DResource()
{
MipLevels = 1,
MostDetailedMip = 0
}
});
}
public void Dispose()
{
if (renderTexture != null)
{
renderTexture.Dispose();
renderTexture = null;
}
if (renderTextureView != null)
{
renderTextureView.Dispose();
renderTextureView = null;
}
}
public void OnRender(float framesPerSecond)
{
if (_isEnabled == false)
return;
if (fps != framesPerSecond)
{
fps = framesPerSecond;
textString = string.Format("FPS: {0}\n{1}", fps.ToString("0.00", culture), _text);
outputMerger.SetRenderTargets(1, renderViews, null);
device.ClearRenderTargetView(renderTextureView, clearColor);
font.DrawText(null, textString, rect, FontDrawFlags.Left, color);
}
}
}
}

Просмотреть файл

@ -1,31 +0,0 @@
using SharpDX;
namespace DemoFramework.SharpDX
{
static class MathHelper
{
public static Matrix Convert(ref BulletSharp.Math.Matrix m)
{
return new Matrix(
m.M11, m.M12, m.M13, m.M14,
m.M21, m.M22, m.M23, m.M24,
m.M31, m.M32, m.M33, m.M34,
m.M41, m.M42, m.M43, m.M44);
}
public static BulletSharp.Math.Matrix Convert(ref Matrix m)
{
BulletSharp.Math.Matrix r = new BulletSharp.Math.Matrix();
r.M11 = m.M11; r.M12 = m.M12; r.M13 = m.M13; r.M14 = m.M14;
r.M21 = m.M21; r.M22 = m.M22; r.M23 = m.M23; r.M24 = m.M24;
r.M31 = m.M31; r.M32 = m.M32; r.M33 = m.M33; r.M34 = m.M34;
r.M41 = m.M41; r.M42 = m.M42; r.M43 = m.M43; r.M44 = m.M44;
return r;
}
public static Vector3 Convert(BulletSharp.Math.Vector3 v)
{
return new Vector3(v.X, v.Y, v.Z);
}
}
}

Просмотреть файл

@ -1,486 +0,0 @@
using System.Collections.Generic;
using System.Runtime.InteropServices;
using BulletSharp;
using BulletSharp.SoftBody;
using SharpDX;
using SharpDX.Direct3D;
using SharpDX.Direct3D10;
using SharpDX.DXGI;
using Buffer = SharpDX.Direct3D10.Buffer;
using Color = System.Drawing.Color;
using DataStream = SharpDX.DataStream;
using Device = SharpDX.Direct3D10.Device;
using Matrix = BulletSharp.Math.Matrix;
using Vector3 = BulletSharp.Math.Vector3;
namespace DemoFramework.SharpDX
{
public struct InstanceData
{
public Matrix WorldTransform;
public uint Color;
public static readonly int SizeInBytes = Marshal.SizeOf(typeof(InstanceData));
}
// Contains the geometry buffers and information of all instances of a particular shape.
public class ShapeData : System.IDisposable
{
public Buffer VertexBuffer;
public int VertexCount;
public Buffer IndexBuffer;
public int IndexCount;
public Format IndexFormat;
public Buffer InstanceDataBuffer;
public List<InstanceData> Instances;
public InstanceData[] InstanceArray;
public PrimitiveTopology PrimitiveTopology;
public VertexBufferBinding[] BufferBindings;
public Vector3[] SoftBodyData;
public ShapeData()
{
Instances = new List<InstanceData>();
InstanceArray = new InstanceData[0];
PrimitiveTopology = PrimitiveTopology.TriangleList;
BufferBindings = new VertexBufferBinding[2];
}
public void SetVertexBuffer(Device device, Vector3[] vectors)
{
BufferDescription vertexBufferDesc = new BufferDescription()
{
SizeInBytes = Vector3.SizeInBytes * vectors.Length,
Usage = ResourceUsage.Default,
BindFlags = BindFlags.VertexBuffer
};
using (var data = new DataStream(vertexBufferDesc.SizeInBytes, false, true))
{
data.WriteRange(vectors);
data.Position = 0;
VertexBuffer = new Buffer(device, data, vertexBufferDesc);
}
BufferBindings[0] = new VertexBufferBinding(VertexBuffer, 24, 0);
}
// Used with soft bodies
public void SetDynamicVertexBuffer(Device device, Vector3[] vectors)
{
if (VertexBuffer != null && VertexCount * 2 == vectors.Length)
{
// Update existing buffer
using (var data = VertexBuffer.Map(MapMode.WriteDiscard))
{
data.WriteRange(vectors, 0, vectors.Length);
VertexBuffer.Unmap();
}
}
else
{
// Create new buffer
if (VertexBuffer != null)
VertexBuffer.Dispose();
BufferDescription vertexBufferDesc = new BufferDescription()
{
SizeInBytes = Vector3.SizeInBytes * vectors.Length,
Usage = ResourceUsage.Dynamic,
BindFlags = BindFlags.VertexBuffer,
CpuAccessFlags = CpuAccessFlags.Write
};
using (var data = new DataStream(vertexBufferDesc.SizeInBytes, false, true))
{
data.WriteRange(vectors);
data.Position = 0;
VertexBuffer = new Buffer(device, data, vertexBufferDesc);
}
VertexCount = vectors.Length / 2;
BufferBindings[0] = new VertexBufferBinding(VertexBuffer, 24, 0);
}
}
public void SetIndexBuffer(Device device, ushort[] indices)
{
IndexFormat = Format.R16_UInt;
BufferDescription indexBufferDesc = new BufferDescription()
{
SizeInBytes = sizeof(ushort) * indices.Length,
Usage = ResourceUsage.Default,
BindFlags = BindFlags.IndexBuffer
};
using (var data = new DataStream(indexBufferDesc.SizeInBytes, false, true))
{
data.WriteRange(indices);
data.Position = 0;
IndexBuffer = new Buffer(device, data, indexBufferDesc);
}
}
public void SetIndexBuffer(Device device, uint[] indices)
{
IndexFormat = Format.R32_UInt;
BufferDescription indexBufferDesc = new BufferDescription()
{
SizeInBytes = sizeof(uint) * indices.Length,
Usage = ResourceUsage.Default,
BindFlags = BindFlags.IndexBuffer
};
using (var data = new DataStream(indexBufferDesc.SizeInBytes, false, true))
{
data.WriteRange(indices);
data.Position = 0;
IndexBuffer = new Buffer(device, data, indexBufferDesc);
}
}
public void Dispose()
{
if (VertexBuffer != null)
{
VertexBuffer.Dispose();
VertexBuffer = null;
}
if (IndexBuffer != null)
{
IndexBuffer.Dispose();
IndexBuffer = null;
}
if (InstanceDataBuffer != null)
{
InstanceDataBuffer.Dispose();
InstanceDataBuffer = null;
}
}
}
// This class creates graphical objects (boxes, cones, cylinders, spheres) on the fly.
public class MeshFactory : DemoFramework.MeshFactory
{
Demo demo;
Device device;
InputAssemblerStage inputAssembler;
Dictionary<CollisionShape, ShapeData> shapes = new Dictionary<CollisionShape, ShapeData>();
List<CollisionShape> removeList = new List<CollisionShape>();
BufferDescription instanceDataDesc;
InputLayout inputLayout;
static uint groundColor = ColorToUint(Color.Green);
static uint activeColor = ColorToUint(Color.Orange);
static uint passiveColor = ColorToUint(Color.OrangeRed);
static uint softBodyColor = ColorToUint(Color.LightBlue);
static int linkColor = Color.Black.ToArgb();
static uint ColorToUint(Color c)
{
return (uint)c.R + ((uint)c.G << 8) + ((uint)c.B << 16) + ((uint)c.A << 24);
}
public MeshFactory(SharpDXGraphics graphics)
{
this.device = graphics.Device;
this.inputAssembler = device.InputAssembler;
this.demo = graphics.Demo;
instanceDataDesc = new BufferDescription()
{
Usage = ResourceUsage.Dynamic,
BindFlags = BindFlags.VertexBuffer,
CpuAccessFlags = CpuAccessFlags.Write,
OptionFlags = ResourceOptionFlags.None,
};
InputElement[] elements = new InputElement[]
{
new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0, InputClassification.PerVertexData, 0),
new InputElement("NORMAL", 0, Format.R32G32B32_Float, 12, 0, InputClassification.PerVertexData, 0),
new InputElement("WORLD", 0, Format.R32G32B32A32_Float, 0, 1, InputClassification.PerInstanceData, 1),
new InputElement("WORLD", 1, Format.R32G32B32A32_Float, 16, 1, InputClassification.PerInstanceData, 1),
new InputElement("WORLD", 2, Format.R32G32B32A32_Float, 32, 1, InputClassification.PerInstanceData, 1),
new InputElement("WORLD", 3, Format.R32G32B32A32_Float, 48, 1, InputClassification.PerInstanceData, 1),
new InputElement("COLOR", 0, Format.R8G8B8A8_UNorm, 64, 1, InputClassification.PerInstanceData, 1)
};
inputLayout = new InputLayout(device, graphics.GetEffectPass().Description.Signature, elements);
}
public override void RemoveShape(CollisionShape shape)
{
if (shapes.ContainsKey(shape))
{
shapes[shape].Dispose();
shapes.Remove(shape);
}
}
public void Clear()
{
foreach (ShapeData shapeData in shapes.Values)
{
shapeData.Dispose();
}
shapes.Clear();
}
public void Dispose()
{
Clear();
}
ShapeData CreateShape(CollisionShape shape)
{
ShapeData shapeData = new ShapeData();
uint[] indices;
Vector3[] vertices = CreateShape(shape, out indices);
shapeData.VertexCount = vertices.Length / 2;
shapeData.SetVertexBuffer(device, vertices);
if (indices != null)
{
shapeData.IndexCount = indices.Length;
ushort[] indices_s = CompactIndexBuffer(indices);
if (indices_s != null)
{
shapeData.SetIndexBuffer(device, indices_s);
}
else
{
shapeData.SetIndexBuffer(device, indices);
}
}
return shapeData;
}
ShapeData InitShapeData(CollisionShape shape)
{
ShapeData shapeData;
if (shapes.TryGetValue(shape, out shapeData) == false)
{
if (shape.ShapeType == BroadphaseNativeType.SoftBodyShape)
{
shapeData = new ShapeData();
}
else
{
shapeData = CreateShape(shape);
}
// Create an initial instance data buffer for a single instance
instanceDataDesc.SizeInBytes = InstanceData.SizeInBytes;
shapeData.InstanceDataBuffer = new Buffer(device, instanceDataDesc);
shapeData.BufferBindings[1] = new VertexBufferBinding(shapeData.InstanceDataBuffer, instanceDataDesc.SizeInBytes, 0);
shapes.Add(shape, shapeData);
}
return shapeData;
}
void InitRigidBodyInstance(CollisionObject colObj, CollisionShape shape, ref Matrix transform)
{
if (shape.ShapeType == BroadphaseNativeType.CompoundShape)
{
foreach (var child in (shape as CompoundShape).ChildList)
{
Matrix childTransform = child.Transform * transform;
InitRigidBodyInstance(colObj, child.ChildShape, ref childTransform);
}
}
else
{
var shapeData = InitShapeData(shape);
shapeData.Instances.Add(new InstanceData()
{
WorldTransform = transform,
Color = "Ground".Equals(colObj.UserObject) ? groundColor :
colObj.ActivationState == ActivationState.ActiveTag ? activeColor : passiveColor
});
}
}
void InitSoftBodyInstance(SoftBody softBody, CollisionShape shape)
{
var shapeData = InitShapeData(shape);
shapeData.Instances.Add(new InstanceData()
{
WorldTransform = Matrix.Identity,
Color = softBodyColor
});
UpdateSoftBody(softBody, shapeData);
}
public void InitInstancedRender(AlignedCollisionObjectArray objects)
{
// Clear instance data
foreach (ShapeData s in shapes.Values)
s.Instances.Clear();
// Gather instance data
int i = objects.Count - 1;
for (; i >= 0; i--)
{
var colObj = objects[i];
var shape = colObj.CollisionShape;
if (shape.ShapeType == BroadphaseNativeType.SoftBodyShape)
{
if (demo.IsDebugDrawEnabled)
continue;
InitSoftBodyInstance(colObj as SoftBody, shape);
}
else
{
Matrix transform;
colObj.GetWorldTransform(out transform);
InitRigidBodyInstance(colObj, shape, ref transform);
}
}
foreach (KeyValuePair<CollisionShape, ShapeData> sh in shapes)
{
ShapeData s = sh.Value;
int instanceCount = s.Instances.Count;
// Is the instance buffer the right size?
if (s.InstanceDataBuffer.Description.SizeInBytes != instanceCount * InstanceData.SizeInBytes)
{
// No, recreate it
s.InstanceDataBuffer.Dispose();
// Remember shapes that have no instances,
// shape is removed after iteration over shapes
if (instanceCount == 0)
{
if (s.IndexBuffer != null)
s.IndexBuffer.Dispose();
s.VertexBuffer.Dispose();
removeList.Add(sh.Key);
continue;
}
instanceDataDesc.SizeInBytes = instanceCount * InstanceData.SizeInBytes;
s.InstanceDataBuffer = new Buffer(device, instanceDataDesc);
s.BufferBindings[1] = new VertexBufferBinding(s.InstanceDataBuffer, InstanceData.SizeInBytes, 0);
}
// Copy the instance list over to the instance array
InstanceData[] instanceArray = s.InstanceArray;
if (instanceArray.Length != instanceCount)
{
instanceArray = new InstanceData[instanceCount];
s.InstanceArray = instanceArray;
}
s.Instances.CopyTo(instanceArray);
using (var data = s.InstanceDataBuffer.Map(MapMode.WriteDiscard, global::SharpDX.Direct3D10.MapFlags.None))
{
data.WriteRange(instanceArray);
s.InstanceDataBuffer.Unmap();
}
}
// Remove shapes that had no instances
if (removeList.Count != 0)
{
foreach (var shape in removeList)
{
shapes.Remove(shape);
}
removeList.Clear();
}
}
public void RenderInstanced()
{
inputAssembler.InputLayout = inputLayout;
foreach (ShapeData s in shapes.Values)
{
inputAssembler.SetVertexBuffers(0, s.BufferBindings);
inputAssembler.PrimitiveTopology = s.PrimitiveTopology;
if (s.IndexBuffer != null)
{
inputAssembler.SetIndexBuffer(s.IndexBuffer, s.IndexFormat, 0);
device.DrawIndexedInstanced(s.IndexCount, s.Instances.Count, 0, 0, 0);
}
else
{
device.DrawInstanced(s.VertexCount, s.Instances.Count, 0, 0);
}
}
}
public void UpdateSoftBody(SoftBody softBody, ShapeData shapeData)
{
// Could just allocate a Vector3 array here at each frame, but reusing shapeData.SoftBodyData is faster.
// Probably uses more memory though.
softBody.GetVertexNormalData(ref shapeData.SoftBodyData);
shapeData.SetDynamicVertexBuffer(device, shapeData.SoftBodyData);
if (softBody.Faces.Count == 0 && softBody.Tetras.Count == 0)
{
shapeData.PrimitiveTopology = PrimitiveTopology.LineList;
}
}
/*
public void RenderSoftBodyTextured(SoftBody softBody)
{
if (!(softBody.UserObject is Array))
return;
object[] userObjArr = softBody.UserObject as object[];
FloatArray vertexBuffer = userObjArr[0] as FloatArray;
IntArray indexBuffer = userObjArr[1] as IntArray;
int vertexCount = (vertexBuffer.Count / 8);
if (vertexCount > 0)
{
int faceCount = indexBuffer.Count / 2;
bool index32 = vertexCount > 65536;
Mesh mesh = new Mesh(device, faceCount, vertexCount,
MeshFlags.SystemMemory | (index32 ? MeshFlags.Use32Bit : 0),
VertexFormat.Position | VertexFormat.Normal | VertexFormat.Texture1);
SlimDX.DataStream indices = mesh.LockIndexBuffer(LockFlags.Discard);
if (index32)
{
foreach (int i in indexBuffer)
indices.Write(i);
}
else
{
foreach (int i in indexBuffer)
indices.Write((ushort)i);
}
mesh.UnlockIndexBuffer();
SlimDX.DataStream verts = mesh.LockVertexBuffer(LockFlags.Discard);
foreach (float f in vertexBuffer)
verts.Write(f);
mesh.UnlockVertexBuffer();
mesh.ComputeNormals();
mesh.DrawSubset(0);
mesh.Dispose();
}
}
* */
}
}

Просмотреть файл

@ -1,96 +0,0 @@
using BulletSharp;
using SharpDX.Direct3D10;
using SharpDX.DXGI;
using DataStream = global::SharpDX.DataStream;
using Device = SharpDX.Direct3D10.Device;
namespace DemoFramework.SharpDX
{
public class PhysicsDebugDraw : BufferedDebugDraw
{
Device _device;
InputAssemblerStage _inputAssembler;
InputLayout _inputLayout;
BufferDescription _vertexBufferDesc;
Buffer _vertexBuffer;
VertexBufferBinding _vertexBufferBinding;
int _vertexCount;
public PhysicsDebugDraw(SharpDXGraphics graphics)
{
_device = graphics.Device;
_inputAssembler = _device.InputAssembler;
InputElement[] elements = {
new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0, InputClassification.PerVertexData, 0),
new InputElement("COLOR", 0, Format.R8G8B8A8_UNorm, 12, 0, InputClassification.PerVertexData, 0)
};
_inputLayout = new InputLayout(_device, graphics.GetDebugDrawPass().Description.Signature, elements);
_vertexBufferDesc = new BufferDescription
{
Usage = ResourceUsage.Dynamic,
BindFlags = BindFlags.VertexBuffer,
CpuAccessFlags = CpuAccessFlags.Write
};
_vertexBufferBinding = new VertexBufferBinding(null, PositionColored.Stride, 0);
}
/*
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (vertexBuffer != null)
{
vertexBuffer.Dispose();
vertexBuffer = null;
}
}
base.Dispose(disposing);
}
*/
public void DrawDebugWorld(DynamicsWorld world)
{
world.DebugDrawWorld();
if (LineIndex == 0)
return;
_inputAssembler.InputLayout = _inputLayout;
if (_vertexCount != LineIndex)
{
if (_vertexBuffer != null)
{
_vertexBuffer.Dispose();
}
_vertexCount = LineIndex;
_vertexBufferDesc.SizeInBytes = PositionColored.Stride * _vertexCount;
using (var data = new DataStream(_vertexBufferDesc.SizeInBytes, false, true))
{
data.WriteRange(Lines, 0, _vertexCount);
data.Position = 0;
_vertexBuffer = new Buffer(_device, data, _vertexBufferDesc);
}
_vertexBufferBinding.Buffer = _vertexBuffer;
}
else
{
using (var map = _vertexBuffer.Map(MapMode.WriteDiscard))
{
map.WriteRange(Lines, 0, _vertexCount);
}
_vertexBuffer.Unmap();
}
_inputAssembler.SetVertexBuffers(0, _vertexBufferBinding);
_inputAssembler.PrimitiveTopology = global::SharpDX.Direct3D.PrimitiveTopology.LineList;
_device.Draw(_vertexCount, 0);
LineIndex = 0;
}
}
};

Просмотреть файл

@ -1,35 +0,0 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("DemoFramework.SharpDX")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Andres Traks")]
[assembly: AssemblyProduct("SharpDX")]
[assembly: AssemblyCopyright("Copyright © Andres Traks 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("00569f77-d19c-4000-9456-f030a71657e0")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Просмотреть файл

@ -1,122 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{3DDE3767-7DA8-4700-A74B-EC34146AB688}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DemoFramework.SharpDX</RootNamespace>
<AssemblyName>DemoFramework.SharpDX</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\..\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>..\..\..\bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\..\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>..\..\..\bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Compile Include="InfoText.cs" />
<Compile Include="MathHelper.cs" />
<Compile Include="MeshFactory.cs" />
<Compile Include="PhysicsDebugDraw.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SharpDXGraphics.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\DemoFramework.csproj">
<Project>{7F50B160-6C4D-467A-9AAB-10C516326BD1}</Project>
<Name>DemoFramework</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="BulletSharp, Version=0.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\bin\Release\BulletSharp.dll</HintPath>
</Reference>
<Reference Include="SharpDX, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>$(SharpDXPackageBinDir)\SharpDX.dll</HintPath>
</Reference>
<Reference Include="SharpDX.D3DCompiler, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(SharpDXPackageBinDir)\SharpDX.D3DCompiler.dll</HintPath>
</Reference>
<Reference Include="SharpDX.Direct3D10, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(SharpDXPackageBinDir)\SharpDX.Direct3D10.dll</HintPath>
</Reference>
<Reference Include="SharpDX.DXGI, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>$(SharpDXPackageBinDir)\SharpDX.DXGI.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="grender.fx" />
<EmbeddedResource Include="shader.fx" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\..\packages\SharpDX.2.6.3\build\SharpDX.targets" Condition="Exists('..\..\..\packages\SharpDX.2.6.3\build\SharpDX.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\..\packages\SharpDX.2.6.3\build\SharpDX.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\SharpDX.2.6.3\build\SharpDX.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Просмотреть файл

@ -1,607 +0,0 @@
using System;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using SharpDX;
using SharpDX.D3DCompiler;
using SharpDX.Direct3D;
using SharpDX.Direct3D10;
using SharpDX.DXGI;
using SharpDX.Windows;
using Buffer = SharpDX.Direct3D10.Buffer;
using Color = System.Drawing.Color;
using Device = SharpDX.Direct3D10.Device;
using DriverType = SharpDX.Direct3D10.DriverType;
using Matrix = SharpDX.Matrix;
using Vector3 = SharpDX.Vector3;
using Vector4 = SharpDX.Vector4;
namespace DemoFramework.SharpDX
{
public class SharpDXGraphics : Graphics
{
Device _device;
public Device Device
{
get { return _device; }
}
OutputMergerStage outputMerger;
InputAssemblerStage inputAssembler;
SwapChain _swapChain;
Texture2D gBufferLight;
Texture2D gBufferNormal;
Texture2D gBufferDiffuse;
Texture2D depthTexture;
Texture2D lightDepthTexture;
EffectShaderResourceVariable lightBufferVar;
EffectShaderResourceVariable normalBufferVar;
EffectShaderResourceVariable diffuseBufferVar;
EffectShaderResourceVariable depthMapVar;
EffectShaderResourceVariable lightDepthMapVar;
EffectMatrixVariable inverseProjectionVar;
EffectMatrixVariable inverseViewVar;
EffectMatrixVariable lightInverseViewProjectionVar;
EffectVectorVariable lightPositionVar;
EffectVectorVariable eyePositionVar;
EffectScalarVariable tanHalfFOVXVar;
EffectScalarVariable tanHalfFOVYVar;
EffectScalarVariable projectionAVar;
EffectScalarVariable projectionBVar;
EffectMatrixVariable overlayViewProjectionVar;
RenderTargetView renderView;
DepthStencilView depthView;
DepthStencilView lightDepthView;
RenderTargetView gBufferNormalView;
RenderTargetView gBufferDiffuseView;
RenderTargetView gBufferLightView;
RenderTargetView[] gBufferViews;
DepthStencilState depthStencilState;
DepthStencilState lightDepthStencilState;
bool shadowsEnabled = false;
RenderTargetView[] renderViews = new RenderTargetView[1];
Effect effect;
Effect effect2;
EffectPass shadowGenPass;
EffectPass gBufferGenPass;
EffectPass gBufferRenderPass;
EffectPass gBufferOverlayPass;
EffectPass debugDrawPass;
public EffectPass GetEffectPass()
{
return gBufferGenPass;
}
public EffectPass GetDebugDrawPass()
{
return debugDrawPass;
}
ShaderResourceView depthRes;
ShaderResourceView lightDepthRes;
ShaderResourceView lightBufferRes;
ShaderResourceView normalBufferRes;
ShaderResourceView diffuseBufferRes;
int _width;
int _height;
float _nearPlane;
ShaderSceneConstants sceneConstants;
Buffer sceneConstantsBuffer;
RasterizerStateDescription _rasterizerStateDesc;
InfoText info;
Color4 ambient;
MeshFactory _meshFactory;
[StructLayout(LayoutKind.Sequential)]
struct ShaderSceneConstants
{
public Matrix View;
public Matrix Projection;
public Matrix ViewInverse;
public Matrix LightViewProjection;
}
public override BulletSharp.IDebugDraw GetPhysicsDebugDrawer()
{
return new PhysicsDebugDraw(this);
}
public override bool IsFullScreen
{
get
{
return !_swapChain.Description.IsWindowed;
}
set
{
_swapChain.SetFullscreenState(value, null);
}
}
public override bool CullingEnabled
{
get
{
return base.CullingEnabled;
}
set
{
if (_device != null)
{
_rasterizerStateDesc.CullMode = value ? CullMode.Back : CullMode.None;
_device.Rasterizer.State.Dispose();
_device.Rasterizer.State = new RasterizerState(_device, _rasterizerStateDesc);
}
base.CullingEnabled = value;
}
}
public SharpDXGraphics(Demo demo)
: base(demo)
{
Form = new RenderForm();
}
/// <summary>
/// Disposes of object resources.
/// </summary>
/// <param name="disposeManagedResources">If true, managed resources should be
/// disposed of in addition to unmanaged resources.</param>
protected override void Dispose(bool disposeManagedResources)
{
if (disposeManagedResources)
{
if (info != null)
info.Dispose();
DisposeBuffers();
//apiContext.Dispose();
Form.Dispose();
}
}
void DisposeBuffers()
{
if (renderView != null)
renderView.Dispose();
if (gBufferLightView != null)
gBufferLightView.Dispose();
if (gBufferNormalView != null)
gBufferNormalView.Dispose();
if (gBufferDiffuseView != null)
gBufferDiffuseView.Dispose();
if (gBufferLight != null)
gBufferLight.Dispose();
if (gBufferNormal != null)
gBufferNormal.Dispose();
if (gBufferDiffuse != null)
gBufferDiffuse.Dispose();
if (depthTexture != null)
depthTexture.Dispose();
if (lightDepthTexture != null)
lightDepthTexture.Dispose();
if (lightBufferRes != null)
lightBufferRes.Dispose();
if (normalBufferRes != null)
normalBufferRes.Dispose();
if (diffuseBufferRes != null)
diffuseBufferRes.Dispose();
if (depthRes != null)
depthRes.Dispose();
if (lightDepthRes != null)
lightDepthRes.Dispose();
}
protected void OnInitializeDevice()
{
Form.ClientSize = new Size(_width, _height);
// SwapChain description
var desc = new SwapChainDescription()
{
BufferCount = 1,
ModeDescription = new ModeDescription(_width, _height, new Rational(60, 1), Format.R8G8B8A8_UNorm),
IsWindowed = true,
OutputHandle = Form.Handle,
SampleDescription = new SampleDescription(1, 0),
SwapEffect = SwapEffect.Discard,
Usage = Usage.RenderTargetOutput,
};
// Create Device and SwapChain
Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, desc, out _device, out _swapChain);
outputMerger = _device.OutputMerger;
inputAssembler = _device.InputAssembler;
Factory factory = _swapChain.GetParent<Factory>();
factory.MakeWindowAssociation(Form.Handle, WindowAssociationFlags.None);
}
void CreateBuffers()
{
DisposeBuffers();
// New RenderTargetView from the backbuffer
using (var bb = Texture2D.FromSwapChain<Texture2D>(_swapChain, 0))
{
renderView = new RenderTargetView(_device, bb);
renderViews[0] = renderView;
}
Texture2DDescription gBufferDesc = new Texture2DDescription()
{
ArraySize = 1,
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
CpuAccessFlags = CpuAccessFlags.None,
Format = Format.R8G8B8A8_UNorm,
Width = _width,
Height = _height,
MipLevels = 1,
OptionFlags = ResourceOptionFlags.None,
SampleDescription = new SampleDescription(1, 0),
Usage = ResourceUsage.Default
};
gBufferLight = new Texture2D(_device, gBufferDesc);
gBufferLightView = new RenderTargetView(_device, gBufferLight);
gBufferNormal = new Texture2D(_device, gBufferDesc);
gBufferNormalView = new RenderTargetView(_device, gBufferNormal);
gBufferDiffuse = new Texture2D(_device, gBufferDesc);
gBufferDiffuseView = new RenderTargetView(_device, gBufferDiffuse);
gBufferViews = new RenderTargetView[] { gBufferLightView, gBufferNormalView, gBufferDiffuseView };
ShaderResourceViewDescription gBufferResourceDesc = new ShaderResourceViewDescription()
{
Format = Format.R8G8B8A8_UNorm,
Dimension = ShaderResourceViewDimension.Texture2D,
Texture2D = new ShaderResourceViewDescription.Texture2DResource()
{
MipLevels = 1,
MostDetailedMip = 0
}
};
lightBufferRes = new ShaderResourceView(_device, gBufferLight, gBufferResourceDesc);
normalBufferRes = new ShaderResourceView(_device, gBufferNormal, gBufferResourceDesc);
diffuseBufferRes = new ShaderResourceView(_device, gBufferDiffuse, gBufferResourceDesc);
Texture2DDescription depthDesc = new Texture2DDescription()
{
ArraySize = 1,
BindFlags = BindFlags.DepthStencil | BindFlags.ShaderResource,
CpuAccessFlags = CpuAccessFlags.None,
Format = Format.R32_Typeless,
Width = _width,
Height = _height,
MipLevels = 1,
OptionFlags = ResourceOptionFlags.None,
SampleDescription = new SampleDescription(1, 0),
Usage = ResourceUsage.Default
};
DepthStencilViewDescription depthViewDesc = new DepthStencilViewDescription()
{
Dimension = DepthStencilViewDimension.Texture2D,
Format = Format.D32_Float,
};
ShaderResourceViewDescription resourceDesc = new ShaderResourceViewDescription()
{
Format = Format.R32_Float,
Dimension = ShaderResourceViewDimension.Texture2D,
Texture2D = new ShaderResourceViewDescription.Texture2DResource()
{
MipLevels = 1,
MostDetailedMip = 0
}
};
depthTexture = new Texture2D(_device, depthDesc);
depthView = new DepthStencilView(_device, depthTexture, depthViewDesc);
depthRes = new ShaderResourceView(_device, depthTexture, resourceDesc);
lightDepthTexture = new Texture2D(_device, depthDesc);
lightDepthView = new DepthStencilView(_device, lightDepthTexture, depthViewDesc);
lightDepthRes = new ShaderResourceView(_device, lightDepthTexture, resourceDesc);
lightBufferVar = effect2.GetVariableByName("lightBuffer").AsShaderResource();
normalBufferVar = effect2.GetVariableByName("normalBuffer").AsShaderResource();
diffuseBufferVar = effect2.GetVariableByName("diffuseBuffer").AsShaderResource();
depthMapVar = effect2.GetVariableByName("depthMap").AsShaderResource();
lightDepthMapVar = effect2.GetVariableByName("lightDepthMap").AsShaderResource();
inverseProjectionVar = effect2.GetVariableByName("InverseProjection").AsMatrix();
inverseViewVar = effect2.GetVariableByName("InverseView").AsMatrix();
lightInverseViewProjectionVar = effect2.GetVariableByName("LightInverseViewProjection").AsMatrix();
lightPositionVar = effect2.GetVariableByName("LightPosition").AsVector();
eyePositionVar = effect2.GetVariableByName("EyePosition").AsVector();
tanHalfFOVXVar = effect2.GetVariableByName("TanHalfFOVX").AsScalar();
tanHalfFOVYVar = effect2.GetVariableByName("TanHalfFOVY").AsScalar();
projectionAVar = effect2.GetVariableByName("ProjectionA").AsScalar();
projectionBVar = effect2.GetVariableByName("ProjectionB").AsScalar();
overlayViewProjectionVar = effect2.GetVariableByName("OverlayViewProjection").AsMatrix();
_device.Rasterizer.SetViewports(new Viewport(0, 0, _width, _height));
}
static ShaderBytecode LoadShader(string name, ShaderFlags flags)
{
Assembly assembly = Assembly.GetExecutingAssembly();
StreamReader reader = new StreamReader(assembly.GetManifestResourceStream("DemoFramework.SharpDX." + name));
string shaderSource = reader.ReadToEnd();
return ShaderBytecode.Compile(shaderSource, "fx_4_0", flags, EffectFlags.None);
}
public override void Initialize()
{
Form.SizeChanged += (o, args) =>
{
if (_swapChain == null)
return;
renderView.Dispose();
depthView.Dispose();
DisposeBuffers();
if (Form.WindowState == FormWindowState.Minimized)
return;
_width = Form.ClientSize.Width;
_height = Form.ClientSize.Height;
_swapChain.ResizeBuffers(_swapChain.Description.BufferCount, 0, 0, Format.Unknown, 0);
CreateBuffers();
SetSceneConstants();
};
_width = 1024;
_height = 768;
_nearPlane = 1.0f;
ambient = new Color4(Color.Gray.ToArgb());
try
{
OnInitializeDevice();
}
catch (Exception e)
{
MessageBox.Show(e.ToString(), "Could not create DirectX 10 device.");
return;
}
// shader.fx
const ShaderFlags shaderFlags = ShaderFlags.None;
//const ShaderFlags shaderFlags = ShaderFlags.Debug | ShaderFlags.SkipOptimization;
ShaderBytecode shaderByteCode = LoadShader("shader.fx", shaderFlags);
effect = new Effect(_device, shaderByteCode);
EffectTechnique technique = effect.GetTechniqueByIndex(0);
shadowGenPass = technique.GetPassByIndex(0);
gBufferGenPass = technique.GetPassByIndex(1);
debugDrawPass = technique.GetPassByName("debug");
BufferDescription sceneConstantsDesc = new BufferDescription()
{
SizeInBytes = Marshal.SizeOf(typeof(ShaderSceneConstants)),
Usage = ResourceUsage.Dynamic,
BindFlags = BindFlags.ConstantBuffer,
CpuAccessFlags = CpuAccessFlags.Write,
OptionFlags = ResourceOptionFlags.None
};
sceneConstantsBuffer = new Buffer(_device, sceneConstantsDesc);
EffectConstantBuffer effectConstantBuffer = effect.GetConstantBufferByName("scene");
effectConstantBuffer.SetConstantBuffer(sceneConstantsBuffer);
_rasterizerStateDesc = new RasterizerStateDescription()
{
CullMode = CullingEnabled ? CullMode.Back : CullMode.None,
FillMode = FillMode.Solid,
DepthBias = 0,
DepthBiasClamp = 0,
SlopeScaledDepthBias = 0,
IsDepthClipEnabled = true,
};
_device.Rasterizer.State = new RasterizerState(_device, _rasterizerStateDesc);
DepthStencilStateDescription depthDesc = new DepthStencilStateDescription()
{
IsDepthEnabled = true,
IsStencilEnabled = false,
DepthWriteMask = DepthWriteMask.All,
DepthComparison = Comparison.Less
};
depthStencilState = new DepthStencilState(_device, depthDesc);
DepthStencilStateDescription lightDepthStateDesc = new DepthStencilStateDescription()
{
IsDepthEnabled = true,
IsStencilEnabled = false,
DepthWriteMask = DepthWriteMask.All,
DepthComparison = Comparison.Less
};
lightDepthStencilState = new DepthStencilState(_device, lightDepthStateDesc);
// grender.fx
shaderByteCode = LoadShader("grender.fx", shaderFlags);
effect2 = new Effect(_device, shaderByteCode);
technique = effect2.GetTechniqueByIndex(0);
gBufferRenderPass = technique.GetPassByIndex(0);
gBufferOverlayPass = technique.GetPassByIndex(1);
info = new InfoText(_device);
_meshFactory = new MeshFactory(this);
MeshFactory = _meshFactory;
CreateBuffers();
GraphicsLibraryManager.LibraryStarted();
}
void SetSceneConstants()
{
FreeLook freelook = Demo.Freelook;
Vector3 up = MathHelper.Convert(freelook.Up);
sceneConstants.View = Matrix.LookAtLH(MathHelper.Convert(freelook.Eye), MathHelper.Convert(freelook.Target), up);
sceneConstants.Projection = Matrix.PerspectiveFovLH(FieldOfView, AspectRatio, _nearPlane, FarPlane);
sceneConstants.ViewInverse = Matrix.Invert(sceneConstants.View);
Vector3 light = new Vector3(20, 30, 10);
Texture2DDescription depthBuffer = lightDepthTexture.Description;
Matrix lightView = Matrix.LookAtLH(light, Vector3.Zero, up);
Matrix lightProjection = Matrix.OrthoLH(depthBuffer.Width / 8.0f, depthBuffer.Height / 8.0f, _nearPlane, FarPlane);
sceneConstants.LightViewProjection = lightView * lightProjection;
using (var data = sceneConstantsBuffer.Map(MapMode.WriteDiscard))
{
Marshal.StructureToPtr(sceneConstants, data.DataPointer, false);
sceneConstantsBuffer.Unmap();
}
inverseProjectionVar.SetMatrix(Matrix.Invert(sceneConstants.Projection));
inverseViewVar.SetMatrix(sceneConstants.ViewInverse);
lightInverseViewProjectionVar.SetMatrix(Matrix.Invert(sceneConstants.LightViewProjection));
lightPositionVar.Set(new Vector4(light, 1));
eyePositionVar.Set(new Vector4(MathHelper.Convert(freelook.Eye), 1));
float tanHalfFOVY = (float)Math.Tan(FieldOfView * 0.5f);
tanHalfFOVXVar.Set(tanHalfFOVY * AspectRatio);
tanHalfFOVYVar.Set(tanHalfFOVY);
float projectionA = FarPlane / (FarPlane - _nearPlane);
float projectionB = -projectionA * _nearPlane;
projectionAVar.Set(projectionA);
projectionBVar.Set(projectionB);
Matrix overlayMatrix = Matrix.Scaling(info.Width / _width, info.Height / _height, 1.0f);
overlayMatrix *= Matrix.Translation(-(_width - info.Width) / _width, (_height - info.Height) / _height, 0.0f);
overlayViewProjectionVar.SetMatrix(overlayMatrix);
}
void Render()
{
// Clear targets
_device.ClearDepthStencilView(depthView, DepthStencilClearFlags.Depth, 1.0f, 0);
//_device.ClearRenderTargetView(renderView, ambient);
//_device.ClearRenderTargetView(gBufferLightView, ambient);
_device.ClearRenderTargetView(gBufferNormalView, ambient);
_device.ClearRenderTargetView(gBufferDiffuseView, ambient);
_meshFactory.InitInstancedRender(Demo.World.CollisionObjectArray);
// Light depth map pass
if (shadowsEnabled)
{
_device.ClearDepthStencilView(lightDepthView, DepthStencilClearFlags.Depth, 1.0f, 0);
outputMerger.SetDepthStencilState(lightDepthStencilState, 0);
outputMerger.SetRenderTargets(0, new RenderTargetView[0], lightDepthView);
shadowGenPass.Apply();
OnRender();
lightDepthMapVar.SetResource(lightDepthRes);
}
// Render to G-buffer
lightBufferVar.SetResource(null);
normalBufferVar.SetResource(null);
diffuseBufferVar.SetResource(null);
depthMapVar.SetResource(null);
lightDepthMapVar.SetResource(null);
outputMerger.SetDepthStencilState(depthStencilState, 0);
outputMerger.SetRenderTargets(3, gBufferViews, depthView);
gBufferGenPass.Apply();
OnRender();
if (Demo.IsDebugDrawEnabled)
{
debugDrawPass.Apply();
(Demo.World.DebugDrawer as PhysicsDebugDraw).DrawDebugWorld(Demo.World);
}
outputMerger.SetDepthStencilState(null, 0);
info.OnRender(Demo.FramesPerSecond);
outputMerger.SetRenderTargets(1, renderViews, null);
inputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip;
// Render G-buffer
lightBufferVar.SetResource(lightBufferRes);
normalBufferVar.SetResource(normalBufferRes);
diffuseBufferVar.SetResource(diffuseBufferRes);
depthMapVar.SetResource(depthRes);
lightDepthMapVar.SetResource(lightDepthRes);
gBufferRenderPass.Apply();
_device.Draw(3, 0);
// Render overlay
diffuseBufferVar.SetResource(info.OverlayBufferRes);
gBufferOverlayPass.Apply();
_device.Draw(4, 0);
_swapChain.Present(0, PresentFlags.None);
}
public override void UpdateView()
{
SetSceneConstants();
}
public override void Run()
{
RenderLoop.Run(Form, () =>
{
Demo.OnHandleInput();
Demo.OnUpdate();
if (Form.WindowState != FormWindowState.Minimized)
Render();
});
}
protected virtual void OnRender()
{
_meshFactory.RenderInstanced();
}
public override void SetInfoText(string text)
{
info.Text = text;
}
}
}

Просмотреть файл

@ -1,121 +0,0 @@
SamplerState defaultSampler
{
Filter = MIN_MAG_MIP_LINEAR;
AddressU = Clamp;
AddressV = Clamp;
};
Texture2D lightBuffer;
Texture2D normalBuffer;
Texture2D diffuseBuffer;
Texture2D depthMap;
Texture2D lightDepthMap;
matrix OverlayViewProjection;
matrix InverseProjection;
matrix InverseView;
matrix LightInverseViewProjection;
float4 LightPosition;
float4 EyePosition;
float TanHalfFOVX;
float TanHalfFOVY;
float ProjectionA;
float ProjectionB;
struct VS_OUT
{
float4 Pos : SV_POSITION;
float2 texCoord : TEXCOORD;
};
VS_OUT VS(uint id : SV_VertexID)
{
VS_OUT output = (VS_OUT)0;
// Construct full-screen triangle
output.texCoord = float2((id << 1) & 2, id & 2);
output.Pos = float4(output.texCoord * float2(2.0f, -2.0f) + float2(-1.0f, 1.0f), 0.0f, 1.0f);
return output;
}
float4 PS( VS_OUT input ) : SV_Target
{
float4 lightSample = lightBuffer.Sample(defaultSampler, input.texCoord);
float4 normalSample = normalBuffer.Sample(defaultSampler, input.texCoord);
float3 diffuseSample = diffuseBuffer.Sample(defaultSampler, input.texCoord).rgb;
float depthSample = depthMap.Sample(defaultSampler, input.texCoord).x;
float lightDepthSample = lightDepthMap.Sample(defaultSampler, input.texCoord).x;
// from 0...1 to -1...1
float2 screenPos = (input.texCoord * float2(2,-2)) + float2(-1,1);
float linearDepth = ProjectionB / (depthSample - ProjectionA);
float4 viewSpacePosition = float4(
linearDepth * screenPos.x*TanHalfFOVX,
linearDepth * screenPos.y*TanHalfFOVY,
linearDepth, 1);
float3 worldPosition = mul(viewSpacePosition, InverseView).xyz;
float3 normal = normalize((normalSample.xyz - 0.5) * 2); // from 0...1 to -1...1
float3 lightDirection = normalize(LightPosition.xyz - worldPosition);
float3 viewDirection = normalize(EyePosition.xyz - worldPosition);
// Ambient term
float3 ambientColor = 0.15 * diffuseSample;//float3(1,1,1);
float3 ambient = ambientColor;
// Diffuse term
float3 diffuse = saturate(dot(normal, lightDirection)) * diffuseSample;
// Specular term
float3 specularColor = float3(1.0, 1.0, 1.0);
float specularIntensity = saturate(dot(reflect(-lightDirection, normal), viewDirection));
specularIntensity = pow(specularIntensity, 64);
float3 specular = specularIntensity * specularColor;
//float shade *= GetShadowAmount(input.LPos);
//diffuse *= shade;
// Debugging
//return float4(worldPosition * 0.01 + 0.25, 1);
//return float4(normal, 1);
return float4(ambient + diffuse + 0.2 * specular, 1);
}
VS_OUT Overlay_VS(uint id : SV_VertexID)
{
VS_OUT output = (VS_OUT)0;
// Construct overlay quad
output.texCoord = 0.5 * float2((id << 1) & 2, id & 2);
output.Pos = float4(output.texCoord * float2(2.0f, -2.0f) + float2(-1.0f, 1.0f), 0.0f, 1.0f);
output.Pos = mul(output.Pos, OverlayViewProjection);
return output;
}
float4 Overlay_PS( VS_OUT input ) : SV_Target
{
return diffuseBuffer.Sample(defaultSampler, input.texCoord);
}
technique10 Render
{
pass P1
{
SetVertexShader( CompileShader( vs_4_0, VS() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, PS() ) );
}
pass Overlay
{
SetVertexShader( CompileShader( vs_4_0, Overlay_VS() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, Overlay_PS() ) );
}
}

Просмотреть файл

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SharpDX" version="2.6.3" targetFramework="net40-client" />
<package id="SharpDX.D3DCompiler" version="2.6.3" targetFramework="net40-client" />
<package id="SharpDX.Direct3D10" version="2.6.3" targetFramework="net40-client" />
<package id="SharpDX.DXGI" version="2.6.3" targetFramework="net40-client" />
</packages>

Просмотреть файл

@ -1,125 +0,0 @@
cbuffer scene
{
matrix View;
matrix Projection;
matrix ViewInverse;
matrix LightViewProjection;
}
struct VS_IN
{
float4 Pos : POSITION;
float3 Normal : NORMAL;
float4 World0 : WORLD0;
float4 World1 : WORLD1;
float4 World2 : WORLD2;
float4 World3 : WORLD3;
float4 Color : COLOR;
};
struct VS_OUT
{
float4 Pos : SV_POSITION;
float3 Normal : TEXCOORD0;
float4 Color : TEXCOORD1;
};
struct PS_OUT_MRT
{
float4 Light : SV_Target0;
float4 Normal : SV_Target1;
float4 Diffuse : SV_Target2;
};
struct VS_DEBUG_IN
{
float4 Pos : POSITION;
float4 Color : COLOR;
};
struct VS_DEBUG_OUT
{
float4 Pos : SV_POSITION;
float4 Color : TEXCOORD1;
};
struct PS_DEBUG_OUT_MRT
{
float4 Diffuse : SV_Target2;
};
float4 shadowGenVS(VS_IN input) : SV_POSITION
{
float4x4 world = float4x4(input.World0, input.World1, input.World2, input.World3);
float4 Pw = mul(input.Pos,world);
float4 Pl = mul(LightViewProjection,Pw); // "P" in light coords
return Pl;
}
VS_OUT VS(VS_IN input)
{
VS_OUT output = (VS_OUT)0;
float4x4 world = float4x4(input.World0, input.World1, input.World2, input.World3);
output.Pos = mul(Projection, mul(View, mul(input.Pos, world)));
output.Normal = mul(input.Normal, (float3x3)world);
output.Color = input.Color;
return output;
}
PS_OUT_MRT PS_MRT( VS_OUT input )
{
PS_OUT_MRT output = (PS_OUT_MRT)0;
float3 normal = normalize(input.Normal);
normal = normal * 0.5 + 0.5; // from -1...1 to 0...1 range
output.Normal = float4(normal, 1);
output.Diffuse = float4(input.Color.rgb, 1);
return output;
}
VS_DEBUG_OUT VS_DEBUG(VS_DEBUG_IN input)
{
VS_DEBUG_OUT output = (VS_DEBUG_OUT)0;
output.Pos = mul(View, input.Pos);
output.Pos = mul(Projection, output.Pos);
output.Color = input.Color;
return output;
}
PS_DEBUG_OUT_MRT PS_DEBUG_MRT( VS_DEBUG_OUT input )
{
PS_DEBUG_OUT_MRT output = (PS_DEBUG_OUT_MRT)0;
output.Diffuse = float4(input.Color.rgb, 1);
return output;
}
technique10 Render
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, shadowGenVS() ) );
SetGeometryShader( NULL );
SetPixelShader( NULL );
}
pass P1
{
SetVertexShader( CompileShader( vs_4_0, VS() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, PS_MRT() ) );
}
pass debug
{
SetVertexShader( CompileShader( vs_4_0, VS_DEBUG() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, PS_DEBUG_MRT() ) );
}
}

Просмотреть файл

@ -23,7 +23,8 @@ namespace DemoFramework.SharpDX11
SharpDX.WIC.Bitmap _wicBitmap;
SolidColorBrush _sceneColorBrush;
Texture2D _renderTexture;
public ShaderResourceView OverlayBufferRes;
public ShaderResourceView OverlayBufferView { get; }
public bool IsEnabled { get; set; }
@ -39,14 +40,8 @@ namespace DemoFramework.SharpDX11
}
}
public float Width
{
get { return _rect.Width; }
}
public float Height
{
get { return _rect.Height; }
}
public float Width => _rect.Width;
public float Height => _rect.Height;
public InfoText(SharpDX.Direct3D11.Device device, int width, int height)
{
@ -96,7 +91,7 @@ namespace DemoFramework.SharpDX11
Usage = ResourceUsage.Dynamic
});
OverlayBufferRes = new ShaderResourceView(device, _renderTexture, new ShaderResourceViewDescription()
OverlayBufferView = new ShaderResourceView(device, _renderTexture, new ShaderResourceViewDescription()
{
Format = _renderTexture.Description.Format,
Dimension = ShaderResourceViewDimension.Texture2D,
@ -122,7 +117,7 @@ namespace DemoFramework.SharpDX11
_wicBitmap.Dispose();
_wicRenderTarget.Dispose();
_sceneColorBrush.Dispose();
OverlayBufferRes.Dispose();
OverlayBufferView.Dispose();
_textFormat.Dispose();
_isDisposed = true;

Просмотреть файл

@ -12,6 +12,7 @@ using DataStream = SharpDX.DataStream;
using Device = SharpDX.Direct3D11.Device;
using Matrix = BulletSharp.Math.Matrix;
using Vector3 = BulletSharp.Math.Vector3;
using System;
namespace DemoFramework.SharpDX11
{
@ -24,7 +25,7 @@ namespace DemoFramework.SharpDX11
}
// Contains the geometry buffers and information of all instances of a particular shape.
public class ShapeData : System.IDisposable
public class ShapeData : IDisposable
{
public Buffer VertexBuffer;
public int VertexCount;

Просмотреть файл

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@ -10,9 +10,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DemoFramework.SharpDX11</RootNamespace>
<AssemblyName>DemoFramework.SharpDX11</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
@ -21,7 +22,7 @@
<OutputPath>..\..\..\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
@ -80,25 +81,37 @@
<Reference Include="BulletSharp">
<HintPath>..\..\..\..\bin\Release\BulletSharp.dll</HintPath>
</Reference>
<Reference Include="SharpDX, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>$(SharpDXPackageBinDir)\SharpDX.dll</HintPath>
<Reference Include="SharpDX, Version=3.0.2.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\SharpDX.3.0.2\lib\net45\SharpDX.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SharpDX.D3DCompiler, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(SharpDXPackageBinDir)\SharpDX.D3DCompiler.dll</HintPath>
<Reference Include="SharpDX.D3DCompiler, Version=3.0.2.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\SharpDX.D3DCompiler.3.0.2\lib\net45\SharpDX.D3DCompiler.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SharpDX.Direct2D1, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>$(SharpDXPackageBinDir)\SharpDX.Direct2D1.dll</HintPath>
<Reference Include="SharpDX.Desktop, Version=3.0.2.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\SharpDX.Desktop.3.0.2\lib\net45\SharpDX.Desktop.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SharpDX.Direct3D11, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>$(SharpDXPackageBinDir)\SharpDX.Direct3D11.dll</HintPath>
<Reference Include="SharpDX.Direct2D1, Version=3.0.2.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\SharpDX.Direct2D1.3.0.2\lib\net45\SharpDX.Direct2D1.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SharpDX.Direct3D11.Effects, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(SharpDXPackageBinDir)\SharpDX.Direct3D11.Effects.dll</HintPath>
<Reference Include="SharpDX.Direct3D11, Version=3.0.2.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\SharpDX.Direct3D11.3.0.2\lib\net45\SharpDX.Direct3D11.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SharpDX.DXGI, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>$(SharpDXPackageBinDir)\SharpDX.DXGI.dll</HintPath>
<Reference Include="SharpDX.Direct3D11.Effects, Version=3.0.2.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\SharpDX.Direct3D11.Effects.3.0.2\lib\net45\SharpDX.Direct3D11.Effects.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SharpDX.DXGI, Version=3.0.2.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\SharpDX.DXGI.3.0.2\lib\net45\SharpDX.DXGI.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SharpDX.Mathematics, Version=3.0.2.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\SharpDX.Mathematics.3.0.2\lib\net45\SharpDX.Mathematics.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
@ -110,24 +123,22 @@
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="light.fx" />
<Content Include="sharpdx_direct3d11_effects_x64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="sharpdx_direct3d11_effects_x86.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="sharpdx_direct3d11_1_effects_arm.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="sharpdx_direct3d11_1_effects_x64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="sharpdx_direct3d11_1_effects_x86.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\..\packages\SharpDX.2.6.3\build\SharpDX.targets" Condition="Exists('..\..\..\packages\SharpDX.2.6.3\build\SharpDX.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\..\packages\SharpDX.2.6.3\build\SharpDX.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\SharpDX.2.6.3\build\SharpDX.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

Просмотреть файл

@ -8,13 +8,11 @@ using SharpDX.Windows;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Buffer = SharpDX.Direct3D11.Buffer;
using Device = SharpDX.Direct3D11.Device;
using Point = System.Drawing.Point;
using Matrix = SharpDX.Matrix;
using Vector3 = SharpDX.Vector3;
using Vector4 = SharpDX.Vector4;
@ -27,11 +25,8 @@ namespace DemoFramework.SharpDX11
bool depthOfFieldEnabled = false;
bool deferredLightingEnabled = true;
Device _device;
public Device Device
{
get { return _device; }
}
public Device Device { get; private set; }
DeviceContext _immediateContext;
OutputMergerStage outputMerger;
InputAssemblerStage inputAssembler;
@ -283,27 +278,7 @@ namespace DemoFramework.SharpDX11
{
Form.ClientSize = new Size(_width, _height);
// SwapChain description
var desc = new SwapChainDescription()
{
BufferCount = 1,
ModeDescription = new ModeDescription(_width, _height, new Rational(60, 1), Format.R8G8B8A8_UNorm),
IsWindowed = true,
OutputHandle = Form.Handle,
SampleDescription = new SampleDescription(1, 0),
SwapEffect = SwapEffect.Discard,
Usage = Usage.RenderTargetOutput,
};
// Create Device and SwapChain
SharpDX.Direct3D11.Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, desc, out _device, out _swapChain);
_immediateContext = _device.ImmediateContext;
outputMerger = _immediateContext.OutputMerger;
inputAssembler = _immediateContext.InputAssembler;
Factory factory = _swapChain.GetParent<Factory>();
factory.MakeWindowAssociation(Form.Handle, WindowAssociationFlags.None);
CreateDeviceAndSwapChain();
var blendStateDesc = new BlendStateDescription();
blendStateDesc.RenderTarget[0].IsBlendEnabled = true;
@ -314,7 +289,7 @@ namespace DemoFramework.SharpDX11
blendStateDesc.RenderTarget[0].DestinationAlphaBlend = BlendOption.Zero;
blendStateDesc.RenderTarget[0].AlphaBlendOperation = BlendOperation.Add;
blendStateDesc.RenderTarget[0].RenderTargetWriteMask = ColorWriteMaskFlags.All;
alphaBlendState = new BlendState(_device, blendStateDesc);
alphaBlendState = new BlendState(Device, blendStateDesc);
blendStateDesc.RenderTarget[0].IsBlendEnabled = true;
blendStateDesc.RenderTarget[0].SourceBlend = BlendOption.One;
@ -324,7 +299,33 @@ namespace DemoFramework.SharpDX11
blendStateDesc.RenderTarget[0].DestinationAlphaBlend = BlendOption.Zero;
blendStateDesc.RenderTarget[0].AlphaBlendOperation = BlendOperation.Add;
blendStateDesc.RenderTarget[0].RenderTargetWriteMask = ColorWriteMaskFlags.All;
additiveBlendState = new BlendState(_device, blendStateDesc);
additiveBlendState = new BlendState(Device, blendStateDesc);
}
private void CreateDeviceAndSwapChain()
{
var desc = new SwapChainDescription
{
BufferCount = 1,
ModeDescription = new ModeDescription(_width, _height, new Rational(60, 1), Format.R8G8B8A8_UNorm),
IsWindowed = true,
OutputHandle = Form.Handle,
SampleDescription = new SampleDescription(1, 0),
SwapEffect = SwapEffect.Discard,
Usage = Usage.RenderTargetOutput,
Flags = SwapChainFlags.AllowModeSwitch
};
Device _device;
Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.SingleThreaded, desc, out _device, out _swapChain);
Device = _device;
_immediateContext = Device.ImmediateContext;
outputMerger = _immediateContext.OutputMerger;
inputAssembler = _immediateContext.InputAssembler;
Factory factory = _swapChain.GetParent<Factory>();
factory.MakeWindowAssociation(Form.Handle, WindowAssociationFlags.None);
}
void CreateBuffers()
@ -334,10 +335,10 @@ namespace DemoFramework.SharpDX11
// New RenderTargetView from the backbuffer
using (var bb = Texture2D.FromSwapChain<Texture2D>(_swapChain, 0))
{
renderView = new RenderTargetView(_device, bb);
renderView = new RenderTargetView(Device, bb);
}
Texture2DDescription gBufferDesc = new Texture2DDescription()
var gBufferDesc = new Texture2DDescription
{
ArraySize = 1,
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
@ -351,30 +352,30 @@ namespace DemoFramework.SharpDX11
Usage = ResourceUsage.Default
};
gBufferLight = new Texture2D(_device, gBufferDesc);
gBufferLightView = new RenderTargetView(_device, gBufferLight);
gBufferLight = new Texture2D(Device, gBufferDesc);
gBufferLightView = new RenderTargetView(Device, gBufferLight);
gBufferNormal = new Texture2D(_device, gBufferDesc);
gBufferNormalView = new RenderTargetView(_device, gBufferNormal);
gBufferNormal = new Texture2D(Device, gBufferDesc);
gBufferNormalView = new RenderTargetView(Device, gBufferNormal);
gBufferDiffuse = new Texture2D(_device, gBufferDesc);
gBufferDiffuseView = new RenderTargetView(_device, gBufferDiffuse);
gBufferDiffuse = new Texture2D(Device, gBufferDesc);
gBufferDiffuseView = new RenderTargetView(Device, gBufferDiffuse);
gBufferPostProcess = new Texture2D(_device, gBufferDesc);
gBufferPostProcessView = new RenderTargetView(_device, gBufferPostProcess);
gBufferPostProcess = new Texture2D(Device, gBufferDesc);
gBufferPostProcessView = new RenderTargetView(Device, gBufferPostProcess);
if (depthOfFieldEnabled)
{
gBufferPostProcessBlur1 = new Texture2D(_device, gBufferDesc);
gBufferPostProcessViewBlur1 = new RenderTargetView(_device, gBufferPostProcessBlur1);
gBufferPostProcessBlur1 = new Texture2D(Device, gBufferDesc);
gBufferPostProcessViewBlur1 = new RenderTargetView(Device, gBufferPostProcessBlur1);
gBufferPostProcessBlur2 = new Texture2D(_device, gBufferDesc);
gBufferPostProcessViewBlur2 = new RenderTargetView(_device, gBufferPostProcessBlur2);
gBufferPostProcessBlur2 = new Texture2D(Device, gBufferDesc);
gBufferPostProcessViewBlur2 = new RenderTargetView(Device, gBufferPostProcessBlur2);
}
gBufferViews = new[] { gBufferNormalView, gBufferDiffuseView };
ShaderResourceViewDescription gBufferResourceDesc = new ShaderResourceViewDescription()
var gBufferResourceDesc = new ShaderResourceViewDescription
{
Format = Format.R8G8B8A8_UNorm,
Dimension = ShaderResourceViewDimension.Texture2D,
@ -384,18 +385,18 @@ namespace DemoFramework.SharpDX11
MostDetailedMip = 0
}
};
lightBufferRes = new ShaderResourceView(_device, gBufferLight, gBufferResourceDesc);
normalBufferRes = new ShaderResourceView(_device, gBufferNormal, gBufferResourceDesc);
diffuseBufferRes = new ShaderResourceView(_device, gBufferDiffuse, gBufferResourceDesc);
postProcessBufferRes = new ShaderResourceView(_device, gBufferPostProcess, gBufferResourceDesc);
lightBufferRes = new ShaderResourceView(Device, gBufferLight, gBufferResourceDesc);
normalBufferRes = new ShaderResourceView(Device, gBufferNormal, gBufferResourceDesc);
diffuseBufferRes = new ShaderResourceView(Device, gBufferDiffuse, gBufferResourceDesc);
postProcessBufferRes = new ShaderResourceView(Device, gBufferPostProcess, gBufferResourceDesc);
if (depthOfFieldEnabled)
{
postProcessBufferBlur1Res = new ShaderResourceView(_device, gBufferPostProcessBlur1, gBufferResourceDesc);
postProcessBufferBlur2Res = new ShaderResourceView(_device, gBufferPostProcessBlur2, gBufferResourceDesc);
postProcessBufferBlur1Res = new ShaderResourceView(Device, gBufferPostProcessBlur1, gBufferResourceDesc);
postProcessBufferBlur2Res = new ShaderResourceView(Device, gBufferPostProcessBlur2, gBufferResourceDesc);
}
Texture2DDescription depthDesc = new Texture2DDescription()
var depthDesc = new Texture2DDescription
{
ArraySize = 1,
BindFlags = BindFlags.DepthStencil | BindFlags.ShaderResource,
@ -409,13 +410,13 @@ namespace DemoFramework.SharpDX11
Usage = ResourceUsage.Default
};
DepthStencilViewDescription depthViewDesc = new DepthStencilViewDescription()
var depthViewDesc = new DepthStencilViewDescription
{
Dimension = DepthStencilViewDimension.Texture2D,
Format = Format.D32_Float,
};
ShaderResourceViewDescription resourceDesc = new ShaderResourceViewDescription()
var resourceDesc = new ShaderResourceViewDescription
{
Format = Format.R32_Float,
Dimension = ShaderResourceViewDimension.Texture2D,
@ -426,13 +427,13 @@ namespace DemoFramework.SharpDX11
}
};
depthTexture = new Texture2D(_device, depthDesc);
depthView = new DepthStencilView(_device, depthTexture, depthViewDesc);
depthBufferRes = new ShaderResourceView(_device, depthTexture, resourceDesc);
depthTexture = new Texture2D(Device, depthDesc);
depthView = new DepthStencilView(Device, depthTexture, depthViewDesc);
depthBufferRes = new ShaderResourceView(Device, depthTexture, resourceDesc);
lightDepthTexture = new Texture2D(_device, depthDesc);
lightDepthView = new DepthStencilView(_device, lightDepthTexture, depthViewDesc);
lightDepthRes = new ShaderResourceView(_device, lightDepthTexture, resourceDesc);
lightDepthTexture = new Texture2D(Device, depthDesc);
lightDepthView = new DepthStencilView(Device, lightDepthTexture, depthViewDesc);
lightDepthRes = new ShaderResourceView(Device, lightDepthTexture, resourceDesc);
_immediateContext.Rasterizer.SetViewport(0, 0, _width, _height);
}
@ -482,14 +483,14 @@ namespace DemoFramework.SharpDX11
string[] sources = { "shader.fx", "grender.fx" };
using (var shaderByteCode = ShaderLoader.FromResource(Assembly.GetExecutingAssembly(), sources, shaderFlags))
{
effect = new Effect(_device, shaderByteCode);
effect = new Effect(Device, shaderByteCode);
}
EffectTechnique technique = effect.GetTechniqueByName("GBufferCreate");
shadowGenPass = technique.GetPassByName("ShadowMap");
gBufferGenPass = technique.GetPassByName("GBufferGen");
debugDrawPass = technique.GetPassByName("DebugDraw");
BufferDescription sceneConstantsDesc = new BufferDescription()
var sceneConstantsDesc = new BufferDescription
{
SizeInBytes = Marshal.SizeOf(typeof(ShaderSceneConstants)),
Usage = ResourceUsage.Dynamic,
@ -498,11 +499,11 @@ namespace DemoFramework.SharpDX11
OptionFlags = ResourceOptionFlags.None
};
sceneConstantsBuffer = new Buffer(_device, sceneConstantsDesc);
sceneConstantsBuffer = new Buffer(Device, sceneConstantsDesc);
EffectConstantBuffer effectConstantBuffer = effect.GetConstantBufferByName("scene");
effectConstantBuffer.SetConstantBuffer(sceneConstantsBuffer);
RasterizerStateDescription _rasterizerStateDesc = new RasterizerStateDescription()
var _rasterizerStateDesc = new RasterizerStateDescription
{
CullMode = CullMode.None,
FillMode = FillMode.Solid,
@ -511,34 +512,34 @@ namespace DemoFramework.SharpDX11
SlopeScaledDepthBias = 0,
IsDepthClipEnabled = true,
};
noCullState = new RasterizerState(_device, _rasterizerStateDesc);
noCullState = new RasterizerState(Device, _rasterizerStateDesc);
_rasterizerStateDesc.CullMode = CullMode.Back;
backCullState = new RasterizerState(_device, _rasterizerStateDesc);
backCullState = new RasterizerState(Device, _rasterizerStateDesc);
_rasterizerStateDesc.CullMode = CullMode.Front;
frontCullState = new RasterizerState(_device, _rasterizerStateDesc);
frontCullState = new RasterizerState(Device, _rasterizerStateDesc);
_immediateContext.Rasterizer.State = CullingEnabled ? backCullState : noCullState;
DepthStencilStateDescription depthDesc = new DepthStencilStateDescription()
var depthDesc = new DepthStencilStateDescription
{
IsDepthEnabled = true,
IsStencilEnabled = false,
DepthWriteMask = DepthWriteMask.All,
DepthComparison = Comparison.Less
};
depthState = new DepthStencilState(_device, depthDesc);
depthState = new DepthStencilState(Device, depthDesc);
depthDesc.DepthWriteMask = DepthWriteMask.Zero;
outsideLightVolumeDepthState = new DepthStencilState(_device, depthDesc);
outsideLightVolumeDepthState = new DepthStencilState(Device, depthDesc);
depthDesc.DepthComparison = Comparison.Greater;
insideLightVolumeDepthState = new DepthStencilState(_device, depthDesc);
insideLightVolumeDepthState = new DepthStencilState(Device, depthDesc);
DepthStencilStateDescription lightDepthStateDesc = new DepthStencilStateDescription()
var lightDepthStateDesc = new DepthStencilStateDescription
{
IsDepthEnabled = true,
IsStencilEnabled = false,
DepthWriteMask = DepthWriteMask.All,
DepthComparison = Comparison.Less
};
lightDepthStencilState = new DepthStencilState(_device, lightDepthStateDesc);
lightDepthStencilState = new DepthStencilState(Device, lightDepthStateDesc);
// grender.fx
@ -565,7 +566,7 @@ namespace DemoFramework.SharpDX11
// light.fx
using (var shaderByteCode = ShaderLoader.FromResource(Assembly.GetExecutingAssembly(), "light.fx", shaderFlags))
{
lightShader = new Effect(_device, shaderByteCode);
lightShader = new Effect(Device, shaderByteCode);
}
technique = lightShader.GetTechniqueByIndex(0);
@ -583,21 +584,21 @@ namespace DemoFramework.SharpDX11
lightEyePositionVar = lightShader.GetVariableByName("EyePosition").AsVector();
lightViewParametersVar = lightShader.GetVariableByName("ViewParameters").AsVector();
InputElement[] elements = new InputElement[]
var elements = new InputElement[]
{
new InputElement("POSITION", 0, Format.R32G32B32_Float, 0, 0, InputClassification.PerVertexData, 0),
};
lightVolumeInputLayout = new InputLayout(Device, lightShader.GetTechniqueByIndex(0).GetPassByName("Light").Description.Signature, elements);
pointLightVolumeVertices = Light.CreatePointLightVolume(out pointLightVolumeIndices);
BufferDescription vertexBufferDesc = new BufferDescription()
var vertexBufferDesc = new BufferDescription
{
SizeInBytes = Vector3.SizeInBytes * pointLightVolumeVertices.Length,
Usage = ResourceUsage.Default,
BindFlags = BindFlags.VertexBuffer,
};
using (var data = new SharpDX.DataStream(vertexBufferDesc.SizeInBytes, false, true))
using (var data = new DataStream(vertexBufferDesc.SizeInBytes, false, true))
{
data.WriteRange(pointLightVolumeVertices);
data.Position = 0;
@ -605,13 +606,13 @@ namespace DemoFramework.SharpDX11
}
pointLightVolumeVertexBufferBinding = new VertexBufferBinding(pointLightVolumeVertexBuffer, 12, 0);
BufferDescription indexBufferDesc = new BufferDescription()
var indexBufferDesc = new BufferDescription
{
SizeInBytes = sizeof(uint) * pointLightVolumeIndices.Length,
Usage = ResourceUsage.Default,
BindFlags = BindFlags.IndexBuffer
};
using (var data = new SharpDX.DataStream(indexBufferDesc.SizeInBytes, false, true))
using (var data = new DataStream(indexBufferDesc.SizeInBytes, false, true))
{
data.WriteRange(pointLightVolumeIndices);
data.Position = 0;
@ -628,7 +629,7 @@ namespace DemoFramework.SharpDX11
//lights.Add(new Light(new Vector3(-10, 5, -10), 20, new Vector4(1, 0, 1, 1)));
info = new InfoText(_device, 256, 256);
info = new InfoText(Device, 256, 256);
_meshFactory = new MeshFactory(this);
MeshFactory = _meshFactory;
@ -654,7 +655,7 @@ namespace DemoFramework.SharpDX11
Matrix lightProjection = Matrix.PerspectiveFovLH(FieldOfView, (float)depthBuffer.Width / (float)depthBuffer.Height, _nearPlane, FarPlane);
sceneConstants.LightViewProjection = lightView * lightProjection;
SharpDX.DataStream data;
DataStream data;
_immediateContext.MapSubresource(sceneConstantsBuffer, MapMode.WriteDiscard, SharpDX.Direct3D11.MapFlags.None, out data);
Marshal.StructureToPtr(sceneConstants, data.DataPointer, false);
_immediateContext.UnmapSubresource(sceneConstantsBuffer, 0);
@ -710,6 +711,73 @@ namespace DemoFramework.SharpDX11
{
}
void Render()
{
ClearTargets();
// Read collision object transforms, create geometry, etc.
_meshFactory.InitInstancedRender();
RenderLightDepthMap();
RenderGBuffer();
RenderFinal();
if (depthOfFieldEnabled)
{
RenderDepthOfFieldBlurPasses();
}
RenderOverlay();
_swapChain.Present(0, PresentFlags.None);
}
private void ClearTargets()
{
_immediateContext.ClearDepthStencilView(depthView, DepthStencilClearFlags.Depth, 1.0f, 0);
//_immediateContext.ClearRenderTargetView(renderView, ambient);
_immediateContext.ClearRenderTargetView(gBufferLightView, Color4.Black);
_immediateContext.ClearRenderTargetView(gBufferNormalView, Color4.Black);
_immediateContext.ClearRenderTargetView(gBufferDiffuseView, Color4.Black);
}
private void RenderLightDepthMap()
{
_immediateContext.ClearDepthStencilView(lightDepthView, DepthStencilClearFlags.Depth, 1.0f, 0);
if (shadowsEnabled)
{
outputMerger.SetDepthStencilState(lightDepthStencilState);
outputMerger.SetRenderTargets(lightDepthView);
shadowGenPass.Apply(_immediateContext);
OnRender();
shadowLightDepthBufferVar.SetResource(lightDepthRes);
}
}
private void RenderGBuffer()
{
// Geometry (colors, normals, depth)
outputMerger.SetDepthStencilState(depthState);
outputMerger.SetTargets(depthView, gBufferViews);
gBufferGenPass.Apply(_immediateContext);
OnRender();
if (Demo.IsDebugDrawEnabled)
{
debugDrawPass.Apply(_immediateContext);
(Demo.World.DebugDrawer as PhysicsDebugDraw).DrawDebugWorld(Demo.World);
}
// Light accumulation
if (deferredLightingEnabled)
{
outputMerger.SetBlendState(additiveBlendState);
// Can't set depthView as render target and shader variable at the same time,
// so early HW depth test is not available for light volumes.
//outputMerger.SetTargets(depthView, gBufferLightView);
outputMerger.SetTargets(gBufferLightView);
RenderLights();
}
}
void RenderLights()
{
inputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
@ -760,56 +828,8 @@ namespace DemoFramework.SharpDX11
_immediateContext.DrawIndexed(pointLightVolumeIndices.Length, 0, 0);
}
void Render()
private void RenderFinal()
{
// Clear targets
_immediateContext.ClearDepthStencilView(depthView, DepthStencilClearFlags.Depth, 1.0f, 0);
//_immediateContext.ClearRenderTargetView(renderView, ambient);
_immediateContext.ClearRenderTargetView(gBufferLightView, Color4.Black);
_immediateContext.ClearRenderTargetView(gBufferNormalView, Color4.Black);
_immediateContext.ClearRenderTargetView(gBufferDiffuseView, Color4.Black);
// Read collision object transforms, create geometry, etc.
_meshFactory.InitInstancedRender();
// Light depth map pass
_immediateContext.ClearDepthStencilView(lightDepthView, DepthStencilClearFlags.Depth, 1.0f, 0);
if (shadowsEnabled)
{
outputMerger.SetDepthStencilState(lightDepthStencilState);
outputMerger.SetRenderTargets(lightDepthView);
shadowGenPass.Apply(_immediateContext);
OnRender();
shadowLightDepthBufferVar.SetResource(lightDepthRes);
}
// Render geometry (colors, normals, depth) to G-buffer
outputMerger.SetDepthStencilState(depthState);
outputMerger.SetTargets(depthView, gBufferViews);
gBufferGenPass.Apply(_immediateContext);
OnRender();
if (Demo.IsDebugDrawEnabled)
{
debugDrawPass.Apply(_immediateContext);
(Demo.World.DebugDrawer as PhysicsDebugDraw).DrawDebugWorld(Demo.World);
}
// Light accumulation to G-buffer
if (deferredLightingEnabled)
{
outputMerger.SetBlendState(additiveBlendState);
// Can't set depthView as render target and shader variable at the same time,
// so early HW depth test is not available for light volumes.
//outputMerger.SetTargets(depthView, gBufferLightView);
outputMerger.SetTargets(gBufferLightView);
RenderLights();
}
// Render G-buffer
outputMerger.SetBlendState(alphaBlendState);
outputMerger.SetDepthStencilState(null);
if (depthOfFieldEnabled)
@ -830,48 +850,47 @@ namespace DemoFramework.SharpDX11
//_immediateContext.ClearRenderTargetView(gBufferPostProcessView, Color4.Black);
gBufferRenderPass.Apply(_immediateContext);
_immediateContext.Draw(3, 0);
}
if (depthOfFieldEnabled)
{
diffuseBufferVar.SetResource(postProcessBufferRes);
outputMerger.SetTargets(gBufferPostProcessViewBlur1);
gBufferPostProcessPass.Apply(_immediateContext);
_immediateContext.Draw(3, 0);
diffuseBufferVar.SetResource(postProcessBufferBlur1Res);
outputMerger.SetTargets(gBufferPostProcessViewBlur2);
gBufferPostProcessPass.Apply(_immediateContext);
_immediateContext.Draw(3, 0);
diffuseBufferVar.SetResource(postProcessBufferBlur2Res);
outputMerger.SetTargets(gBufferPostProcessViewBlur1);
gBufferPostProcessPass.Apply(_immediateContext);
_immediateContext.Draw(3, 0);
diffuseBufferVar.SetResource(postProcessBufferBlur1Res);
outputMerger.SetTargets(gBufferPostProcessViewBlur2);
gBufferPostProcessPass.Apply(_immediateContext);
_immediateContext.Draw(3, 0);
diffuseBufferVar.SetResource(postProcessBufferRes);
normalBufferVar.SetResource(postProcessBufferBlur2Res);
outputMerger.SetTargets(renderView);
gBufferPostProcessPass2.Apply(_immediateContext);
_immediateContext.Draw(3, 0);
}
// Render overlay
private void RenderOverlay()
{
info.Render();
outputMerger.SetBlendState(alphaBlendState);
diffuseBufferVar.SetResource(info.OverlayBufferRes);
diffuseBufferVar.SetResource(info.OverlayBufferView);
gBufferOverlayPass.Apply(_immediateContext);
_immediateContext.Draw(4, 0);
}
_swapChain.Present(0, PresentFlags.None);
private void RenderDepthOfFieldBlurPasses()
{
diffuseBufferVar.SetResource(postProcessBufferRes);
outputMerger.SetTargets(gBufferPostProcessViewBlur1);
gBufferPostProcessPass.Apply(_immediateContext);
_immediateContext.Draw(3, 0);
diffuseBufferVar.SetResource(postProcessBufferBlur1Res);
outputMerger.SetTargets(gBufferPostProcessViewBlur2);
gBufferPostProcessPass.Apply(_immediateContext);
_immediateContext.Draw(3, 0);
diffuseBufferVar.SetResource(postProcessBufferBlur2Res);
outputMerger.SetTargets(gBufferPostProcessViewBlur1);
gBufferPostProcessPass.Apply(_immediateContext);
_immediateContext.Draw(3, 0);
diffuseBufferVar.SetResource(postProcessBufferBlur1Res);
outputMerger.SetTargets(gBufferPostProcessViewBlur2);
gBufferPostProcessPass.Apply(_immediateContext);
_immediateContext.Draw(3, 0);
diffuseBufferVar.SetResource(postProcessBufferRes);
normalBufferVar.SetResource(postProcessBufferBlur2Res);
outputMerger.SetTargets(renderView);
gBufferPostProcessPass2.Apply(_immediateContext);
_immediateContext.Draw(3, 0);
}
protected virtual void OnRender()

Просмотреть файл

@ -1,9 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SharpDX" version="2.6.3" targetFramework="net40-client" />
<package id="SharpDX.D3DCompiler" version="2.6.3" targetFramework="net40-client" />
<package id="SharpDX.Direct2D1" version="2.6.3" targetFramework="net40-client" />
<package id="SharpDX.Direct3D11" version="2.6.3" targetFramework="net40-client" />
<package id="SharpDX.Direct3D11.Effects" version="2.6.3" targetFramework="net40-client" />
<package id="SharpDX.DXGI" version="2.6.3" targetFramework="net40-client" />
<package id="SharpDX" version="3.0.2" targetFramework="net461" />
<package id="SharpDX.D3DCompiler" version="3.0.2" targetFramework="net461" />
<package id="SharpDX.Desktop" version="3.0.2" targetFramework="net461" />
<package id="SharpDX.Direct2D1" version="3.0.2" targetFramework="net461" />
<package id="SharpDX.Direct3D11" version="3.0.2" targetFramework="net461" />
<package id="SharpDX.Direct3D11.Effects" version="3.0.2" targetFramework="net461" />
<package id="SharpDX.DXGI" version="3.0.2" targetFramework="net461" />
<package id="SharpDX.Mathematics" version="3.0.2" targetFramework="net461" />
</packages>

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Просмотреть файл

@ -70,7 +70,7 @@ namespace DemoFramework.SlimDX
bool isFormClosed = false;
bool formIsResizing = false;
bool deviceLost = false;
System.IDisposable apiContext;
IDisposable apiContext;
FormWindowState currentFormWindowState;
FormWindowState windowedFormWindowState;
FormBorderStyle windowedFormBorderStyle;

Просмотреть файл

@ -1,20 +1,17 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DemoFramework", "DemoFramework\DemoFramework.csproj", "{7F50B160-6C4D-467A-9AAB-10C516326BD1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicDemo", "BasicDemo\BasicDemo.csproj", "{8B5B1C14-C924-42FD-ABAB-4CD851F06DF9}"
ProjectSection(ProjectDependencies) = postProject
{540E0C60-3FBD-4166-933D-D80284D1CA0E} = {540E0C60-3FBD-4166-933D-D80284D1CA0E}
{3DDE3767-7DA8-4700-A74B-EC34146AB688} = {3DDE3767-7DA8-4700-A74B-EC34146AB688}
{3CD13788-CD50-451F-8267-AF7578403621} = {3CD13788-CD50-451F-8267-AF7578403621}
{67DF42D4-C318-4E52-9017-43A2EFD7790B} = {67DF42D4-C318-4E52-9017-43A2EFD7790B}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpDX", "DemoFramework\Graphics\SharpDX\SharpDX.csproj", "{3DDE3767-7DA8-4700-A74B-EC34146AB688}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SlimDX", "DemoFramework\Graphics\SlimDX\SlimDX.csproj", "{67DF42D4-C318-4E52-9017-43A2EFD7790B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK", "DemoFramework\Graphics\OpenTK\OpenTK.csproj", "{3CD13788-CD50-451F-8267-AF7578403621}"
@ -22,7 +19,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CcdPhysicsDemo", "CcdPhysicsDemo\CcdPhysicsDemo.csproj", "{60FB11CC-8D7D-4EBE-80AF-D4914BC88759}"
ProjectSection(ProjectDependencies) = postProject
{540E0C60-3FBD-4166-933D-D80284D1CA0E} = {540E0C60-3FBD-4166-933D-D80284D1CA0E}
{3DDE3767-7DA8-4700-A74B-EC34146AB688} = {3DDE3767-7DA8-4700-A74B-EC34146AB688}
{3CD13788-CD50-451F-8267-AF7578403621} = {3CD13788-CD50-451F-8267-AF7578403621}
{67DF42D4-C318-4E52-9017-43A2EFD7790B} = {67DF42D4-C318-4E52-9017-43A2EFD7790B}
EndProjectSection
@ -30,7 +26,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BenchmarkDemo", "BenchmarkDemo\BenchmarkDemo.csproj", "{8712106F-F6B3-4196-B124-6516936451C3}"
ProjectSection(ProjectDependencies) = postProject
{540E0C60-3FBD-4166-933D-D80284D1CA0E} = {540E0C60-3FBD-4166-933D-D80284D1CA0E}
{3DDE3767-7DA8-4700-A74B-EC34146AB688} = {3DDE3767-7DA8-4700-A74B-EC34146AB688}
{3CD13788-CD50-451F-8267-AF7578403621} = {3CD13788-CD50-451F-8267-AF7578403621}
{67DF42D4-C318-4E52-9017-43A2EFD7790B} = {67DF42D4-C318-4E52-9017-43A2EFD7790B}
EndProjectSection
@ -38,7 +33,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Box2DDemo", "Box2DDemo\Box2DDemo.csproj", "{C47829F1-A1BC-440F-8879-63B41E5176F6}"
ProjectSection(ProjectDependencies) = postProject
{540E0C60-3FBD-4166-933D-D80284D1CA0E} = {540E0C60-3FBD-4166-933D-D80284D1CA0E}
{3DDE3767-7DA8-4700-A74B-EC34146AB688} = {3DDE3767-7DA8-4700-A74B-EC34146AB688}
{3CD13788-CD50-451F-8267-AF7578403621} = {3CD13788-CD50-451F-8267-AF7578403621}
{67DF42D4-C318-4E52-9017-43A2EFD7790B} = {67DF42D4-C318-4E52-9017-43A2EFD7790B}
EndProjectSection
@ -46,7 +40,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SoftDemo", "SoftDemo\SoftDemo.csproj", "{99135BBD-934C-411D-9DB0-1157BA35EDB6}"
ProjectSection(ProjectDependencies) = postProject
{540E0C60-3FBD-4166-933D-D80284D1CA0E} = {540E0C60-3FBD-4166-933D-D80284D1CA0E}
{3DDE3767-7DA8-4700-A74B-EC34146AB688} = {3DDE3767-7DA8-4700-A74B-EC34146AB688}
{3CD13788-CD50-451F-8267-AF7578403621} = {3CD13788-CD50-451F-8267-AF7578403621}
{67DF42D4-C318-4E52-9017-43A2EFD7790B} = {67DF42D4-C318-4E52-9017-43A2EFD7790B}
EndProjectSection
@ -54,7 +47,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BspDemo", "BspDemo\BspDemo.csproj", "{AD666B32-ADA7-46EF-9546-4CBD680B7E18}"
ProjectSection(ProjectDependencies) = postProject
{540E0C60-3FBD-4166-933D-D80284D1CA0E} = {540E0C60-3FBD-4166-933D-D80284D1CA0E}
{3DDE3767-7DA8-4700-A74B-EC34146AB688} = {3DDE3767-7DA8-4700-A74B-EC34146AB688}
{3CD13788-CD50-451F-8267-AF7578403621} = {3CD13788-CD50-451F-8267-AF7578403621}
{67DF42D4-C318-4E52-9017-43A2EFD7790B} = {67DF42D4-C318-4E52-9017-43A2EFD7790B}
EndProjectSection
@ -62,7 +54,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConstraintDemo", "ConstraintDemo\ConstraintDemo.csproj", "{E53D74AE-3F31-41A5-9046-57109CC9CBD5}"
ProjectSection(ProjectDependencies) = postProject
{540E0C60-3FBD-4166-933D-D80284D1CA0E} = {540E0C60-3FBD-4166-933D-D80284D1CA0E}
{3DDE3767-7DA8-4700-A74B-EC34146AB688} = {3DDE3767-7DA8-4700-A74B-EC34146AB688}
{3CD13788-CD50-451F-8267-AF7578403621} = {3CD13788-CD50-451F-8267-AF7578403621}
{67DF42D4-C318-4E52-9017-43A2EFD7790B} = {67DF42D4-C318-4E52-9017-43A2EFD7790B}
EndProjectSection
@ -70,7 +61,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConvexDecompositionDemo", "ConvexDecompositionDemo\ConvexDecompositionDemo.csproj", "{6E5A81BA-E9B2-4C38-92B2-CCB660690DA4}"
ProjectSection(ProjectDependencies) = postProject
{540E0C60-3FBD-4166-933D-D80284D1CA0E} = {540E0C60-3FBD-4166-933D-D80284D1CA0E}
{3DDE3767-7DA8-4700-A74B-EC34146AB688} = {3DDE3767-7DA8-4700-A74B-EC34146AB688}
{3CD13788-CD50-451F-8267-AF7578403621} = {3CD13788-CD50-451F-8267-AF7578403621}
{67DF42D4-C318-4E52-9017-43A2EFD7790B} = {67DF42D4-C318-4E52-9017-43A2EFD7790B}
EndProjectSection
@ -78,7 +68,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RagdollDemo", "RagdollDemo\RagdollDemo.csproj", "{712ED1AC-EC4E-49E8-8B48-25FFFBFCD5D9}"
ProjectSection(ProjectDependencies) = postProject
{540E0C60-3FBD-4166-933D-D80284D1CA0E} = {540E0C60-3FBD-4166-933D-D80284D1CA0E}
{3DDE3767-7DA8-4700-A74B-EC34146AB688} = {3DDE3767-7DA8-4700-A74B-EC34146AB688}
{3CD13788-CD50-451F-8267-AF7578403621} = {3CD13788-CD50-451F-8267-AF7578403621}
{67DF42D4-C318-4E52-9017-43A2EFD7790B} = {67DF42D4-C318-4E52-9017-43A2EFD7790B}
EndProjectSection
@ -86,7 +75,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SerializeDemo", "SerializeDemo\SerializeDemo.csproj", "{EDB369AD-86B1-4B2E-B0D6-77A3B50C1875}"
ProjectSection(ProjectDependencies) = postProject
{540E0C60-3FBD-4166-933D-D80284D1CA0E} = {540E0C60-3FBD-4166-933D-D80284D1CA0E}
{3DDE3767-7DA8-4700-A74B-EC34146AB688} = {3DDE3767-7DA8-4700-A74B-EC34146AB688}
{3CD13788-CD50-451F-8267-AF7578403621} = {3CD13788-CD50-451F-8267-AF7578403621}
{67DF42D4-C318-4E52-9017-43A2EFD7790B} = {67DF42D4-C318-4E52-9017-43A2EFD7790B}
EndProjectSection
@ -94,7 +82,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GImpactTestDemo", "GImpactTestDemo\GImpactTestDemo.csproj", "{67C912BA-AE82-431C-AE11-326A7C00C5B0}"
ProjectSection(ProjectDependencies) = postProject
{540E0C60-3FBD-4166-933D-D80284D1CA0E} = {540E0C60-3FBD-4166-933D-D80284D1CA0E}
{3DDE3767-7DA8-4700-A74B-EC34146AB688} = {3DDE3767-7DA8-4700-A74B-EC34146AB688}
{3CD13788-CD50-451F-8267-AF7578403621} = {3CD13788-CD50-451F-8267-AF7578403621}
{67DF42D4-C318-4E52-9017-43A2EFD7790B} = {67DF42D4-C318-4E52-9017-43A2EFD7790B}
EndProjectSection
@ -102,7 +89,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VehicleDemo", "VehicleDemo\VehicleDemo.csproj", "{B6135DE9-0844-40A8-A57B-EA0F20ADFD55}"
ProjectSection(ProjectDependencies) = postProject
{540E0C60-3FBD-4166-933D-D80284D1CA0E} = {540E0C60-3FBD-4166-933D-D80284D1CA0E}
{3DDE3767-7DA8-4700-A74B-EC34146AB688} = {3DDE3767-7DA8-4700-A74B-EC34146AB688}
{3CD13788-CD50-451F-8267-AF7578403621} = {3CD13788-CD50-451F-8267-AF7578403621}
{67DF42D4-C318-4E52-9017-43A2EFD7790B} = {67DF42D4-C318-4E52-9017-43A2EFD7790B}
EndProjectSection
@ -110,7 +96,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CharacterDemo", "CharacterDemo\CharacterDemo.csproj", "{2C4C781D-BB0E-4BE9-AE46-D25641F6D531}"
ProjectSection(ProjectDependencies) = postProject
{540E0C60-3FBD-4166-933D-D80284D1CA0E} = {540E0C60-3FBD-4166-933D-D80284D1CA0E}
{3DDE3767-7DA8-4700-A74B-EC34146AB688} = {3DDE3767-7DA8-4700-A74B-EC34146AB688}
{3CD13788-CD50-451F-8267-AF7578403621} = {3CD13788-CD50-451F-8267-AF7578403621}
{67DF42D4-C318-4E52-9017-43A2EFD7790B} = {67DF42D4-C318-4E52-9017-43A2EFD7790B}
EndProjectSection
@ -118,7 +103,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CollisionInterfaceDemo", "CollisionInterfaceDemo\CollisionInterfaceDemo.csproj", "{C945B9CB-E50E-44C9-810D-3483F18D4F8C}"
ProjectSection(ProjectDependencies) = postProject
{540E0C60-3FBD-4166-933D-D80284D1CA0E} = {540E0C60-3FBD-4166-933D-D80284D1CA0E}
{3DDE3767-7DA8-4700-A74B-EC34146AB688} = {3DDE3767-7DA8-4700-A74B-EC34146AB688}
{3CD13788-CD50-451F-8267-AF7578403621} = {3CD13788-CD50-451F-8267-AF7578403621}
{67DF42D4-C318-4E52-9017-43A2EFD7790B} = {67DF42D4-C318-4E52-9017-43A2EFD7790B}
EndProjectSection
@ -126,7 +110,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DistanceDemo", "DistanceDemo\DistanceDemo.csproj", "{3EE18FE3-D5C4-4BDD-92F9-1763E586F246}"
ProjectSection(ProjectDependencies) = postProject
{540E0C60-3FBD-4166-933D-D80284D1CA0E} = {540E0C60-3FBD-4166-933D-D80284D1CA0E}
{3DDE3767-7DA8-4700-A74B-EC34146AB688} = {3DDE3767-7DA8-4700-A74B-EC34146AB688}
{3CD13788-CD50-451F-8267-AF7578403621} = {3CD13788-CD50-451F-8267-AF7578403621}
{67DF42D4-C318-4E52-9017-43A2EFD7790B} = {67DF42D4-C318-4E52-9017-43A2EFD7790B}
EndProjectSection
@ -134,7 +117,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConcaveRaycastDemo", "ConcaveRaycastDemo\ConcaveRaycastDemo.csproj", "{435BCDE5-8EA0-4B94-8768-65AC338F85F0}"
ProjectSection(ProjectDependencies) = postProject
{540E0C60-3FBD-4166-933D-D80284D1CA0E} = {540E0C60-3FBD-4166-933D-D80284D1CA0E}
{3DDE3767-7DA8-4700-A74B-EC34146AB688} = {3DDE3767-7DA8-4700-A74B-EC34146AB688}
{3CD13788-CD50-451F-8267-AF7578403621} = {3CD13788-CD50-451F-8267-AF7578403621}
{67DF42D4-C318-4E52-9017-43A2EFD7790B} = {67DF42D4-C318-4E52-9017-43A2EFD7790B}
EndProjectSection
@ -142,7 +124,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConcaveConvexCastDemo", "ConcaveConvexCastDemo\ConcaveConvexCastDemo.csproj", "{216CE49B-474F-4A64-9084-E23E487CB0C9}"
ProjectSection(ProjectDependencies) = postProject
{540E0C60-3FBD-4166-933D-D80284D1CA0E} = {540E0C60-3FBD-4166-933D-D80284D1CA0E}
{3DDE3767-7DA8-4700-A74B-EC34146AB688} = {3DDE3767-7DA8-4700-A74B-EC34146AB688}
{3CD13788-CD50-451F-8267-AF7578403621} = {3CD13788-CD50-451F-8267-AF7578403621}
{67DF42D4-C318-4E52-9017-43A2EFD7790B} = {67DF42D4-C318-4E52-9017-43A2EFD7790B}
EndProjectSection
@ -150,7 +131,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MotorDemo", "MotorDemo\MotorDemo.csproj", "{9B13DC6C-3704-4969-810C-412557FC9E47}"
ProjectSection(ProjectDependencies) = postProject
{540E0C60-3FBD-4166-933D-D80284D1CA0E} = {540E0C60-3FBD-4166-933D-D80284D1CA0E}
{3DDE3767-7DA8-4700-A74B-EC34146AB688} = {3DDE3767-7DA8-4700-A74B-EC34146AB688}
{3CD13788-CD50-451F-8267-AF7578403621} = {3CD13788-CD50-451F-8267-AF7578403621}
{67DF42D4-C318-4E52-9017-43A2EFD7790B} = {67DF42D4-C318-4E52-9017-43A2EFD7790B}
EndProjectSection
@ -158,7 +138,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RollingFrictionDemo", "RollingFrictionDemo\RollingFrictionDemo.csproj", "{F88BB418-67AD-45D8-BEC7-781CCA1CCA98}"
ProjectSection(ProjectDependencies) = postProject
{540E0C60-3FBD-4166-933D-D80284D1CA0E} = {540E0C60-3FBD-4166-933D-D80284D1CA0E}
{3DDE3767-7DA8-4700-A74B-EC34146AB688} = {3DDE3767-7DA8-4700-A74B-EC34146AB688}
{3CD13788-CD50-451F-8267-AF7578403621} = {3CD13788-CD50-451F-8267-AF7578403621}
{67DF42D4-C318-4E52-9017-43A2EFD7790B} = {67DF42D4-C318-4E52-9017-43A2EFD7790B}
EndProjectSection
@ -166,7 +145,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BulletXmlImportDemo", "BulletXmlImportDemo\BulletXmlImportDemo.csproj", "{8CADFD40-525F-4C72-8D38-443B094DB1BE}"
ProjectSection(ProjectDependencies) = postProject
{540E0C60-3FBD-4166-933D-D80284D1CA0E} = {540E0C60-3FBD-4166-933D-D80284D1CA0E}
{3DDE3767-7DA8-4700-A74B-EC34146AB688} = {3DDE3767-7DA8-4700-A74B-EC34146AB688}
{3CD13788-CD50-451F-8267-AF7578403621} = {3CD13788-CD50-451F-8267-AF7578403621}
{67DF42D4-C318-4E52-9017-43A2EFD7790B} = {67DF42D4-C318-4E52-9017-43A2EFD7790B}
EndProjectSection
@ -174,7 +152,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FeatherStoneDemo", "FeatherStoneDemo\FeatherStoneDemo.csproj", "{82F0CD92-FD49-414A-9150-621D30FCA29D}"
ProjectSection(ProjectDependencies) = postProject
{540E0C60-3FBD-4166-933D-D80284D1CA0E} = {540E0C60-3FBD-4166-933D-D80284D1CA0E}
{3DDE3767-7DA8-4700-A74B-EC34146AB688} = {3DDE3767-7DA8-4700-A74B-EC34146AB688}
{3CD13788-CD50-451F-8267-AF7578403621} = {3CD13788-CD50-451F-8267-AF7578403621}
{67DF42D4-C318-4E52-9017-43A2EFD7790B} = {67DF42D4-C318-4E52-9017-43A2EFD7790B}
EndProjectSection
@ -184,7 +161,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PendulumDemo", "PendulumDemo\PendulumDemo.csproj", "{56363BE1-F548-45A7-9DC1-7DCF7B5A97CF}"
ProjectSection(ProjectDependencies) = postProject
{540E0C60-3FBD-4166-933D-D80284D1CA0E} = {540E0C60-3FBD-4166-933D-D80284D1CA0E}
{3DDE3767-7DA8-4700-A74B-EC34146AB688} = {3DDE3767-7DA8-4700-A74B-EC34146AB688}
{3CD13788-CD50-451F-8267-AF7578403621} = {3CD13788-CD50-451F-8267-AF7578403621}
{67DF42D4-C318-4E52-9017-43A2EFD7790B} = {67DF42D4-C318-4E52-9017-43A2EFD7790B}
EndProjectSection
@ -203,10 +179,6 @@ Global
{8B5B1C14-C924-42FD-ABAB-4CD851F06DF9}.Debug|x86.Build.0 = Debug|x86
{8B5B1C14-C924-42FD-ABAB-4CD851F06DF9}.Release|x86.ActiveCfg = Release|x86
{8B5B1C14-C924-42FD-ABAB-4CD851F06DF9}.Release|x86.Build.0 = Release|x86
{3DDE3767-7DA8-4700-A74B-EC34146AB688}.Debug|x86.ActiveCfg = Debug|x86
{3DDE3767-7DA8-4700-A74B-EC34146AB688}.Debug|x86.Build.0 = Debug|x86
{3DDE3767-7DA8-4700-A74B-EC34146AB688}.Release|x86.ActiveCfg = Release|x86
{3DDE3767-7DA8-4700-A74B-EC34146AB688}.Release|x86.Build.0 = Release|x86
{67DF42D4-C318-4E52-9017-43A2EFD7790B}.Debug|x86.ActiveCfg = Debug|x86
{67DF42D4-C318-4E52-9017-43A2EFD7790B}.Release|x86.ActiveCfg = Release|x86
{3CD13788-CD50-451F-8267-AF7578403621}.Debug|x86.ActiveCfg = Debug|x86