Skip to content

Commit 2bd8a9f

Browse files
* 习题6卡通化代码(已注释),调整wave项目的起始平行光源位置
1 parent 032bc09 commit 2bd8a9f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Chapter 8 Lighting/Core/Shaders/LightingUtil.hlsl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ float3 BlinnPhong(float3 lightStrength, float3 lightVec, float3 normal, float3 t
4747
float3 halfVec = normalize(toEye + lightVec);
4848

4949
float roughnessFactor = (m + 8.0f)*pow(max(dot(halfVec, normal), 0.0f), m) / 8.0f;
50+
51+
// ¿¨Í¨»¯
52+
// if (roughnessFactor <= 0.1) roughnessFactor = 0.0;
53+
// else if (roughnessFactor <= 0.8) roughnessFactor = 0.5;
54+
// else roughnessFactor = 0.8;
55+
5056
float3 fresnelFactor = SchlickFresnel(mat.FresnelR0, halfVec, lightVec);
5157

5258
float3 specAlbedo = fresnelFactor*roughnessFactor;
@@ -68,6 +74,12 @@ float3 ComputeDirectionalLight(Light L, Material mat, float3 normal, float3 toEy
6874

6975
// Scale light down by Lambert's cosine law.
7076
float ndotl = max(dot(lightVec, normal), 0.0f);
77+
78+
// ¿¨Í¨»¯
79+
// if (ndotl <= 0.0) ndotl = 0.4;
80+
// else if (ndotl <= 0.5) ndotl = 0.6;
81+
// else ndotl = 1.0;
82+
7183
float3 lightStrength = L.Strength * ndotl;
7284

7385
return BlinnPhong(lightStrength, lightVec, normal, toEye, mat);

Chapter 8 Lighting/GameApp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class GameApp : public GameCore::IGameApp
7878
ByteAddressBuffer m_IndexBufferWaves;
7979
std::vector<Vertex> m_verticesWaves;
8080
Matrix4 m_waveWorld = Transpose(Matrix4(kIdentity));
81-
float mSunTheta = 1.25f * XM_PI;
81+
float mSunTheta = 0.25f * XM_PI;
8282
float mSunPhi = XM_PIDIV4;
8383

8484
// 摄像机

0 commit comments

Comments
 (0)