Remarque
L’accès à cette page nécessite une autorisation. Vous pouvez essayer de vous connecter ou de modifier des répertoires.
L’accès à cette page nécessite une autorisation. Vous pouvez essayer de modifier des répertoires.
Nuanceur utilisé pour implémenter des primitives d’intersection personnalisées pour les rayons qui croisent un volume englobant associé (cadre englobant).
Le nuanceur d’intersection n’a pas accès à la charge utile de rayon, mais définit les attributs d’intersection pour chaque accès via un appel à ReportHit. La gestion de ReportHit peut arrêter le nuanceur d’intersection tôt, si l’indicateur de rayon RAY_FLAG_ACCEPT_FIRST_HIT_\AND_\END_SEARCH est défini, ou AcceptHitAndEndSearch est appelé à partir d’un nuanceur de correspondance. Sinon, elle retourne true si l’accès a été accepté ou false si l’accès a été rejeté. Cela signifie qu’un nuanceur de correspondance, s’il est présent, doit s’exécuter avant que le contrôle ne retourne de manière conditionnelle au nuanceur d’intersection.
Attribut Type de nuanceur
[shader("intersection")]
Exemple
struct CustomPrimitiveDef { ... };
struct MyAttributes { ... };
struct CustomIntersectionIterator {...};
void InitCustomIntersectionIterator(CustomIntersectionIterator it) {...}
bool IntersectCustomPrimitiveFrontToBack(
CustomPrimitiveDef prim,
inout CustomIntersectionIterator it,
float3 origin, float3 dir,
float rayTMin, inout float curT,
out MyAttributes attr);
[shader("intersection")]
void intersection_main()
{
float THit = RayTCurrent();
MyAttributes attr;
CustomIntersectionIterator it;
InitCustomIntersectionIterator(it);
while(IntersectCustomPrimitiveFrontToBack(
CustomPrimitiveDefinitions[LocalConstants.PrimitiveIndex],
it, ObjectRayOrigin(), ObjectRayDirection(),
RayTMin(), THit, attr))
{
// Exit on the first hit. Note that if the ray has
// RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH or an
// anyhit shader is used and calls AcceptHitAndEndSearch(),
// that would also fully exit this intersection shader (making
// the “break” below moot in that case).
if (ReportHit(THit, /*hitKind*/ 0, attr) && (RayFlags() & RAY_FLAG_FORCE_OPAQUE))
break;
}
}