[Bf-cycles] Tiled Texture Caching for Cycles

Stefan Werner stewreo at gmail.com
Tue May 2 22:02:42 CEST 2017

Thanks Brecht for your input. Answers are inline:

> On 30. Apr 2017, at 13:29, Brecht Van Lommel <brechtvanlommel at pandora.be> wrote:
> 1) Running the shader 3 times is interesting, would be good to see
> what kind of performance impact that has in practice. The way I
> imagined it is that we'd have two variations of shaders, one with
> differentials and one without. However if we can automate it without
> too much of a performance impact that would be great.

I’ve taken a look at how OSL is doing it, and maybe their code for automatic
derivatives could help (dual.h in the OSL includes). Having differentials
only where necessary is probably necessary to not impact performance too much.

> I think texture
> coordinates being looked up in textures can work, you could do lookups
> at P, P+dPdx and P+dPdx, all with the same differentials dPdx and
> dPdy, and then compute the differentials from the results of those 3
> texture lookups.

That would require all three shaders to be run in parallel then, like a tiny
REYES grid. Which would allow the introduction of Dx() Dy() nodes
to get partial derivatives of any variable.

> 2) I would keep this an SVM implementation thing without any new type
> of socket exposed to the outside. I think the input would be tagged as
> requiring differentials somehow, and then the SVM compiler and nodes
> could allocate and use more space for those sockets.

That would be the most transparent method, yes.

> For the current case though, isn't
> it possible to compute differentials somehow? I think we know the view
> direction, current shading normal, and light direction when
> shader_setup_from_sample() is called. So there must be some
> differentials we can derive from that?

Not until we ask the BSDF for how it treats the differentials. In my
experience, domega_in_dx/_dy are important, and especially with
glossy nodes that vary in roughness, the correct calculation of a ray’s
footprint can have a big impact on performance.


More information about the Bf-cycles mailing list