tlorach / nvFX

Generic Effect system for Graphic API's (OpenGL and DirectX)
280 stars 53 forks source link
    Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved.
    Copyright (c) 2013, Tristan Lorach. All rights reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions
    are met:
     * Redistributions of source code must retain the above copyright
       notice, this list of conditions and the following disclaimer.
     * Neither the name of NVIDIA CORPORATION nor the names of its
       contributors may be used to endorse or promote products derived
       from this software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
    OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

What is nvFX ?

nvFx is a new approach for compositing shaders and compute kernels together, using an API-agnostic description of effects for objects materials and scene management (post-processing, management of rendering passes). This approach builds on the original concepts of NVIDIA CgFX and expands it to new levels of flexibility and extensibility. Rather than creating a new shading language, we supersede existing ones (GLSL, HLSL) to avoid complex parsing and yet deploy the effect in a variety of environments. For more details, check the presentation here :

Siggraph 2013: http://www.nvidia.com/object/siggraph2013-tech-talks.html ( direct Ustream link http://www.ustream.tv/recorded/36222497 )

NVIDIA GTC conference: http://www.gputechconf.com/gtcnew/on-demand-gtc.php?searchByKeyword=nvFx&searchItems=&sessionTopic=&sessionEvent=&sessionYear=&sessionFormat=&submit=&select=+#2173

and Siggraph: http://nvidia.fullviewmedia.com/siggraph2012/ondemand/SB117.html

There is a Doxygen folder with more details. However I need to update the documentation for few topics and added features

Example

Comments on the code

I tried to keep the code as simple as possible. It is difficult to stick to that because new features always added-up yet another set of code that made it more complicated than I expected. However, I tried on purpose to not get into crazy optimizations, so that it is still fine to step into the source code without getting too much lost. In other words, I didn't design so much the inside of nvFx and left some code non-optimized for the benefit of keeping it readable (example: iteration through pass-states). I figured-out that better optimizations could be done by whoever wants to adopt the concept of nvFx; or could be done as another step or in another branch...

I am using the idea of Abstract classes as the API entry points. But I didn't push so far this sort of abstraction, to avoid over-engineering the whole project. So, the project is really C++ centric and thus can't be used from pure C project.

I am also aware that any Bison/Flex experts will have 'something to say' about the actual grammar... I have identified lots of things to fix and clean and will do it as soon as I have time. For now, this is working and at least is a good enough implementation.


To be done as soon as possible


Known issues


What do you need to build properly

For running samples, please check the comment in "Known issues" about "Working Directory"

You can install nvFx thanks to CMake. It is a clean way to use it later for other projects

how to configure CMake

options

external packages

CMake will try its best to find what is required. If it failed, you can still have a look at the cmake folder in which you will see the scripts used to try to locate those components.

I know this is the most annoying and frustrating part, when cmake doesn't want to build a clean project. So I will do my best to add comments on possible issues.

Glew

When cmake tries to find glew, it can become tricky. The best solutions for me was to add a trick: if glew.c is found, the project will use it instead of linking with any library. This solve lots of headache.

User Interface SvcMFCUI

CMake will try to locate the UI library SvcMFCUI by going back in the file system and check if you downloaded it from GitHub... and compiled it. It will of course check CMake variable and env. variables. See https://github.com/tlorach/SvcMFCUI for more information

ZLib

I used the native ZLib project and installed it (C:\Program Files\zlib) where 'include', 'lib' and 'bin' folders are.

GLUT

GLUT_LOCATION can be set as env. variable or cmake variable to point to Freeglut root folder. But again: Glut is not mandatory...

Bison & Flex

Major update history


Please direct any questions to tlorach@nvidia.com (Tristan Lorach)

I hope this project will be of any help for some of you!