Skip to content

Commit 3f08702

Browse files
committed
Added comments
1 parent 7ddb4a7 commit 3f08702

1 file changed

Lines changed: 0 additions & 108 deletions

File tree

Engine/Shaders/RayTracingPipeline/lighting.hlsl

Lines changed: 0 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -165,31 +165,6 @@ float3 ImportanceSampleCosineHemisphere(float2 xi, float3 N)
165165
return normalize(tangentX * H.x + tangentY * H.y + N * H.z);
166166
}
167167

168-
float3 RayTracedIrradiance(float3 pos, float3 normal, uint Recursion, int sampleCount)
169-
{
170-
/*
171-
float3 irradiance = float3(0.0, 0.0, 0.0);
172-
173-
for (int i = 0; i < sampleCount; ++i)
174-
{
175-
// Generate stratified sample direction in hemisphere
176-
float2 xi = Hammersley(i, sampleCount);
177-
float3 sampleDir = ImportanceSampleCosineHemisphere(xi, normal);
178-
179-
// Cast ray
180-
PrimaryRayPayload payload = CastReflectionRay(pos, sampleDir, Recursion);
181-
182-
// Weight by cosine
183-
float weight = max(dot(normal, sampleDir), 0.0);
184-
irradiance += payload.Color * weight;
185-
}
186-
187-
irradiance /= PI * sampleCount;
188-
return irradiance;*/
189-
return float3(0.0, 0.0, 0.0);
190-
191-
}
192-
193168

194169
// Bitwise reverse for radical inverse
195170
float RadicalInverse_VdC(uint bits)
@@ -201,90 +176,7 @@ float RadicalInverse_VdC(uint bits)
201176
bits = ((bits & 0x00FF00FFu) << 8) | ((bits & 0xFF00FF00u) >> 8);
202177
return float(bits) * 2.3283064365386963e-10; // = 1.0 / (2^32)
203178
}
204-
/*
205-
// Hammersley point generator
206-
float2 Hammersley(uint i, uint N)
207-
{
208-
return float2((float) i / float(N), RadicalInverse_VdC(i));
209-
}
210-
211-
float3 CosineSampleHemisphere(uint sampleIndex, uint sampleCount, float3 normal)
212-
{
213-
// Generate quasi-random values using Hammersley sequence
214-
float2 Xi = Hammersley(sampleIndex, sampleCount);
215-
216-
float phi = 2.0 * 3.14159265 * Xi.x;
217-
float cosTheta = sqrt(1.0 - Xi.y);
218-
float sinTheta = sqrt(Xi.y);
219-
220-
// Spherical to Cartesian
221-
float3 tangentSample = float3(cos(phi) * sinTheta, sin(phi) * sinTheta, cosTheta);
222-
223-
// Create TBN basis from normal
224-
float3 up = abs(normal.z) < 0.999 ? float3(0.0, 0.0, 1.0) : float3(1.0, 0.0, 0.0);
225-
float3 tangent = normalize(cross(up, normal));
226-
float3 bitangent = cross(normal, tangent);
227-
228-
// Transform sample to world space
229-
float3 sampleDir = tangentSample.x * tangent + tangentSample.y * bitangent + tangentSample.z * normal;
230-
return normalize(sampleDir);
231-
}
232-
233-
float3 AccumulateDiffuseGI(float3 Pos, float3 Norm, uint Recursion, float3 albedo, float metalness)
234-
{
235-
const int sampleCount = 16;
236-
float3 irradiance = float3(0.0, 0.0, 0.0);
237-
238-
for (int i = 0; i < sampleCount; ++i)
239-
{
240-
float3 sampleDir = CosineSampleHemisphere(i, sampleCount, Norm); // You implement this
241-
PrimaryRayPayload payload = CastReflectionRay(Pos, sampleDir, Recursion, Norm);
242-
irradiance += payload.Color; // Assume payload contains indirect bounce color
243-
}
244-
245-
irradiance /= sampleCount;
246-
247-
float3 kD = 1.0 - lerp(float3(0.04, 0.04, 0.04), albedo, metalness);
248-
kD *= 1.0 - metalness;
249-
250-
return (albedo / PI) * irradiance * kD;
251-
}
252-
253-
float3 ImportanceSampleGGX(float3 V, float2 Xi, float3 N, float roughness)
254-
{
255-
float a = roughness * roughness;
256179

257-
float phi = 2.0 * 3.14159265 * Xi.x;
258-
float cosTheta = sqrt((1.0 - Xi.y) / (1.0 + (a * a - 1.0) * Xi.y));
259-
float sinTheta = sqrt(1.0 - cosTheta * cosTheta);
260-
261-
float3 H;
262-
H.x = cos(phi) * sinTheta;
263-
H.y = sin(phi) * sinTheta;
264-
H.z = cosTheta;
265-
266-
// Transform H to world space
267-
float3 up = abs(N.z) < 0.999 ? float3(0.0, 0.0, 1.0) : float3(1.0, 0.0, 0.0);
268-
float3 tangent = normalize(cross(up, N));
269-
float3 bitangent = cross(N, tangent);
270-
float3 Hworld = tangent * H.x + bitangent * H.y + N * H.z;
271-
272-
// Reflect view vector V around H to get sample direction
273-
return reflect(-V, normalize(Hworld));
274-
}
275-
276-
float3 ComputeSpecularGI(float3 Pos, float3 Norm, float3 V, float3 F0, float roughness, uint Recursion)
277-
{
278-
float3 R = ImportanceSampleGGX(V, 0, Norm, roughness);
279-
PrimaryRayPayload reflPayload = CastReflectionRay(Pos, R, Recursion, Norm);
280-
281-
float NdotV = max(dot(Norm, V), 0.0);
282-
float3 F = fresnelSchlickRoughness(NdotV, F0, roughness);
283-
float2 brdf = lut.SampleLevel(skybox_sampler, float2(NdotV, roughness), 0);
284-
float3 specular = reflPayload.Color * (F * brdf.x + brdf.y);
285-
return specular;
286-
}
287-
*/
288180

289181
void LightingPass(inout float3 Color, float3 Pos, float3 Norm, uint Recursion, float metalness, float roughness)
290182
{

0 commit comments

Comments
 (0)