So this went a little further than expected...
Instead of making a special case for the Toon shader I went with a more generic implementation.
It's broken up in to two things, the ShaderDef building and the Parameter loading.
ShaderDef part
Looking at camera_projection I noticed that it had a soft.node_type STRING "camera" line.
I guessed it's to tell what type of objects to show in the pick browser but the soft.node_type has never been implemented in ShaderDef. So I went ahead and implemented that.
It works like this:
AI_TYPE_NODE will get pickers by default (just like before so this isn't new)
AI_TYPE_STRING that has the soft.node_type attribute will get a Picker instead of a string field.
I implemented all the filters in siShaderReferenceFilterType
If array is added as a second word after the filter type, a ShaderArrayParamDef will be created instead of standard ShaderParamDef.
The metadata for lights and rim_light of the toon shader looks like this.
Parameter Loading
Parameter loading does two new things:
If the shader input is AI_TYPE_STRING and the parameter is a Picker, do a name translation.
If the parameter is a ShaderArrayParameter but the shader input is AI_TYPE_STRING, loop through the Array items and build a semicolon separated string of translated names.
Other changes
Increased hardmax on output_filter_width from 10 to 100 so one can use thick lines when using contour filter.
Added diffuse and specular of toon shader to viewport.
Added test 0267 for Toon shader that covers light picking/translation, gradient tone mapping and stylized highlight.
So this went a little further than expected... Instead of making a special case for the Toon shader I went with a more generic implementation. It's broken up in to two things, the ShaderDef building and the Parameter loading.
ShaderDef part Looking at
camera_projection
I noticed that it had asoft.node_type STRING "camera"
line. I guessed it's to tell what type of objects to show in the pick browser but thesoft.node_type
has never been implemented in ShaderDef. So I went ahead and implemented that. It works like this:AI_TYPE_NODE
will get pickers by default (just like before so this isn't new)AI_TYPE_STRING
that has thesoft.node_type
attribute will get a Picker instead of a string field. I implemented all the filters insiShaderReferenceFilterType
Ifarray
is added as a second word after the filter type, aShaderArrayParamDef
will be created instead of standardShaderParamDef.
The metadata forlights
andrim_light
of the toon shader looks like this.And the Shader UI ends up like this:![toon](https://user-images.githubusercontent.com/23527584/44960631-49a34680-af03-11e8-9c9c-150ffb4fdd00.png)
Parameter Loading Parameter loading does two new things:
ShaderArrayParameter
but the shader input isAI_TYPE_STRING
, loop through the Array items and build a semicolon separated string of translated names.Other changes
output_filter_width
from 10 to 100 so one can use thick lines when usingcontour
filter.This passes the testsuite and closes #24