customShaderFeature.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef CUSTOMSHADERFEATURE_H
  23. #define CUSTOMSHADERFEATURE_H
  24. #ifndef _SIMOBJECT_H_
  25. #include "console/simObject.h"
  26. #endif
  27. #ifdef TORQUE_D3D11
  28. class CustomFeatureHLSL;
  29. #endif
  30. #ifdef TORQUE_OPENGL
  31. class CustomFeatureGLSL;
  32. #endif
  33. class CustomShaderFeatureData : public SimObject
  34. {
  35. typedef SimObject Parent;
  36. public:
  37. #ifdef TORQUE_D3D11
  38. CustomFeatureHLSL* mFeatureHLSL;
  39. #endif
  40. #ifdef TORQUE_OPENGL
  41. CustomFeatureGLSL* mFeatureGLSL;
  42. #endif
  43. Vector<StringTableEntry> mAddedShaderConstants;
  44. public:
  45. CustomShaderFeatureData();
  46. virtual ~CustomShaderFeatureData();
  47. // Declare this object as a ConsoleObject so that we can
  48. // instantiate it into the world and network it
  49. DECLARE_CONOBJECT(CustomShaderFeatureData);
  50. //--------------------------------------------------------------------------
  51. // Object Editing
  52. // Since there is always a server and a client object in Torque and we
  53. // actually edit the server object we need to implement some basic
  54. // networking functions
  55. //--------------------------------------------------------------------------
  56. // Set up any fields that we want to be editable (like position)
  57. static void initPersistFields();
  58. // Handle when we are added to the scene and removed from the scene
  59. bool onAdd();
  60. void onRemove();
  61. //shadergen setup
  62. void addVariable(String name, String type, String defaultValue);
  63. void addUniform(String name, String type, String defaultValue, U32 arraySize);
  64. void addSampler(String name, String type, U32 arraySize);
  65. void addTexture(String name, String type, String samplerState, U32 arraySize);
  66. void addConnector(String name, String type, String elementName);
  67. void addVertTexCoord(String name);
  68. bool hasFeature(String name);
  69. void writeLine(String format, S32 argc, ConsoleValue *argv);
  70. };
  71. #endif