Page 1 of 1

OSL normals

PostPosted: Thu May 09, 2019 9:32 am
by baltort
Hi all,

I've been playing around with OSL textures and trying to generate some normal maps. I'm seeing some weird behaviour which I'm hoping someone can shed some light on.

Here's a simple scene with a white diffuse model:

basic diffuse.jpg


Next I've created a simple (REALLY simple) OSL texture that just sets the colour to the Geometric normal of the surface. I've applied the texture to the diffuse channel and it looks like the kind of thing one would expect:

Ng applied to diffuse.jpg


Finally I applied the Geometric Normal texture to the texture slot on the diffuse material. I was hoping this would do nothing and render like the first image, but it's getting strange artifacts:

NG applied to normal.jpg


Does anyone know what's going on? Do I need to transform the geometric normal in OSL to something else?

Cheers,

James.

Re: OSL normals

PostPosted: Thu May 09, 2019 8:45 pm
by juanjgon
Perhaps the problem is that you need to declare the output as "vector" or "normal", not as "color"
https://docs.otoy.com/StandaloneH_STA/S ... rTypes.htm

Thanks,
-Juanjo

Re: OSL normals

PostPosted: Thu May 09, 2019 9:52 pm
by calus
juanjgon wrote:Perhaps the problem is that you need to declare the output as "vector" or "normal", not as "color"
https://docs.otoy.com/StandaloneH_STA/S ... rTypes.htm

Thanks,
-Juanjo

it would make sens but as far as I know octane OSL texture only support color output.

Re: OSL normals

PostPosted: Fri May 10, 2019 10:49 am
by baltort
Thanks all,

No dice, I'm afraid. Changing the output to a vector gives this:

error: Signature mismatch, expecting a shader with 1 output of type color.

Cheers,

James.

Re: OSL normals

PostPosted: Tue May 14, 2019 5:17 pm
by baltort
I think I've got to the bottom of this...

The Octane materials expect normal maps in tangent space rather than 'common' or 'world' space. This means that if you want a null map (i.e. a normal map that doesn't change anything - a good starting point for something that does!) you need to supply a map that points purely in the Z direction. The added hook is that the vectors are normalised so that each component lies in the range (0,1) rather than (-1,1). As such, linking the normal map to an OSL node (or an RGB node) that just outputs the colour (0.5, 0.5, 1.0) gives a result that matches a material with no normal map.

This is a long winded way of saying (0.5, 0.5, 1) is the colour of a normal map that does nothing at all.

Next week I shall investigate why 0 is the correct amount to enter into an ATM when you don't want to take any money out...

J.