@@ -467,19 +467,32 @@ float ComputeCaustic(float3 V, float3 positionOS, float3 lightDirOS, BSDFData bs
467
467
468
468
// This is a test coming from Heretic demo. It is way more expensive
469
469
// and is sometimes better, sometime not than the "else" codee and don't support caustic.
470
- void LightEyeTransform (PositionInputs posInput, BSDFData bsdfData, inout float3 positionRWS, inout float3 forward, inout float3 right, inout float3 up )
470
+ void LightEyeTransform (PositionInputs posInput, BSDFData bsdfData, inout LightData lightData )
471
471
{
472
- float3 L = normalize (positionRWS - posInput.positionWS);
472
+ float3 L = normalize (lightData. positionRWS - posInput.positionWS);
473
473
float3 refractL = -refract (-L, bsdfData.geomNormalWS, 1.0 / bsdfData.IOR);
474
474
475
475
float3 axis = normalize (cross (L, refractL));
476
476
477
477
float angle = acos (dot (L, refractL));
478
478
479
- positionRWS = Rotate (posInput.positionWS, positionRWS, axis, angle);
480
- forward = Rotate (float3 (0 , 0 , 0 ), forward, axis, angle);
481
- right = Rotate (float3 (0 , 0 , 0 ), right, axis, angle);
482
- up = Rotate (float3 (0 , 0 , 0 ), up, axis, angle);
479
+ lightData.positionRWS = Rotate (posInput.positionWS, lightData.positionRWS, axis, angle);
480
+ lightData.forward = Rotate (float3 (0 , 0 , 0 ), lightData.forward, axis, angle);
481
+ lightData.right = Rotate (float3 (0 , 0 , 0 ), lightData.right, axis, angle);
482
+ lightData.up = Rotate (float3 (0 , 0 , 0 ), lightData.up, axis, angle);
483
+ }
484
+ void LightEyeTransform (PositionInputs posInput, BSDFData bsdfData, inout DirectionalLightData lightData)
485
+ {
486
+ float3 L = -lightData.forward;
487
+ float3 refractL = -refract (-L, bsdfData.geomNormalWS, 1.0 / bsdfData.IOR);
488
+
489
+ float3 axis = normalize (cross (L, refractL));
490
+
491
+ float angle = acos (dot (L, refractL));
492
+
493
+ lightData.forward = Rotate (float3 (0 , 0 , 0 ), lightData.forward, axis, angle);
494
+ lightData.right = Rotate (float3 (0 , 0 , 0 ), lightData.right, axis, angle);
495
+ lightData.up = Rotate (float3 (0 , 0 , 0 ), lightData.up, axis, angle);
483
496
}
484
497
//-----------------------------------------------------------------------------
485
498
// EvaluateBSDF_Directional
@@ -502,7 +515,7 @@ DirectLighting EvaluateBSDF_Directional(LightLoopContext lightLoopContext,
502
515
c = ComputeCausticFromLUT (preLightData.irisPlanePosition, bsdfData.irisPlaneOffset, lightPosOS, bsdfData.causticIntensity);
503
516
}
504
517
// Evaluate a second time the light but for a different position and for diffuse only.
505
- LightEyeTransform (posInput, bsdfData, lightData.positionRWS, lightData.forward, lightData.right, lightData.up );
518
+ LightEyeTransform (posInput, bsdfData, lightData);
506
519
507
520
DirectLighting dlIris = ShadeSurface_Directional ( lightLoopContext, posInput, builtinData,
508
521
preLightData, lightData, bsdfData, V);
@@ -541,7 +554,7 @@ DirectLighting EvaluateBSDF_Punctual(LightLoopContext lightLoopContext,
541
554
c = ComputeCausticFromLUT (preLightData.irisPlanePosition, bsdfData.irisPlaneOffset, TransformWorldToObject (lightData.positionRWS), bsdfData.causticIntensity);
542
555
}
543
556
// Evaluate a second time the light but for a different position and for diffuse only.
544
- LightEyeTransform (posInput, bsdfData, lightData.positionRWS, lightData.forward, lightData.right, lightData.up );
557
+ LightEyeTransform (posInput, bsdfData, lightData);
545
558
546
559
DirectLighting dlIris = ShadeSurface_Punctual ( lightLoopContext, posInput, builtinData,
547
560
preLightData, lightData, bsdfData, V);
@@ -696,7 +709,7 @@ DirectLighting EvaluateBSDF_Area(LightLoopContext lightLoopContext,
696
709
c = ComputeCausticFromLUT (preLightData.irisPlanePosition, bsdfData.irisPlaneOffset, TransformWorldToObject (lightData.positionRWS), bsdfData.causticIntensity);
697
710
}
698
711
699
- LightEyeTransform (posInput, bsdfData, lightData.positionRWS, lightData.forward, lightData.right, lightData.up );
712
+ LightEyeTransform (posInput, bsdfData, lightData);
700
713
701
714
DirectLighting dl2 = EvaluateBSDF_Area2 (lightLoopContext, V, posInput, preLightData, lightData, bsdfData, builtinData);
702
715
0 commit comments