Archive 17/01/2023.

Skybox generator for space

ab4daa

Reproduced the generator of space-3d. (its repo)

Urho3D version

I made a SpaceBoxGen class to help generate texturecube.
E_SPACEBOXGEN event will send parameters of sun, maybe can use them to setup directional light.
The RTT scene in SpaceBoxGen will be destroyed in E_ENDFRAME.


{
  SubscribeToEvent(E_SPACEBOXGEN, URHO3D_HANDLER(RenderToTexture, ChangeLight));
  Node * space = scene_->CreateChild("Space Box");
  space->SetScale(500.0f); // The scale actually does not matter
  auto* spacebox = space->CreateComponent<Skybox>();
  spacebox->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
  SharedPtr<Material> space_mat = MakeShared<Material>(GetContext());
  space_mat->SetCullMode(CULL_NONE);
  space_mat->SetNumTechniques(1);
  space_mat->SetTechnique(0, cache->GetResource<Technique>("Techniques/DiffSkybox.xml"), QUALITY_MAX);
  gen = MakeShared<SpaceBoxGen>(context_);
  space_mat->SetTexture(TU_DIFFUSE, gen->SpaceCube);
  gen->Generate();
  spacebox->SetMaterial(space_mat);
}

Maybe it’s not as epic as recent games, it’s already too good to keep consistency with my other self-made assets :\