AcademySoftwareFoundation / AcademySoftwareFoundation/OpenShadingLanguage

can't set shader parameter with init code to zero

Open
#906 1 comment 0 reactions 1 assignee Claimed by @lgritz View on GitHub
Dominant language
C++
Stars
2.3k
Forks
414
Avg merge
3d 1h
Merged PRs (30d)
10

Description

A shader parameter with some initialization code can't be set to zero. It looks a lot like zero is used as a magic value to know if the init code should be run or not.

The problem is easy to reproduce with this trivial shader:

```
shader simple(
float a = 0.5,
float value = 1 - a )
{
printf("value is %f\n", value);
}
```

Default run is fine:
```
$ testshade --shader simple l
value is 0.500000
```
Most values work fine:
```
$ testshade --param value 0.8 --shader simple l
value is 0.800000
```
But zero runs the init code anyway:
```
$ testshade --param value 0.0 --shader simple l
value is 0.500000
```

That last case should print `0.000000`, not `0.500000`

The same happens with a color parameter. Tested against current master branch (7a56abdfb0b2b560415dc6e85b8861c09bbc3a77) on linux.

Oh and it seems to check for binary zero as this works:
```
$ testshade --param value -0.0 --shader simple l
value is -0.000000
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.