gBufferConditionerHLSL.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 _GBUFFER_CONDITIONER_HLSL_H_
  23. #define _GBUFFER_CONDITIONER_HLSL_H_
  24. #ifndef _CONDITIONER_BASE_H_
  25. #include "shaderGen/conditionerFeature.h"
  26. #endif
  27. #ifndef _SHADEROP_H_
  28. #include "shaderGen/shaderOp.h"
  29. #endif
  30. ///
  31. class GBufferConditionerHLSL : public ConditionerFeature
  32. {
  33. typedef ConditionerFeature Parent;
  34. public:
  35. enum NormalStorage
  36. {
  37. CartesianXYZ,
  38. CartesianXY,
  39. Spherical,
  40. LambertAzimuthal,
  41. };
  42. enum NormalSpace
  43. {
  44. WorldSpace,
  45. ViewSpace,
  46. };
  47. protected:
  48. NormalStorage mNormalStorageType;
  49. bool mCanWriteNegativeValues;
  50. U32 mBitsPerChannel;
  51. public:
  52. GBufferConditionerHLSL( const GFXFormat bufferFormat, const NormalSpace nrmSpace );
  53. virtual ~GBufferConditionerHLSL();
  54. virtual void processVert( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd );
  55. virtual void processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd );
  56. virtual Resources getResources( const MaterialFeatureData &fd );
  57. virtual String getName() { return "GBuffer Conditioner"; }
  58. protected:
  59. virtual Var *printMethodHeader( MethodType methodType, const String &methodName, Stream &stream, MultiLine *meta );
  60. virtual GenOp* _posnegEncode( GenOp *val );
  61. virtual GenOp* _posnegDecode( GenOp *val );
  62. virtual Var* _conditionOutput( Var *unconditionedOutput, MultiLine *meta );
  63. virtual Var* _unconditionInput( Var *conditionedInput, MultiLine *meta );
  64. };
  65. #endif // _GBUFFER_CONDITIONER_HLSL_H_