@@ -25,8 +25,6 @@ struct VS_OUTPUT
2525 float2 TexCoord : TEXCOORD4 ;
2626};
2727
28- // --- Constant Buffers ---
29-
3028cbuffer TransformCB : register (b0) {
3129 row_major float4x4 WVP;
3230 row_major float4x4 World;
@@ -95,8 +93,6 @@ cbuffer BoneMatrices : register(b3) {
9593 row_major float4x4 boneMatrices[MAX_BONES];
9694};
9795
98- // --- Textures & Samplers ---
99-
10096Texture2D diffuseTexture : register (t0);
10197Texture2D normalTexture : register (t1);
10298Texture2D specularTexture : register (t2);
@@ -107,9 +103,6 @@ Texture2D emissiveTexture : register(t6);
107103
108104SamplerState mainSampler : register (s0);
109105
110- // ============================================================
111- // Vertex Shader
112- // ============================================================
113106VS_OUTPUT VS_Main (VS_INPUT input)
114107{
115108 VS_OUTPUT output;
@@ -153,10 +146,6 @@ VS_OUTPUT VS_Main(VS_INPUT input)
153146 return output;
154147}
155148
156- // ============================================================
157- // PBR Helper Functions
158- // ============================================================
159-
160149static const float PI = 3.14159265359 ;
161150
162151// GGX/Trowbridge-Reitz normal distribution
@@ -207,25 +196,19 @@ float AttenuateUE4(float distance, float range) {
207196 return (falloff * falloff) / (distance * distance + 1.0 );
208197}
209198
210- // ============================================================
211- // Pixel Shader
212- // ============================================================
213199float4 PS_Main (VS_OUTPUT input) : SV_Target
214200{
215201 // Apply UV tiling and offset
216202 float2 uv = input.TexCoord * matTiling + matOffset;
217203
218- // --- Base Color ---
219204 float4 baseColor = matDiffuseColor * input.Color;
220205 if (HasDiffuseMap)
221206 baseColor *= diffuseTexture.Sample (mainSampler, uv);
222207
223- // --- Alpha Cutoff ---
224208 float alpha = baseColor.a * matOpacity;
225209 if (matAlphaCutoff > 0.0 && alpha < matAlphaCutoff)
226210 discard ;
227211
228- // --- Normal ---
229212 float3 N = normalize (input.WorldNorm);
230213 if (HasNormalMap) {
231214 float3 tangentNormal =
@@ -239,7 +222,6 @@ float4 PS_Main(VS_OUTPUT input) : SV_Target
239222 N = normalize (mul (tangentNormal, TBN));
240223 }
241224
242- // --- Material Properties ---
243225 float roughness = matRoughness;
244226 if (HasRoughnessMap)
245227 roughness *= roughnessTexture.Sample (mainSampler, uv).r;
@@ -253,15 +235,13 @@ float4 PS_Main(VS_OUTPUT input) : SV_Target
253235 if (HasAOMap)
254236 ao *= aoTexture.Sample (mainSampler, uv).r;
255237
256- // --- PBR Setup ---
257238 float3 albedo = baseColor.rgb;
258239 float3 V = normalize (CameraPos - input.WorldPos);
259240
260241 // Reflectance at normal incidence (F0)
261242 float3 F0 = float3 (0.04 , 0.04 , 0.04 );
262243 F0 = lerp (F0, albedo, metallic);
263244
264- // --- Accumulate Light Contributions ---
265245 float3 Lo = float3 (0.0 , 0.0 , 0.0 );
266246
267247 for (uint i = 0 ; i < NumActiveLights; i++) {
@@ -332,16 +312,13 @@ float4 PS_Main(VS_OUTPUT input) : SV_Target
332312 }
333313 }
334314
335- // --- Ambient ---
336315 float3 ambient = AmbientColor * AmbientIntensity
337316 * albedo * ao;
338317
339- // --- Emissive ---
340318 float3 emissive = matEmissiveColor * matEmissiveIntensity;
341319 if (HasEmissiveMap)
342320 emissive *= emissiveTexture.Sample (mainSampler, uv).rgb;
343321
344- // --- Final Composition ---
345322 float3 finalColor = ambient + Lo + emissive;
346323
347324 return float4 (finalColor, alpha);
0 commit comments