Torque3D Documentation / _generateds / gfxStateBlockData.cpp

gfxStateBlockData.cpp

Engine/source/gfx/sim/gfxStateBlockData.cpp

More...

Public Functions

ConsoleDocClass(GFXSamplerStateData , "@brief A sampler state used by <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GFXStateBlockData.\n\n</a>" "The samplers define how <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> texture will be sampled when used from the shader " "or fixed function <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "singleton <a href="/coding/class/classgfxsamplerstatedata/">GFXSamplerStateData</a>(SamplerClampLinear)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   textureColorOp = GFXTOPModulate;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   addressModeU = <a href="/coding/file/gfxenums_8h/#gfxenums_8h_1ae684e1965a704ebd7c0e5186d758050ea69e67e1346037c0e28b95fc2c883cb08">GFXAddressClamp</a>;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   addressModeV = <a href="/coding/file/gfxenums_8h/#gfxenums_8h_1ae684e1965a704ebd7c0e5186d758050ea69e67e1346037c0e28b95fc2c883cb08">GFXAddressClamp</a>;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   addressModeW = <a href="/coding/file/gfxenums_8h/#gfxenums_8h_1ae684e1965a704ebd7c0e5186d758050ea69e67e1346037c0e28b95fc2c883cb08">GFXAddressClamp</a>;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   magFilter = <a href="/coding/file/gfxenums_8h/#gfxenums_8h_1a01a7cf72b310b59de23a172c301fd3e5a58ee59906f03658ed3d4abea19dfdd17">GFXTextureFilterLinear</a>;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   minFilter = <a href="/coding/file/gfxenums_8h/#gfxenums_8h_1a01a7cf72b310b59de23a172c301fd3e5a58ee59906f03658ed3d4abea19dfdd17">GFXTextureFilterLinear</a>;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   mipFilter = <a href="/coding/file/gfxenums_8h/#gfxenums_8h_1a01a7cf72b310b59de23a172c301fd3e5a58ee59906f03658ed3d4abea19dfdd17">GFXTextureFilterLinear</a>;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "};\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n</a>" "There are <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> few predefined samplers in the core scripts which you can use with " "<a href="/coding/class/classgfxstateblockdata/">GFXStateBlockData</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the most common rendering <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">cases:\n</a>" " - <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">SamplerClampLinear\n</a>" " - <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">SamplerClampPoint\n</a>" " - <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">SamplerWrapLinear\n</a>" " - <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">SamplerWrapPoint\n</a>" "\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GFXStateBlockData\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GFX\n</a>" )
ConsoleDocClass(GFXStateBlockData , "@brief A state block description <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">rendering.\n\n</a>" "This object is used with <a href="/coding/class/classshaderdata/">ShaderData</a> in <a href="/coding/class/classcustommaterial/">CustomMaterial</a> and <a href="/coding/class/classposteffect/">PostEffect</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> define the " "<a href="/coding/file/editortool_8cpp/#editortool_8cpp_1a4cb041169a32ea3d4cacadbb955e06b4">render</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">state.\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "singleton <a href="/coding/class/classgfxstateblockdata/">GFXStateBlockData</a>( PFX_DOFDownSampleStateBlock )\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   zDefined = true;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   zEnable = false;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   zWriteEnable = false;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   samplersDefined = true;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   samplerStates[0] = SamplerClampLinear;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   samplerStates[1] = SamplerClampPoint;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   // Copy the clamped linear sampler, but <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">change\n</a>" "   // the u coord <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> wrap <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this special <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">case.\n</a>" "   samplerStates[2] = <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/class/classgfxsamplerstatedata/">GFXSamplerStateData</a>( : SamplerClampLinear )\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   {\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "      addressModeU = <a href="/coding/file/gfxenums_8h/#gfxenums_8h_1ae684e1965a704ebd7c0e5186d758050ea655a1d0a3299435428f820b7624be54c">GFXAddressWrap</a>;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   };\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "};\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n</a>" "@note The 'xxxxDefined' fields are used <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> know what groups of fields are modified " "when combining multiple state blocks in material processing. You should take care <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> " "enable the right ones when setting <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">values.\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GFX\n</a>" )

Detailed Description

Public Functions

ConsoleDocClass(GFXSamplerStateData , "@brief A sampler state used by <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GFXStateBlockData.\n\n</a>" "The samplers define how <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> texture will be sampled when used from the shader " "or fixed function <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "singleton <a href="/coding/class/classgfxsamplerstatedata/">GFXSamplerStateData</a>(SamplerClampLinear)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   textureColorOp = GFXTOPModulate;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   addressModeU = <a href="/coding/file/gfxenums_8h/#gfxenums_8h_1ae684e1965a704ebd7c0e5186d758050ea69e67e1346037c0e28b95fc2c883cb08">GFXAddressClamp</a>;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   addressModeV = <a href="/coding/file/gfxenums_8h/#gfxenums_8h_1ae684e1965a704ebd7c0e5186d758050ea69e67e1346037c0e28b95fc2c883cb08">GFXAddressClamp</a>;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   addressModeW = <a href="/coding/file/gfxenums_8h/#gfxenums_8h_1ae684e1965a704ebd7c0e5186d758050ea69e67e1346037c0e28b95fc2c883cb08">GFXAddressClamp</a>;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   magFilter = <a href="/coding/file/gfxenums_8h/#gfxenums_8h_1a01a7cf72b310b59de23a172c301fd3e5a58ee59906f03658ed3d4abea19dfdd17">GFXTextureFilterLinear</a>;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   minFilter = <a href="/coding/file/gfxenums_8h/#gfxenums_8h_1a01a7cf72b310b59de23a172c301fd3e5a58ee59906f03658ed3d4abea19dfdd17">GFXTextureFilterLinear</a>;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   mipFilter = <a href="/coding/file/gfxenums_8h/#gfxenums_8h_1a01a7cf72b310b59de23a172c301fd3e5a58ee59906f03658ed3d4abea19dfdd17">GFXTextureFilterLinear</a>;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "};\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n</a>" "There are <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> few predefined samplers in the core scripts which you can use with " "<a href="/coding/class/classgfxstateblockdata/">GFXStateBlockData</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the most common rendering <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">cases:\n</a>" " - <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">SamplerClampLinear\n</a>" " - <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">SamplerClampPoint\n</a>" " - <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">SamplerWrapLinear\n</a>" " - <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">SamplerWrapPoint\n</a>" "\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GFXStateBlockData\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GFX\n</a>" )

ConsoleDocClass(GFXStateBlockData , "@brief A state block description <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">rendering.\n\n</a>" "This object is used with <a href="/coding/class/classshaderdata/">ShaderData</a> in <a href="/coding/class/classcustommaterial/">CustomMaterial</a> and <a href="/coding/class/classposteffect/">PostEffect</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> define the " "<a href="/coding/file/editortool_8cpp/#editortool_8cpp_1a4cb041169a32ea3d4cacadbb955e06b4">render</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">state.\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "singleton <a href="/coding/class/classgfxstateblockdata/">GFXStateBlockData</a>( PFX_DOFDownSampleStateBlock )\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   zDefined = true;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   zEnable = false;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   zWriteEnable = false;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   samplersDefined = true;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   samplerStates[0] = SamplerClampLinear;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   samplerStates[1] = SamplerClampPoint;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   // Copy the clamped linear sampler, but <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">change\n</a>" "   // the u coord <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> wrap <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this special <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">case.\n</a>" "   samplerStates[2] = <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/class/classgfxsamplerstatedata/">GFXSamplerStateData</a>( : SamplerClampLinear )\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   {\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "      addressModeU = <a href="/coding/file/gfxenums_8h/#gfxenums_8h_1ae684e1965a704ebd7c0e5186d758050ea655a1d0a3299435428f820b7624be54c">GFXAddressWrap</a>;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   };\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "};\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n</a>" "@note The 'xxxxDefined' fields are used <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> know what groups of fields are modified " "when combining multiple state blocks in material processing. You should take care <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> " "enable the right ones when setting <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">values.\n</a>" "@ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GFX\n</a>" )

IMPLEMENT_CONOBJECT(GFXSamplerStateData )

IMPLEMENT_CONOBJECT(GFXStateBlockData )

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#include "platform/platform.h"
 25#include "gfx/sim/gfxStateBlockData.h"
 26
 27#include "console/consoleTypes.h"
 28#include "gfx/gfxStringEnumTranslate.h"
 29
 30
 31IMPLEMENT_CONOBJECT( GFXStateBlockData );
 32
 33ConsoleDocClass(  GFXStateBlockData, 
 34                  "@brief A state block description for rendering.\n\n"
 35                  "This object is used with ShaderData in CustomMaterial and PostEffect to define the "
 36                  "render state.\n"
 37                  "@tsexample\n"
 38                  "singleton GFXStateBlockData( PFX_DOFDownSampleStateBlock )\n"
 39                  "{\n"
 40                  "   zDefined = true;\n"
 41                  "   zEnable = false;\n"
 42                  "   zWriteEnable = false;\n"
 43                  "\n"
 44                  "   samplersDefined = true;\n"
 45                  "   samplerStates[0] = SamplerClampLinear;\n"
 46                  "   samplerStates[1] = SamplerClampPoint;\n"
 47                  "\n"
 48                  "   // Copy the clamped linear sampler, but change\n"
 49                  "   // the u coord to wrap for this special case.\n"
 50                  "   samplerStates[2] = new GFXSamplerStateData( : SamplerClampLinear )\n"
 51                  "   {\n"
 52                  "      addressModeU = GFXAddressWrap;\n"
 53                  "   };\n"                  
 54                  "};\n"
 55                  "@endtsexample\n"
 56                  "@note The 'xxxxDefined' fields are used to know what groups of fields are modified "
 57                  "when combining multiple state blocks in material processing.  You should take care to "
 58                  "enable the right ones when setting values.\n"
 59                  "@ingroup GFX\n" );
 60
 61GFXStateBlockData::GFXStateBlockData()
 62{
 63   for (U32 i = 0; i < GFX_TEXTURE_STAGE_COUNT; i++)
 64      mSamplerStates[i] = NULL;
 65}
 66
 67void GFXStateBlockData::initPersistFields()
 68{
 69   addGroup( "Alpha Blending" );
 70
 71      addField( "blendDefined", TypeBool, Offset(mState.blendDefined, GFXStateBlockData),
 72         "Set to true if the alpha blend state is not all defaults." );
 73
 74      addField( "blendEnable", TypeBool, Offset(mState.blendEnable, GFXStateBlockData),
 75         "Enables alpha blending.  The default is false." );
 76
 77      addField( "blendSrc", TypeGFXBlend, Offset(mState.blendSrc, GFXStateBlockData),
 78         "The source blend state.  The default is GFXBlendOne." );
 79
 80      addField("blendDest", TypeGFXBlend, Offset(mState.blendDest, GFXStateBlockData),
 81         "The destination blend state.  The default is GFXBlendZero." );
 82
 83      addField("blendOp", TypeGFXBlendOp, Offset(mState.blendOp, GFXStateBlockData),
 84         "The arithmetic operation applied to alpha blending.  The default is GFXBlendOpAdd." );   
 85
 86   endGroup( "Alpha Blending" );
 87
 88
 89   addGroup( "Separate Alpha Blending" );
 90
 91      addField( "separateAlphaBlendDefined", TypeBool, Offset(mState.separateAlphaBlendDefined, GFXStateBlockData),
 92         "Set to true if the seperate alpha blend state is not all defaults." );
 93
 94      addField( "separateAlphaBlendEnable", TypeBool, Offset(mState.separateAlphaBlendEnable, GFXStateBlockData),
 95         "Enables the separate blend mode for the alpha channel.  The default is false." );
 96
 97      addField( "separateAlphaBlendSrc", TypeGFXBlend, Offset(mState.separateAlphaBlendSrc, GFXStateBlockData),
 98         "The source blend state.  The default is GFXBlendOne." );
 99
100      addField( "separateAlphaBlendDest", TypeGFXBlend, Offset(mState.separateAlphaBlendDest, GFXStateBlockData),
101         "The destination blend state.  The default is GFXBlendZero." );
102
103      addField( "separateAlphaBlendOp", TypeGFXBlendOp, Offset(mState.separateAlphaBlendOp, GFXStateBlockData),
104         "The arithmetic operation applied to separate alpha blending.  The default is GFXBlendOpAdd." );   
105
106   endGroup( "Separate Alpha Blending" );
107
108
109   addGroup( "Alpha Test" );
110
111      addField( "alphaDefined", TypeBool, Offset(mState.alphaDefined, GFXStateBlockData),
112         "Set to true if the alpha test state is not all defaults." );
113
114      addField( "alphaTestEnable", TypeBool, Offset(mState.alphaTestEnable, GFXStateBlockData),
115         "Enables per-pixel alpha testing.  The default is false." );
116
117      addField( "alphaTestFunc", TypeGFXCmpFunc, Offset(mState.alphaTestFunc, GFXStateBlockData),
118         "The test function used to accept or reject a pixel based on its alpha value.  The default is GFXCmpGreaterEqual." );
119
120      addField( "alphaTestRef", TypeS32, Offset(mState.alphaTestRef, GFXStateBlockData),
121         "The reference alpha value against which pixels are tested.  The default is zero." );
122
123   endGroup( "Alpha Test" );
124
125
126   addGroup( "Color Write" );
127
128      addField( "colorWriteDefined", TypeBool, Offset(mState.colorWriteDefined, GFXStateBlockData),
129         "Set to true if the color write state is not all defaults." );
130
131      addField( "colorWriteRed", TypeBool, Offset(mState.colorWriteRed, GFXStateBlockData),
132         "Enables red channel writes.  The default is true." );
133
134      addField( "colorWriteBlue", TypeBool, Offset(mState.colorWriteBlue, GFXStateBlockData),
135         "Enables blue channel writes.  The default is true." );
136
137      addField( "colorWriteGreen", TypeBool, Offset(mState.colorWriteGreen, GFXStateBlockData),
138         "Enables green channel writes.  The default is true." );
139
140      addField( "colorWriteAlpha", TypeBool, Offset(mState.colorWriteAlpha, GFXStateBlockData),
141         "Enables alpha channel writes.  The default is true." );
142
143   endGroup( "Color Write" );
144
145
146   addGroup( "Culling" );
147
148      addField("cullDefined", TypeBool, Offset(mState.cullDefined, GFXStateBlockData),
149         "Set to true if the culling state is not all defaults." );
150
151      addField("cullMode", TypeGFXCullMode, Offset(mState.cullMode, GFXStateBlockData),        
152         "Defines how back facing triangles are culled if at all.  The default is GFXCullCCW." );
153
154   endGroup( "Culling" );
155
156
157   addGroup( "Depth" );
158
159      addField( "zDefined", TypeBool, Offset(mState.zDefined, GFXStateBlockData),
160         "Set to true if the depth state is not all defaults." );
161
162      addField( "zEnable", TypeBool, Offset(mState.zEnable, GFXStateBlockData),
163         "Enables z-buffer reads.  The default is true." );
164
165      addField( "zWriteEnable", TypeBool, Offset(mState.zWriteEnable, GFXStateBlockData),
166         "Enables z-buffer writes.  The default is true." );
167
168      addField( "zFunc", TypeGFXCmpFunc, Offset(mState.zFunc, GFXStateBlockData),
169         "The depth comparision function which a pixel must pass to be written to the z-buffer.  The default is GFXCmpLessEqual." );
170
171      addField( "zBias", TypeF32, Offset(mState.zBias, GFXStateBlockData),
172         "A floating-point bias used when comparing depth values.  The default is zero." );
173
174      addField( "zSlopeBias", TypeF32, Offset(mState.zSlopeBias, GFXStateBlockData),
175         "An additional floating-point bias based on the maximum depth slop of the triangle being rendered.  The default is zero." );
176
177   endGroup( "Depth" );
178
179
180   addGroup( "Stencil" );
181
182      addField( "stencilDefined", TypeBool, Offset(mState.stencilDefined, GFXStateBlockData),
183         "Set to true if the stencil state is not all defaults." );
184
185      addField( "stencilEnable", TypeBool, Offset(mState.stencilEnable, GFXStateBlockData),
186         "Enables stenciling.  The default is false." );
187
188      addField( "stencilFailOp", TypeGFXStencilOp, Offset(mState.stencilFailOp, GFXStateBlockData),
189         "The stencil operation to perform if the stencil test fails.  The default is GFXStencilOpKeep." );
190      
191      addField( "stencilZFailOp", TypeGFXStencilOp, Offset(mState.stencilZFailOp, GFXStateBlockData),
192         "The stencil operation to perform if the stencil test passes and the depth test fails.  The default is GFXStencilOpKeep." );
193      
194      addField( "stencilPassOp", TypeGFXStencilOp, Offset(mState.stencilPassOp, GFXStateBlockData), 
195         "The stencil operation to perform if both the stencil and the depth tests pass.  The default is GFXStencilOpKeep." );
196      
197      addField( "stencilFunc", TypeGFXCmpFunc, Offset(mState.stencilFunc, GFXStateBlockData),
198         "The comparison function to test the reference value to a stencil buffer entry.  The default is GFXCmpNever." );
199
200      addField( "stencilRef", TypeS32, Offset(mState.stencilRef, GFXStateBlockData),
201         "The reference value for the stencil test.  The default is zero." );
202
203      addField( "stencilMask", TypeS32, Offset(mState.stencilMask, GFXStateBlockData),
204         "The mask applied to the reference value and each stencil buffer entry to determine the significant bits for the stencil test. The default is 0xFFFFFFFF." );
205
206      addField( "stencilWriteMask", TypeS32, Offset(mState.stencilWriteMask, GFXStateBlockData),
207         "The write mask applied to values written into the stencil buffer. The default is 0xFFFFFFFF." );
208
209   endGroup( "Stencil" );
210
211
212   addGroup( "Fixed Function" );
213
214      addField( "vertexColorEnable", TypeBool, Offset(mState.vertexColorEnable, GFXStateBlockData),
215         "Enables fixed function vertex coloring when rendering without a shader.  The default is false." );
216
217   endGroup( "Fixed Function" );
218
219
220   addGroup( "Sampler States" );
221
222      addField( "samplersDefined", TypeBool, Offset(mState.samplersDefined, GFXStateBlockData),
223         "Set to true if the sampler states are not all defaults." );
224
225      addField( "samplerStates", TYPEID<GFXSamplerStateData>(), Offset(mSamplerStates, GFXStateBlockData), GFX_TEXTURE_STAGE_COUNT,
226         "The array of texture sampler states.\n"
227         "@note Not all graphics devices support 16 samplers.  In general "
228         "all systems support 4 samplers with most modern cards doing 8." );
229
230      addField( "textureFactor", TypeColorI, Offset(mState.textureFactor, GFXStateBlockData),
231         "The color used for multiple-texture blending with the GFXTATFactor texture-blending argument or "
232         "the GFXTOPBlendFactorAlpha texture-blending operation.  The default is opaque white (255, 255, 255, 255)." );
233
234   endGroup( "Sampler States" );
235
236   Parent::initPersistFields();
237}
238
239bool GFXStateBlockData::onAdd()
240{
241   if (!Parent::onAdd())
242      return false;
243
244   for (U32 i = 0; i < GFX_TEXTURE_STAGE_COUNT; i++)
245   {  
246      if (mSamplerStates[i])
247         mSamplerStates[i]->setSamplerState(mState.samplers[i]);
248   }
249   return true;
250}
251
252
253IMPLEMENT_CONOBJECT( GFXSamplerStateData );
254
255ConsoleDocClass(  GFXSamplerStateData, 
256                  "@brief A sampler state used by GFXStateBlockData.\n\n"
257                  "The samplers define how a texture will be sampled when used from the shader "
258                  "or fixed function device\n"
259                  "@tsexample\n"
260                  "singleton GFXSamplerStateData(SamplerClampLinear)\n"
261                  "{\n"
262                  "   textureColorOp = GFXTOPModulate;\n"
263                  "   addressModeU = GFXAddressClamp;\n"
264                  "   addressModeV = GFXAddressClamp;\n"
265                  "   addressModeW = GFXAddressClamp;\n"
266                  "   magFilter = GFXTextureFilterLinear;\n"
267                  "   minFilter = GFXTextureFilterLinear;\n"
268                  "   mipFilter = GFXTextureFilterLinear;\n"
269                  "};\n"
270                  "@endtsexample\n"
271                  "There are a few predefined samplers in the core scripts which you can use with "
272                  "GFXStateBlockData for the most common rendering cases:\n"
273                  "  - SamplerClampLinear\n"
274                  "  - SamplerClampPoint\n"
275                  "  - SamplerWrapLinear\n"
276                  "  - SamplerWrapPoint\n"
277                  "\n"
278                  "@see GFXStateBlockData\n"
279                  "@ingroup GFX\n" );
280
281void GFXSamplerStateData::initPersistFields()
282{
283   Parent::initPersistFields();
284
285   addGroup( "Address Mode" );
286
287      addField("addressModeU", TypeGFXTextureAddressMode, Offset(mState.addressModeU, GFXSamplerStateData),
288         "The texture address mode for the u coordinate.  The default is GFXAddressWrap." );
289
290      addField("addressModeV", TypeGFXTextureAddressMode, Offset(mState.addressModeV, GFXSamplerStateData),
291         "The texture address mode for the v coordinate.  The default is GFXAddressWrap." );
292
293      addField("addressModeW", TypeGFXTextureAddressMode, Offset(mState.addressModeW, GFXSamplerStateData),
294         "The texture address mode for the w coordinate.  The default is GFXAddressWrap." );
295
296   endGroup( "Address Mode" );
297
298   addGroup( "Filter State" );
299
300      addField("magFilter", TypeGFXTextureFilterType, Offset(mState.magFilter, GFXSamplerStateData),
301         "The texture magnification filter.  The default is GFXTextureFilterLinear." );
302
303      addField("minFilter", TypeGFXTextureFilterType, Offset(mState.minFilter, GFXSamplerStateData),
304         "The texture minification filter.  The default is GFXTextureFilterLinear." );
305
306      addField("mipFilter", TypeGFXTextureFilterType, Offset(mState.mipFilter, GFXSamplerStateData),
307         "The texture mipmap filter used during minification.  The default is GFXTextureFilterLinear." );
308
309      addField("mipLODBias", TypeF32, Offset(mState.mipLODBias, GFXSamplerStateData),
310         "The mipmap level of detail bias.  The default value is zero." );
311
312      addField("maxAnisotropy", TypeS32, Offset(mState.maxAnisotropy, GFXSamplerStateData),
313         "The maximum texture anisotropy.  The default value is 1." );
314
315   endGroup( "Filter State" );
316
317   addField("samplerFunc", TypeGFXCmpFunc, Offset(mState.samplerFunc, GFXSamplerStateData),
318      "Compares sampled data against existing sampled data.  The default is GFXCmpNever.");
319}
320
321/// Copies the data of this object into desc
322void GFXSamplerStateData::setSamplerState(GFXSamplerStateDesc& desc)
323{
324   desc = mState;
325}
326