Material Shader Ball Preview

Material Shader Ball Preview

JokerMartini23
Enthusiast Enthusiast
1,445 Views
3 Replies
Message 1 of 4

Material Shader Ball Preview

JokerMartini23
Enthusiast
Enthusiast

Is there a way to generate a shaderball preview using the 3ds Max SDK? I've written a plugin for 3ds Max using the SDK and I would like to display a small thumbnail image of the shader assigned to the material slot. How can I do this?

 

In my case I'd be displaying a thumbnail preview on my modifier rollout.

 

shaderpreview.PNG

 

 

0 Likes
Accepted solutions (1)
1,446 Views
3 Replies
Replies (3)
Message 2 of 4

denis_grigor
Autodesk Support
Autodesk Support
Hi John,

To have a material display within Material Browser, you would have to rely on IMaterialBrowserEntryInfo Class - an interface which "allows materials and textures to customize their appearance in the Material Browser". There is even an example of how it is used within maxsdk\howto\Graphics\HLSLShaderMaterial example.

In your particular case, you could take a look at that interface, and if I am not mistaking, you could get that thumbnail through call to "Bitmap* GetEntryThumbnail( )" on any material that implemented that interface and use the provided bitmap on your modifier rollout.

Cheers,

Denis GRIGOR
Developer Technical Services
Autodesk Developer Network



0 Likes
Message 3 of 4

klvnk
Collaborator
Collaborator
Accepted solution

could just use MtlBase::GetPStamp and MtlBase::CreatePStamp instead

 

void DisplayMB(MtlBase *mb, HDC hdc, int x, int y) {
    mb->CreatePStamp(0,TRUE); // create and render a small pstamp
    PStamp *ps = mb->GetPStamp(0);
    if (ps) {
        int d = PSDIM(0);
        int scanw = ByteWidth(d);
        int nb = scanw*d;
        UBYTE *workImg = new UBYTE[nb];
        if (NULL == workImg)
            return;
        ps->GetImage(workImg);
        Rect rect;
        rect.left = x;
        rect.top = y;
        rect.right = x+d;
        rect.bottom = y+d;
        GetGPort()->DisplayMap(hdc, rect,0,0, workImg, scanw);
        delete [] workImg;
    }
}

from the sdk help

0 Likes
Message 4 of 4

JokerMartini23
Enthusiast
Enthusiast

This is great information guys. Thank you very much i appreciate it. I'll take what you guys said and try it out.

0 Likes