One-parameter shader

calendar_today

04.09.2022

label

Shading

mouse

Houdini 18.0

1 Description

A minimalist one-parameter shader that smoothly runs from emissive (0.0), over translucent (0.75), to diffuse (1.0) and opaque (1.25) to metallic (2.0).

float shading = chf('shading');
vector color = chv('color');

vector pos_light = {2.6, 1.2, 0.6};
vector dir = normalize(pos_light - v@P);

float lumen = max(1.0 - shading, 0.0);
float angle = max(dot(dir, v@N), lumen);
shading = fit(shading, 1, 2, 1, 20);
float shade = pow(angle, max(shading, 1.0));

v@Cd = color * shade;
comments

comments

Leave a comment

Available formatting commands

Use Markdown commands or their HTML equivalents to add simple formatting to your comment:

Text markup
*italic*, **bold**, ~~strikethrough~~, `code` and <mark>marked text</mark>.
Lists
- Unordered item 1
- Unordered list item 2
1. Ordered list item 1
2. Ordered list item 2
Quotations
> Quoted text
Code blocks
```
// A simple code block
```
```php
// Some PHP code
phpinfo();
```
Links
[Link text](https://example.com)
Full URLs are automatically converted into links.