three-gpu-pathtracer icon indicating copy to clipboard operation
three-gpu-pathtracer copied to clipboard

Add support for wrapS and wrapT properties

Open gkjohnson opened this issue 2 years ago • 3 comments

Related to #165, #91

Add support for RepeatWrapping, ClampToEdgeWrapping, and maybe MirroredRepeatWrapping to the renderer shader.

gkjohnson avatar Jun 04 '22 23:06 gkjohnson

I think that these are actually rarely used in my opinion. So nice to have, but definitely not absolutely required.

Here is some example code that replicates these modes:

// RepeatWrapping
texCoord0 = fract(texCoord0);

// ClampToEdgeWrapping
texCoord0 = clamp(texCoord0,0,1);

// MirroredRepeatWrapping (Ben: Is this right?  I haven't checked.)
texCoord0 = fract(texCoord0*0.5)*2.0;
texCoord0 = 1 - abs(texCoord0-1);

From here: https://forum.derivative.ca/t/custom-texture-wrapping-per-instance-in-a-glsl-shader/8661/3

bhouston avatar Jun 06 '22 12:06 bhouston

I actually didn't even know MirroredRepeatWrapping existed - I expect that one might be particularly rarely used? I feel like Clamped is more common, though. Happy to wait until there's a good test model in the wild to add these. We have two remaining pixels per texture transform parameters that can be used to store this information.

gkjohnson avatar Jun 06 '22 14:06 gkjohnson

Interesting discussion on twitter of which modes are actually needed: https://twitter.com/SebAaltonen/status/1536316682813186050

bhouston avatar Jun 13 '22 12:06 bhouston