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
Commits
9b867608
Commit
9b867608
authored
Apr 13, 2019
by
chili
Browse files
constant strife
parent
6ed79cdb
Changes
3
Show whitespace changes
Inline
Side-by-side
hw3d/PhongPS.hlsl
View file @
9b867608
cbuffer
LightCBuf
{
float3
lightPos
;
float3
materialColor
;
float3
ambient
;
float3
diffuseColor
;
float
diffuseIntensity
;
float
attConst
;
float
attLin
;
float
attQuad
;
};
static
const
float3
materialColor
=
{
0
.
7
f
,
0
.
7
f
,
0
.
9
f
};
static
const
float3
ambient
=
{
0
.
05
f
,
0
.
05
f
,
0
.
05
f
};
static
const
float3
diffuseColor
=
{
1
.
0
f
,
1
.
0
f
,
1
.
0
f
};
static
const
float
diffuseIntensity
=
1
.
0
f
;
static
const
float
attConst
=
1
.
0
f
;
static
const
float
attLin
=
0
.
045
f
;
static
const
float
attQuad
=
0
.
0075
f
;
float4
main
(
float3
worldPos
:
Position
,
float3
n
:
Normal
)
:
SV_Target
{
...
...
hw3d/PointLight.cpp
View file @
9b867608
...
...
@@ -5,16 +5,18 @@ PointLight::PointLight( Graphics& gfx,float radius )
:
mesh
(
gfx
,
radius
),
cbuf
(
gfx
)
{}
{
Reset
();
}
void
PointLight
::
SpawnControlWindow
()
noexcept
{
if
(
ImGui
::
Begin
(
"Light"
)
)
{
ImGui
::
Text
(
"Position"
);
ImGui
::
SliderFloat
(
"X"
,
&
pos
.
x
,
-
60.0
f
,
60.0
f
,
"%.1f"
);
ImGui
::
SliderFloat
(
"Y"
,
&
pos
.
y
,
-
60.0
f
,
60.0
f
,
"%.1f"
);
ImGui
::
SliderFloat
(
"Z"
,
&
pos
.
z
,
-
60.0
f
,
60.0
f
,
"%.1f"
);
ImGui
::
SliderFloat
(
"X"
,
&
cbData
.
pos
.
x
,
-
60.0
f
,
60.0
f
,
"%.1f"
);
ImGui
::
SliderFloat
(
"Y"
,
&
cbData
.
pos
.
y
,
-
60.0
f
,
60.0
f
,
"%.1f"
);
ImGui
::
SliderFloat
(
"Z"
,
&
cbData
.
pos
.
z
,
-
60.0
f
,
60.0
f
,
"%.1f"
);
if
(
ImGui
::
Button
(
"Reset"
)
)
{
Reset
();
...
...
@@ -25,17 +27,26 @@ void PointLight::SpawnControlWindow() noexcept
void
PointLight
::
Reset
()
noexcept
{
pos
=
{
0.0
f
,
0.0
f
,
0.0
f
};
cbData
=
{
{
0.0
f
,
0.0
f
,
0.0
f
},
{
0.7
f
,
0.7
f
,
0.9
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
,
0.045
f
,
0.0075
f
,
};
}
void
PointLight
::
Draw
(
Graphics
&
gfx
)
const
noexcept
(
!
IS_DEBUG
)
{
mesh
.
SetPos
(
pos
);
mesh
.
SetPos
(
cbData
.
pos
);
mesh
.
Draw
(
gfx
);
}
void
PointLight
::
Bind
(
Graphics
&
gfx
)
const
noexcept
{
cbuf
.
Update
(
gfx
,
PointLightCBuf
{
pos
}
);
cbuf
.
Update
(
gfx
,
cbData
);
cbuf
.
Bind
(
gfx
);
}
hw3d/PointLight.h
View file @
9b867608
...
...
@@ -15,10 +15,16 @@ private:
struct
PointLightCBuf
{
DirectX
::
XMFLOAT3
pos
;
float
padding
;
DirectX
::
XMFLOAT3
materialColor
;
DirectX
::
XMFLOAT3
ambient
;
DirectX
::
XMFLOAT3
diffuseColor
;
float
diffuseIntensity
;
float
attConst
;
float
attLin
;
float
attQuad
;
};
private:
DirectX
::
XMFLOAT3
pos
=
{
0.0
f
,
0.0
f
,
0.0
f
};
;
PointLightCBuf
cbData
;
mutable
SolidSphere
mesh
;
mutable
PixelConstantBuffer
<
PointLightCBuf
>
cbuf
;
};
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment