Results 1 to 6 of 6

Thread: Using existing shader inside my own c++ shader

  1. #1
    Join Date
    Apr 2012
    Posts
    6

    Default Using existing shader inside my own c++ shader

    Hello all,

    I'm writing my first shader for softimage, using visual c++ 2010 express. Since now everything worked like a charm, I've always found help and docs on the web.
    But now I would like to add a sss feature to my shader but i still can't find information about it's calculations.

    The best would be to write the sss feature to really understand what happens inside mental ray, and how to deal with lightmaps.

    The other thing I am trying to do is to use the built-in misss_fast_shader inside my c++ script ; then composite the result with the other feature i've already witten.

    Is it possible to "include" the misss_fast_shader into my cpp file and how can I import it?

    When reading the mental ray help, I've found the mi_call_shader funcion that seems to fit but i'm not sure it is what i need.

    Thanks you in advance.

    For information, the feature I've already written ( the very basics ) :
    Lambert, shadow color, specular, incandescence, occlusion , reflection , inirect illumination , mix 4 colors , easy framebuffer creation.

    to do : sub surface scattering, refraction, opacity/transparency, translucency, z depth, motion vectors, normal pass, uv pass.

    Bibliography :

    Sevral forum
    Writing Mental ray shaders : a Perceptual Introduction by Andy Kopra
    Shader_p Source code

  2. #2
    Join Date
    Nov 2008
    Posts
    233

    Default

    With mi_call_shader_x you do actualy 'evaluate' a shader which happens at 'runtime', which also means you'll have to create an instance of the shader class and initialize it with all its parameters (ie. the passed tag ain't a mere c++ pointer but a mray DB pointer to an existing mray shader instance). You can't 'include' compiled shaders if with that you mean something like importing/using an external class at 'compile' time, however as it seems you wanna just 'composite' the called shader with other custom features, you should go fine with the mi_call_shader_x.

  3. #3

    Default

    Or, you can try to write a phenomenon works quite nice if you want to combine shaders.

  4. #4
    Join Date
    Apr 2012
    Posts
    6

    Default

    @ haggi :

    I've thought about writing a phenomenon, but I have one big cpp file exporting one dll. And as I said in my original post I have already coded some features like specular, that have to be added after the sss feature.
    So if my guess are right, that will force me to cut my program into little pieces to make it work properly? ( one dll by features )

    @ maxt :

    I'm a new c++ programmer, what to you mean by "at runtime" ? You mean that, the shader evaluated by mi_call_shader_x must be written in my script ? sorry for that question but if the shader isn't compiled, I don't know where it could be.




    Thanks for your precious help.

  5. #5

    Default

    No, there is no need to split your shader into little pieces.
    Lets say you have your shader designed in a way that it has an input for sss. In a phenomenon you create a sss shader, your own shader and you connect the sss shader output to your input for sss. Its like a shadergraph in mayas hypershade or the rendertree in softimage. Then in the phenomenon you can offer a simplified interface for the control of the combined shaders.

  6. #6
    Join Date
    Apr 2012
    Posts
    6

    Default

    oh yes !
    Thank you Haggi.

    I've spent all night writing the phenomenon, and now it's working (almost) fine. I still have little issues but I think it's a spdl/phenomenon writing problem and it's softimage-specific. So I guess I'm not the right place to post.

    Thanks again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •