mirror of
https://github.com/blender/blender
synced 2026-10-25 03:07:01 +03:00
It allows to implement tricks based on a knowledge whether the path ever cam through a portal or not, and even something more advanced based on the number of portals. The main current objective is for strokes shading: stroke shader uses Ray Portal BSDF to place ray to the center of the stroke and point it in the direction of the surface it is generated for. This gives stroke a single color which matches shading of the original object. For this usecase to work the ray bounced from the original surface should ignore the strokes, which is now possible by using Portal Depth input and mixing with the Transparent BSDF. It also helps to make shading look better when there are multiple stroke layers. A solution of using portal depth is chosen over a single flag due to various factors: - Last time we've looked into it it was a bit tricky to implement as a flag due to us running out of bits. - It feels to be more flexible solution, even though it is a bit hard to come up with 100% compelling setup for it. - It needs to be slightly different from the current "Is Foo" flags, and be more "Is Portal Descendant" or something. An extra uint16 is added to the state to count the portal depth, but it is only allocated for scenes that use Ray Portal BSDF. Portal BSDF still increments Transparent bounce, as it is required to have some "limiting" factor so that ray does not get infinitely move to different place of the scene. Ref #125213 Pull Request: https://projects.blender.org/blender/blender/pulls/143107
57 lines
2 KiB
Text
57 lines
2 KiB
Text
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
|
|
|
#include "stdcycles.h"
|
|
|
|
shader node_light_path(output float IsCameraRay = 0.0,
|
|
output float IsShadowRay = 0.0,
|
|
output float IsDiffuseRay = 0.0,
|
|
output float IsGlossyRay = 0.0,
|
|
output float IsSingularRay = 0.0,
|
|
output float IsReflectionRay = 0.0,
|
|
output float IsTransmissionRay = 0.0,
|
|
output float IsVolumeScatterRay = 0.0,
|
|
output float RayLength = 0.0,
|
|
output float RayDepth = 0.0,
|
|
output float DiffuseDepth = 0.0,
|
|
output float GlossyDepth = 0.0,
|
|
output float TransparentDepth = 0.0,
|
|
output float TransmissionDepth = 0.0,
|
|
output float PortalDepth = 0.0)
|
|
{
|
|
IsCameraRay = raytype("camera");
|
|
IsShadowRay = raytype("shadow");
|
|
IsDiffuseRay = raytype("diffuse");
|
|
IsGlossyRay = raytype("glossy");
|
|
IsSingularRay = raytype("singular");
|
|
IsReflectionRay = raytype("reflection");
|
|
IsTransmissionRay = raytype("refraction");
|
|
IsVolumeScatterRay = raytype("volume_scatter");
|
|
|
|
getattribute("path:ray_length", RayLength);
|
|
|
|
int ray_depth = 0;
|
|
getattribute("path:ray_depth", ray_depth);
|
|
RayDepth = (float)ray_depth;
|
|
|
|
int diffuse_depth = 0;
|
|
getattribute("path:diffuse_depth", diffuse_depth);
|
|
DiffuseDepth = (float)diffuse_depth;
|
|
|
|
int glossy_depth = 0;
|
|
getattribute("path:glossy_depth", glossy_depth);
|
|
GlossyDepth = (float)glossy_depth;
|
|
|
|
int transparent_depth = 0;
|
|
getattribute("path:transparent_depth", transparent_depth);
|
|
TransparentDepth = (float)transparent_depth;
|
|
|
|
int transmission_depth = 0;
|
|
getattribute("path:transmission_depth", transmission_depth);
|
|
TransmissionDepth = (float)transmission_depth;
|
|
|
|
int portal_depth = 0;
|
|
getattribute("path:portal_depth", portal_depth);
|
|
PortalDepth = (float)portal_depth;
|
|
}
|