Blender 2.79 - Custom material - need specific texture 'slots'.

Hello, first post here.

After 16 years of 3dsmax I decided it was time to go all in on blender development.
I have written exporters, internal renderers and other things for 3dsmax, and now I’m writing a render addon for blender.
I’ve gotten a long way already, but I’m stuck on something relatively easy (I assume).

I have now overridden the material GUI, and I have my renderer in the dropdown menu, and some custom properties in my material (float values for bump\sigma values, which works as expected. (See attachment).

But now I want specific slots for my textures, for example one for diffuse, one for bump, one for specular and so on.
I was kinda expecting that I could just add a custom property just as what I did with float value, then it would assign a gui item for selecting a texture, then I could click it and add a texture to the custom property.

If I choose ‘cycles’ then it has this small button on the right side where you define the diffuse color, you can click there and select ‘image texture’, that is what I need in my custom material, when I switch to my renderer it show the ‘diffuse color’ but not any way to choose ‘image texture’ and assign that.

I need some guidance with this, so that I can understand how this part works…


Cycles has that button because its just a gui version of the diffuse node, that button being the color input. Not sure how your renderer works…

I guess I need something similar then.
I was hoping to just have a button like it, browse to a image, then a reference to it would be stored in a variable in my material.
I’ll dig around some more tonight and see if I can find a solution.

I found out how it works now. I found a already existing texture script, stripped it down, set my renderer as ‘compative’ so that the custom gui for the texture shows up, that enabled me to have a button for defining the texture.
It was a bit different from what I’m used to, but now I know how it’s put together and can progress on what I’m doing.

I have a similar requirement but perhaps for a different purpose. Would you mind sending me a link to the code you found? PM is ok if you prefer that.

TIA

I took this, removed all code not needed, that left me with a texture that shows up in my texture panel,


but I have to admit it did not work as expected (which I realized after writing my previous reply)…

I got this far :

It did add a ‘slot’ in the texture panel, but not a unique one per material for some reason.
I have to look further into this, it’s still a bit confusing to me how all this works in blender at the moment, I’m not that used to python and how blender’s API is yet (working on it)…