Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Clark Lin
hw3d
Compare Revisions
2526ae6c195eafa6f55c68e00217b2874c43354c...0d65e345b511954f6260ce376fd5b4bc6d946987
Hide whitespace changes
Inline
Side-by-side
hw3d/Plane.h
0 → 100644
View file @
0d65e345
#pragma once
#include <optional>
#include "Vertex.h"
#include "IndexedTriangleList.h"
#include <DirectXMath.h>
#include "ChiliMath.h"
#include <array>
class
Plane
{
public:
static
IndexedTriangleList
MakeTesselatedTextured
(
Dvtx
::
VertexLayout
layout
,
int
divisions_x
,
int
divisions_y
)
{
namespace
dx
=
DirectX
;
assert
(
divisions_x
>=
1
);
assert
(
divisions_y
>=
1
);
constexpr
float
width
=
2.0
f
;
constexpr
float
height
=
2.0
f
;
const
int
nVertices_x
=
divisions_x
+
1
;
const
int
nVertices_y
=
divisions_y
+
1
;
Dvtx
::
VertexBuffer
vb
{
std
::
move
(
layout
)
};
{
const
float
side_x
=
width
/
2.0
f
;
const
float
side_y
=
height
/
2.0
f
;
const
float
divisionSize_x
=
width
/
float
(
divisions_x
);
const
float
divisionSize_y
=
height
/
float
(
divisions_y
);
const
float
divisionSize_x_tc
=
1.0
f
/
float
(
divisions_x
);
const
float
divisionSize_y_tc
=
1.0
f
/
float
(
divisions_y
);
for
(
int
y
=
0
,
i
=
0
;
y
<
nVertices_y
;
y
++
)
{
const
float
y_pos
=
float
(
y
)
*
divisionSize_y
-
side_y
;
const
float
y_pos_tc
=
1.0
f
-
float
(
y
)
*
divisionSize_y_tc
;
for
(
int
x
=
0
;
x
<
nVertices_x
;
x
++
,
i
++
)
{
const
float
x_pos
=
float
(
x
)
*
divisionSize_x
-
side_x
;
const
float
x_pos_tc
=
float
(
x
)
*
divisionSize_x_tc
;
vb
.
EmplaceBack
(
dx
::
XMFLOAT3
{
x_pos
,
y_pos
,
0.0
f
},
dx
::
XMFLOAT3
{
0.0
f
,
0.0
f
,
-
1.0
f
},
dx
::
XMFLOAT2
{
x_pos_tc
,
y_pos_tc
}
);
}
}
}
std
::
vector
<
unsigned
short
>
indices
;
indices
.
reserve
(
sq
(
divisions_x
*
divisions_y
)
*
6
);
{
const
auto
vxy2i
=
[
nVertices_x
](
size_t
x
,
size_t
y
)
{
return
(
unsigned
short
)(
y
*
nVertices_x
+
x
);
};
for
(
size_t
y
=
0
;
y
<
divisions_y
;
y
++
)
{
for
(
size_t
x
=
0
;
x
<
divisions_x
;
x
++
)
{
const
std
::
array
<
unsigned
short
,
4
>
indexArray
=
{
vxy2i
(
x
,
y
),
vxy2i
(
x
+
1
,
y
),
vxy2i
(
x
,
y
+
1
),
vxy2i
(
x
+
1
,
y
+
1
)
};
indices
.
push_back
(
indexArray
[
0
]
);
indices
.
push_back
(
indexArray
[
2
]
);
indices
.
push_back
(
indexArray
[
1
]
);
indices
.
push_back
(
indexArray
[
1
]
);
indices
.
push_back
(
indexArray
[
2
]
);
indices
.
push_back
(
indexArray
[
3
]
);
}
}
}
return
{
std
::
move
(
vb
),
std
::
move
(
indices
)
};
}
static
IndexedTriangleList
Make
()
{
using
Dvtx
::
VertexLayout
;
VertexLayout
vl
;
vl
.
Append
(
VertexLayout
::
Position3D
);
vl
.
Append
(
VertexLayout
::
Normal
);
vl
.
Append
(
VertexLayout
::
Texture2D
);
return
MakeTesselatedTextured
(
std
::
move
(
vl
),
1
,
1
);
}
};
hw3d/PointLight.cpp
View file @
0d65e345
...
@@ -39,7 +39,7 @@ void PointLight::SpawnControlWindow() noexcept
...
@@ -39,7 +39,7 @@ void PointLight::SpawnControlWindow() noexcept
void
PointLight
::
Reset
()
noexcept
void
PointLight
::
Reset
()
noexcept
{
{
cbData
=
{
cbData
=
{
{
1.5
f
,
1
4.0
f
,
-
4.5
f
},
{
0.0
f
,
4.0
f
,
-
4.5
f
},
{
0.05
f
,
0.05
f
,
0.05
f
},
{
0.05
f
,
0.05
f
,
0.05
f
},
{
1.0
f
,
1.0
f
,
1.0
f
},
{
1.0
f
,
1.0
f
,
1.0
f
},
1.0
f
,
1.0
f
,
...
...
hw3d/SolidPS.hlsl
View file @
0d65e345
cbuffer
CBuf
cbuffer
CBuf
:
register
(
b1
)
{
{
float4
color
;
float4
color
;
};
};
...
...
hw3d/SolidSphere.cpp
View file @
0d65e345
...
@@ -27,7 +27,7 @@ SolidSphere::SolidSphere( Graphics& gfx,float radius )
...
@@ -27,7 +27,7 @@ SolidSphere::SolidSphere( Graphics& gfx,float radius )
dx
::
XMFLOAT3
color
=
{
1.0
f
,
1.0
f
,
1.0
f
};
dx
::
XMFLOAT3
color
=
{
1.0
f
,
1.0
f
,
1.0
f
};
float
padding
;
float
padding
;
}
colorConst
;
}
colorConst
;
AddBind
(
PixelConstantBuffer
<
PSColorConstant
>::
Resolve
(
gfx
,
colorConst
)
);
AddBind
(
PixelConstantBuffer
<
PSColorConstant
>::
Resolve
(
gfx
,
colorConst
,
1u
)
);
AddBind
(
InputLayout
::
Resolve
(
gfx
,
model
.
vertices
.
GetLayout
(),
pvsbc
)
);
AddBind
(
InputLayout
::
Resolve
(
gfx
,
model
.
vertices
.
GetLayout
(),
pvsbc
)
);
...
...
hw3d/TestCube.cpp
0 → 100644
View file @
0d65e345
#include "TestCube.h"
#include "Cube.h"
#include "BindableCommon.h"
#include "TransformCbufDoubleboi.h"
#include "imgui/imgui.h"
TestCube
::
TestCube
(
Graphics
&
gfx
,
float
size
)
{
using
namespace
Bind
;
namespace
dx
=
DirectX
;
auto
model
=
Cube
::
MakeIndependentTextured
();
model
.
Transform
(
dx
::
XMMatrixScaling
(
size
,
size
,
size
)
);
model
.
SetNormalsIndependentFlat
();
const
auto
geometryTag
=
"$cube."
+
std
::
to_string
(
size
);
AddBind
(
VertexBuffer
::
Resolve
(
gfx
,
geometryTag
,
model
.
vertices
)
);
AddBind
(
IndexBuffer
::
Resolve
(
gfx
,
geometryTag
,
model
.
indices
)
);
AddBind
(
Texture
::
Resolve
(
gfx
,
"Images
\\
brickwall.jpg"
)
);
AddBind
(
Texture
::
Resolve
(
gfx
,
"Images
\\
brickwall_normal.jpg"
,
1u
)
);
auto
pvs
=
VertexShader
::
Resolve
(
gfx
,
"PhongVS.cso"
);
auto
pvsbc
=
pvs
->
GetBytecode
();
AddBind
(
std
::
move
(
pvs
)
);
AddBind
(
PixelShader
::
Resolve
(
gfx
,
"PhongPSNormalMap.cso"
)
);
AddBind
(
PixelConstantBuffer
<
PSMaterialConstant
>::
Resolve
(
gfx
,
pmc
,
1u
)
);
AddBind
(
InputLayout
::
Resolve
(
gfx
,
model
.
vertices
.
GetLayout
(),
pvsbc
)
);
AddBind
(
Topology
::
Resolve
(
gfx
,
D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST
)
);
AddBind
(
std
::
make_shared
<
TransformCbufDoubleboi
>
(
gfx
,
*
this
,
0u
,
2u
)
);
}
void
TestCube
::
SetPos
(
DirectX
::
XMFLOAT3
pos
)
noexcept
{
this
->
pos
=
pos
;
}
void
TestCube
::
SetRotation
(
float
roll
,
float
pitch
,
float
yaw
)
noexcept
{
this
->
roll
=
roll
;
this
->
pitch
=
pitch
;
this
->
yaw
=
yaw
;
}
DirectX
::
XMMATRIX
TestCube
::
GetTransformXM
()
const
noexcept
{
return
DirectX
::
XMMatrixRotationRollPitchYaw
(
roll
,
pitch
,
yaw
)
*
DirectX
::
XMMatrixTranslation
(
pos
.
x
,
pos
.
y
,
pos
.
z
);
}
void
TestCube
::
SpawnControlWindow
(
Graphics
&
gfx
)
noexcept
{
if
(
ImGui
::
Begin
(
"Cube"
)
)
{
ImGui
::
Text
(
"Position"
);
ImGui
::
SliderFloat
(
"X"
,
&
pos
.
x
,
-
80.0
f
,
80.0
f
,
"%.1f"
);
ImGui
::
SliderFloat
(
"Y"
,
&
pos
.
y
,
-
80.0
f
,
80.0
f
,
"%.1f"
);
ImGui
::
SliderFloat
(
"Z"
,
&
pos
.
z
,
-
80.0
f
,
80.0
f
,
"%.1f"
);
ImGui
::
Text
(
"Orientation"
);
ImGui
::
SliderAngle
(
"Roll"
,
&
roll
,
-
180.0
f
,
180.0
f
);
ImGui
::
SliderAngle
(
"Pitch"
,
&
pitch
,
-
180.0
f
,
180.0
f
);
ImGui
::
SliderAngle
(
"Yaw"
,
&
yaw
,
-
180.0
f
,
180.0
f
);
ImGui
::
Text
(
"Shading"
);
bool
changed0
=
ImGui
::
SliderFloat
(
"Spec. Int."
,
&
pmc
.
specularIntensity
,
0.0
f
,
1.0
f
);
bool
changed1
=
ImGui
::
SliderFloat
(
"Spec. Power"
,
&
pmc
.
specularPower
,
0.0
f
,
100.0
f
);
bool
checkState
=
pmc
.
normalMappingEnabled
==
TRUE
;
bool
changed2
=
ImGui
::
Checkbox
(
"Enable Normal Map"
,
&
checkState
);
pmc
.
normalMappingEnabled
=
checkState
?
TRUE
:
FALSE
;
if
(
changed0
||
changed1
||
changed2
)
{
QueryBindable
<
Bind
::
PixelConstantBuffer
<
PSMaterialConstant
>>
()
->
Update
(
gfx
,
pmc
);
}
}
ImGui
::
End
();
}
hw3d/TestCube.h
0 → 100644
View file @
0d65e345
#pragma once
#include "Drawable.h"
class
TestCube
:
public
Drawable
{
public:
TestCube
(
Graphics
&
gfx
,
float
size
);
void
SetPos
(
DirectX
::
XMFLOAT3
pos
)
noexcept
;
void
SetRotation
(
float
roll
,
float
pitch
,
float
yaw
)
noexcept
;
DirectX
::
XMMATRIX
GetTransformXM
()
const
noexcept
override
;
void
SpawnControlWindow
(
Graphics
&
gfx
)
noexcept
;
private:
struct
PSMaterialConstant
{
float
specularIntensity
=
0.1
f
;
float
specularPower
=
20.0
f
;
BOOL
normalMappingEnabled
=
TRUE
;
float
padding
[
1
];
}
pmc
;
DirectX
::
XMFLOAT3
pos
=
{
1.0
f
,
1.0
f
,
1.0
f
};
float
roll
=
0.0
f
;
float
pitch
=
0.0
f
;
float
yaw
=
0.0
f
;
};
\ No newline at end of file
hw3d/TestPlane.cpp
0 → 100644
View file @
0d65e345
#include "TestPlane.h"
#include "Plane.h"
#include "BindableCommon.h"
#include "imgui/imgui.h"
#include "TransformCbufDoubleboi.h"
TestPlane
::
TestPlane
(
Graphics
&
gfx
,
float
size
)
{
using
namespace
Bind
;
namespace
dx
=
DirectX
;
auto
model
=
Plane
::
Make
();
model
.
Transform
(
dx
::
XMMatrixScaling
(
size
,
size
,
1.0
f
)
);
const
auto
geometryTag
=
"$plane."
+
std
::
to_string
(
size
);
AddBind
(
VertexBuffer
::
Resolve
(
gfx
,
geometryTag
,
model
.
vertices
)
);
AddBind
(
IndexBuffer
::
Resolve
(
gfx
,
geometryTag
,
model
.
indices
)
);
AddBind
(
Texture
::
Resolve
(
gfx
,
"Images
\\
brickwall.jpg"
)
);
AddBind
(
Texture
::
Resolve
(
gfx
,
"Images
\\
brickwall_normal.jpg"
,
1u
)
);
auto
pvs
=
VertexShader
::
Resolve
(
gfx
,
"PhongVS.cso"
);
auto
pvsbc
=
pvs
->
GetBytecode
();
AddBind
(
std
::
move
(
pvs
)
);
AddBind
(
PixelShader
::
Resolve
(
gfx
,
"PhongPSNormalMapObject.cso"
)
);
AddBind
(
PixelConstantBuffer
<
PSMaterialConstant
>::
Resolve
(
gfx
,
pmc
,
1u
)
);
AddBind
(
InputLayout
::
Resolve
(
gfx
,
model
.
vertices
.
GetLayout
(),
pvsbc
)
);
AddBind
(
Topology
::
Resolve
(
gfx
,
D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST
)
);
AddBind
(
std
::
make_shared
<
TransformCbufDoubleboi
>
(
gfx
,
*
this
,
0u
,
2u
)
);
}
void
TestPlane
::
SetPos
(
DirectX
::
XMFLOAT3
pos
)
noexcept
{
this
->
pos
=
pos
;
}
void
TestPlane
::
SetRotation
(
float
roll
,
float
pitch
,
float
yaw
)
noexcept
{
this
->
roll
=
roll
;
this
->
pitch
=
pitch
;
this
->
yaw
=
yaw
;
}
DirectX
::
XMMATRIX
TestPlane
::
GetTransformXM
()
const
noexcept
{
return
DirectX
::
XMMatrixRotationRollPitchYaw
(
roll
,
pitch
,
yaw
)
*
DirectX
::
XMMatrixTranslation
(
pos
.
x
,
pos
.
y
,
pos
.
z
);
}
void
TestPlane
::
SpawnControlWindow
(
Graphics
&
gfx
)
noexcept
{
if
(
ImGui
::
Begin
(
"Plane"
)
)
{
ImGui
::
Text
(
"Position"
);
ImGui
::
SliderFloat
(
"X"
,
&
pos
.
x
,
-
80.0
f
,
80.0
f
,
"%.1f"
);
ImGui
::
SliderFloat
(
"Y"
,
&
pos
.
y
,
-
80.0
f
,
80.0
f
,
"%.1f"
);
ImGui
::
SliderFloat
(
"Z"
,
&
pos
.
z
,
-
80.0
f
,
80.0
f
,
"%.1f"
);
ImGui
::
Text
(
"Orientation"
);
ImGui
::
SliderAngle
(
"Roll"
,
&
roll
,
-
180.0
f
,
180.0
f
);
ImGui
::
SliderAngle
(
"Pitch"
,
&
pitch
,
-
180.0
f
,
180.0
f
);
ImGui
::
SliderAngle
(
"Yaw"
,
&
yaw
,
-
180.0
f
,
180.0
f
);
ImGui
::
Text
(
"Shading"
);
bool
changed0
=
ImGui
::
SliderFloat
(
"Spec. Int."
,
&
pmc
.
specularIntensity
,
0.0
f
,
1.0
f
);
bool
changed1
=
ImGui
::
SliderFloat
(
"Spec. Power"
,
&
pmc
.
specularPower
,
0.0
f
,
100.0
f
);
bool
checkState
=
pmc
.
normalMappingEnabled
==
TRUE
;
bool
changed2
=
ImGui
::
Checkbox
(
"Enable Normal Map"
,
&
checkState
);
pmc
.
normalMappingEnabled
=
checkState
?
TRUE
:
FALSE
;
if
(
changed0
||
changed1
||
changed2
)
{
QueryBindable
<
Bind
::
PixelConstantBuffer
<
PSMaterialConstant
>>
()
->
Update
(
gfx
,
pmc
);
}
}
ImGui
::
End
();
}
hw3d/TestPlane.h
0 → 100644
View file @
0d65e345
#pragma once
#include "Drawable.h"
class
TestPlane
:
public
Drawable
{
public:
TestPlane
(
Graphics
&
gfx
,
float
size
);
void
SetPos
(
DirectX
::
XMFLOAT3
pos
)
noexcept
;
void
SetRotation
(
float
roll
,
float
pitch
,
float
yaw
)
noexcept
;
DirectX
::
XMMATRIX
GetTransformXM
()
const
noexcept
override
;
void
SpawnControlWindow
(
Graphics
&
gfx
)
noexcept
;
private:
struct
PSMaterialConstant
{
float
specularIntensity
=
0.18
f
;
float
specularPower
=
18.0
f
;
BOOL
normalMappingEnabled
=
TRUE
;
float
padding
[
1
];
}
pmc
;
DirectX
::
XMFLOAT3
pos
=
{
0.0
f
,
0.0
f
,
0.0
f
};
float
roll
=
0.0
f
;
float
pitch
=
0.0
f
;
float
yaw
=
0.0
f
;
};
\ No newline at end of file
hw3d/TransformCbuf.cpp
View file @
0d65e345
...
@@ -13,18 +13,26 @@ namespace Bind
...
@@ -13,18 +13,26 @@ namespace Bind
}
}
void
TransformCbuf
::
Bind
(
Graphics
&
gfx
)
noexcept
void
TransformCbuf
::
Bind
(
Graphics
&
gfx
)
noexcept
{
UpdateBindImpl
(
gfx
,
GetTransforms
(
gfx
)
);
}
void
TransformCbuf
::
UpdateBindImpl
(
Graphics
&
gfx
,
const
Transforms
&
tf
)
noexcept
{
pVcbuf
->
Update
(
gfx
,
tf
);
pVcbuf
->
Bind
(
gfx
);
}
TransformCbuf
::
Transforms
TransformCbuf
::
GetTransforms
(
Graphics
&
gfx
)
noexcept
{
{
const
auto
modelView
=
parent
.
GetTransformXM
()
*
gfx
.
GetCamera
();
const
auto
modelView
=
parent
.
GetTransformXM
()
*
gfx
.
GetCamera
();
const
Transforms
tf
=
return
{
{
DirectX
::
XMMatrixTranspose
(
modelView
),
DirectX
::
XMMatrixTranspose
(
modelView
),
DirectX
::
XMMatrixTranspose
(
DirectX
::
XMMatrixTranspose
(
modelView
*
modelView
*
gfx
.
GetProjection
()
gfx
.
GetProjection
()
)
)
};
};
pVcbuf
->
Update
(
gfx
,
tf
);
pVcbuf
->
Bind
(
gfx
);
}
}
std
::
unique_ptr
<
VertexConstantBuffer
<
TransformCbuf
::
Transforms
>>
TransformCbuf
::
pVcbuf
;
std
::
unique_ptr
<
VertexConstantBuffer
<
TransformCbuf
::
Transforms
>>
TransformCbuf
::
pVcbuf
;
...
...
hw3d/TransformCbuf.h
View file @
0d65e345
...
@@ -7,15 +7,18 @@ namespace Bind
...
@@ -7,15 +7,18 @@ namespace Bind
{
{
class
TransformCbuf
:
public
Bindable
class
TransformCbuf
:
public
Bindable
{
{
pr
ivate
:
pr
otected
:
struct
Transforms
struct
Transforms
{
{
DirectX
::
XMMATRIX
modelView
;
DirectX
::
XMMATRIX
modelViewProj
;
DirectX
::
XMMATRIX
modelViewProj
;
DirectX
::
XMMATRIX
model
;
};
};
public:
public:
TransformCbuf
(
Graphics
&
gfx
,
const
Drawable
&
parent
,
UINT
slot
=
0u
);
TransformCbuf
(
Graphics
&
gfx
,
const
Drawable
&
parent
,
UINT
slot
=
0u
);
void
Bind
(
Graphics
&
gfx
)
noexcept
override
;
void
Bind
(
Graphics
&
gfx
)
noexcept
override
;
protected:
void
UpdateBindImpl
(
Graphics
&
gfx
,
const
Transforms
&
tf
)
noexcept
;
Transforms
GetTransforms
(
Graphics
&
gfx
)
noexcept
;
private:
private:
static
std
::
unique_ptr
<
VertexConstantBuffer
<
Transforms
>>
pVcbuf
;
static
std
::
unique_ptr
<
VertexConstantBuffer
<
Transforms
>>
pVcbuf
;
const
Drawable
&
parent
;
const
Drawable
&
parent
;
...
...
hw3d/TransformCbufDoubleboi.cpp
0 → 100644
View file @
0d65e345
#include "TransformCbufDoubleboi.h"
namespace
Bind
{
TransformCbufDoubleboi
::
TransformCbufDoubleboi
(
Graphics
&
gfx
,
const
Drawable
&
parent
,
UINT
slotV
,
UINT
slotP
)
:
TransformCbuf
(
gfx
,
parent
,
slotV
)
{
if
(
!
pPcbuf
)
{
pPcbuf
=
std
::
make_unique
<
PixelConstantBuffer
<
Transforms
>>
(
gfx
,
slotP
);
}
}
void
Bind
::
TransformCbufDoubleboi
::
Bind
(
Graphics
&
gfx
)
noexcept
{
const
auto
tf
=
GetTransforms
(
gfx
);
TransformCbuf
::
UpdateBindImpl
(
gfx
,
tf
);
UpdateBindImpl
(
gfx
,
tf
);
}
void
TransformCbufDoubleboi
::
UpdateBindImpl
(
Graphics
&
gfx
,
const
Transforms
&
tf
)
noexcept
{
pPcbuf
->
Update
(
gfx
,
tf
);
pPcbuf
->
Bind
(
gfx
);
}
std
::
unique_ptr
<
PixelConstantBuffer
<
TransformCbuf
::
Transforms
>>
TransformCbufDoubleboi
::
pPcbuf
;
}
\ No newline at end of file
hw3d/TransformCbufDoubleboi.h
0 → 100644
View file @
0d65e345
#pragma once
#include "TransformCbuf.h"
namespace
Bind
{
class
TransformCbufDoubleboi
:
public
TransformCbuf
{
public:
TransformCbufDoubleboi
(
Graphics
&
gfx
,
const
Drawable
&
parent
,
UINT
slotV
=
0u
,
UINT
slotP
=
0u
);
void
Bind
(
Graphics
&
gfx
)
noexcept
override
;
protected:
void
UpdateBindImpl
(
Graphics
&
gfx
,
const
Transforms
&
tf
)
noexcept
;
private:
static
std
::
unique_ptr
<
PixelConstantBuffer
<
Transforms
>>
pPcbuf
;
};
}
\ No newline at end of file
hw3d/Vertex.cpp
View file @
0d65e345
...
@@ -71,6 +71,10 @@ namespace Dvtx
...
@@ -71,6 +71,10 @@ namespace Dvtx
return
sizeof
(
Map
<
Texture2D
>::
SysType
);
return
sizeof
(
Map
<
Texture2D
>::
SysType
);
case
Normal
:
case
Normal
:
return
sizeof
(
Map
<
Normal
>::
SysType
);
return
sizeof
(
Map
<
Normal
>::
SysType
);
case
Tangent
:
return
sizeof
(
Map
<
Tangent
>::
SysType
);
case
Bitangent
:
return
sizeof
(
Map
<
Bitangent
>::
SysType
);
case
Float3Color
:
case
Float3Color
:
return
sizeof
(
Map
<
Float3Color
>::
SysType
);
return
sizeof
(
Map
<
Float3Color
>::
SysType
);
case
Float4Color
:
case
Float4Color
:
...
@@ -97,6 +101,10 @@ namespace Dvtx
...
@@ -97,6 +101,10 @@ namespace Dvtx
return
Map
<
Texture2D
>::
code
;
return
Map
<
Texture2D
>::
code
;
case
Normal
:
case
Normal
:
return
Map
<
Normal
>::
code
;
return
Map
<
Normal
>::
code
;
case
Tangent
:
return
Map
<
Tangent
>::
code
;
case
Bitangent
:
return
Map
<
Bitangent
>::
code
;
case
Float3Color
:
case
Float3Color
:
return
Map
<
Float3Color
>::
code
;
return
Map
<
Float3Color
>::
code
;
case
Float4Color
:
case
Float4Color
:
...
@@ -119,6 +127,10 @@ namespace Dvtx
...
@@ -119,6 +127,10 @@ namespace Dvtx
return
GenerateDesc
<
Texture2D
>
(
GetOffset
()
);
return
GenerateDesc
<
Texture2D
>
(
GetOffset
()
);
case
Normal
:
case
Normal
:
return
GenerateDesc
<
Normal
>
(
GetOffset
()
);
return
GenerateDesc
<
Normal
>
(
GetOffset
()
);
case
Tangent
:
return
GenerateDesc
<
Tangent
>
(
GetOffset
()
);
case
Bitangent
:
return
GenerateDesc
<
Bitangent
>
(
GetOffset
()
);
case
Float3Color
:
case
Float3Color
:
return
GenerateDesc
<
Float3Color
>
(
GetOffset
()
);
return
GenerateDesc
<
Float3Color
>
(
GetOffset
()
);
case
Float4Color
:
case
Float4Color
:
...
@@ -146,10 +158,20 @@ namespace Dvtx
...
@@ -146,10 +158,20 @@ namespace Dvtx
// VertexBuffer
// VertexBuffer
VertexBuffer
::
VertexBuffer
(
VertexLayout
layout
)
noxnd
VertexBuffer
::
VertexBuffer
(
VertexLayout
layout
,
size_t
size
)
noxnd
:
:
layout
(
std
::
move
(
layout
)
)
layout
(
std
::
move
(
layout
)
)
{}
{
Resize
(
size
);
}
void
VertexBuffer
::
Resize
(
size_t
newSize
)
noxnd
{
const
auto
size
=
Size
();
if
(
size
<
newSize
)
{
buffer
.
resize
(
buffer
.
size
()
+
layout
.
Size
()
*
(
newSize
-
size
)
);
}
}
const
char
*
VertexBuffer
::
GetData
()
const
noxnd
const
char
*
VertexBuffer
::
GetData
()
const
noxnd
{
{
return
buffer
.
data
();
return
buffer
.
data
();
...
...
hw3d/Vertex.h
View file @
0d65e345
...
@@ -16,6 +16,8 @@ namespace Dvtx
...
@@ -16,6 +16,8 @@ namespace Dvtx
Position3D
,
Position3D
,
Texture2D
,
Texture2D
,
Normal
,
Normal
,
Tangent
,
Bitangent
,
Float3Color
,
Float3Color
,
Float4Color
,
Float4Color
,
BGRAColor
,
BGRAColor
,
...
@@ -50,6 +52,20 @@ namespace Dvtx
...
@@ -50,6 +52,20 @@ namespace Dvtx
static
constexpr
const
char
*
semantic
=
"Normal"
;
static
constexpr
const
char
*
semantic
=
"Normal"
;
static
constexpr
const
char
*
code
=
"N"
;
static
constexpr
const
char
*
code
=
"N"
;
};
};
template
<
>
struct
Map
<
Tangent
>
{
using
SysType
=
DirectX
::
XMFLOAT3
;
static
constexpr
DXGI_FORMAT
dxgiFormat
=
DXGI_FORMAT_R32G32B32_FLOAT
;
static
constexpr
const
char
*
semantic
=
"Tangent"
;
static
constexpr
const
char
*
code
=
"Nt"
;
};
template
<
>
struct
Map
<
Bitangent
>
{
using
SysType
=
DirectX
::
XMFLOAT3
;
static
constexpr
DXGI_FORMAT
dxgiFormat
=
DXGI_FORMAT_R32G32B32_FLOAT
;
static
constexpr
const
char
*
semantic
=
"Bitangent"
;
static
constexpr
const
char
*
code
=
"Nb"
;
};
template
<
>
struct
Map
<
Float3Color
>
template
<
>
struct
Map
<
Float3Color
>
{
{
using
SysType
=
DirectX
::
XMFLOAT3
;
using
SysType
=
DirectX
::
XMFLOAT3
;
...
@@ -146,6 +162,12 @@ namespace Dvtx
...
@@ -146,6 +162,12 @@ namespace Dvtx
case
VertexLayout
::
Normal
:
case
VertexLayout
::
Normal
:
SetAttribute
<
VertexLayout
::
Normal
>
(
pAttribute
,
std
::
forward
<
T
>
(
val
)
);
SetAttribute
<
VertexLayout
::
Normal
>
(
pAttribute
,
std
::
forward
<
T
>
(
val
)
);
break
;
break
;
case
VertexLayout
::
Tangent
:
SetAttribute
<
VertexLayout
::
Tangent
>
(
pAttribute
,
std
::
forward
<
T
>
(
val
)
);
break
;
case
VertexLayout
::
Bitangent
:
SetAttribute
<
VertexLayout
::
Bitangent
>
(
pAttribute
,
std
::
forward
<
T
>
(
val
)
);
break
;
case
VertexLayout
::
Float3Color
:
case
VertexLayout
::
Float3Color
:
SetAttribute
<
VertexLayout
::
Float3Color
>
(
pAttribute
,
std
::
forward
<
T
>
(
val
)
);
SetAttribute
<
VertexLayout
::
Float3Color
>
(
pAttribute
,
std
::
forward
<
T
>
(
val
)
);
break
;
break
;
...
@@ -204,9 +226,10 @@ namespace Dvtx
...
@@ -204,9 +226,10 @@ namespace Dvtx
class
VertexBuffer
class
VertexBuffer
{
{
public:
public:
VertexBuffer
(
VertexLayout
layout
)
noxnd
;
VertexBuffer
(
VertexLayout
layout
,
size_t
size
=
0u
)
noxnd
;
const
char
*
GetData
()
const
noxnd
;
const
char
*
GetData
()
const
noxnd
;
const
VertexLayout
&
GetLayout
()
const
noexcept
;
const
VertexLayout
&
GetLayout
()
const
noexcept
;
void
Resize
(
size_t
newSize
)
noxnd
;
size_t
Size
()
const
noxnd
;
size_t
Size
()
const
noxnd
;
size_t
SizeBytes
()
const
noxnd
;
size_t
SizeBytes
()
const
noxnd
;
template
<
typename
...
Params
>
template
<
typename
...
Params
>
...
...
hw3d/hw3d.vcxproj
View file @
0d65e345
...
@@ -112,15 +112,27 @@
...
@@ -112,15 +112,27 @@
<ClCompile
Include=
"InputLayout.cpp"
/>
<ClCompile
Include=
"InputLayout.cpp"
/>
<ClCompile
Include=
"Keyboard.cpp"
/>
<ClCompile
Include=
"Keyboard.cpp"
/>
<ClCompile
Include=
"Mesh.cpp"
/>
<ClCompile
Include=
"Mesh.cpp"
/>
<FxCompile
Include=
"PhongPSNormalMapObject.hlsl"
>
<FileType>
Document
</FileType>
<ShaderModel
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
4.0
</ShaderModel>
<ShaderModel
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
4.0
</ShaderModel>
<ObjectFileOutput
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
$(ProjectDir)%(Filename).cso
</ObjectFileOutput>
<ObjectFileOutput
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
$(ProjectDir)%(Filename).cso
</ObjectFileOutput>
<ShaderType
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
Pixel
</ShaderType>
<ShaderType
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
Pixel
</ShaderType>
</FxCompile>
<ClCompile
Include=
"PointLight.cpp"
/>
<ClCompile
Include=
"PointLight.cpp"
/>
<ClCompile
Include=
"Mouse.cpp"
/>
<ClCompile
Include=
"Mouse.cpp"
/>
<ClCompile
Include=
"PixelShader.cpp"
/>
<ClCompile
Include=
"PixelShader.cpp"
/>
<ClCompile
Include=
"Sampler.cpp"
/>
<ClCompile
Include=
"Sampler.cpp"
/>
<ClCompile
Include=
"SolidSphere.cpp"
/>
<ClCompile
Include=
"SolidSphere.cpp"
/>
<ClCompile
Include=
"Surface.cpp"
/>
<ClCompile
Include=
"Surface.cpp"
/>
<ClCompile
Include=
"TestCube.cpp"
/>
<ClCompile
Include=
"TestPlane.cpp"
/>
<ClCompile
Include=
"Texture.cpp"
/>
<ClCompile
Include=
"Texture.cpp"
/>
<ClCompile
Include=
"Topology.cpp"
/>
<ClCompile
Include=
"Topology.cpp"
/>
<ClCompile
Include=
"TransformCbuf.cpp"
/>
<ClCompile
Include=
"TransformCbuf.cpp"
/>
<ClCompile
Include=
"TransformCbufDoubleboi.cpp"
/>
<ClCompile
Include=
"Vertex.cpp"
/>
<ClCompile
Include=
"Vertex.cpp"
/>
<ClCompile
Include=
"VertexBuffer.cpp"
/>
<ClCompile
Include=
"VertexBuffer.cpp"
/>
<ClCompile
Include=
"VertexShader.cpp"
/>
<ClCompile
Include=
"VertexShader.cpp"
/>
...
@@ -141,6 +153,8 @@
...
@@ -141,6 +153,8 @@
<ClInclude
Include=
"Color.h"
/>
<ClInclude
Include=
"Color.h"
/>
<ClInclude
Include=
"ConditionalNoexcept.h"
/>
<ClInclude
Include=
"ConditionalNoexcept.h"
/>
<ClInclude
Include=
"ConstantBuffers.h"
/>
<ClInclude
Include=
"ConstantBuffers.h"
/>
<ClInclude
Include=
"Cube.h"
/>
<ClInclude
Include=
"TestCube.h"
/>
<ClInclude
Include=
"Drawable.h"
/>
<ClInclude
Include=
"Drawable.h"
/>
<ClInclude
Include=
"dxerr.h"
/>
<ClInclude
Include=
"dxerr.h"
/>
<ClInclude
Include=
"DxgiInfoManager.h"
/>
<ClInclude
Include=
"DxgiInfoManager.h"
/>
...
@@ -161,6 +175,7 @@
...
@@ -161,6 +175,7 @@
<ClInclude
Include=
"InputLayout.h"
/>
<ClInclude
Include=
"InputLayout.h"
/>
<ClInclude
Include=
"Keyboard.h"
/>
<ClInclude
Include=
"Keyboard.h"
/>
<ClInclude
Include=
"Mesh.h"
/>
<ClInclude
Include=
"Mesh.h"
/>
<ClInclude
Include=
"Plane.h"
/>
<ClInclude
Include=
"PointLight.h"
/>
<ClInclude
Include=
"PointLight.h"
/>
<ClInclude
Include=
"Mouse.h"
/>
<ClInclude
Include=
"Mouse.h"
/>
<ClInclude
Include=
"PixelShader.h"
/>
<ClInclude
Include=
"PixelShader.h"
/>
...
@@ -169,9 +184,11 @@
...
@@ -169,9 +184,11 @@
<ClInclude
Include=
"SolidSphere.h"
/>
<ClInclude
Include=
"SolidSphere.h"
/>
<ClInclude
Include=
"Sphere.h"
/>
<ClInclude
Include=
"Sphere.h"
/>
<ClInclude
Include=
"Surface.h"
/>
<ClInclude
Include=
"Surface.h"
/>
<ClInclude
Include=
"TestPlane.h"
/>
<ClInclude
Include=
"Texture.h"
/>
<ClInclude
Include=
"Texture.h"
/>
<ClInclude
Include=
"Topology.h"
/>
<ClInclude
Include=
"Topology.h"
/>
<ClInclude
Include=
"TransformCbuf.h"
/>
<ClInclude
Include=
"TransformCbuf.h"
/>
<ClInclude
Include=
"TransformCbufDoubleboi.h"
/>
<ClInclude
Include=
"Vertex.h"
/>
<ClInclude
Include=
"Vertex.h"
/>
<ClInclude
Include=
"VertexBuffer.h"
/>
<ClInclude
Include=
"VertexBuffer.h"
/>
<ClInclude
Include=
"VertexShader.h"
/>
<ClInclude
Include=
"VertexShader.h"
/>
...
@@ -191,7 +208,7 @@
...
@@ -191,7 +208,7 @@
<None
Include=
"DXTrace.inl"
/>
<None
Include=
"DXTrace.inl"
/>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<FxCompile
Include=
"PhongPS
Spec
Map.hlsl"
>
<FxCompile
Include=
"PhongPS
Normal
Map.hlsl"
>
<ShaderType
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
Pixel
</ShaderType>
<ShaderType
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
Pixel
</ShaderType>
<ShaderModel
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
4.0
</ShaderModel>
<ShaderModel
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
4.0
</ShaderModel>
<ShaderType
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
Pixel
</ShaderType>
<ShaderType
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
Pixel
</ShaderType>
...
@@ -199,6 +216,22 @@
...
@@ -199,6 +216,22 @@
<ObjectFileOutput
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
$(ProjectDir)%(Filename).cso
</ObjectFileOutput>
<ObjectFileOutput
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
$(ProjectDir)%(Filename).cso
</ObjectFileOutput>
<ObjectFileOutput
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
$(ProjectDir)%(Filename).cso
</ObjectFileOutput>
<ObjectFileOutput
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
$(ProjectDir)%(Filename).cso
</ObjectFileOutput>
</FxCompile>
</FxCompile>
<FxCompile
Include=
"PhongPSSpecNormalMap.hlsl"
>
<ShaderType
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
Pixel
</ShaderType>
<ShaderModel
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
4.0
</ShaderModel>
<ShaderType
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
Pixel
</ShaderType>
<ShaderModel
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
4.0
</ShaderModel>
<ObjectFileOutput
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
$(ProjectDir)%(Filename).cso
</ObjectFileOutput>
<ObjectFileOutput
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
$(ProjectDir)%(Filename).cso
</ObjectFileOutput>
</FxCompile>
<FxCompile
Include=
"PhongVSNormalMap.hlsl"
>
<ShaderModel
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
4.0
</ShaderModel>
<ShaderModel
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
4.0
</ShaderModel>
<ShaderType
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
Vertex
</ShaderType>
<ShaderType
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
Vertex
</ShaderType>
<ObjectFileOutput
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
$(ProjectDir)%(Filename).cso
</ObjectFileOutput>
<ObjectFileOutput
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
$(ProjectDir)%(Filename).cso
</ObjectFileOutput>
</FxCompile>
<FxCompile
Include=
"SolidPS.hlsl"
>
<FxCompile
Include=
"SolidPS.hlsl"
>
<ShaderType
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
Pixel
</ShaderType>
<ShaderType
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
Pixel
</ShaderType>
<ShaderModel
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
4.0
</ShaderModel>
<ShaderModel
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
4.0
</ShaderModel>
...
...
hw3d/hw3d.vcxproj.filters
View file @
0d65e345
...
@@ -150,6 +150,15 @@
...
@@ -150,6 +150,15 @@
<ClCompile
Include=
"Mesh.cpp"
>
<ClCompile
Include=
"Mesh.cpp"
>
<Filter>
Source Files
</Filter>
<Filter>
Source Files
</Filter>
</ClCompile>
</ClCompile>
<ClCompile
Include=
"TestPlane.cpp"
>
<Filter>
Source Files\Drawable
</Filter>
</ClCompile>
<ClCompile
Include=
"TransformCbufDoubleboi.cpp"
>
<Filter>
Source Files\Bindable
</Filter>
</ClCompile>
<ClCompile
Include=
"TestCube.cpp"
>
<Filter>
Source Files\Drawable
</Filter>
</ClCompile>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<ClInclude
Include=
"WindowsMessageMap.h"
>
<ClInclude
Include=
"WindowsMessageMap.h"
>
...
@@ -299,6 +308,21 @@
...
@@ -299,6 +308,21 @@
<ClInclude
Include=
"BindableCodex.h"
>
<ClInclude
Include=
"BindableCodex.h"
>
<Filter>
Header Files\Bindable
</Filter>
<Filter>
Header Files\Bindable
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"Plane.h"
>
<Filter>
Header Files\Geometry
</Filter>
</ClInclude>
<ClInclude
Include=
"TestPlane.h"
>
<Filter>
Header Files\Drawable
</Filter>
</ClInclude>
<ClInclude
Include=
"TransformCbufDoubleboi.h"
>
<Filter>
Header Files\Bindable
</Filter>
</ClInclude>
<ClInclude
Include=
"Cube.h"
>
<Filter>
Header Files\Geometry
</Filter>
</ClInclude>
<ClInclude
Include=
"TestCube.h"
>
<Filter>
Header Files\Drawable
</Filter>
</ClInclude>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<ResourceCompile
Include=
"hw3d.rc"
>
<ResourceCompile
Include=
"hw3d.rc"
>
...
@@ -334,7 +358,16 @@
...
@@ -334,7 +358,16 @@
<FxCompile
Include=
"SolidVS.hlsl"
>
<FxCompile
Include=
"SolidVS.hlsl"
>
<Filter>
Shader
</Filter>
<Filter>
Shader
</Filter>
</FxCompile>
</FxCompile>
<FxCompile
Include=
"PhongPSSpecMap.hlsl"
>
<FxCompile
Include=
"PhongPSNormalMap.hlsl"
>
<Filter>
Shader
</Filter>
</FxCompile>
<FxCompile
Include=
"PhongVSNormalMap.hlsl"
>
<Filter>
Shader
</Filter>
</FxCompile>
<FxCompile
Include=
"PhongPSSpecNormalMap.hlsl"
>
<Filter>
Shader
</Filter>
</FxCompile>
<FxCompile
Include=
"PhongPSNormalMapObject.hlsl"
>
<Filter>
Shader
</Filter>
<Filter>
Shader
</Filter>
</FxCompile>
</FxCompile>
</ItemGroup>
</ItemGroup>
...
...
Prev
1
2
Next