Light2D.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. #include "Precompiled.h"
  2. #include "../Core/Context.h"
  3. #include "../Graphics/Graphics.h"
  4. #include "../Graphics/Viewport.h"
  5. #include "../Scene/Scene.h"
  6. #include "../Graphics/Camera.h"
  7. #include "../Graphics/Octree.h"
  8. #include "../Atomic2D/Light2D.h"
  9. #include "../Graphics/Renderer.h"
  10. #include "../Resource/XMLFile.h"
  11. #include "../Graphics/GraphicsEvents.h"
  12. #include "../Graphics/RenderPath.h"
  13. #include "../Graphics/Material.h"
  14. #include "../Graphics/Technique.h"
  15. #include "../Atomic2D/RigidBody2D.h"
  16. #include "../Atomic2D/Renderer2D.h"
  17. #include "../IO/Log.h"
  18. #include "../Resource/ResourceCache.h"
  19. namespace Atomic
  20. {
  21. extern const char* ATOMIC2D_CATEGORY;
  22. Light2D::Light2D(Context* context) : Component(context),
  23. castShadows_(false),
  24. softShadows_(false),
  25. softShadowLength_(2.5f),
  26. backtrace_(false)
  27. {
  28. SetNumRays(32);
  29. }
  30. Light2D::~Light2D()
  31. {
  32. }
  33. void Light2D::SetNumRays(int numRays)
  34. {
  35. rays_.Resize(numRays);
  36. }
  37. void Light2D::OnSetEnabled()
  38. {
  39. Component::OnSetEnabled();
  40. if (lightgroup_)
  41. lightgroup_->SetDirty();
  42. if (!enabled_)
  43. {
  44. vertices_.Clear();
  45. }
  46. }
  47. void Light2D::AddVertices(Vector<Vertex2D>& vertices)
  48. {
  49. vertices += vertices_;
  50. }
  51. void Light2D::RegisterObject(Context* context)
  52. {
  53. context->RegisterFactory<Light2D>(ATOMIC2D_CATEGORY);
  54. COPY_BASE_ATTRIBUTES(Component);
  55. }
  56. void Light2D::CastRays()
  57. {
  58. PhysicsWorld2D* physicsWorld = lightgroup_->GetPhysicsWorld();
  59. if (physicsWorld && castShadows_) {
  60. for (unsigned i = 0; i < rays_.Size(); i++) {
  61. Light2DRay& ray = rays_[i];
  62. Vector2 oend = ray.end_;
  63. float distance = (ray.end_ - ray.start_).Length();
  64. if (Abs(distance < .01f))
  65. distance = .01f;
  66. float bestDistance = 999999;
  67. PODVector<PhysicsRaycastResult2D> results;
  68. physicsWorld->Raycast(results, ray.start_, ray.end_);
  69. RigidBody2D* body = NULL;
  70. for (PODVector<PhysicsRaycastResult2D>::ConstIterator itr = results.Begin(); itr != results.End(); itr++)
  71. {
  72. const PhysicsRaycastResult2D& result = *itr;
  73. if (result.body_->GetCastShadows() && result.distance_ < distance && result.distance_ < bestDistance)
  74. {
  75. bestDistance = result.distance_;
  76. body = result.body_;
  77. ray.fraction_ = result.distance_ / distance;
  78. ray.end_.x_ = result.position_.x_;
  79. ray.end_.y_ = result.position_.y_;
  80. }
  81. }
  82. // backtracing can introduce artifacts, for now don't backtrace
  83. // on static hit... also, may need to clamp on a body size
  84. if (backtrace_ && body && body->GetBodyType() != BT_STATIC)
  85. {
  86. results.Clear();
  87. bestDistance = -999999;
  88. physicsWorld->Raycast(results, oend, ray.end_);
  89. for (PODVector<PhysicsRaycastResult2D>::ConstIterator itr = results.Begin(); itr != results.End(); itr++)
  90. {
  91. const PhysicsRaycastResult2D& result = *itr;
  92. if (result.distance_ > bestDistance && result.body_->GetBodyType() != BT_STATIC)
  93. {
  94. bestDistance = result.distance_;
  95. ray.fraction_ = (distance - result.distance_) / distance;
  96. ray.end_.x_ = result.position_.x_;
  97. ray.end_.y_ = result.position_.y_;
  98. }
  99. }
  100. }
  101. }
  102. }
  103. }
  104. DirectionalLight2D::DirectionalLight2D(Context* context) : Light2D(context),
  105. direction_(-45.0f)
  106. {
  107. lightType_ = LIGHT2D_DIRECTIONAL;
  108. }
  109. DirectionalLight2D::~DirectionalLight2D()
  110. {
  111. }
  112. void DirectionalLight2D::RegisterObject(Context* context)
  113. {
  114. context->RegisterFactory<DirectionalLight2D>(ATOMIC2D_CATEGORY);
  115. COPY_BASE_ATTRIBUTES(Light2D);
  116. }
  117. void DirectionalLight2D::UpdateVertices()
  118. {
  119. vertices_.Clear();
  120. if (!lightgroup_ || !enabled_)
  121. return;
  122. const BoundingBox& frustumBox = lightgroup_->GetFrustumBox();
  123. float cos = Cos(direction_);
  124. float sin = Sin(direction_);
  125. float width = frustumBox.Size().x_;
  126. float height = frustumBox.Size().y_;
  127. float sizeOfScreen = width > height ? width : height;
  128. float xAxelOffSet = sizeOfScreen * cos;
  129. float yAxelOffSet = sizeOfScreen * sin;
  130. // preventing length <0 assertion error on box2d.
  131. if ((xAxelOffSet * xAxelOffSet < 0.1f) && (yAxelOffSet * yAxelOffSet < 0.1f)) {
  132. xAxelOffSet = 1;
  133. yAxelOffSet = 1;
  134. }
  135. float widthOffSet = sizeOfScreen * -sin;
  136. float heightOffSet = sizeOfScreen * cos;
  137. float x = (frustumBox.min_.x_ + frustumBox.max_.x_) * 0.5f - widthOffSet;
  138. float y = (frustumBox.min_.y_ + frustumBox.max_.y_) * 0.5f - heightOffSet;
  139. unsigned rayNum = rays_.Size();
  140. float portionX = 2.0f * widthOffSet / (rayNum - 1);
  141. x = (floorf(x / (portionX * 2))) * portionX * 2;
  142. float portionY = 2.0f * heightOffSet / (rayNum - 1);
  143. y = (ceilf(y / (portionY * 2))) * portionY * 2;
  144. for (unsigned i = 0; i < rayNum; i++)
  145. {
  146. Light2DRay& ray = rays_[i];
  147. float steppedX = float(i) * portionX + x;
  148. float steppedY = float(i) * portionY + y;
  149. ray.start_.x_ = steppedX - xAxelOffSet;
  150. ray.start_.y_ = steppedY - yAxelOffSet;
  151. ray.end_.x_ = steppedX + xAxelOffSet;
  152. ray.end_.y_ = steppedY + yAxelOffSet;
  153. ray.fraction_ = 0.0f;
  154. }
  155. CastRays();
  156. Vertex2D vertex0;
  157. Vertex2D vertex1;
  158. Vertex2D vertex2;
  159. Vertex2D vertex3;
  160. vertex0.color_ = vertex1.color_ = vertex2.color_ = vertex3.color_ = color_.ToUInt();
  161. for (unsigned i = 0; i < rayNum - 1; i++) {
  162. Light2DRay& ray0 = rays_[i];
  163. Light2DRay& ray1 = rays_[i + 1];
  164. vertex0.position_ = Vector3( ray0.start_.x_, ray0.start_.y_, 0.0f);
  165. vertex1.position_ = Vector3( ray0.end_.x_, ray0.end_.y_, 0.0f);
  166. vertex2.position_ = Vector3( ray1.start_.x_, ray1.start_.y_, 0.0f);
  167. vertex3.position_ = Vector3( ray1.end_.x_, ray1.end_.y_, 0.0f);
  168. vertex0.uv_.x_ = 1.0f;
  169. vertex2.uv_.x_ = 1.0 ;
  170. vertex1.uv_.x_ = 1.0f;
  171. vertex3.uv_.x_ = 1.0f;
  172. vertices_.Push(vertex0);
  173. vertices_.Push(vertex1);
  174. vertices_.Push(vertex3);
  175. vertices_.Push(vertex0);
  176. vertices_.Push(vertex3);
  177. vertices_.Push(vertex2);
  178. }
  179. if (softShadows_ && castShadows_)
  180. {
  181. unsigned uambient = lightgroup_->GetAmbientColor().ToUInt();
  182. // THIS CAN BE OPTIMIZED!
  183. for (unsigned i = 0; i < rays_.Size() - 1; i++) {
  184. Light2DRay& ray0 = rays_[i];
  185. Light2DRay& ray1 = rays_[i + 1];
  186. vertex0.position_ = Vector3( ray0.end_.x_, ray0.end_.y_, 0.0f);
  187. Vector2 v0 = (ray0.end_ - ray0.start_).Normalized();
  188. Vector2 v1 = (ray1.end_ - ray1.start_).Normalized();
  189. vertex1.position_ = Vector3( ray0.end_.x_ + v0.x_ * softShadowLength_,
  190. ray0.end_.y_ + v0.y_ * softShadowLength_, 0.0f);
  191. vertex2.position_ = Vector3( ray1.end_.x_ + v1.x_ * softShadowLength_,
  192. ray1.end_.y_ + v1.y_ * softShadowLength_, 0.0f);
  193. vertex3.position_ = Vector3( ray1.end_.x_, ray1.end_.y_, 0.0f);
  194. vertex0.color_ = 0;
  195. vertex3.color_ = 0;
  196. vertex0.uv_.x_ = 0;
  197. vertex3.uv_.x_ = 0;
  198. vertex1.color_ = 0;
  199. vertex2.color_ = 0;
  200. vertex1.uv_.x_ = 1.0;
  201. vertex2.uv_.x_ = 1.0;
  202. vertices_.Push(vertex0);
  203. vertices_.Push(vertex1);
  204. vertices_.Push(vertex2);
  205. vertices_.Push(vertex0);
  206. vertices_.Push(vertex2);
  207. vertices_.Push(vertex3);
  208. }
  209. }
  210. }
  211. PositionalLight2D::PositionalLight2D(Context* context) : Light2D(context)
  212. {
  213. }
  214. PositionalLight2D::~PositionalLight2D()
  215. {
  216. }
  217. void PositionalLight2D::RegisterObject(Context* context)
  218. {
  219. context->RegisterFactory<PositionalLight2D>(ATOMIC2D_CATEGORY);
  220. COPY_BASE_ATTRIBUTES(Light2D);
  221. }
  222. void PositionalLight2D::UpdateVertices()
  223. {
  224. vertices_.Clear();
  225. if (!lightgroup_ || !enabled_)
  226. return;
  227. CastRays();
  228. Vertex2D vertex0;
  229. Vertex2D vertex1;
  230. Vertex2D vertex2;
  231. Vertex2D vertex3;
  232. vertex0.color_ = vertex1.color_ = vertex2.color_ = vertex3.color_ = color_.ToUInt();
  233. for (unsigned i = 0; i < rays_.Size() - 1; i++) {
  234. Light2DRay& ray0 = rays_[i];
  235. Light2DRay& ray1 = rays_[i + 1];
  236. vertex0.position_ = Vector3( ray0.start_.x_, ray0.start_.y_, 0.0f);
  237. vertex1.position_ = Vector3( ray0.end_.x_, ray0.end_.y_, 0.0f);
  238. vertex2.position_ = Vector3( ray1.end_.x_, ray1.end_.y_, 0.0f);
  239. vertex0.uv_.x_ = 1.0f;
  240. vertex1.uv_.x_ = 1.0f - ray0.fraction_;
  241. vertex2.uv_.x_ = 1.0f - ray1.fraction_;
  242. vertices_.Push(vertex0);
  243. vertices_.Push(vertex1);
  244. vertices_.Push(vertex2);
  245. }
  246. if (softShadows_ && castShadows_)
  247. {
  248. // THIS CAN BE OPTIMIZED!
  249. for (unsigned i = 0; i < rays_.Size(); i++) {
  250. Light2DRay& ray0 = rays_[i];
  251. Light2DRay& ray1 = rays_[i + 1 == rays_.Size() ? 0 : i + 1];
  252. float s0 = (1.0f - ray0.fraction_);
  253. float s1 = (1.0f - ray1.fraction_);
  254. vertex0.position_ = Vector3( ray0.end_.x_, ray0.end_.y_, 0.0f);
  255. vertex1.position_ = Vector3( ray0.end_.x_ + s0 * softShadowLength_ * ray0.cos_,
  256. (ray0.end_.y_ + s0 * softShadowLength_ * ray0.sin_), 0.0f);
  257. vertex2.position_ = Vector3( ray1.end_.x_ + s1 * softShadowLength_ * ray1.cos_,
  258. (ray1.end_.y_ + s1 * softShadowLength_ * ray1.sin_), 0.0f);
  259. vertex3.position_ = Vector3( ray1.end_.x_, ray1.end_.y_, 0.0f);
  260. vertex1.uv_.x_ = 0;
  261. vertex2.uv_.x_ = 0;
  262. vertex1.color_ = 0x00000000;
  263. vertex2.color_ = 0x00000000;
  264. // darkness of shadow, we should break this all out of uint
  265. vertex0.uv_.x_ = s0 * .65f;
  266. vertex3.uv_.x_ = s1 * .65f;
  267. vertices_.Push(vertex0);
  268. vertices_.Push(vertex1);
  269. vertices_.Push(vertex2);
  270. vertices_.Push(vertex0);
  271. vertices_.Push(vertex2);
  272. vertices_.Push(vertex3);
  273. }
  274. }
  275. }
  276. PointLight2D::PointLight2D(Context* context) : PositionalLight2D(context),
  277. radius_(1.0f)
  278. {
  279. lightType_ = LIGHT2D_POINT;
  280. }
  281. PointLight2D::~PointLight2D()
  282. {
  283. }
  284. void PointLight2D::RegisterObject(Context* context)
  285. {
  286. context->RegisterFactory<PointLight2D>(ATOMIC2D_CATEGORY);
  287. COPY_BASE_ATTRIBUTES(PositionalLight2D);
  288. }
  289. void PointLight2D::UpdateVertices()
  290. {
  291. vertices_.Clear();
  292. if (!lightgroup_ || !enabled_)
  293. return;
  294. const PhysicsWorld2D* physicsWorld = lightgroup_->GetPhysicsWorld();
  295. const Node* lightNode = GetNode();
  296. Vector2 start = lightNode->GetWorldPosition2D();
  297. float angleNum = 360.0f / float((rays_.Size() - 1));
  298. for (unsigned i = 0; i < rays_.Size(); i++) {
  299. float angle = angleNum * i;
  300. Light2DRay& ray = rays_[i];
  301. ray.start_ = start;
  302. ray.sin_ = Sin(angle);
  303. ray.cos_ = Cos(angle);
  304. ray.end_.x_ = ray.start_.x_ + radius_ * ray.cos_;
  305. ray.end_.y_ = ray.start_.y_ + radius_ * ray.sin_;
  306. ray.fraction_ = 1.0f;
  307. }
  308. PositionalLight2D::UpdateVertices();
  309. }
  310. void Light2DGroup::RegisterObject(Context* context)
  311. {
  312. context->RegisterFactory<Light2DGroup>(ATOMIC2D_CATEGORY);
  313. COPY_BASE_ATTRIBUTES(Drawable2D);
  314. }
  315. void Light2DGroup::OnNodeSet(Node* node)
  316. {
  317. // Do not call Drawable2D::OnNodeSet(node)
  318. if (node)
  319. {
  320. if (renderer_.Null())
  321. {
  322. renderer_ = node->GetOrCreateComponent<Renderer2D>();
  323. renderer_->SetUseTris(true);
  324. }
  325. if (light2DMaterial_.Null())
  326. CreateLight2DMaterial();
  327. Scene* scene = GetScene();
  328. if (scene)
  329. {
  330. if (IsEnabledEffective())
  331. renderer_->AddDrawable(this);
  332. }
  333. node->AddListener(this);
  334. }
  335. else
  336. {
  337. if (renderer_)
  338. renderer_->RemoveDrawable(this);
  339. }
  340. }
  341. Light2DGroup::Light2DGroup(Context* context) : Drawable2D(context),
  342. ambientColor_(0, 0, 0, 0),
  343. frustum_(0)
  344. {
  345. SubscribeToEvent(E_BEGINRENDERING, HANDLER(Light2DGroup, HandleBeginRendering));
  346. SubscribeToEvent(E_BEGINVIEWUPDATE, HANDLER(Light2DGroup, HandleBeginViewUpdate));
  347. }
  348. Light2DGroup::~Light2DGroup()
  349. {
  350. Renderer* renderer = GetSubsystem<Renderer>();
  351. if (renderer)
  352. {
  353. Viewport* viewport = renderer->GetViewport(0);
  354. if (viewport)
  355. {
  356. RenderPath* renderpath = viewport->GetRenderPath();
  357. if (renderpath)
  358. renderpath->RemoveCommands("Light2D");
  359. }
  360. }
  361. }
  362. void Light2DGroup::HandleBeginViewUpdate(StringHash eventType, VariantMap& eventData)
  363. {
  364. using namespace BeginViewUpdate;
  365. Scene* scene = GetScene();
  366. // Check that we are updating the correct scene
  367. if (scene != eventData[P_SCENE].GetPtr())
  368. return;
  369. Camera* camera = static_cast<Camera*>(eventData[P_CAMERA].GetPtr());
  370. frustum_ = &camera->GetFrustum();
  371. if (camera->IsOrthographic())// && camera->GetNode()->GetWorldDirection() == Vector3::FORWARD)
  372. {
  373. // Define bounding box with min and max points
  374. // todo: handle rotation
  375. frustumBoundingBox_.Define(frustum_->vertices_[2], frustum_->vertices_[4]);
  376. }
  377. }
  378. void Light2DGroup::HandleBeginRendering(StringHash eventType, VariantMap& eventData)
  379. {
  380. verticesDirty_ = true;
  381. }
  382. void Light2DGroup::OnWorldBoundingBoxUpdate()
  383. {
  384. boundingBox_.Define(-M_LARGE_VALUE, M_LARGE_VALUE);
  385. worldBoundingBox_.Define(-M_LARGE_VALUE, M_LARGE_VALUE);
  386. }
  387. void Light2DGroup::UpdateVertices()
  388. {
  389. // This is the shadow map
  390. if (!verticesDirty_)
  391. return;
  392. vertices_.Clear();
  393. for (Vector<WeakPtr<Light2D> >::Iterator itr = lights_.Begin(); itr != lights_.End(); itr++)
  394. {
  395. Light2D* light = *itr;
  396. if (!light->IsEnabled())
  397. continue;
  398. light->UpdateVertices();
  399. light->AddVertices(vertices_);
  400. }
  401. verticesDirty_ = false;
  402. }
  403. void Light2DGroup::AddLight(Light2D* light)
  404. {
  405. for (Vector<WeakPtr<Light2D> >::ConstIterator itr = lights_.Begin(); itr != lights_.End(); itr++)
  406. if (*itr == light)
  407. return;
  408. light->SetLightGroup(this);
  409. lights_.Push(WeakPtr<Light2D>(light));
  410. }
  411. void Light2DGroup::SetPhysicsWorld(PhysicsWorld2D* physicsWorld)
  412. {
  413. physicsWorld_ = physicsWorld;
  414. }
  415. void Light2DGroup::SetAmbientColor(const Color& color)
  416. {
  417. if (color == ambientColor_)
  418. return;
  419. ambientColor_ = color;
  420. Renderer* renderer = GetSubsystem<Renderer>();
  421. // only on main viewport atm and viewport must first be set
  422. if (renderer)
  423. {
  424. Viewport* viewport = renderer->GetViewport(0);
  425. if (viewport)
  426. {
  427. RenderPath* renderpath = viewport->GetRenderPath();
  428. renderpath->SetShaderParameter("ShadowAmbient", ambientColor_);
  429. }
  430. }
  431. }
  432. void Light2DGroup::CreateLight2DMaterial()
  433. {
  434. Renderer* renderer = GetSubsystem<Renderer>();
  435. // only on main viewport atm and viewport must first be set
  436. Viewport* viewport = renderer->GetViewport(0);
  437. RenderPath* renderpath = viewport->GetRenderPath();
  438. RenderTargetInfo ntarget;
  439. ntarget.enabled_ = true;
  440. ntarget.name_ = "light2dtarget";
  441. ntarget.tag_ = "Light2D";
  442. ntarget.format_ = Graphics::GetRGBAFormat();
  443. ntarget.sizeMode_ = SIZE_VIEWPORTDIVISOR;
  444. ntarget.size_ = Vector2(4, 4);
  445. // try true
  446. ntarget.filtered_ = false;
  447. renderpath->AddRenderTarget(ntarget);
  448. RenderPathCommand clearCommand;
  449. clearCommand.tag_ = "Light2D";
  450. clearCommand.type_ = CMD_CLEAR;
  451. clearCommand.clearColor_ = Color(0, 0, 0, 0);
  452. clearCommand.clearFlags_ = CLEAR_COLOR;
  453. clearCommand.enabled_ = true;
  454. clearCommand.SetNumOutputs(1);
  455. clearCommand.SetOutputName(0, "light2dtarget");
  456. renderpath->AddCommand(clearCommand);
  457. RenderPathCommand passCommand;
  458. passCommand.tag_ = "Light2D";
  459. passCommand.type_ = CMD_SCENEPASS;
  460. passCommand.pass_ = "light2d";
  461. passCommand.enabled_ = true;
  462. passCommand.SetNumOutputs(1);
  463. passCommand.SetOutputName(0, "light2dtarget");
  464. renderpath->AddCommand(passCommand);
  465. ResourceCache* cache = GetSubsystem<ResourceCache>();
  466. XMLFile* light2DBlur = cache->GetResource<XMLFile>("PostProcess/Light2DBlur.xml");
  467. renderpath->Append(light2DBlur);
  468. RenderPathCommand copyCommand;
  469. copyCommand.enabled_ = true;
  470. copyCommand.tag_ = "Light2D";
  471. copyCommand.type_ = CMD_QUAD;
  472. copyCommand.vertexShaderName_ = "Shadow2D";
  473. copyCommand.pixelShaderName_ = "Shadow2D";
  474. copyCommand.SetTextureName(TU_DIFFUSE, "viewport");
  475. copyCommand.SetTextureName(TU_EMISSIVE, "light2dtarget");
  476. copyCommand.SetShaderParameter("ShadowAmbient", ambientColor_);
  477. copyCommand.SetNumOutputs(1);
  478. copyCommand.SetOutputName(0, "viewport");
  479. renderpath->AddCommand(copyCommand);
  480. light2DMaterial_ = new Material(context_);
  481. light2DMaterial_->SetName("Light2DMaterial");
  482. Technique* tech = new Technique(context_);
  483. Pass* pass = tech->CreatePass(PASS_LIGHT2D);
  484. pass->SetBlendMode(BLEND_ADDALPHA);
  485. pass->SetDepthTestMode(CMP_ALWAYS);
  486. pass->SetVertexShader("Light2D");
  487. pass->SetPixelShader("Light2D");
  488. pass->SetDepthWrite(false);
  489. light2DMaterial_->SetTechnique(0, tech);
  490. light2DMaterial_->SetCullMode(CULL_NONE);
  491. SetCustomMaterial(light2DMaterial_);
  492. }
  493. }