mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-07 03:15:32 +00:00
added sun rendering (unfinished)
This commit is contained in:
parent
705d85e7d1
commit
c884f70a61
1 changed files with 29 additions and 0 deletions
|
@ -70,6 +70,35 @@ namespace MWRender
|
||||||
clouds_node->attachObject(clouds_ent);
|
clouds_node->attachObject(clouds_ent);
|
||||||
mCloudMaterial = clouds_ent->getSubEntity(0)->getMaterial();
|
mCloudMaterial = clouds_ent->getSubEntity(0)->getMaterial();
|
||||||
|
|
||||||
|
// Sun
|
||||||
|
/// \todo calculate the sun position based on time of day
|
||||||
|
Vector3 sunPosition(0, 0, 1.f);
|
||||||
|
|
||||||
|
// this distance has to be set accordingly so that the sun is
|
||||||
|
// behind the clouds, but still in front of the atmosphere
|
||||||
|
const float sunDistance = 1000.f;
|
||||||
|
|
||||||
|
const float sunScale = 700.f;
|
||||||
|
|
||||||
|
Vector3 finalPosition = sunPosition.normalisedCopy() * sunDistance;
|
||||||
|
|
||||||
|
// Create a camera-aligned billboard to render the sun
|
||||||
|
BillboardSet* bbSet = mSceneMgr->createBillboardSet("SkyBillboardSet", 1);
|
||||||
|
bbSet->setDefaultDimensions(sunScale, sunScale);
|
||||||
|
bbSet->setRenderQueueGroup(RENDER_QUEUE_SKIES_EARLY);
|
||||||
|
SceneNode* bbNode = mRootNode->createChildSceneNode();
|
||||||
|
bbNode->translate(finalPosition);
|
||||||
|
bbNode->attachObject(bbSet);
|
||||||
|
bbSet->createBillboard(0,0,0);
|
||||||
|
|
||||||
|
MaterialPtr sunMaterial = MaterialManager::getSingleton().create("SunMaterial", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
|
||||||
|
sunMaterial->removeAllTechniques();
|
||||||
|
Pass* p = sunMaterial->createTechnique()->createPass();
|
||||||
|
p->setSceneBlending(SBT_TRANSPARENT_ALPHA);
|
||||||
|
p->setDepthWriteEnabled(false);
|
||||||
|
TextureUnitState* tus = p->createTextureUnitState("textures\\tx_sun_05.dds");
|
||||||
|
bbSet->setMaterialName("SunMaterial");
|
||||||
|
|
||||||
// I'm not sure if the materials are being used by any other objects
|
// I'm not sure if the materials are being used by any other objects
|
||||||
// Make a unique "modifiable" copy of the materials to be sure
|
// Make a unique "modifiable" copy of the materials to be sure
|
||||||
mCloudMaterial = mCloudMaterial->clone("Clouds");
|
mCloudMaterial = mCloudMaterial->clone("Clouds");
|
||||||
|
|
Loading…
Reference in a new issue