OSL normals

Forums: OSL normals
Newtek Lightwave 3D (exporter developed by holocube, Integrated Plugin developed by juanjgon)

Moderator: juanjgon

OSL normals

Postby baltort » Thu May 09, 2019 9:32 am

baltort Thu May 09, 2019 9:32 am
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.
baltort
Licensed Customer
Licensed Customer
 
Posts: 72
Joined: Mon Jul 07, 2014 4:00 pm

Re: OSL normals

Postby juanjgon » Thu May 09, 2019 8:45 pm

juanjgon Thu May 09, 2019 8:45 pm
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
User avatar
juanjgon
Octane Plugin Developer
Octane Plugin Developer
 
Posts: 8867
Joined: Tue Jan 19, 2010 12:01 pm
Location: Spain

Re: OSL normals

Postby calus » Thu May 09, 2019 9:52 pm

calus Thu May 09, 2019 9:52 pm
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.
Pascal ANDRE
calus
Licensed Customer
Licensed Customer
 
Posts: 1308
Joined: Sat May 22, 2010 9:31 am
Location: Paris

Re: OSL normals

Postby baltort » Fri May 10, 2019 10:49 am

baltort Fri May 10, 2019 10:49 am
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.
baltort
Licensed Customer
Licensed Customer
 
Posts: 72
Joined: Mon Jul 07, 2014 4:00 pm

Re: OSL normals

Postby baltort » Tue May 14, 2019 5:17 pm

baltort Tue May 14, 2019 5:17 pm
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.
baltort
Licensed Customer
Licensed Customer
 
Posts: 72
Joined: Mon Jul 07, 2014 4:00 pm

Return to Lightwave 3D


Who is online

Users browsing this forum: No registered users and 14 guests

Fri Apr 19, 2024 9:26 pm [ UTC ]