Generic Shader tool for Cg prototyping in Fusion

Generic Shader 3D is a template for quick shader development and tweaking in Fusion. We created it to avoid having to generate a full Visual C++ project for every random shader idea that we dream up. The tool provides the user with a large number of Fusion inputs that are passed as Cg parameters: booleans, floats, colors, materials, gradients, lights, and a transformation matrix. The user can also switch between the numbered shaders by adjusting a slider, which is implemented as a literal parameter so that only the selected code branch is compiled.

Once a shader proves to be useful and the required inputs are more or less locked-down, we typically convert it into a full-fledged 3D Fusion tool (expect more of these posted soon, by the way).

GS3

Download GenericShader3D 1.1Download GenericShader3D

Some things to note:

  • You must restart Fusion after changing the .cg shader file.
  • Make sure to set FUSION_ENABLE_CG_DEBUG_OUTPUT=TRUE.  The line numbers won’t be correct, but it will provide some clues as to what is potentially wrong.
  • User Controls can be used to customize the UI.
  • Cg/OpenGL only.  Fails for Software (or other) renderers.
  • Fragment shaders only.
  • Nvidia’s Cg documentation
  • Fusion 6.0/6.1 uses Cg 2.2.0010
  • There will be a delay while the Cg compiles.  Depending on the number and types of shaders in your comp, and your computer, this may cause significant lag.
  • It can be useful to put two variations of your shader into two different slots.  Makes it simple to compare the results side by side or do benchmarks, or to just keep a working backup while you mess around with a new idea.

Chad has put together a great example comp showing the Generic Shader in action (see below). Have fun with the tool and feel free to send in any delicious shaders you come up with while using it.

Download Generic Shader example comp B03Download Generic Shader example comp

GS_Example_A01


4 Responses

  1. Sven Says:

    Hi Matt,

    i keep getting the following error:

    Unable to load plugin:GenericShader3D-6_0-win32.plugin.
    The specified procedure could not be found.

    I’m running Vista x64, Fusion 6.1 (win32 and 64) build 667

    Geforce 8800GTX, driver 197.45

  2. Sven Says:

    Doh, never mind, i just dropped the entire plugin map from the zip into our plugin library, never notice there are specific plugin versions for 6.0 and 6.1

    The plugin loads now.

  3. Chad Says:

    Yeah, until the SDK settles down (and we don’t really want it to, as we’re hoping for some changes) expect 3D plugins to have specific pairings to builds. We know this adds complexity to the install, but considering the nature of this plugin, we don’t see it as a big problem.

  4. Chad Says:

    I’ve updated the sample comp to reflect the shader number changes made with the latest version of the fragment shader.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.