Search Unity

ShaderLab shaders in native OpenGL

Discussion in 'Shaders' started by Gooms9, Jun 23, 2012.

  1. Gooms9

    Gooms9

    Joined:
    Dec 17, 2011
    Posts:
    31
    Hey, I was wondering if there is any way to use Unity shaders when using the low level native rendering interface from a c++ and openGL plugin. I'm doing some rendering from a plugin and wish to integrate it with the lights in my scene. I would rather not have to re-implement all the complex lighting stuff in unity.

    From what I can tell if I can't just easily tap into the unity shader pipeline from my native plugin, then I will need to retrieve a list of all the lights affecting my object, make them available to my GLSL shader, and then perform all the correct lighting calculations from my own custom GLSL shader. Any shortcuts around this? Is there a simple way of getting access to all the variables that unity makes available for "free" when writing GLSL shaders in editor?

    Ideally I would like to just be able to write a typical ShaderLab shader and pass the GLSL compiled version into my native plugin and just call glUseProgram(program); and have everything magically work, but I'm guessing it's not going to be quite that easy.
     
  2. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
  3. Gooms9

    Gooms9

    Joined:
    Dec 17, 2011
    Posts:
    31
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    you can not hook into the rendering pipeline itself writing a plugin that creates things 'existing within the rendered environment but not owned by unity'
    Thats not possible.

    If thats your target you make your plugin best update a mesh, texture or whatever and let it otherwise exist as a Unity object