Port god ray to use SP
This commit is contained in:
parent
1400257a60
commit
345f2bc64b
@ -36,6 +36,7 @@
|
||||
#include "graphics/shaders.hpp"
|
||||
#include "graphics/sp_mesh_loader.hpp"
|
||||
#include "graphics/sp/sp_base.hpp"
|
||||
#include "graphics/sp/sp_dynamic_draw_call.hpp"
|
||||
#include "graphics/sp/sp_mesh.hpp"
|
||||
#include "graphics/sp/sp_mesh_node.hpp"
|
||||
#include "graphics/sp/sp_texture_manager.hpp"
|
||||
@ -63,6 +64,7 @@
|
||||
#include "states_screens/dialogs/confirm_resolution_dialog.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "utils/constants.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/profiler.hpp"
|
||||
@ -141,6 +143,7 @@ IrrDriver::IrrDriver()
|
||||
m_clear_color = video::SColor(255, 100, 101, 140);
|
||||
m_skinning_joint = 0;
|
||||
m_recording = false;
|
||||
m_sun_interposer = NULL;
|
||||
|
||||
} // IrrDriver
|
||||
|
||||
@ -678,6 +681,7 @@ void IrrDriver::setMaxTextureSize()
|
||||
void IrrDriver::cleanSunInterposer()
|
||||
{
|
||||
delete m_sun_interposer;
|
||||
m_sun_interposer = NULL;
|
||||
} // cleanSunInterposer
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -685,32 +689,33 @@ void IrrDriver::createSunInterposer()
|
||||
{
|
||||
#ifndef SERVER_ONLY
|
||||
scene::IMesh * sphere = m_scene_manager->getGeometryCreator()
|
||||
->createSphereMesh(1, 16, 16);
|
||||
for (unsigned i = 0; i < sphere->getMeshBufferCount(); ++i)
|
||||
->createSphereMesh(1, 16, 16);
|
||||
Material* material = material_manager->getSPMaterial("solid");
|
||||
m_sun_interposer = new SP::SPDynamicDrawCall
|
||||
(scene::EPT_TRIANGLES, NULL/*shader*/, material);
|
||||
for (unsigned i = 0; i < sphere->getMeshBufferCount(); i++)
|
||||
{
|
||||
scene::IMeshBuffer *mb = sphere->getMeshBuffer(i);
|
||||
scene::IMeshBuffer* mb = sphere->getMeshBuffer(i);
|
||||
if (!mb)
|
||||
{
|
||||
continue;
|
||||
mb->getMaterial().setTexture(0,
|
||||
STKTexManager::getInstance()->getUnicolorTexture(video::SColor(255, 255, 255, 255)));
|
||||
mb->getMaterial().setTexture(1,
|
||||
STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
|
||||
mb->getMaterial().setTexture(2,
|
||||
STKTexManager::getInstance()->getUnicolorTexture(video::SColor(0, 0, 0, 0)));
|
||||
}
|
||||
assert(mb->getVertexType() == video::EVT_STANDARD);
|
||||
video::S3DVertex* v_ptr = (video::S3DVertex*)mb->getVertices();
|
||||
uint16_t* idx_ptr = mb->getIndices();
|
||||
for (unsigned j = 0; j < mb->getIndexCount(); j++)
|
||||
{
|
||||
// For sun interposer we only need position for glow shader
|
||||
video::S3DVertexSkinnedMesh sp;
|
||||
const unsigned v_idx = idx_ptr[j];
|
||||
sp.m_position = v_ptr[v_idx].Pos;
|
||||
m_sun_interposer->addSPMVertex(sp);
|
||||
}
|
||||
}
|
||||
m_sun_interposer = new STKMeshSceneNode(sphere,
|
||||
m_scene_manager->getRootSceneNode(),
|
||||
NULL, -1, "sun_interposer");
|
||||
|
||||
m_sun_interposer->grab();
|
||||
m_sun_interposer->setParent(NULL);
|
||||
m_sun_interposer->recalculateBoundingBox();
|
||||
m_sun_interposer->setPosition(Track::getCurrentTrack()
|
||||
->getGodRaysPosition());
|
||||
m_sun_interposer->setScale(core::vector3df(20));
|
||||
|
||||
m_sun_interposer->getMaterial(0).Lighting = false;
|
||||
m_sun_interposer->getMaterial(0).ColorMask = video::ECP_NONE;
|
||||
m_sun_interposer->getMaterial(0).ZWriteEnable = false;
|
||||
m_sun_interposer->getMaterial(0).MaterialType = Shaders::getShader(ES_OBJECTPASS);
|
||||
|
||||
sphere->drop();
|
||||
#endif
|
||||
}
|
||||
|
@ -50,6 +50,12 @@
|
||||
#endif
|
||||
|
||||
|
||||
namespace SP
|
||||
{
|
||||
class SPDynamicDrawCall;
|
||||
}
|
||||
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene { class ISceneManager; class IMesh; class IAnimatedMeshSceneNode; class IAnimatedMesh;
|
||||
@ -170,7 +176,7 @@ private:
|
||||
unsigned m_last_light_bucket_distance;
|
||||
unsigned m_skinning_joint;
|
||||
u32 m_renderpass;
|
||||
class STKMeshSceneNode *m_sun_interposer;
|
||||
SP::SPDynamicDrawCall* m_sun_interposer;
|
||||
core::vector3df m_sun_direction;
|
||||
video::SColorf m_suncolor;
|
||||
|
||||
@ -462,7 +468,7 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
void clearLights();
|
||||
// ------------------------------------------------------------------------
|
||||
class STKMeshSceneNode *getSunInterposer() { return m_sun_interposer; }
|
||||
SP::SPDynamicDrawCall* getSunInterposer() { return m_sun_interposer; }
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
void cleanSunInterposer();
|
||||
|
@ -31,10 +31,12 @@
|
||||
#include "graphics/rtts.hpp"
|
||||
#include "graphics/shaders.hpp"
|
||||
#include "graphics/shared_gpu_objects.hpp"
|
||||
#include "graphics/stk_mesh_scene_node.hpp"
|
||||
#include "graphics/stk_texture.hpp"
|
||||
#include "graphics/stk_tex_manager.hpp"
|
||||
#include "graphics/weather.hpp"
|
||||
#include "graphics/sp/sp_dynamic_draw_call.hpp"
|
||||
#include "graphics/sp/sp_shader.hpp"
|
||||
#include "graphics/sp/sp_uniform_assigner.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "karts/abstract_kart.hpp"
|
||||
#include "karts/kart_model.hpp"
|
||||
@ -1316,12 +1318,17 @@ void PostProcessing::renderGodRays(scene::ICameraSceneNode * const camnode,
|
||||
const SColor col = track->getGodRaysColor();
|
||||
|
||||
// The sun interposer
|
||||
STKMeshSceneNode *sun = irr_driver->getSunInterposer();
|
||||
sun->setGlowColors(col);
|
||||
sun->setPosition(track->getGodRaysPosition());
|
||||
sun->updateAbsolutePosition();
|
||||
irr_driver->setPhase(GLOW_PASS);
|
||||
sun->render();
|
||||
SP::SPDynamicDrawCall* sun = irr_driver->getSunInterposer();
|
||||
// This will only do thing when you update the sun position
|
||||
sun->uploadInstanceData();
|
||||
SP::SPShader* glow_shader = SP::getGlowShader();
|
||||
glow_shader->use();
|
||||
SP::SPUniformAssigner* glow_color_assigner = glow_shader
|
||||
->getUniformAssigner("col");
|
||||
assert(glow_color_assigner != NULL);
|
||||
glow_color_assigner->setValue(video::SColorf(track->getGodRaysColor()));
|
||||
sun->draw();
|
||||
glow_shader->unuse();
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
// Fade to quarter
|
||||
|
@ -1808,6 +1808,7 @@ void addDynamicDrawCall(std::shared_ptr<SPDynamicDrawCall> dy_dc)
|
||||
{
|
||||
g_dy_dc.push_back(dy_dc);
|
||||
} // addDynamicDrawCall
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
SPMesh* convertEVTStandard(irr::scene::IMesh* mesh,
|
||||
const irr::video::SColor* color)
|
||||
@ -1818,6 +1819,10 @@ SPMesh* convertEVTStandard(irr::scene::IMesh* mesh,
|
||||
{
|
||||
std::vector<video::S3DVertexSkinnedMesh> vertices;
|
||||
scene::IMeshBuffer* mb = mesh->getMeshBuffer(i);
|
||||
if (!mb)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
assert(mb->getVertexType() == video::EVT_STANDARD);
|
||||
video::S3DVertex* v_ptr = (video::S3DVertex*)mb->getVertices();
|
||||
for (unsigned j = 0; j < mb->getVertexCount(); j++)
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
~SPDynamicDrawCall() {}
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void draw(DrawCallType dct, int material_id = -1,
|
||||
virtual void draw(DrawCallType dct = DCT_NORMAL, int material_id = -1,
|
||||
bool bindless_texture = false) const
|
||||
{
|
||||
#ifndef SERVER_ONLY
|
||||
|
@ -109,7 +109,7 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
~SPMeshBuffer();
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void draw(DrawCallType dct, int material_id = -1,
|
||||
virtual void draw(DrawCallType dct = DCT_NORMAL, int material_id = -1,
|
||||
bool bindless_texture = false) const
|
||||
{
|
||||
glBindVertexArray(m_vao[dct]);
|
||||
|
Loading…
Reference in New Issue
Block a user