OSL UV Displacement with Bitmap

Forums: OSL UV Displacement with Bitmap
Houdini Integrated Plugin

Moderator: juanjgon

OSL UV Displacement with Bitmap

Postby andrewprousalis » Fri May 05, 2023 7:18 pm

andrewprousalis Fri May 05, 2023 7:18 pm
Is there a trick to make octane displace using OSL to sample a bitmap? I have tried it a few different ways and it seems to work fine with triplanar, built-in uvs, other projections, etc. it also works fine with procedural noise, etc generated within the OSL shader. As soon as I instruct OSL to sample a bitmap using supplied uv values, displacement stops working. and ideas? here's my osl test shader:

#include <octane-oslintrin.h>
shader customuv
(
color img = color(0.0, 0.0, 0.0),
color uv = color(0.0, 0.0, 0.0),
output color result = color(0.0, 0.0, 0.0)
)
{
result = _evaluateDelayed(img, uv[0], uv[1]);
}
andrewprousalis
Licensed Customer
Licensed Customer
 
Posts: 30
Joined: Wed Oct 21, 2015 3:44 am

Re: OSL UV Displacement with Bitmap

Postby WoutTgh » Sat May 06, 2023 11:39 pm

WoutTgh Sat May 06, 2023 11:39 pm
I assume you're trying this on the old displacement node ? That one is quite limited and I'm pretty sure anything but a simple texture input won't work unfortunately.

Another thing to try, which will only work with the vertex displacement node, is setting your uv in an osl projection shader. ( u and v are given variables in an osl projection shader, and the output is a point type, not color )

uv.jpg
WoutTgh
Licensed Customer
Licensed Customer
 
Posts: 182
Joined: Sat Jul 27, 2019 8:39 pm

Re: OSL UV Displacement with Bitmap

Postby andrewprousalis » Mon May 08, 2023 5:04 pm

andrewprousalis Mon May 08, 2023 5:04 pm
Hi! Thanks for the response. Yes, I'm using the vertex displacement. I can get good results when referencing the internal U and V OSL variables, but when I use arbitrary attributes to set my UV coordinates, all displacement goes flat.

shader proj
(
color pos = color(0, 0, 0),
output point uvw = 0
)
{
uvw = point(pos[0],pos[1], 0);
}
andrewprousalis
Licensed Customer
Licensed Customer
 
Posts: 30
Joined: Wed Oct 21, 2015 3:44 am

Re: OSL UV Displacement with Bitmap

Postby WoutTgh » Mon May 08, 2023 5:18 pm

WoutTgh Mon May 08, 2023 5:18 pm
Can you show me the shader tree ? Perhaps you're using that in the wrong type of osl shader ? It also looks like you're using the components of a color input to use as uvw coordinates so my first try would be to import the uvs as point also

shader proj
(
color pos = color(0, 0, 0),
output point uvw = 0
)
{
uvw = point(pos[0],pos[1], 0);
}


shader proj
(
point pos = 0,
output point uvw = 0
)
{
uvw = point(pos[0],pos[1], 0);
}
WoutTgh
Licensed Customer
Licensed Customer
 
Posts: 182
Joined: Sat Jul 27, 2019 8:39 pm

Re: OSL UV Displacement with Bitmap

Postby andrewprousalis » Mon May 08, 2023 6:13 pm

andrewprousalis Mon May 08, 2023 6:13 pm
Thanks again for the reply. Importing the attribute as Point type doesn't work correctly, but it does work fine as Color - and works as expected when the output is fed into BaseColor. It just fails as a displacement. Oddly enough, if Auto Bump is enabled, then I get the artifacts of the bump map, just no displacement. The only way I have been able to use a texture as a displacement source is if it is using the standard UVs (1-3) or it is manipulating those standard UVs through OSL. If provided and an entirely fresh set of UVs from and attribute, they work just fine everywhere but displacement.
Image
andrewprousalis
Licensed Customer
Licensed Customer
 
Posts: 30
Joined: Wed Oct 21, 2015 3:44 am

Re: OSL UV Displacement with Bitmap

Postby WoutTgh » Mon May 08, 2023 6:31 pm

WoutTgh Mon May 08, 2023 6:31 pm
ooh, interesting, perhaps it's a bug or limitation.

I discovered a new trick btw : Using a procedural noise as uv coordinates gives really nice results, and no seams of course :p
It also work swith vertex displacement

noise_as_uvs.jpg



Out of curiosity : why do you need to import uvs from an attribute ?
Last edited by WoutTgh on Mon May 08, 2023 6:45 pm, edited 1 time in total.
WoutTgh
Licensed Customer
Licensed Customer
 
Posts: 182
Joined: Sat Jul 27, 2019 8:39 pm

Re: OSL UV Displacement with Bitmap

Postby andrewprousalis » Mon May 08, 2023 6:45 pm

andrewprousalis Mon May 08, 2023 6:45 pm
Yeah, I think it might be a bug as well. Arbitrarily limiting usable UVs to 3 hardly seems like a good design decision. More UVs are needed when building complex materials for dual-rest setups with changing topology (texturing a fluid sim, that kinda thing). Thanks for the assistance! Hopefully someone from otoy will weigh in on what's going on here.
andrewprousalis
Licensed Customer
Licensed Customer
 
Posts: 30
Joined: Wed Oct 21, 2015 3:44 am

Re: OSL UV Displacement with Bitmap

Postby WoutTgh » Mon May 08, 2023 7:25 pm

WoutTgh Mon May 08, 2023 7:25 pm
you're welcome :)
WoutTgh
Licensed Customer
Licensed Customer
 
Posts: 182
Joined: Sat Jul 27, 2019 8:39 pm

Return to Houdini


Who is online

Users browsing this forum: No registered users and 29 guests

Sun Apr 28, 2024 9:29 am [ UTC ]