Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- the prerender callback only works with production rendering, I guess activeShade rendering isn't classed as rendering.
- */
- FN ApplyEditMaterials=
- (
- --print "PreRender callback for applyEditMaterials() has been intiated"
- for i in geometry where i.modifiers.count > 0 do
- (
- --print "there are modifiers"
- for m in i.modifiers where m.name == "Edit Material" do
- (
- if (classof i.mat == ai_standard_surface) do
- (
- --print "there is a standardSurface"
- if i.mat.base_color_shader != undefined do
- (
- --print "there is something in the base color"
- if i.mat.base_color_shader.name != "oslCCPlug" do --YOU NEED TO CHECK THE NAME OF THE PLUG NOW!
- (
- --print "Now editing the material"
- oslCC = osl_UberColorCorrect name:"oslCC"
- oslCCPlug = MultiOutputChannelTexmapToTexmap outputChannelIndex:1 name:"oslCCPlug" --plugs the output into the base color
- oslGetAtt = osl_GetAttribute Attribute:"brightness" FltDef:1.0 AddPrefix:1 name:"oslGetAtt"
- oslGetAttPlug = MultiOutputChannelTexmapToTexmap outputChannelIndex:2 --plugs the float val into the brightness
- oslCC.input_map = i.mat.base_color_shader --we move in the original shader into the oslCC
- i.mat.base_color_shader = oslCCPlug
- oslCCPlug.source_map = oslCC
- oslCC.Brightness_map = oslGetAttPlug
- oslGetAttPlug.source_map = oslGetAtt
- )
- )
- )
- )
- )
- )
- FN DelUserProp obj propertyToDelete =
- (
- allUserProp = getUserPropBuffer obj
- deleteString = (propertyToDelete + " = " + (getUserProp obj propertyToDelete as string))
- newUserProp = substituteString allUserProp deleteString ""
- setUserPropBuffer obj newUserProp
- )
- FN EditMaterialDeleted =
- (
- if ((callbacks.notificationParam())[2].name == "Edit Material") do
- (
- DelUserProp (callbacks.notificationParam())[1] "brightness"
- )
- )
- callbacks.addScript #preRender "applyEditMaterials()" id:#editMaterial
- --callbacks.removeScripts #preRender id:#editMaterial --I guess you'd never disable this callback, because you can always create the edit material modifier
- callbacks.addScript #postModifierDeleted "EditMaterialDeleted()" id:#editMaterialDeleted
- --callbacks.removeScripts #postModifierDeleted id:#editMaterialDeleted
- plugin modifier editMaterial
- name:"Edit Material"
- classID:#(0x43044e75, 0x72d69ab8) --genclassid()
- extends:EmptyModifier replaceUI:true
- (
- parameters main rollout:params
- (
- brightness type:#float default:1.0 ui:brightness
- on brightness set val do
- (
- --print "updated"
- --print val
- -- for i in geometry where i.modifiers["Edit Material"] == selection[1].modifiers["Edit Material"] do
- -- (
- -- --print i
- -- setUserProp i "brightness" val
- -- )
- theArr = (refs.dependentNodes selection[1].modifiers["Edit Material"])
- try --without the try I get No "map" function for undefined when adding the modifier...
- (
- for i in theArr do
- (
- setUserProp i "brightness" val
- )
- )catch()
- )
- )
- rollout params "Edit Material"
- (
- spinner brightness "Brightness: " type:#float range:[-100.0,100.0,1.0]
- )
- )
- /*
- --this doesn't work, It doesn't create the array as a plugin.
- for i in (refs.dependentNodes selection[1].modifiers["Edit Material"]) do
- (
- setUserProp i "brightness" val
- )
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement