Merge remote-tracking branch 'origin/master' into BoxModelCollision
This commit is contained in:
@@ -45,7 +45,7 @@ void InputProxy::Update(double dt)
|
||||
}
|
||||
}
|
||||
|
||||
void InputProxy::Process()
|
||||
void InputProxy::Process(bool suppressNewEvents /*= false*/)
|
||||
{
|
||||
for (auto& pair : m_CommandHandlers) {
|
||||
const std::string& command = pair.first;
|
||||
@@ -62,8 +62,10 @@ void InputProxy::Process()
|
||||
e.PlayerID = -1;
|
||||
e.Command = command;
|
||||
e.Value = currentValue;
|
||||
m_EventBroker->Publish(e);
|
||||
//LOG_DEBUG("Input: Published command %s=%f for player %i", e.Command.c_str(), e.Value, e.PlayerID);
|
||||
if (!suppressNewEvents || e.Value == 0) {
|
||||
m_EventBroker->Publish(e);
|
||||
//LOG_DEBUG("Input: Published command %s=%f for player %i", e.Command.c_str(), e.Value, e.PlayerID);
|
||||
}
|
||||
m_LastCommandValues[command] = currentValue;
|
||||
}
|
||||
}
|
||||
@@ -78,8 +80,10 @@ void InputProxy::Process()
|
||||
e.Value += value;
|
||||
}
|
||||
//e.Value = std::max(-1.f, std::min(e.Value, 1.f));
|
||||
m_EventBroker->Publish(e);
|
||||
//LOG_DEBUG("Input: Published command %s=%f for player %i", e.Command.c_str(), e.Value, e.PlayerID);
|
||||
if (!suppressNewEvents || e.Value == 0) {
|
||||
m_EventBroker->Publish(e);
|
||||
//LOG_DEBUG("Input: Published command %s=%f for player %i", e.Command.c_str(), e.Value, e.PlayerID);
|
||||
}
|
||||
}
|
||||
m_CommandQueue.clear();
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ void Client::Connect(std::string address, int port)
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &Client::OnDoubleJump);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EDashAbility, &Client::OnDashAbility);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ESearchForServers, &Client::OnSearchForServers);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EConnectRequest, &Client::OnConnectRequest);
|
||||
auto config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||
m_Address = address;
|
||||
if (address.empty()) {
|
||||
@@ -180,8 +181,8 @@ void Client::parseTCPConnect(Packet& packet)
|
||||
Packet UnreliablePacket(MessageType::Connect, m_SendPacketID);
|
||||
// Add player id and other stuff
|
||||
packet.WritePrimitive(m_PlayerID);
|
||||
// m_Unreliable.Send(packet);
|
||||
// LOG_INFO("Sent UDP Connect Server");
|
||||
// m_Unreliable.Send(packet);
|
||||
// LOG_INFO("Sent UDP Connect Server");
|
||||
}
|
||||
|
||||
void Client::parsePlayerConnected(Packet & packet)
|
||||
@@ -456,12 +457,14 @@ void Client::parseSnapshot(Packet& packet)
|
||||
|
||||
void Client::disconnect()
|
||||
{
|
||||
removeWorld();
|
||||
m_IsConnected = false;
|
||||
m_PreviousPacketID = 0;
|
||||
m_PacketID = 0;
|
||||
Packet packet(MessageType::Disconnect, m_SendPacketID);
|
||||
m_Reliable.Send(packet);
|
||||
m_Reliable.Disconnect();
|
||||
createMainMenu();
|
||||
}
|
||||
|
||||
bool Client::OnInputCommand(const Events::InputCommand & e)
|
||||
@@ -472,7 +475,7 @@ bool Client::OnInputCommand(const Events::InputCommand & e)
|
||||
|
||||
if (e.Command == "ConnectToServer") { // Connect for now
|
||||
if (e.Value > 0) {
|
||||
m_Reliable.Connect(m_PlayerName, m_Address, m_Port);
|
||||
//m_Reliable.Connect(m_PlayerName, m_Address, m_Port);
|
||||
// m_Unreliable.Connect(m_PlayerName, m_Address, m_Port);
|
||||
}
|
||||
//LOG_DEBUG("Client::OnInputCommand: Command is %s. Value is %f. PlayerID is %i.", e.Command.c_str(), e.Value, e.PlayerID);
|
||||
@@ -545,6 +548,23 @@ bool Client::OnDashAbility(const Events::DashAbility& e)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Client::OnConnectRequest(const Events::ConnectRequest& e)
|
||||
{
|
||||
removeWorld();
|
||||
if (m_Reliable.Connect(m_PlayerName, e.IP, e.Port)) {
|
||||
// The client sent a successful connect message
|
||||
return true;
|
||||
|
||||
} else {
|
||||
// The client could not send a successful connect message
|
||||
createMainMenu();
|
||||
// Load the main menu again ?
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Client::OnSearchForServers(const Events::SearchForServers& e)
|
||||
{
|
||||
m_SearchingForServers = true;
|
||||
@@ -671,6 +691,26 @@ void Client::displayServerlist()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Client::removeWorld()
|
||||
{
|
||||
std::vector<EntityID> childrenToBeDeleted;
|
||||
auto rootEntites = m_World->GetDirectChildren(EntityID_Invalid);
|
||||
for (auto it = rootEntites.first; it != rootEntites.second; it++) {
|
||||
childrenToBeDeleted.push_back(it->second);
|
||||
}
|
||||
for (int i = 0; i < childrenToBeDeleted.size(); ++i) {
|
||||
m_World->DeleteEntity(childrenToBeDeleted[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Client::createMainMenu()
|
||||
{
|
||||
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/StartMenu.xml");
|
||||
entityFile->MergeInto(m_World);
|
||||
}
|
||||
|
||||
bool Client::clientServerMapsHasEntity(EntityID clientEntityID)
|
||||
{
|
||||
if (m_ClientIDToServerID.find(clientEntityID) != m_ClientIDToServerID.end()) {
|
||||
|
||||
@@ -7,6 +7,8 @@ Server::Server(World* world, EventBroker* eventBroker, int port)
|
||||
ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||
snapshotInterval = 1000 * config->Get<float>("Networking.SnapshotInterval", 0.05f);
|
||||
pingIntervalMs = config->Get<float>("Networking.PingIntervalMs", 1000);
|
||||
m_ServerName = config->Get<std::string>("Networking.Name", "Unnamed");
|
||||
|
||||
// Subscribe to events
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Server::OnInputCommand);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &Server::OnPlayerSpawned);
|
||||
@@ -410,7 +412,7 @@ void Server::parseServerlistRequest(boost::asio::ip::udp::endpoint endpoint)
|
||||
Packet packet(MessageType::ServerlistRequest);
|
||||
packet.WriteString(m_Reliable.Address());
|
||||
packet.WritePrimitive<int>(m_Reliable.Port());
|
||||
packet.WriteString("SERVERNAME");
|
||||
packet.WriteString(m_ServerName);
|
||||
packet.WritePrimitive<int>(m_ConnectedPlayers.size());
|
||||
m_ServerlistRequest.Send(packet);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ TCPClient::~TCPClient()
|
||||
{
|
||||
}
|
||||
|
||||
void TCPClient::Connect(std::string playerName, std::string address, int port)
|
||||
bool TCPClient::Connect(std::string playerName, std::string address, int port)
|
||||
{
|
||||
if (m_Socket) {
|
||||
if (m_IsConnected) {
|
||||
@@ -19,6 +19,7 @@ void TCPClient::Connect(std::string playerName, std::string address, int port)
|
||||
Send(packet);
|
||||
LOG_INFO("Connect message sent again!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (!m_IsConnected) {
|
||||
boost::system::error_code error = boost::asio::error::host_not_found;
|
||||
@@ -34,11 +35,13 @@ void TCPClient::Connect(std::string playerName, std::string address, int port)
|
||||
packet.WriteString(playerName);
|
||||
Send(packet);
|
||||
LOG_INFO("Connect message sent!");
|
||||
return true;
|
||||
}
|
||||
// If error
|
||||
else {
|
||||
m_Socket->close();
|
||||
m_Socket = nullptr;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,14 +10,15 @@ UDPClient::~UDPClient()
|
||||
{
|
||||
}
|
||||
|
||||
void UDPClient::Connect(std::string playerName, std::string address, int port)
|
||||
bool UDPClient::Connect(std::string playerName, std::string address, int port)
|
||||
{
|
||||
if (m_Socket) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
m_ReceiverEndpoint = udp::endpoint(boost::asio::ip::address().from_string(address), port);
|
||||
m_Socket = boost::shared_ptr<boost::asio::ip::udp::socket>(new boost::asio::ip::udp::socket(m_IOService));
|
||||
m_Socket->open(boost::asio::ip::udp::v4());
|
||||
return true;
|
||||
}
|
||||
|
||||
void UDPClient::Disconnect()
|
||||
|
||||
@@ -10,7 +10,7 @@ BlurHUD::BlurHUD(IRenderer* renderer)
|
||||
|
||||
void BlurHUD::InitializeTextures()
|
||||
{
|
||||
m_BlackTexture = CommonFunctions::LoadTexture("Textures/Core/Black.png", false);
|
||||
m_BlackTexture = CommonFunctions::TryLoadResource<Texture, false>("Textures/Core/Black.png");
|
||||
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh");
|
||||
}
|
||||
|
||||
|
||||
@@ -50,13 +50,15 @@ void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapp
|
||||
glm::vec4 perspective;
|
||||
glm::decompose(boneTransform, scale, rotation, translation, skew, perspective);
|
||||
|
||||
glm::vec3 angles = glm::vec3(-glm::pitch(rotation), -glm::yaw(rotation), -glm::roll(rotation));
|
||||
rotation = glm::quat((glm::vec3)entity["BoneAttachment"]["OrientationOffset"]) * rotation;
|
||||
rotation = glm::inverse(rotation);
|
||||
glm::vec3 angles = glm::eulerAngles(rotation);
|
||||
|
||||
if ((bool)entity["BoneAttachment"]["InheritPosition"]) {
|
||||
(glm::vec3&)entity["Transform"]["Position"] = translation + (glm::vec3)entity["BoneAttachment"]["PositionOffset"];
|
||||
}
|
||||
if ((bool)entity["BoneAttachment"]["InheritOrientation"]) {
|
||||
(glm::vec3&)entity["Transform"]["Orientation"] = angles + (glm::vec3)entity["BoneAttachment"]["OrientationOffset"];
|
||||
(glm::vec3&)entity["Transform"]["Orientation"] = angles;
|
||||
}
|
||||
if ((bool)entity["BoneAttachment"]["InheritScale"]) {
|
||||
(glm::vec3&)entity["Transform"]["Scale"] = scale * (glm::vec3)entity["BoneAttachment"]["ScaleOffset"];
|
||||
|
||||
@@ -9,9 +9,14 @@ DrawBloomPass::DrawBloomPass(IRenderer* renderer, ConfigFile* config)
|
||||
ChangeQuality(m_Config->Get<int>("GLOW.Quality", 2));
|
||||
}
|
||||
|
||||
DrawBloomPass::~DrawBloomPass() {
|
||||
CommonFunctions::DeleteTexture(&m_GaussianTexture_horiz);
|
||||
CommonFunctions::DeleteTexture(&m_GaussianTexture_vert);
|
||||
}
|
||||
|
||||
void DrawBloomPass::InitializeTextures()
|
||||
{
|
||||
m_BlackTexture = CommonFunctions::LoadTexture("Textures/Core/Black.png", false);
|
||||
m_BlackTexture = CommonFunctions::TryLoadResource<Texture, false>("Textures/Core/Black.png");
|
||||
}
|
||||
|
||||
void DrawBloomPass::ChangeQuality(int quality)
|
||||
|
||||
@@ -12,13 +12,21 @@ DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCulling
|
||||
InitializeFrameBuffers();
|
||||
}
|
||||
|
||||
DrawFinalPass::~DrawFinalPass(){
|
||||
CommonFunctions::DeleteTexture(&m_BloomTexture);
|
||||
CommonFunctions::DeleteTexture(&m_SceneTexture);
|
||||
CommonFunctions::DeleteTexture(&m_DepthBuffer);
|
||||
CommonFunctions::DeleteTexture(&m_ShieldBuffer);
|
||||
CommonFunctions::DeleteTexture(&m_CubeMapTexture);
|
||||
}
|
||||
|
||||
void DrawFinalPass::InitializeTextures()
|
||||
{
|
||||
m_WhiteTexture = CommonFunctions::LoadTexture("Textures/Core/White.png", false);
|
||||
m_BlackTexture = CommonFunctions::LoadTexture("Textures/Core/Black.png", false);
|
||||
m_NeutralNormalTexture = CommonFunctions::LoadTexture("Textures/Core/NeutralNormalMap.png", false);
|
||||
m_GreyTexture = CommonFunctions::LoadTexture("Textures/Core/Grey.png", false);
|
||||
m_ErrorTexture = CommonFunctions::LoadTexture("Textures/Core/ErrorTexture.png", false);
|
||||
m_WhiteTexture = CommonFunctions::TryLoadResource<Texture, false>("Textures/Core/White.png");
|
||||
m_BlackTexture = CommonFunctions::TryLoadResource<Texture, false>("Textures/Core/Black.png");
|
||||
m_NeutralNormalTexture = CommonFunctions::TryLoadResource<Texture, false>("Textures/Core/NeutralNormalMap.png");
|
||||
m_GreyTexture = CommonFunctions::TryLoadResource<Texture, false>("Textures/Core/Grey.png");
|
||||
m_ErrorTexture = CommonFunctions::TryLoadResource<Texture, false>("Textures/Core/ErrorTexture.png");
|
||||
}
|
||||
|
||||
void DrawFinalPass::InitializeFrameBuffers()
|
||||
@@ -351,6 +359,8 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
||||
GLuint explosionSkinnedHandle = m_ExplosionEffectSkinnedProgram->GetHandle();
|
||||
GLuint explosionSplatMapSkinnedHandle = m_ExplosionEffectSplatMapSkinnedProgram->GetHandle();
|
||||
GLuint forwardSplatMapSkinnedHandle = m_ForwardPlusSplatMapSkinnedProgram->GetHandle();
|
||||
GLuint lastShader = 0;
|
||||
unsigned int lastModel = 0;
|
||||
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO());
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO());
|
||||
@@ -367,9 +377,17 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
||||
case RawModel::MaterialType::SingleTextures:
|
||||
{
|
||||
if (explosionEffectJob->Model->IsSkinned()) {
|
||||
|
||||
m_ExplosionEffectSkinnedProgram->Bind();
|
||||
GLERROR("Bind ExplosionEffectSkinned program");
|
||||
if (lastShader != m_ExplosionEffectSkinnedProgram->GetHandle()) {
|
||||
m_ExplosionEffectSkinnedProgram->Bind();
|
||||
lastShader = m_ExplosionEffectSkinnedProgram->GetHandle();
|
||||
GLERROR("Bind ExplosionEffectSkinned program");
|
||||
glUniform1i(glGetUniformLocation(explosionSkinnedHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(explosionSkinnedHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(explosionSkinnedHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind ExplosionEffectSkinned Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindExplosionUniforms(explosionSkinnedHandle, explosionEffectJob, scene);
|
||||
//bind textures
|
||||
@@ -389,8 +407,17 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
||||
|
||||
}
|
||||
else {
|
||||
m_ExplosionEffectProgram->Bind();
|
||||
GLERROR("Bind ExplosionEffect program");
|
||||
if (lastShader != m_ExplosionEffectProgram->GetHandle()) {
|
||||
m_ExplosionEffectProgram->Bind();
|
||||
lastShader = m_ExplosionEffectProgram->GetHandle();
|
||||
GLERROR("Bind ExplosionEffect program");
|
||||
glUniform1i(glGetUniformLocation(explosionHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(explosionHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(explosionHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind ExplosionEffect Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindExplosionUniforms(explosionHandle, explosionEffectJob, scene);
|
||||
//bind textures
|
||||
@@ -404,8 +431,17 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
||||
case RawModel::MaterialType::SplatMapping:
|
||||
{
|
||||
if (explosionEffectJob->Model->IsSkinned()) {
|
||||
m_ExplosionEffectSplatMapSkinnedProgram->Bind();
|
||||
GLERROR("Bind ExplosionEffectSplatMapSkinned program");
|
||||
if (lastShader != m_ExplosionEffectSplatMapSkinnedProgram->GetHandle()) {
|
||||
m_ExplosionEffectSplatMapSkinnedProgram->Bind();
|
||||
lastShader = m_ExplosionEffectSplatMapSkinnedProgram->GetHandle();
|
||||
GLERROR("Bind ExplosionEffectSplatMapSkinned program");
|
||||
glUniform1i(glGetUniformLocation(explosionSplatMapSkinnedHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(explosionSplatMapSkinnedHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind ExplosionEffectSplatMapSkinned Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindExplosionUniforms(explosionSplatMapSkinnedHandle, explosionEffectJob, scene);
|
||||
//bind textures
|
||||
@@ -421,9 +457,17 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
||||
|
||||
}
|
||||
else {
|
||||
m_ExplosionEffectSplatMapProgram->Bind();
|
||||
GLERROR("Bind ExplosionEffectSplatMap program");
|
||||
//bind uniforms
|
||||
if (lastShader != m_ExplosionEffectSplatMapProgram->GetHandle()) {
|
||||
m_ExplosionEffectSplatMapProgram->Bind();
|
||||
lastShader = m_ExplosionEffectSplatMapProgram->GetHandle();
|
||||
GLERROR("Bind ExplosionEffectSplatMap program");
|
||||
glUniform1i(glGetUniformLocation(explosionSplatMapHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(explosionSplatMapHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(explosionSplatMapHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind ExplosionEffectSplatMap Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindExplosionUniforms(explosionSplatMapHandle, explosionEffectJob, scene);
|
||||
//bind textures
|
||||
@@ -436,8 +480,11 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
//draw
|
||||
glBindVertexArray(explosionEffectJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, explosionEffectJob->Model->ElementBuffer);
|
||||
if (lastModel != explosionEffectJob->ModelID) {
|
||||
glBindVertexArray(explosionEffectJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, explosionEffectJob->Model->ElementBuffer);
|
||||
lastModel = explosionEffectJob->ModelID;
|
||||
}
|
||||
glDrawElements(GL_TRIANGLES, explosionEffectJob->EndIndex - explosionEffectJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(explosionEffectJob->StartIndex*sizeof(unsigned int)));
|
||||
glEnable(GL_CULL_FACE);
|
||||
GLERROR("explosion effect end");
|
||||
@@ -451,8 +498,17 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
||||
case RawModel::MaterialType::SingleTextures:
|
||||
{
|
||||
if (modelJob->Model->IsSkinned()) {
|
||||
m_ForwardPlusSkinnedProgram->Bind();
|
||||
GLERROR("Bind ForwardPlusSkinnedProgram");
|
||||
if (lastShader != m_ForwardPlusSkinnedProgram->GetHandle()) {
|
||||
m_ForwardPlusSkinnedProgram->Bind();
|
||||
lastShader = m_ForwardPlusSkinnedProgram->GetHandle();
|
||||
GLERROR("Bind ForwardPlusSkinnedProgram program");
|
||||
glUniform1i(glGetUniformLocation(forwardSkinnedHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(forwardSkinnedHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(forwardSkinnedHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind ForwardPlusSkinnedProgram Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindModelUniforms(forwardSkinnedHandle, modelJob, scene);
|
||||
//bind textures
|
||||
@@ -470,8 +526,17 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||
}
|
||||
else {
|
||||
m_ForwardPlusProgram->Bind();
|
||||
GLERROR("Bind ForwardPlusProgram");
|
||||
if (lastShader != m_ForwardPlusProgram->GetHandle()) {
|
||||
m_ForwardPlusProgram->Bind();
|
||||
lastShader = m_ForwardPlusProgram->GetHandle();
|
||||
GLERROR("Bind ForwardPlusProgram program");
|
||||
glUniform1i(glGetUniformLocation(forwardHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(forwardHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(forwardHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind ForwardPlusProgram Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindModelUniforms(forwardHandle, modelJob, scene);
|
||||
//bind textures
|
||||
@@ -485,8 +550,17 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
||||
case RawModel::MaterialType::SplatMapping:
|
||||
{
|
||||
if (modelJob->Model->IsSkinned()) {
|
||||
m_ForwardPlusSplatMapSkinnedProgram->Bind();
|
||||
GLERROR("Bind SplatMap program");
|
||||
if (lastShader != m_ForwardPlusSplatMapSkinnedProgram->GetHandle()) {
|
||||
m_ForwardPlusSplatMapSkinnedProgram->Bind();
|
||||
lastShader = m_ForwardPlusSplatMapSkinnedProgram->GetHandle();
|
||||
GLERROR("Bind SkinnedSplatMapProgram program");
|
||||
glUniform1i(glGetUniformLocation(forwardSplatMapSkinnedHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(forwardSplatMapSkinnedHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind SkinnedSplatMapProgram Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindModelUniforms(forwardSplatMapSkinnedHandle, modelJob, scene);
|
||||
//bind textures
|
||||
@@ -502,8 +576,17 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
||||
|
||||
}
|
||||
else {
|
||||
m_ForwardPlusSplatMapProgram->Bind();
|
||||
GLERROR("Bind SplatMap program");
|
||||
if (lastShader != m_ForwardPlusSplatMapProgram->GetHandle()) {
|
||||
m_ForwardPlusSplatMapProgram->Bind();
|
||||
lastShader = m_ForwardPlusSplatMapProgram->GetHandle();
|
||||
GLERROR("Bind SplatMap program");
|
||||
glUniform1i(glGetUniformLocation(forwardSplatMapHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(forwardSplatMapHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(forwardSplatMapHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind SplatMap Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindModelUniforms(forwardSplatMapHandle, modelJob, scene);
|
||||
//bind textures
|
||||
@@ -514,8 +597,11 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
||||
}
|
||||
}
|
||||
//draw
|
||||
glBindVertexArray(modelJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||
if (lastModel != modelJob->ModelID) {
|
||||
glBindVertexArray(modelJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||
lastModel = modelJob->ModelID;
|
||||
}
|
||||
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex*sizeof(unsigned int)));
|
||||
if (GLERROR("models end")) {
|
||||
continue;
|
||||
@@ -544,6 +630,8 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
||||
GLuint explosionSkinnedShieldCheckHandle = m_ExplosionEffectSkinnedShieldCheckProgram->GetHandle();
|
||||
GLuint explosionSplatMapSkinnedShieldCheckHandle = m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->GetHandle();
|
||||
GLuint forwardSplatMapSkinnedShieldCheckHandle = m_ForwardPlusSplatMapSkinnedShieldCheckProgram->GetHandle();
|
||||
GLuint lastShader = 0;
|
||||
unsigned int lastModel = 0;
|
||||
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO());
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO());
|
||||
@@ -564,9 +652,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
||||
case RawModel::MaterialType::SingleTextures:
|
||||
{
|
||||
if (explosionEffectJob->Model->IsSkinned()) {
|
||||
|
||||
m_ExplosionEffectSkinnedShieldCheckProgram->Bind();
|
||||
GLERROR("Bind ExplosionEffectSkinned program");
|
||||
if (lastShader != m_ExplosionEffectSkinnedShieldCheckProgram->GetHandle()) {
|
||||
m_ExplosionEffectSkinnedShieldCheckProgram->Bind();
|
||||
lastShader = m_ExplosionEffectSkinnedShieldCheckProgram->GetHandle();
|
||||
GLERROR("Bind ExplosionEffectSkinned program");
|
||||
glUniform1i(glGetUniformLocation(explosionSkinnedShieldCheckHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedShieldCheckHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedShieldCheckHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(explosionSkinnedShieldCheckHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(explosionSkinnedShieldCheckHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind ExplosionEffectSkinned Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindExplosionUniforms(explosionSkinnedShieldCheckHandle, explosionEffectJob, scene);
|
||||
//bind textures
|
||||
@@ -585,8 +681,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
||||
|
||||
}
|
||||
else {
|
||||
m_ExplosionEffectShieldCheckProgram->Bind();
|
||||
GLERROR("Bind ExplosionEffect program");
|
||||
if (lastShader != m_ExplosionEffectShieldCheckProgram->GetHandle()) {
|
||||
m_ExplosionEffectShieldCheckProgram->Bind();
|
||||
lastShader = m_ExplosionEffectShieldCheckProgram->GetHandle();
|
||||
GLERROR("Bind ExplosionEffect program");
|
||||
glUniform1i(glGetUniformLocation(explosionShieldCheckHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionShieldCheckHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionShieldCheckHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(explosionShieldCheckHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(explosionShieldCheckHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind ExplosionEffect Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindExplosionUniforms(explosionShieldCheckHandle, explosionEffectJob, scene);
|
||||
//bind textures
|
||||
@@ -601,8 +706,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
||||
case RawModel::MaterialType::SplatMapping:
|
||||
{
|
||||
if (explosionEffectJob->Model->IsSkinned()) {
|
||||
m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->Bind();
|
||||
GLERROR("Bind ExplosionEffectSplatMapSkinned program");
|
||||
if (lastShader != m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->GetHandle()) {
|
||||
m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->Bind();
|
||||
lastShader = m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->GetHandle();
|
||||
GLERROR("Bind ExplosionEffectSplatMapSkinned program");
|
||||
glUniform1i(glGetUniformLocation(explosionSplatMapSkinnedShieldCheckHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedShieldCheckHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedShieldCheckHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(explosionSplatMapSkinnedShieldCheckHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(explosionSplatMapSkinnedShieldCheckHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind ExplosionEffectSplatMapSkinned Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindExplosionUniforms(explosionSplatMapSkinnedShieldCheckHandle, explosionEffectJob, scene);
|
||||
//bind textures
|
||||
@@ -619,9 +733,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
||||
|
||||
}
|
||||
else {
|
||||
m_ExplosionEffectSplatMapShieldCheckProgram->Bind();
|
||||
GLERROR("Bind ExplosionEffectSplatMap program");
|
||||
//bind uniforms
|
||||
if (lastShader != m_ExplosionEffectSplatMapShieldCheckProgram->GetHandle()) {
|
||||
m_ExplosionEffectSplatMapShieldCheckProgram->Bind();
|
||||
lastShader = m_ExplosionEffectSplatMapShieldCheckProgram->GetHandle();
|
||||
GLERROR("Bind ExplosionEffectSplatMap program");
|
||||
glUniform1i(glGetUniformLocation(explosionSplatMapShieldCheckHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapShieldCheckHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapShieldCheckHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(explosionSplatMapShieldCheckHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(explosionSplatMapShieldCheckHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind ExplosionEffectSplatMap Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindExplosionUniforms(explosionSplatMapShieldCheckHandle, explosionEffectJob, scene);
|
||||
//bind textures
|
||||
@@ -637,9 +759,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
||||
case RawModel::MaterialType::SingleTextures:
|
||||
{
|
||||
if (explosionEffectJob->Model->IsSkinned()) {
|
||||
|
||||
m_ExplosionEffectSkinnedProgram->Bind();
|
||||
GLERROR("Bind ExplosionEffectSkinned program");
|
||||
if (lastShader != m_ExplosionEffectSkinnedProgram->GetHandle()) {
|
||||
m_ExplosionEffectSkinnedProgram->Bind();
|
||||
lastShader = m_ExplosionEffectSkinnedProgram->GetHandle();
|
||||
GLERROR("Bind ExplosionEffectSkinned program");
|
||||
glUniform1i(glGetUniformLocation(explosionSkinnedHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(explosionSkinnedHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(explosionSkinnedHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind ExplosionEffectSkinned Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindExplosionUniforms(explosionSkinnedHandle, explosionEffectJob, scene);
|
||||
//bind textures
|
||||
@@ -657,8 +787,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||
}
|
||||
else {
|
||||
m_ExplosionEffectProgram->Bind();
|
||||
GLERROR("Bind ExplosionEffect program");
|
||||
if (lastShader != m_ExplosionEffectProgram->GetHandle()) {
|
||||
m_ExplosionEffectProgram->Bind();
|
||||
lastShader = m_ExplosionEffectProgram->GetHandle();
|
||||
GLERROR("Bind ExplosionEffect program");
|
||||
glUniform1i(glGetUniformLocation(explosionHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(explosionHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(explosionHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind ExplosionEffect Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindExplosionUniforms(explosionHandle, explosionEffectJob, scene);
|
||||
//bind textures
|
||||
@@ -672,8 +811,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
||||
case RawModel::MaterialType::SplatMapping:
|
||||
{
|
||||
if (explosionEffectJob->Model->IsSkinned()) {
|
||||
m_ExplosionEffectSplatMapSkinnedProgram->Bind();
|
||||
GLERROR("Bind ExplosionEffectSplatMapSkinned program");
|
||||
if (lastShader != m_ExplosionEffectSplatMapSkinnedProgram->GetHandle()) {
|
||||
m_ExplosionEffectSplatMapSkinnedProgram->Bind();
|
||||
lastShader = m_ExplosionEffectSplatMapSkinnedProgram->GetHandle();
|
||||
GLERROR("Bind ExplosionEffectSkinnedSplatMap program");
|
||||
glUniform1i(glGetUniformLocation(explosionSplatMapSkinnedHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(explosionSplatMapSkinnedHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind ExplosionEffectSkinnedSplatMap Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindExplosionUniforms(explosionSplatMapSkinnedHandle, explosionEffectJob, scene);
|
||||
//bind textures
|
||||
@@ -689,9 +837,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
||||
|
||||
}
|
||||
else {
|
||||
m_ExplosionEffectSplatMapProgram->Bind();
|
||||
GLERROR("Bind ExplosionEffectSplatMap program");
|
||||
//bind uniforms
|
||||
if (lastShader != m_ExplosionEffectSplatMapProgram->GetHandle()) {
|
||||
m_ExplosionEffectSplatMapProgram->Bind();
|
||||
lastShader = m_ExplosionEffectSplatMapProgram->GetHandle();
|
||||
GLERROR("Bind ExplosionEffectSplatMap program");
|
||||
glUniform1i(glGetUniformLocation(explosionSplatMapHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(explosionSplatMapHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(explosionSplatMapHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind ExplosionEffectSplatMap Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindExplosionUniforms(explosionSplatMapHandle, explosionEffectJob, scene);
|
||||
//bind textures
|
||||
@@ -705,8 +861,11 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
//draw
|
||||
glBindVertexArray(explosionEffectJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, explosionEffectJob->Model->ElementBuffer);
|
||||
if (lastModel != explosionEffectJob->ModelID) {
|
||||
glBindVertexArray(explosionEffectJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, explosionEffectJob->Model->ElementBuffer);
|
||||
lastModel = explosionEffectJob->ModelID;
|
||||
}
|
||||
glDrawElements(GL_TRIANGLES, explosionEffectJob->EndIndex - explosionEffectJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(explosionEffectJob->StartIndex*sizeof(unsigned int)));
|
||||
glEnable(GL_CULL_FACE);
|
||||
GLERROR("explosion effect end");
|
||||
@@ -721,8 +880,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
||||
case RawModel::MaterialType::SingleTextures:
|
||||
{
|
||||
if (modelJob->Model->IsSkinned()) {
|
||||
m_ForwardPlusSkinnedShieldCheckProgram->Bind();
|
||||
GLERROR("Bind ForwardPlusSkinnedProgram");
|
||||
if (lastShader != m_ForwardPlusSkinnedShieldCheckProgram->GetHandle()) {
|
||||
m_ForwardPlusSkinnedShieldCheckProgram->Bind();
|
||||
lastShader = m_ForwardPlusSkinnedShieldCheckProgram->GetHandle();
|
||||
GLERROR("Bind ForwardPlusSkinnedProgram program");
|
||||
glUniform1i(glGetUniformLocation(forwardSkinnedShieldCheckHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedShieldCheckHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedShieldCheckHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(forwardSkinnedShieldCheckHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(forwardSkinnedShieldCheckHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind ForwardPlusSkinnedProgram Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindModelUniforms(forwardSkinnedShieldCheckHandle, modelJob, scene);
|
||||
//bind textures
|
||||
@@ -741,8 +909,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
||||
|
||||
}
|
||||
else {
|
||||
m_ForwardPlusShieldCheckProgram->Bind();
|
||||
GLERROR("Bind ForwardPlusProgram");
|
||||
if (lastShader != m_ForwardPlusShieldCheckProgram->GetHandle()) {
|
||||
m_ForwardPlusShieldCheckProgram->Bind();
|
||||
lastShader = m_ForwardPlusShieldCheckProgram->GetHandle();
|
||||
GLERROR("Bind ForwardPlusProgram program");
|
||||
glUniform1i(glGetUniformLocation(forwardShieldCheckHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardShieldCheckHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardShieldCheckHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(forwardShieldCheckHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(forwardShieldCheckHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind ForwardPlusProgram Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindModelUniforms(forwardShieldCheckHandle, modelJob, scene);
|
||||
//bind textures
|
||||
@@ -756,8 +933,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
||||
case RawModel::MaterialType::SplatMapping:
|
||||
{
|
||||
if (modelJob->Model->IsSkinned()) {
|
||||
m_ForwardPlusSplatMapSkinnedShieldCheckProgram->Bind();
|
||||
GLERROR("Bind SplatMap program");
|
||||
if (lastShader != m_ForwardPlusSplatMapSkinnedShieldCheckProgram->GetHandle()) {
|
||||
m_ForwardPlusSplatMapSkinnedShieldCheckProgram->Bind();
|
||||
lastShader = m_ForwardPlusSplatMapSkinnedShieldCheckProgram->GetHandle();
|
||||
GLERROR("Bind ForwardPlusProgramSplatMapSkinned program");
|
||||
glUniform1i(glGetUniformLocation(forwardSplatMapSkinnedShieldCheckHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedShieldCheckHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedShieldCheckHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(forwardSplatMapSkinnedShieldCheckHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(forwardSplatMapSkinnedShieldCheckHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind ForwardPlusProgramSplatMapSkinned Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindModelUniforms(forwardSplatMapSkinnedShieldCheckHandle, modelJob, scene);
|
||||
//bind textures
|
||||
@@ -773,8 +959,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||
}
|
||||
else {
|
||||
m_ForwardPlusSplatMapShieldCheckProgram->Bind();
|
||||
GLERROR("Bind SplatMap program");
|
||||
if (lastShader != m_ForwardPlusSplatMapShieldCheckProgram->GetHandle()) {
|
||||
m_ForwardPlusSplatMapShieldCheckProgram->Bind();
|
||||
lastShader = m_ForwardPlusSplatMapShieldCheckProgram->GetHandle();
|
||||
GLERROR("Bind SplatMap program");
|
||||
glUniform1i(glGetUniformLocation(forwardSplatShieldCheckHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardSplatShieldCheckHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardSplatShieldCheckHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(forwardSplatShieldCheckHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(forwardSplatShieldCheckHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind SplatMap Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindModelUniforms(forwardSplatShieldCheckHandle, modelJob, scene);
|
||||
//bind textures
|
||||
@@ -790,8 +985,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
||||
case RawModel::MaterialType::SingleTextures:
|
||||
{
|
||||
if (modelJob->Model->IsSkinned()) {
|
||||
m_ForwardPlusSkinnedProgram->Bind();
|
||||
GLERROR("Bind ForwardPlusSkinnedProgram");
|
||||
if (lastShader != m_ForwardPlusSkinnedProgram->GetHandle()) {
|
||||
m_ForwardPlusSkinnedProgram->Bind();
|
||||
lastShader = m_ForwardPlusSkinnedProgram->GetHandle();
|
||||
GLERROR("Bind ForwardPlusSkinnedProgram program");
|
||||
glUniform1i(glGetUniformLocation(forwardSkinnedHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(forwardSkinnedHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(forwardSkinnedHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind ForwardPlusSkinnedProgram Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindModelUniforms(forwardSkinnedHandle, modelJob, scene);
|
||||
//bind textures
|
||||
@@ -810,8 +1014,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
||||
|
||||
}
|
||||
else {
|
||||
m_ForwardPlusProgram->Bind();
|
||||
GLERROR("Bind ForwardPlusProgram");
|
||||
if (lastShader != m_ForwardPlusProgram->GetHandle()) {
|
||||
m_ForwardPlusProgram->Bind();
|
||||
lastShader = m_ForwardPlusProgram->GetHandle();
|
||||
GLERROR("Bind ForwardPlusProgram program");
|
||||
glUniform1i(glGetUniformLocation(forwardHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(forwardHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(forwardHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind ForwardPlusProgram Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindModelUniforms(forwardHandle, modelJob, scene);
|
||||
//bind textures
|
||||
@@ -825,8 +1038,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
||||
case RawModel::MaterialType::SplatMapping:
|
||||
{
|
||||
if (modelJob->Model->IsSkinned()) {
|
||||
m_ForwardPlusSplatMapSkinnedProgram->Bind();
|
||||
GLERROR("Bind SplatMap program");
|
||||
if (lastShader != m_ForwardPlusSplatMapSkinnedProgram->GetHandle()) {
|
||||
m_ForwardPlusSplatMapSkinnedProgram->Bind();
|
||||
lastShader = m_ForwardPlusSplatMapSkinnedProgram->GetHandle();
|
||||
GLERROR("Bind SplatMap program");
|
||||
glUniform1i(glGetUniformLocation(forwardSplatMapSkinnedHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(forwardSplatMapSkinnedHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind SplatMap Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindModelUniforms(forwardSplatMapSkinnedHandle, modelJob, scene);
|
||||
//bind textures
|
||||
@@ -842,8 +1064,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||
}
|
||||
else {
|
||||
m_ForwardPlusSplatMapProgram->Bind();
|
||||
GLERROR("Bind SplatMap program");
|
||||
if (lastShader != m_ForwardPlusSplatMapProgram->GetHandle()) {
|
||||
m_ForwardPlusSplatMapProgram->Bind();
|
||||
lastShader = m_ForwardPlusSplatMapProgram->GetHandle();
|
||||
GLERROR("Bind SplatMap program");
|
||||
glUniform1i(glGetUniformLocation(forwardSplatMapHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(forwardSplatMapHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(forwardSplatMapHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind SplatMap Uniforms");
|
||||
}
|
||||
//bind uniforms
|
||||
BindModelUniforms(forwardSplatMapHandle, modelJob, scene);
|
||||
//bind textures
|
||||
@@ -855,8 +1086,11 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
||||
}
|
||||
}
|
||||
//draw
|
||||
glBindVertexArray(modelJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||
if (lastModel != modelJob->ModelID) {
|
||||
glBindVertexArray(modelJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||
lastModel = modelJob->ModelID;
|
||||
}
|
||||
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex*sizeof(unsigned int)));
|
||||
if (GLERROR("models end")) {
|
||||
continue;
|
||||
@@ -961,17 +1195,26 @@ void DrawFinalPass::DrawShieldedModelRenderQueue(std::list<std::shared_ptr<Rende
|
||||
|
||||
void DrawFinalPass::DrawToDepthStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
|
||||
{
|
||||
|
||||
|
||||
GLuint shaderSkinnedHandle = m_FillDepthStencilBufferSkinnedProgram->GetHandle();
|
||||
GLuint shaderHandle = m_FillDepthStencilBufferProgram->GetHandle();
|
||||
GLuint lastShader = 0;
|
||||
for (auto &job : jobs) {
|
||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||
|
||||
if(modelJob->Model->IsSkinned()) {
|
||||
m_FillDepthStencilBufferSkinnedProgram->Bind();
|
||||
GLuint shaderHandle = m_FillDepthStencilBufferSkinnedProgram->GetHandle();
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||
if (lastShader != m_FillDepthStencilBufferSkinnedProgram->GetHandle()) {
|
||||
m_FillDepthStencilBufferSkinnedProgram->Bind();
|
||||
lastShader = m_FillDepthStencilBufferSkinnedProgram->GetHandle();
|
||||
glUniform1i(glGetUniformLocation(shaderSkinnedHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(shaderSkinnedHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(shaderSkinnedHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind Uniforms 1");
|
||||
}
|
||||
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * modelJob->Matrix));
|
||||
GLERROR("Bind PVM uniform");
|
||||
|
||||
std::vector<glm::mat4> frameBones;
|
||||
if (modelJob->BlendTree != nullptr) {
|
||||
@@ -982,11 +1225,19 @@ void DrawFinalPass::DrawToDepthStencilBuffer(std::list<std::shared_ptr<RenderJob
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||
|
||||
} else {
|
||||
m_FillDepthStencilBufferProgram->Bind();
|
||||
GLuint shaderHandle = m_FillDepthStencilBufferProgram->GetHandle();
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||
if (lastShader != m_FillDepthStencilBufferProgram->GetHandle()) {
|
||||
m_FillDepthStencilBufferProgram->Bind();
|
||||
lastShader = m_FillDepthStencilBufferProgram->GetHandle();
|
||||
glUniform1i(glGetUniformLocation(shaderHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glUniform4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind Uniforms 2");
|
||||
}
|
||||
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * modelJob->Matrix));
|
||||
GLERROR("Bind PVM uniform");
|
||||
}
|
||||
|
||||
|
||||
@@ -1008,6 +1259,9 @@ void DrawFinalPass::DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, Rend
|
||||
|
||||
GLuint shaderHandle = m_SpriteProgram->GetHandle();
|
||||
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform3fv(glGetUniformLocation(shaderHandle, "CameraPos"), 1, glm::value_ptr(scene.Camera->Position()));
|
||||
|
||||
for(auto& job : jobs) {
|
||||
auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job);
|
||||
RenderState jobState;
|
||||
@@ -1016,10 +1270,7 @@ void DrawFinalPass::DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, Rend
|
||||
if(spriteJob->Depth == 0) {
|
||||
jobState.Disable(GL_DEPTH_TEST);
|
||||
}
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(spriteJob->Matrix));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform3fv(glGetUniformLocation(shaderHandle, "CameraPos"), 1, glm::value_ptr(scene.Camera->Position()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * spriteJob->Matrix));
|
||||
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(spriteJob->Color));
|
||||
glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(spriteJob->FillColor));
|
||||
glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), spriteJob->FillPercentage);
|
||||
@@ -1049,17 +1300,14 @@ void DrawFinalPass::DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, Rend
|
||||
|
||||
void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene)
|
||||
{
|
||||
glUniform1i(glGetUniformLocation(shaderHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
GLERROR("Bind 1 uniform");
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix));
|
||||
GLERROR("Bind 2 uniform");
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
GLERROR("Bind 3 uniform");
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
GLERROR("Bind 4 uniform");
|
||||
|
||||
glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
GLERROR("Bind 5 uniform");
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * job->Matrix));
|
||||
GLERROR("Bind PVM uniform");
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "VM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix() * job->Matrix));
|
||||
GLERROR("Bind VM uniform");
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "TIM"), 1, GL_FALSE, glm::value_ptr(glm::transpose(glm::inverse(job->Matrix))));
|
||||
GLERROR("Bind TIM uniform");
|
||||
|
||||
glUniform3fv(glGetUniformLocation(shaderHandle, "ExplosionOrigin"), 1, glm::value_ptr(job->ExplosionOrigin));
|
||||
GLERROR("Bind 6 uniform");
|
||||
@@ -1090,29 +1338,21 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<E
|
||||
GLERROR("Bind 18 uniform");
|
||||
glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), job->FillPercentage);
|
||||
GLERROR("Bind 19 uniform");
|
||||
glUniform4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
GLERROR("Bind 20 uniform");
|
||||
glUniform1f(glGetUniformLocation(shaderHandle, "GlowIntensity"), job->GlowIntensity);
|
||||
GLERROR("END");
|
||||
}
|
||||
|
||||
void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene)
|
||||
{
|
||||
glUniform1i(glGetUniformLocation(shaderHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
GLERROR("Bind 1 uniform");
|
||||
GLint Location_M = glGetUniformLocation(shaderHandle, "M");
|
||||
glUniformMatrix4fv(Location_M, 1, GL_FALSE, glm::value_ptr(job->Matrix));
|
||||
GLERROR("Bind 2 uniform");
|
||||
GLint Location_V = glGetUniformLocation(shaderHandle, "V");
|
||||
glUniformMatrix4fv(Location_V, 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
GLERROR("Bind 3 uniform");
|
||||
GLint Location_P = glGetUniformLocation(shaderHandle, "P");
|
||||
glUniformMatrix4fv(Location_P, 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
GLERROR("Bind 4 uniform");
|
||||
|
||||
GLint Location_ScreenDimensions = glGetUniformLocation(shaderHandle, "ScreenDimensions");
|
||||
glUniform2f(Location_ScreenDimensions, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
GLERROR("Bind 5 uniform");
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * job->Matrix));
|
||||
GLERROR("Bind PVM uniform");
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "VM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix() * job->Matrix));
|
||||
GLERROR("Bind VM uniform");
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "TIM"), 1, GL_FALSE, glm::value_ptr(glm::transpose(glm::inverse(job->Matrix))));
|
||||
GLERROR("Bind TIM uniform");
|
||||
|
||||
GLint Location_FillPercentage = glGetUniformLocation(shaderHandle, "FillPercentage");
|
||||
glUniform1f(Location_FillPercentage, job->FillPercentage);
|
||||
@@ -1125,11 +1365,6 @@ void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr<Model
|
||||
GLERROR("Bind 8 uniform");
|
||||
GLint Location_Color = glGetUniformLocation(shaderHandle, "Color");
|
||||
glUniform4fv(Location_Color, 1, glm::value_ptr(job->Color));
|
||||
GLERROR("Bind 9 uniform");
|
||||
GLint Location_AmbientColor = glGetUniformLocation(shaderHandle, "AmbientColor");
|
||||
glUniform4fv(Location_AmbientColor, 1, glm::value_ptr(scene.AmbientColor));
|
||||
|
||||
GLERROR("Bind 10 uniform");
|
||||
GLint Location_GlowIntensity = glGetUniformLocation(shaderHandle, "GlowIntensity");
|
||||
|
||||
glUniform1f(Location_GlowIntensity, job->GlowIntensity);
|
||||
|
||||
@@ -10,31 +10,31 @@ Model::Model(std::string fileName)
|
||||
case RawModel::MaterialType::SingleTextures:
|
||||
{
|
||||
RawModel::MaterialSingleTextures* materialSingleTexture = static_cast<RawModel::MaterialSingleTextures*>(materialProperty.material);
|
||||
materialSingleTexture->ColorMap.Texture = CommonFunctions::LoadTexture(materialSingleTexture->ColorMap.TexturePath, false);
|
||||
materialSingleTexture->NormalMap.Texture = CommonFunctions::LoadTexture(materialSingleTexture->NormalMap.TexturePath, false);
|
||||
materialSingleTexture->SpecularMap.Texture = CommonFunctions::LoadTexture(materialSingleTexture->SpecularMap.TexturePath, false);
|
||||
materialSingleTexture->IncandescenceMap.Texture = CommonFunctions::LoadTexture(materialSingleTexture->IncandescenceMap.TexturePath, false);
|
||||
materialSingleTexture->ColorMap.Texture = CommonFunctions::TryLoadResource<Texture, false>(materialSingleTexture->ColorMap.TexturePath);
|
||||
materialSingleTexture->NormalMap.Texture = CommonFunctions::TryLoadResource<Texture, false>(materialSingleTexture->NormalMap.TexturePath);
|
||||
materialSingleTexture->SpecularMap.Texture = CommonFunctions::TryLoadResource<Texture, false>(materialSingleTexture->SpecularMap.TexturePath);
|
||||
materialSingleTexture->IncandescenceMap.Texture = CommonFunctions::TryLoadResource<Texture, false>(materialSingleTexture->IncandescenceMap.TexturePath);
|
||||
}
|
||||
break;
|
||||
case RawModel::MaterialType::SplatMapping:
|
||||
{
|
||||
RawModel::MaterialSplatMapping* materialSplatMapping = static_cast<RawModel::MaterialSplatMapping*>(materialProperty.material);
|
||||
materialSplatMapping->SplatMap.Texture = CommonFunctions::LoadTexture(materialSplatMapping->SplatMap.TexturePath, false);
|
||||
materialSplatMapping->SplatMap.Texture = CommonFunctions::TryLoadResource<Texture, false>(materialSplatMapping->SplatMap.TexturePath);
|
||||
for (auto& texture : materialSplatMapping->ColorMaps)
|
||||
{
|
||||
texture.Texture = CommonFunctions::LoadTexture(texture.TexturePath, false);
|
||||
texture.Texture = CommonFunctions::TryLoadResource<Texture, false>(texture.TexturePath);
|
||||
}
|
||||
for (auto& texture : materialSplatMapping->NormalMaps)
|
||||
{
|
||||
texture.Texture = CommonFunctions::LoadTexture(texture.TexturePath, false);
|
||||
texture.Texture = CommonFunctions::TryLoadResource<Texture, false>(texture.TexturePath);
|
||||
}
|
||||
for (auto& texture : materialSplatMapping->SpecularMaps)
|
||||
{
|
||||
texture.Texture = CommonFunctions::LoadTexture(texture.TexturePath, false);
|
||||
texture.Texture = CommonFunctions::TryLoadResource<Texture, false>(texture.TexturePath);
|
||||
}
|
||||
for (auto& texture : materialSplatMapping->IncandescenceMaps)
|
||||
{
|
||||
texture.Texture = CommonFunctions::LoadTexture(texture.TexturePath, false);
|
||||
texture.Texture = CommonFunctions::TryLoadResource<Texture, false>(texture.TexturePath);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -12,7 +12,8 @@ PickingPass::PickingPass(IRenderer* renderer, EventBroker* eb)
|
||||
|
||||
PickingPass::~PickingPass()
|
||||
{
|
||||
|
||||
CommonFunctions::DeleteTexture(&m_PickingTexture);
|
||||
CommonFunctions::DeleteTexture(&m_DepthBuffer);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,8 +62,9 @@ void PickingPass::Draw(RenderScene& scene)
|
||||
//TODO: Render: Add code for more jobs than modeljobs.
|
||||
GLuint shaderHandle = m_PickingProgram->GetHandle();
|
||||
GLuint shaderSkinnedHandle = m_PickingSkinnedProgram->GetHandle();
|
||||
GLuint lastShader = 0;
|
||||
unsigned int lastModel = 0;
|
||||
m_PickingProgram->Bind();
|
||||
|
||||
if (scene.ClearDepth) {
|
||||
//glClear(GL_DEPTH_BUFFER_BIT);
|
||||
state->Disable(GL_DEPTH_TEST);
|
||||
@@ -98,10 +100,11 @@ void PickingPass::Draw(RenderScene& scene)
|
||||
m_PickingColorsToEntity[glm::ivec2(pickColor[0], pickColor[1])] = pickInfo;
|
||||
|
||||
if (modelJob->Model->IsSkinned()) {
|
||||
m_PickingSkinnedProgram->Bind();
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
if (lastShader != m_PickingSkinnedProgram->GetHandle()) {
|
||||
m_PickingSkinnedProgram->Bind();
|
||||
lastShader = m_PickingSkinnedProgram->GetHandle();
|
||||
}
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * modelJob->Matrix));
|
||||
glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||
|
||||
std::vector<glm::mat4> frameBones;
|
||||
@@ -114,15 +117,19 @@ void PickingPass::Draw(RenderScene& scene)
|
||||
|
||||
|
||||
} else {
|
||||
m_PickingProgram->Bind();
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
if (lastShader != m_PickingProgram->GetHandle()) {
|
||||
m_PickingProgram->Bind();
|
||||
lastShader = m_PickingProgram->GetHandle();
|
||||
}
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * modelJob->Matrix));
|
||||
glUniform2fv(glGetUniformLocation(shaderHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||
}
|
||||
|
||||
glBindVertexArray(modelJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||
if (lastModel != modelJob->ModelID) {
|
||||
glBindVertexArray(modelJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||
lastModel = modelJob->ModelID;
|
||||
}
|
||||
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex * sizeof(unsigned int)));
|
||||
}
|
||||
}
|
||||
@@ -208,10 +215,11 @@ void PickingPass::Draw(RenderScene& scene)
|
||||
m_PickingColorsToEntity[glm::ivec2(pickColor[0], pickColor[1])] = pickInfo;
|
||||
|
||||
if (modelJob->Model->IsSkinned()) {
|
||||
m_PickingSkinnedProgram->Bind();
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
if (lastShader != m_PickingSkinnedProgram->GetHandle()) {
|
||||
m_PickingSkinnedProgram->Bind();
|
||||
lastShader = m_PickingSkinnedProgram->GetHandle();
|
||||
}
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * modelJob->Matrix));
|
||||
glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||
|
||||
std::vector<glm::mat4> frameBones;
|
||||
@@ -224,19 +232,24 @@ void PickingPass::Draw(RenderScene& scene)
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||
|
||||
} else {
|
||||
m_PickingProgram->Bind();
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
if (lastShader != m_PickingProgram->GetHandle()) {
|
||||
m_PickingProgram->Bind();
|
||||
lastShader = m_PickingProgram->GetHandle();
|
||||
}
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * modelJob->Matrix));
|
||||
glUniform2fv(glGetUniformLocation(shaderHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||
}
|
||||
|
||||
glBindVertexArray(modelJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||
if (lastModel != modelJob->ModelID) {
|
||||
glBindVertexArray(modelJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||
lastModel = modelJob->ModelID;
|
||||
}
|
||||
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex * sizeof(unsigned int)));
|
||||
}
|
||||
}
|
||||
|
||||
m_PickingProgram->Bind();
|
||||
for (auto& job : scene.Jobs.SpriteJob) {
|
||||
auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job);
|
||||
if (!spriteJob->Pickable) {
|
||||
@@ -271,14 +284,11 @@ void PickingPass::Draw(RenderScene& scene)
|
||||
|
||||
m_PickingColorsToEntity[glm::ivec2(pickColor[0], pickColor[1])] = pickInfo;
|
||||
|
||||
m_PickingProgram->Bind();
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(spriteJob->Matrix));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * spriteJob->Matrix));
|
||||
glUniform2fv(glGetUniformLocation(shaderHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||
|
||||
glBindVertexArray(spriteJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, spriteJob->Model->ElementBuffer);
|
||||
glBindVertexArray(spriteJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, spriteJob->Model->ElementBuffer);
|
||||
glDrawElements(GL_TRIANGLES, spriteJob->EndIndex - spriteJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(spriteJob->StartIndex * sizeof(unsigned int)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -449,7 +449,7 @@ void RenderSystem::Update(double dt)
|
||||
fillModels(scene.Jobs);
|
||||
fillPointLights(scene.Jobs.PointLight, m_World);
|
||||
//TODO: Make sure all objects needed are also sorted.
|
||||
scene.Jobs.OpaqueObjects.sort();
|
||||
scene.Jobs.OpaqueObjects.sort([](auto& a, auto& b) {return *a < *b; });
|
||||
fillSprites(scene.Jobs.SpriteJob, m_World);
|
||||
fillDirectionalLights(scene.Jobs.DirectionalLight, m_World);
|
||||
fillText(scene.Jobs.Text, m_World);
|
||||
|
||||
@@ -2,6 +2,19 @@
|
||||
|
||||
std::unordered_map<GLFWwindow*, Renderer*> Renderer::m_WindowToRenderer;
|
||||
|
||||
Renderer::~Renderer() {
|
||||
delete m_PickingPass;
|
||||
delete m_LightCullingPass;
|
||||
delete m_ImGuiRenderPass;
|
||||
delete m_DrawFinalPass;
|
||||
delete m_DrawScreenQuadPass;
|
||||
delete m_DrawBloomPass;
|
||||
delete m_DrawColorCorrectionPass;
|
||||
delete m_SSAOPass;
|
||||
delete m_CubeMapPass;
|
||||
delete m_TextPass;
|
||||
}
|
||||
|
||||
void Renderer::Initialize()
|
||||
{
|
||||
m_SSAO_Quality = m_Config->Get<int>("SSAO.Quality", 0);
|
||||
@@ -220,8 +233,8 @@ PickData Renderer::Pick(glm::vec2 screenCoord)
|
||||
|
||||
void Renderer::InitializeTextures()
|
||||
{
|
||||
m_ErrorTexture = CommonFunctions::LoadTexture("Textures/Core/ErrorTexture.png", false);
|
||||
m_WhiteTexture = CommonFunctions::LoadTexture("Textures/Core/White.png", false);
|
||||
m_ErrorTexture = CommonFunctions::TryLoadResource<Texture, false>("Textures/Core/ErrorTexture.png");
|
||||
m_WhiteTexture = CommonFunctions::TryLoadResource<Texture, false>("Textures/Core/White.png");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,12 +4,19 @@ SSAOPass::SSAOPass(IRenderer* renderer, ConfigFile* config)
|
||||
: m_Renderer(renderer)
|
||||
, m_Config(config)
|
||||
{
|
||||
m_WhiteTexture = CommonFunctions::LoadTexture("Textures/Core/White.png", false);
|
||||
m_WhiteTexture = CommonFunctions::TryLoadResource<Texture, false>("Textures/Core/White.png");
|
||||
|
||||
ChangeQuality(m_Config->Get<int>("SSAO.Quality", 0));
|
||||
|
||||
}
|
||||
|
||||
SSAOPass::~SSAOPass() {
|
||||
CommonFunctions::DeleteTexture(&m_SSAOTexture);
|
||||
CommonFunctions::DeleteTexture(&m_SSAOViewSpaceZTexture);
|
||||
CommonFunctions::DeleteTexture(&m_Gaussian_horiz);
|
||||
CommonFunctions::DeleteTexture(&m_Gaussian_vert);
|
||||
}
|
||||
|
||||
void SSAOPass::ChangeQuality(int quality)
|
||||
{
|
||||
if (m_Quality == quality) {
|
||||
|
||||
@@ -4,22 +4,32 @@ GLuint Shader::CompileShader(GLenum shaderType, std::string fileName)
|
||||
{
|
||||
LOG_INFO("Compiling shader \"%s\"", fileName.c_str());
|
||||
|
||||
std::string shaderFile;
|
||||
std::ifstream in(fileName, std::ios::in);
|
||||
if (!in) {
|
||||
LOG_ERROR("Error: Failed to open shader file \"%s\"", fileName.c_str());
|
||||
return 0;
|
||||
}
|
||||
in.seekg(0, std::ios::end);
|
||||
shaderFile.resize((int)in.tellg());
|
||||
in.seekg(0, std::ios::beg);
|
||||
in.read(&shaderFile[0], shaderFile.size());
|
||||
in.close();
|
||||
std::string shaderFile = ReadFile(fileName);
|
||||
|
||||
GLuint shader = glCreateShader(shaderType);
|
||||
if (GLERROR("glCreateShader"))
|
||||
return 0;
|
||||
|
||||
std::size_t startPos = 0;
|
||||
std::size_t SEofNewFile[2];
|
||||
std::string key = "#include";
|
||||
while((startPos = shaderFile.find(key, startPos)) != std::string::npos)
|
||||
{
|
||||
SEofNewFile[0] = shaderFile.find('"', startPos+key.length())+1;
|
||||
SEofNewFile[1] = shaderFile.find('"', SEofNewFile[0]);
|
||||
if (SEofNewFile[0] == std::string::npos || SEofNewFile[1] == std::string::npos)
|
||||
return 0;
|
||||
|
||||
std::string replacementFileName = shaderFile.substr(SEofNewFile[0], SEofNewFile[1] - SEofNewFile[0]);
|
||||
std::string replacementString = ReadFile(replacementFileName);
|
||||
size_t firstof = replacementString.find_first_of((char)0);
|
||||
replacementString.erase(firstof, replacementString.size() - firstof);
|
||||
if (replacementString.length() <= 0)
|
||||
return 0;
|
||||
shaderFile.replace(startPos, SEofNewFile[1]+2 - startPos, replacementString + "\n");
|
||||
startPos += replacementString.length(); //This might not be wanted.
|
||||
}
|
||||
|
||||
const GLchar* shaderFiles = shaderFile.c_str();
|
||||
const GLint length = static_cast<GLint>(shaderFile.length());
|
||||
glShaderSource(shader, 1, &shaderFiles, &length);
|
||||
@@ -46,6 +56,24 @@ GLuint Shader::CompileShader(GLenum shaderType, std::string fileName)
|
||||
return shader;
|
||||
}
|
||||
|
||||
std::string Shader::ReadFile(std::string fileName)
|
||||
{
|
||||
std::string shaderFile;
|
||||
std::ifstream in(fileName, std::ios::in);
|
||||
if (!in) {
|
||||
LOG_ERROR("Error: Failed to open shader file \"%s\"", fileName.c_str());
|
||||
return "";
|
||||
}
|
||||
|
||||
in.seekg(0, std::ios::end);
|
||||
shaderFile.resize((int)in.tellg());
|
||||
in.seekg(0, std::ios::beg);
|
||||
in.read(&shaderFile[0], shaderFile.size());
|
||||
in.close();
|
||||
return shaderFile;
|
||||
}
|
||||
|
||||
|
||||
Shader::Shader(GLenum shaderType, std::string fileName) : m_ShaderType(shaderType), m_FileName(fileName)
|
||||
{
|
||||
m_ShaderHandle = 0;
|
||||
|
||||
@@ -4,18 +4,6 @@ Texture::Texture(std::string path)
|
||||
{
|
||||
PNG* img = ResourceManager::Load<PNG, true>(path); //TODO: Make this threaded. Catch exeptions in all other load places.
|
||||
|
||||
//PNG image(path);
|
||||
|
||||
//if (img->Width == 0 && img->Height == 0 || img->Format == Image::ImageFormat::Unknown) {
|
||||
// //image = PNG("Textures/Core/ErrorTexture.png");
|
||||
// //return; // Temporary fix to remove crash
|
||||
|
||||
// if (img->Width == 0 && img->Height == 0 || img->Format == Image::ImageFormat::Unknown) {
|
||||
// LOG_ERROR("Couldn't even load the error texture. This is a dark day indeed.");
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
|
||||
this->Width = img->Width;
|
||||
this->Height = img->Height;
|
||||
this->Data = img->Data;
|
||||
@@ -29,9 +17,9 @@ Texture::Texture(std::string path)
|
||||
format = GL_RGBA;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Construct the OpenGL texture
|
||||
|
||||
glGenTextures(1, &m_Texture);
|
||||
glBindTexture(GL_TEXTURE_2D, m_Texture);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#include "Rendering/TextureSprite.h"
|
||||
|
||||
TextureSprite::TextureSprite(std::string path)
|
||||
:Texture(path)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST_MIPMAP_NEAREST);
|
||||
GLERROR("Texture load");
|
||||
}
|
||||
@@ -1,23 +1,5 @@
|
||||
#include "Rendering/Util/CommonFunctions.h"
|
||||
|
||||
Texture* CommonFunctions::LoadTexture(std::string path, bool threaded)
|
||||
{
|
||||
Texture* img;
|
||||
try {
|
||||
if(threaded) {
|
||||
img = ResourceManager::Load<Texture, true>(path);
|
||||
} else {
|
||||
img = ResourceManager::Load<Texture, false>(path);
|
||||
}
|
||||
} catch (const Resource::StillLoadingException&) {
|
||||
img = ResourceManager::Load<Texture>("Textures/Core/ErrorTexture.png");
|
||||
} catch (const std::exception&) {
|
||||
img = nullptr;
|
||||
}
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
void CommonFunctions::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type)
|
||||
{
|
||||
glDeleteTextures(1, texture);
|
||||
|
||||
@@ -37,7 +37,7 @@ ScreenCoords::PixelData ScreenCoords::ToPixelData(float x, float y, FrameBuffer*
|
||||
glReadPixels(x, y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pdata);
|
||||
GLERROR("glReadPixels(pdata) Error");
|
||||
PickDataBuffer->Unbind();
|
||||
|
||||
GLERROR("Unbind Error");
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, DepthBuffer);
|
||||
GLERROR("glBindFramebuffer(DepthBuffer) Error");
|
||||
float depthData;
|
||||
|
||||
Reference in New Issue
Block a user