Compare commits

..

11 Commits

Author SHA1 Message Date
Jace 494746ad8b Merge remote-tracking branch 'origin/Recording' into Recording 2016-03-14 16:33:53 +01:00
Jace b886d9146b WIP STUFF 2016-03-14 08:33:33 +01:00
Jace 57715d5846 Merge branch 'master' into Recording 2016-03-14 06:13:23 +01:00
William Moberg fb3842ba5b Indentation. 2016-03-14 06:05:11 +01:00
William Moberg 6daaccb9ed Merge branch 'Recording' of github.com:teamfisk/TacticalZ into Recording
# Conflicts:
#	src/Engine/Editor/EditorSystem.cpp
2016-03-14 06:02:47 +01:00
William Moberg 0cd161184e Smoother movement for editor camera. 2016-03-14 06:00:12 +01:00
Jace 87b983ec6f Stuff 2016-03-14 05:56:09 +01:00
Jace 592f33653e Better shadows for recording 2016-03-14 04:44:53 +01:00
Jace c74a4e375e Better CP_Valhalla lighting 2016-03-14 04:24:40 +01:00
Jace 78a383b03c Merge branch 'master' into Recording 2016-03-14 04:04:20 +01:00
Jace 24de85b476 Editor no longer resets camera 2016-03-14 04:02:05 +01:00
34 changed files with 24538 additions and 480 deletions
+1 -1
Submodule assets updated: a66a2786e4...ed93148764
+1
View File
@@ -43,6 +43,7 @@ private:
EditorGUI::WidgetSpace m_WidgetSpace = EditorGUI::WidgetSpace::Global;
EntityWrapper m_Widget = EntityWrapper::Invalid;
EntityWrapper m_CurrentSelection = EntityWrapper::Invalid;
glm::vec3 m_CamVelocity;
// Utility functions
EntityWrapper importEntity(EntityWrapper parent, boost::filesystem::path filePath);
-71
View File
@@ -1,71 +0,0 @@
#ifndef DDS_h__
#define DDS_h__
#include <cstdint>
#include "../Common.h"
#include "../Core/ResourceManager.h"
#include "Image.h"
// DXT5
class DDS : public Image, public Resource
{
public:
DDS(std::string path);
~DDS();
void FlipY(unsigned char* data, std::size_t rowBytes, std::size_t totalSize, std::size_t numBlocksWide);
private:
static const uint32_t MagicNumber = 0x20534444; // "DDS "
struct Header_t
{
uint32_t Size;
uint32_t Flags;
uint32_t Height;
uint32_t Width;
uint32_t PitchOrLinearSize;
uint32_t Depth;
uint32_t MipMapCount;
uint32_t RESERVED1[11];
struct PixelFormat_t
{
uint32_t Size;
uint32_t Flags;
uint32_t FourCC;
uint32_t RGBBitCount;
uint32_t RBitMask;
uint32_t GBitMask;
uint32_t BBitMask;
uint32_t ABitMask;
} PixelFormat;
uint32_t Caps;
uint32_t Caps2;
uint32_t Caps3;
uint32_t Caps4;
uint32_t RESERVED2;
} m_Header;
struct Block_t
{
struct Alpha_t
{
uint8_t Colors[2];
uint8_t Data[6];
} Alpha;
struct Data_t
{
uint16_t Colors[2];
uint8_t Data[4];
} Data;
};
std::size_t m_NumBlocksWide;
std::size_t m_NumBlocksHigh;
std::size_t m_RowBytes;
void flipBlock(Block_t* block);
};
#endif
-3
View File
@@ -15,10 +15,7 @@ struct Image
unsigned int Width = 0;
unsigned int Height = 0;
ImageFormat Format = ImageFormat::Unknown;
unsigned int MipMapLevels = 0;
bool Compressed = false;
unsigned char* Data = nullptr;
std::size_t ByteSize = 0;
};
#endif
+3 -3
View File
@@ -29,8 +29,8 @@ struct ShadowFrustum
class ShadowPass
{
public:
ShadowPass(IRenderer* renderer, bool useShadow);
ShadowPass(IRenderer * renderer, int ShadowResX, int ShadowResY, bool useShadow);
ShadowPass(IRenderer* renderer);
ShadowPass(IRenderer * renderer, int ShadowResX, int ShadowResY);
~ShadowPass();
void InitializeFrameBuffers();
@@ -69,7 +69,7 @@ private:
std::array<glm::mat4, MAX_SPLITS> m_LightProjection;
std::array<glm::mat4, MAX_SPLITS> m_LightView;
GLfloat m_NearFarPlane[2] = { -34.f, 27.f };
GLfloat m_NearFarPlane[2] = { -128.f, 128.f };
GLuint m_ResolutionSizeWidth = 1024 * 2;
GLuint m_ResolutionSizeHeight = 1024 * 2;
+2 -5
View File
@@ -1,11 +1,9 @@
#ifndef Texture_h__
#define Texture_h__
#include <boost/filesystem.hpp>
#include "../OpenGL.h"
#include "BaseTexture.h"
#include "PNG.h"
#include "DDS.h"
class Texture : public BaseTexture
{
@@ -20,9 +18,8 @@ public:
void Bind(GLenum textureUnit = GL_TEXTURE0);
GLuint m_Texture = 0;
enum TextureType : GLint { cInvalid = 0, cDDS = 1, cPNG = 2};
TextureType m_Type;
unsigned char* Data = nullptr;
};
#endif
+5
View File
@@ -14,6 +14,11 @@ protected:
TextureSprite(std::string path);
public:
void Bind(GLenum textureUnit = GL_TEXTURE0);
GLuint m_Texture = 0;
unsigned char* Data = nullptr;
};
#endif
+6 -9
View File
@@ -3,11 +3,11 @@ AutoReload=true
[Debug]
LogLevel=1
LoadMap=Schema/Entities/StartMenu.xml
LoadMap=
; if true -> Pool allocation is not used when calling Allocate/Free, just use regular dynamic allocation.
; if false -> Use pool allocation.
DisableMemoryPool=false
RespawnTime=-1.0
RespawnTime = -1.0
EditorEnabled=false
OutOfBodyExperience=false
@@ -22,7 +22,7 @@ Height=720
FOV=45
[Networking]
StartNetwork=true
StartNetwork=false
IsServer=false
Name=Bob
Address=127.0.0.1
@@ -30,7 +30,7 @@ Port=27666
MaxConnections=8
SnapshotInterval=0.05
SendInputIntervalMs=33
PingIntervalMs=1000
PingIntervalMs= 1000
TimeoutMs=15000
[Multithreading]
@@ -43,7 +43,7 @@ AnnouncerVolume=1.0
Announcer=female
[SSAO]
Quality=1
Quality=0
[SSAO1]
Radius=1.0
@@ -88,7 +88,4 @@ NumIterations=4
NumIterations=6
[MSAA]
Level=2
[Shadows]
Enable=false
Level = 0;
+1 -1
View File
@@ -1,5 +1,5 @@
[Mouse]
Sensitivity=0.05
Sensitivity=0.5
InvertPitch=false
[Keyboard]
-17
View File
@@ -1,17 +0,0 @@
To start a server
1. Run Server.bat in the installation directory (C:\Program Files\Axyz)
2. Press F1 to open the editor mode
3. Expand the Entities window if it is minimized, by double-clicking it
4. Mark StartMenu_Origin and hit Delete twice
5. Hit Import and choose CP_Valhalla.xml
6. Press F1 again to leave editor mode for an acceptable framerate
To join a game
1. Run Axyz from the start menu or Axyz.exe in the installation directory (C:\Program Files\Axyz)
2. Press Play
3. Hit the refresh icon if no server is visible
4. Click the server you want to join
5. Follow on-screen directions
6. Enjoy the game :)
+1 -1
View File
@@ -2,5 +2,5 @@
<Camera xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Camera.xsd">
<FOV>59</FOV> <!-- 90 horizontal FOV at 1080p -->
<NearClip>0.01</NearClip>
<FarClip>5000</FarClip>
<FarClip>300</FarClip>
</Camera>
+138
View File
@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:SceneLight>
<AmbientColor A="1" B="0.392156869" G="0.392156869" R="0.392156869"/>
<Gamma>1</Gamma>
<Exposure>0.82000017166137695</Exposure>
</c:SceneLight>
<c:CapturePointGameMode>
<RespawnTime>0.32289272439493288</RespawnTime>
<MaxRespawnTime>0.5</MaxRespawnTime>
</c:CapturePointGameMode>
<c:Transform/>
</Components>
<Children>
<Entity>
<Components>
<c:Collidable/>
<c:Model>
<GlowIntensity>1.0199999809265137</GlowIntensity>
<Resource>Models/Props/Walls/SciFiWallTop.mesh</Resource>
<Color A="1" B="3.92156863" G="1" R="1"/>
<Shadow>false</Shadow>
</c:Model>
<c:Transform>
<Position X="0" Y="58.718792" Z="15.6310005"/>
<Orientation X="0" Y="0" Z="3.14199996"/>
<Scale X="0.279000014" Y="1" Z="0.279000014"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Collidable/>
<c:Model>
<GlowIntensity>1.5</GlowIntensity>
<Resource>Models/Props/Pillars/SciFiPillar2Blue.mesh</Resource>
<Shadow>false</Shadow>
</c:Model>
<c:Transform>
<Position X="-14.4384613" Y="-1.2316848" Z="0"/>
<Orientation X="0" Y="2.64800024" Z="0"/>
<Scale X="2" Y="3.60000014" Z="1.9000001"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Collidable/>
<c:Model>
<GlowIntensity>1.5</GlowIntensity>
<Resource>Models/Props/Pillars/SciFiPillar2Blue.mesh</Resource>
<Shadow>false</Shadow>
</c:Model>
<c:Transform>
<Position X="14.3019333" Y="-1.12725353" Z="0"/>
<Orientation X="0" Y="3.84800029" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="Dir">
<Components>
<c:DirectionalLight>
<Color A="1" B="0.725490212" G="0.75686276" R="0.741176486"/>
<Intensity>1.0699999332427979</Intensity>
</c:DirectionalLight>
<c:Transform>
<Orientation X="3.68318534" Y="0" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="Cam">
<Components>
<c:Camera>
<FOV>47</FOV>
</c:Camera>
<c:Model>
<Resource>Models/Core/UnitSphere.mesh</Resource>
<Shadow>false</Shadow>
<NormalMap>false</NormalMap>
<DiffuseTexture>false</DiffuseTexture>
<SpecularMap>false</SpecularMap>
<GlowMap>false</GlowMap>
</c:Model>
<c:Transform>
<Position X="0.100000001" Y="-0.0670000017" Z="-32.8670006"/>
<Orientation X="0" Y="3.1400001" Z="0"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="Spawn">
<Components>
<c:Team>
<Team>
<Blue/>
</Team>
</c:Team>
<c:PlayerSpawn>
<AssaultFile>Schema/Entities/PlayerAssaultBlue.xml</AssaultFile>
<DefenderFile>Schema/Entities/PlayerDefenderBlue.xml</DefenderFile>
<SniperFile></SniperFile>
</c:PlayerSpawn>
<c:Model>
<Resource>Models/Characters/Assault/AssaultBlue.mesh</Resource>
<Visible>false</Visible>
</c:Model>
<c:Spawner>
<EntityFile></EntityFile>
</c:Spawner>
<c:Transform>
<Position X="0.100000001" Y="2.8398931" Z="-29.0827847"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Model>
<Resource>Models/Highgrounds/Hg21.mesh</Resource>
</c:Model>
<c:Transform>
<Position X="0" Y="-1.75605178" Z="-20.9220009"/>
<Scale X="0.407000005" Y="0.407000005" Z="0.407000005"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
File diff suppressed because it is too large Load Diff
-19
View File
@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:SceneLight>
<AmbientColor A="1" B="1" G="1" R="1"/>
</c:SceneLight>
<c:Sprite>
<DiffuseTexture>Textures/Core/UnitRaptor.png</DiffuseTexture>
<GlowMap></GlowMap>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="-1.60000002"/>
</c:Transform>
</Components>
<Children/>
</Entity>
File diff suppressed because it is too large Load Diff
+2 -4
View File
@@ -50,18 +50,16 @@ Source: "..\..\bin\Schema\*"; DestDir: "{app}\Schema\"; Flags: ignoreversion cre
Source: "..\..\bin\Shaders\*"; DestDir: "{app}\Shaders\"; Flags: ignoreversion createallsubdirs recursesubdirs
Source: "..\..\bin\Textures\*"; DestDir: "{app}\Textures\"; Flags: ignoreversion createallsubdirs recursesubdirs
Source: "..\..\bin\assimp.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\..\resources\DefaultConfig.ini"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\..\resources\DefaultInput.ini"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\..\bin\DefaultConfig.ini"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\..\bin\DefaultInput.ini"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\..\bin\glew32.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\..\bin\glfw3.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\..\bin\imgui.ini"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\..\bin\Input.ini"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\..\bin\libpng16.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\..\bin\Axyz.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\..\bin\Server.bat"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\..\bin\xerces-c_3_1.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\..\bin\zlib.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\..\resources\README.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\..\deps\redist\VC_redist.x64.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall
[Icons]
+8 -5
View File
@@ -1,10 +1,7 @@
#version 430
#include "Shaders/Util/CommonNormalFunc.glsl"
#define MIN_AMBIENT_LIGHT 0.3
#define MAX_SPLITS 4
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
@@ -19,7 +16,6 @@ uniform vec3 CameraPosition;
uniform int SSAOQuality;
uniform float FarDistance[MAX_SPLITS];
uniform int NormalTextureType;
uniform vec2 DiffuseUVRepeat;
uniform vec2 NormalUVRepeat;
uniform vec2 SpecularUVRepeat;
@@ -143,6 +139,13 @@ LightResult CalcDirectionalLightSource(vec4 direction, vec4 color, float intensi
return result;
}
vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textureCoordinate, sampler2D normalMap)
{
mat3 TBN = mat3(tangent, bitangent, normal);
vec3 NormalMap = texture(normalMap, textureCoordinate).xyz * 2.0 - vec3(1.0);
return vec4(TBN * normalize(NormalMap), 0.0);
}
// Returns a "random" value.
float Random(vec3 seed, int i)
{
@@ -298,7 +301,7 @@ void main()
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate * DiffuseUVRepeat);
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat);
vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate * SpecularUVRepeat);
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate * NormalUVRepeat, NormalMapTexture, NormalTextureType);
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate * NormalUVRepeat, NormalMapTexture);
normal = normalize(normal);
//vec4 normal = normalize(V * vec4(Input.Normal, 0.0));
vec4 viewVec = normalize(-Input.ViewSpacePosition);
@@ -1,7 +1,5 @@
#version 430
#include "Shaders/Util/CommonNormalFunc.glsl"
#define MIN_AMBIENT_LIGHT 0.3
#define MAX_SPLITS 4
@@ -19,7 +17,6 @@ uniform float GlowIntensity;
uniform vec3 CameraPosition;
uniform int SSAOQuality;
uniform int NormalTextureType;
uniform vec2 DiffuseUVRepeat;
uniform vec2 NormalUVRepeat;
uniform vec2 SpecularUVRepeat;
@@ -125,6 +122,13 @@ LightResult CalcDirectionalLightSource(vec4 direction, vec4 color, float intensi
return result;
}
vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textureCoordinate, sampler2D normalMap)
{
mat3 TBN = mat3(tangent, bitangent, normal);
vec3 NormalMap = texture(normalMap, textureCoordinate).xyz * 2.0 - vec3(1.0);
return vec4(TBN * normalize(NormalMap), 0.0);
}
void main()
{
float shieldDepthValue = texelFetch(ShieldBuffer, ivec2(gl_FragCoord.xy), 0).r;
@@ -138,7 +142,7 @@ void main()
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate * DiffuseUVRepeat);
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat);
vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate * SpecularUVRepeat);
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate * NormalUVRepeat, NormalMapTexture, NormalTextureType);
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate * NormalUVRepeat, NormalMapTexture);
normal = normalize(normal);
//vec4 normal = normalize(V * vec4(Input.Normal, 0.0));
vec4 viewVec = normalize(-Input.ViewSpacePosition);
@@ -1,7 +1,5 @@
#version 430
#include "Shaders/Util/CommonNormalFunc.glsl"
#define MIN_AMBIENT_LIGHT 0.3
#define MAX_SPLITS 4
uniform mat4 M;
@@ -20,10 +18,6 @@ layout (binding = 0) uniform sampler2D AOTexture;
layout (binding = 30) uniform sampler2DArrayShadow DepthMap;
//Get bineded at the same time as the textures
uniform int NormalTextureType1;
uniform int NormalTextureType2;
uniform int NormalTextureType3;
uniform vec2 DiffuseUVRepeat1;
uniform vec2 DiffuseUVRepeat2;
uniform vec2 DiffuseUVRepeat3;
@@ -187,12 +181,11 @@ vec4 CalcBlendedTexel(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B,
}
vec4 CalcBlendedNormal(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B,
vec2 R_TileValues, vec2 G_TileValues, vec2 B_TileValues,
int R_TextureType, int G_TextureType, int B_TextureType) {
vec2 R_TileValues, vec2 G_TileValues, vec2 B_TileValues){
mat3 TBN = mat3(Input.Tangent, Input.BiTangent, Input.Normal);
vec3 R_Channel = NormalMapValue(Input.TextureCoordinate * R_TileValues, R, R_TextureType);
vec3 G_Channel = NormalMapValue(Input.TextureCoordinate * G_TileValues, G, G_TextureType);
vec3 B_Channel = NormalMapValue(Input.TextureCoordinate * B_TileValues, B, B_TextureType);
vec3 R_Channel = texture(R, Input.TextureCoordinate * R_TileValues).xyz * 2.0 - vec3(1.0);
vec3 G_Channel = texture(G, Input.TextureCoordinate * G_TileValues).xyz * 2.0 - vec3(1.0);
vec3 B_Channel = texture(B, Input.TextureCoordinate * B_TileValues).xyz * 2.0 - vec3(1.0);
float total = blendValue.r + blendValue.g + blendValue.b + blendValue.a;
float totalDiv = 1 / total;
@@ -370,8 +363,7 @@ void main()
SpecularUVRepeat1, SpecularUVRepeat2, SpecularUVRepeat3);
//vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, SplatMapTexture);
vec4 normal = V * CalcBlendedNormal(splatTexel, NormalMapTexture1, NormalMapTexture2, NormalMapTexture3,
NormalUVRepeat1, NormalUVRepeat2, NormalUVRepeat3,
NormalTextureType1, NormalTextureType2, NormalTextureType3);
NormalUVRepeat1, NormalUVRepeat2, NormalUVRepeat3);
normal = normalize(normal);
//vec4 normal = normalize(V * vec4(Input.Normal, 0.0));
vec4 viewVec = normalize(-Input.ViewSpacePosition);
@@ -1,7 +1,5 @@
#version 430
#include "Shaders/Util/CommonNormalFunc.glsl"
#define MIN_AMBIENT_LIGHT 0.3
#define MAX_SPLITS 4
uniform mat4 M;
@@ -16,10 +14,6 @@ uniform vec4 AmbientColor;
uniform int SSAOQuality;
//Get bineded at the same time as the textures
uniform int NormalTextureType1;
uniform int NormalTextureType2;
uniform int NormalTextureType3;
uniform vec2 DiffuseUVRepeat1;
uniform vec2 DiffuseUVRepeat2;
uniform vec2 DiffuseUVRepeat3;
@@ -166,12 +160,11 @@ vec4 CalcBlendedTexel(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B,
}
vec4 CalcBlendedNormal(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B,
vec2 R_TileValues, vec2 G_TileValues, vec2 B_TileValues,
int R_TextureType, int G_TextureType, int B_TextureType) {
vec2 R_TileValues, vec2 G_TileValues, vec2 B_TileValues){
mat3 TBN = mat3(Input.Tangent, Input.BiTangent, Input.Normal);
vec3 R_Channel = NormalMapValue(Input.TextureCoordinate * R_TileValues, R, R_TextureType);
vec3 G_Channel = NormalMapValue(Input.TextureCoordinate * G_TileValues, G, G_TextureType);
vec3 B_Channel = NormalMapValue(Input.TextureCoordinate * B_TileValues, B, B_TextureType);
vec3 R_Channel = texture(R, Input.TextureCoordinate * R_TileValues).xyz * 2.0 - vec3(1.0);
vec3 G_Channel = texture(G, Input.TextureCoordinate * G_TileValues).xyz * 2.0 - vec3(1.0);
vec3 B_Channel = texture(B, Input.TextureCoordinate * B_TileValues).xyz * 2.0 - vec3(1.0);
float total = blendValue.r + blendValue.g + blendValue.b + blendValue.a;
float totalDiv = 1 / total;
@@ -201,8 +194,7 @@ void main()
SpecularUVRepeat1, SpecularUVRepeat2, SpecularUVRepeat3);
//vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, SplatMapTexture);
vec4 normal = V * CalcBlendedNormal(splatTexel, NormalMapTexture1, NormalMapTexture2, NormalMapTexture3,
NormalUVRepeat1, NormalUVRepeat2, NormalUVRepeat3,
NormalTextureType1, NormalTextureType2, NormalTextureType3);
NormalUVRepeat1, NormalUVRepeat2, NormalUVRepeat3);
normal = normalize(normal);
//vec4 normal = normalize(V * vec4(Input.Normal, 0.0));
vec4 viewVec = normalize(-Input.ViewSpacePosition);
Binary file not shown.
+51 -9
View File
@@ -8,6 +8,7 @@ EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame
: System(params)
, m_Renderer(renderer)
, m_RenderFrame(renderFrame)
, m_CamVelocity(0.f)
{
m_EditorWorld = new World();
m_EditorWorldSystemPipeline = new SystemPipeline(m_EditorWorld, m_EventBroker, IsClient, IsServer);
@@ -83,14 +84,55 @@ void EditorSystem::Update(double dt)
}
}
m_EditorWorldSystemPipeline->Update(actualDelta);
ComponentWrapper& cameraTransform = m_EditorCamera["Transform"];
Field<glm::vec3> ori = cameraTransform["Orientation"];
ori.x(m_EditorCameraInputController->Rotation().x);
ori.y(m_EditorCameraInputController->Rotation().y);
Field<glm::vec3> pos = cameraTransform["Position"];
pos += m_EditorCameraInputController->Movement() * glm::inverse(glm::quat(ori)) * (float)actualDelta;
}
ComponentWrapper& cameraTransform = m_EditorCamera["Transform"];
Field<glm::vec3> ori = cameraTransform["Orientation"];
glm::vec3 newOri;
newOri.x = glm::mix(ori.x(), m_EditorCameraInputController->Rotation().x, 0.05f);
newOri.y = glm::mix(ori.y(), m_EditorCameraInputController->Rotation().y, 0.05f);
//ori.x(m_EditorCameraInputController->Rotation().x);
//ori.y(m_EditorCameraInputController->Rotation().y);
ori.x(newOri.x);
ori.y(newOri.y);
Field<glm::vec3> pos = cameraTransform["Position"];
auto move = m_EditorCameraInputController->Movement();
const float decreaseAccelleration = 3.75f;
const float increaseAccelleration = 5.25f;
if (move.x == 0) {
m_CamVelocity.x -= m_CamVelocity.x * (float)actualDelta * decreaseAccelleration;
//m_CamVelocity.x -= glm::sign(m_CamVelocity.x) * (float)actualDelta * decreaseAccelleration;
if (glm::abs(m_CamVelocity.x) < 0.01f) {
m_CamVelocity.x = 0;
}
} else {
m_CamVelocity.x += glm::sign(move.x) * (float)actualDelta * increaseAccelleration;
m_CamVelocity.x = glm::max(m_CamVelocity.x, -glm::abs(move.x));
m_CamVelocity.x = glm::min(m_CamVelocity.x, glm::abs(move.x));
}
if (move.y == 0) {
m_CamVelocity.y -= m_CamVelocity.y * (float)actualDelta * decreaseAccelleration;
//m_CamVelocity.y -= glm::sign(m_CamVelocity.y) * (float)actualDelta * decreaseAccelleration;
if (glm::abs(m_CamVelocity.y) < 0.01f) {
m_CamVelocity.y = 0;
}
} else {
m_CamVelocity.y += glm::sign(move.y) * (float)actualDelta * increaseAccelleration;
m_CamVelocity.y = glm::max(m_CamVelocity.y, -glm::abs(move.y));
m_CamVelocity.y = glm::min(m_CamVelocity.y, glm::abs(move.y));
}
if (move.z == 0) {
m_CamVelocity.z -= m_CamVelocity.z * (float)actualDelta * decreaseAccelleration;
//m_CamVelocity.z -= glm::sign(m_CamVelocity.z) * (float)actualDelta * decreaseAccelleration;
if (glm::abs(m_CamVelocity.z) < 0.01f) {
m_CamVelocity.z = 0;
}
} else {
m_CamVelocity.z += glm::sign(move.z) * (float)actualDelta * increaseAccelleration;
m_CamVelocity.z = glm::max(m_CamVelocity.z, -glm::abs(move.z));
m_CamVelocity.z = glm::min(m_CamVelocity.z, glm::abs(move.z));
}
pos += m_CamVelocity * glm::inverse(glm::quat(ori)) * (float)actualDelta;
}
void EditorSystem::Enable()
@@ -117,11 +159,11 @@ void EditorSystem::Enable()
void EditorSystem::Disable()
{
m_EditorCameraInputController->Disable();
//m_EditorCameraInputController->Disable();
m_EventBroker->Publish(Events::LockMouse());
Events::SetCamera e;
e.CameraEntity = m_ActualCamera;
m_EventBroker->Publish(e);
//m_EventBroker->Publish(e);
m_Enabled = false;
}
+1 -1
View File
@@ -747,7 +747,7 @@ void Server::resetMap()
reliableBroadcast(removeMap);
removeWorld();
// Hardcoded for now.
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/CP_Valhalla.xml");
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/CP_Rocky2.xml");
entityFile->MergeInto(m_World);
Packet newWorld(MessageType::Snapshot);
createWorldSnapshot(newWorld);
+5 -12
View File
@@ -11,7 +11,7 @@ void CubeMapPass::LoadTextures(std::string cubemapName)
if (m_PreviusCubeMapTexture != cubemapName) {
m_CubeMapTextures.clear();
for (int i = 0; i < 6; i++) {
std::string path = "Textures/Test/CubeMap/" + cubemapName + "/CubeMapTest0" + std::to_string(i) + ".dds";
std::string path = "Textures/Test/CubeMap/" + cubemapName + "/CubeMapTest0" + std::to_string(i) + ".png";
m_CubeMapTextures.push_back(path);
}
GenerateCubeMapTexture();
@@ -21,22 +21,15 @@ void CubeMapPass::LoadTextures(std::string cubemapName)
void CubeMapPass::GenerateCubeMapTexture()
{
if (m_CubeMapTexture == 0) {
if (m_CubeMapTexture == -1) {
glGenTextures(1, &m_CubeMapTexture);
}
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapTexture);
for (int i = 0; i < 6; i++) {
DDS* img = ResourceManager::Load<DDS>(m_CubeMapTextures[i]);
std::size_t bpe = 16;
std::size_t numBlocksWide = std::max<std::size_t>(1, (img->Width + 3) / 4);
std::size_t numBlocksHigh = std::max<std::size_t>(1, (img->Height + 3) / 4);
std::size_t rowBytes = numBlocksWide * bpe;
std::size_t numRows = numBlocksHigh;
std::size_t numBytes = rowBytes * numBlocksHigh;
glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, img->Width, img->Height, 0, numBytes, img->Data);
//glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA32F, img->Width, img->Height, 0, GL_COMPRESSED_RGBA, GL_UNSIGNED_BYTE, img->Data);
ResourceManager::Release("DDS", m_CubeMapTextures[i]);
PNG* img = ResourceManager::Load<PNG>(m_CubeMapTextures[i]);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA32F, img->Width, img->Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, img->Data);
ResourceManager::Release("PNG", m_CubeMapTextures[i]);
}
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-121
View File
@@ -1,121 +0,0 @@
#include "Rendering/DDS.h"
DDS::DDS(std::string path)
{
std::ifstream in(path.c_str(), std::ios_base::binary | std::ios_base::ate);
if (!in.is_open()) {
throw Resource::FailedLoadingException("Failed to open file.");
}
unsigned int fileSize = static_cast<unsigned int>(in.tellg());
in.seekg(0, std::ios_base::beg);
if (fileSize < sizeof(MagicNumber) + sizeof(DDS::Header_t)) {
throw Resource::FailedLoadingException("Invalid DDS file; not even big enough to contain the DDS header!");
}
// Read magic number
uint32_t magicNumber;
in.read(reinterpret_cast<char*>(&magicNumber), sizeof(MagicNumber));
if (magicNumber != DDS::MagicNumber) {
throw Resource::FailedLoadingException("Invalid DDS file; magic number doesn't match.");
}
// Read header
in.read(reinterpret_cast<char*>(&m_Header), sizeof(DDS::Header_t));
// Validate header
if (m_Header.Size != sizeof(DDS::Header_t) || m_Header.PixelFormat.Size != sizeof(DDS::Header_t::PixelFormat_t)) {
throw Resource::FailedLoadingException("Corrupt DDS file; header size doesn't match!");
}
// Make sure it's DC3 (DXT5)
char format[5];
memcpy(&format, &m_Header.PixelFormat.FourCC, 4);
format[4] = '\0';
if (strcmp(format, "DXT5")) {
std::stringstream ss;
ss << "Invalid DDS file; Unsupported compression format \"" << format << "\"";
throw Resource::FailedLoadingException(ss.str().c_str());
}
this->Width = m_Header.Width;
this->Height = m_Header.Height;
this->Format = Image::ImageFormat::RGBA;
this->Compressed = true;
if (m_Header.MipMapCount != 0) {
this->MipMapLevels = m_Header.MipMapCount - 1;
}
// Read data
std::size_t dataSize = fileSize - sizeof(MagicNumber) - sizeof(DDS::Header_t);
this->Data = new unsigned char[dataSize];
this->ByteSize = dataSize;
in.read(reinterpret_cast<char*>(this->Data), dataSize);
// Flip!
unsigned int w = this->Width;
unsigned int h = this->Height;
unsigned char* mipMapData = this->Data;
for (unsigned int i = 0; i < this->MipMapLevels; ++i) {
std::size_t bpe = 16;
std::size_t numBlocksWide = std::max<std::size_t>(1, (w + 3) / 4);
std::size_t numBlocksHigh = std::max<std::size_t>(1, (h + 3) / 4);
std::size_t rowBytes = numBlocksWide * bpe;
std::size_t numRows = numBlocksHigh;
std::size_t numBytes = rowBytes * numBlocksHigh;
FlipY(mipMapData, rowBytes, numBytes, numBlocksWide);
w = w >> 1;
h = h >> 1;
mipMapData += numBytes;
}
}
DDS::~DDS()
{
if (this->Data != nullptr) {
delete[] this->Data;
this->Data = nullptr;
}
}
void DDS::FlipY(unsigned char* data, std::size_t rowBytes, std::size_t totalSize, std::size_t numBlocksWide)
{
std::size_t height = totalSize / rowBytes;
unsigned char* topLine = data;
unsigned char* bottomLine = data + (height - 1) * rowBytes;
for (std::size_t line = 0; line < height / 2; ++line) {
Block_t* topBlocks = reinterpret_cast<Block_t*>(topLine);
Block_t* bottomBlocks = reinterpret_cast<Block_t*>(bottomLine);
for (std::size_t block = 0; block < numBlocksWide; ++block) {
flipBlock(&topBlocks[block]);
flipBlock(&bottomBlocks[block]);
std::swap(topBlocks[block], bottomBlocks[block]);
}
topLine += rowBytes;
bottomLine -= rowBytes;
}
}
void DDS::flipBlock(Block_t* block)
{
// Extract both rows of pixel Data into a 32 bit sized values.
uint32_t pixelRow0 = block->Alpha.Data[0] + ((block->Alpha.Data[1] + (block->Alpha.Data[2] << 8)) << 8);
uint32_t pixelRow1 = block->Alpha.Data[3] + ((block->Alpha.Data[4] + (block->Alpha.Data[5] << 8)) << 8);
// Swap the extracted row Data. These values will be read from and shifted into the final block locations.
uint32_t pixelRow0Swapped = ((pixelRow0 & 0x000fff) << 12) | ((pixelRow0 & 0xfff000) >> 12);
uint32_t pixelRow1Swapped = ((pixelRow1 & 0x000fff) << 12) | ((pixelRow1 & 0xfff000) >> 12);
// Swapped Data from row 1 is written
block->Alpha.Data[0] = static_cast<uint8_t>(pixelRow1Swapped & 0x0000ff);
block->Alpha.Data[1] = static_cast<uint8_t>((pixelRow1Swapped & 0x00ff00) >> 8);
block->Alpha.Data[2] = static_cast<uint8_t>((pixelRow1Swapped & 0xff0000) >> 16);
// Swapped Data from row 0 is written
block->Alpha.Data[3] = static_cast<uint8_t>(pixelRow0Swapped & 0x0000ff);
block->Alpha.Data[4] = static_cast<uint8_t>((pixelRow0Swapped & 0x00ff00) >> 8);
block->Alpha.Data[5] = static_cast<uint8_t>((pixelRow0Swapped & 0xff0000) >> 16);
std::swap(block->Data.Data[0], block->Data.Data[3]);
std::swap(block->Data.Data[1], block->Data.Data[2]);
}
+13 -22
View File
@@ -1523,12 +1523,10 @@ void DrawFinalPass::BindExplosionTextures(GLuint shaderHandle, std::shared_ptr<E
if (job->NormalTexture.size() > 0 && job->NormalTexture[0]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->NormalTexture[0]->Texture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(job->NormalTexture[0]->UVRepeat));
glUniform1i(glGetUniformLocation(shaderHandle, "NormalTextureType"), job->NormalTexture[0]->Texture->m_Type);
}
else {
glBindTexture(GL_TEXTURE_2D, m_NeutralNormalTexture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
glUniform1i(glGetUniformLocation(shaderHandle, "NormalTextureType"), m_NeutralNormalTexture->m_Type);
}
glActiveTexture(GL_TEXTURE3);
@@ -1581,12 +1579,10 @@ void DrawFinalPass::BindExplosionTextures(GLuint shaderHandle, std::shared_ptr<E
if (job->NormalTexture.size() > i && job->NormalTexture[i]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->NormalTexture[i]->Texture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UniformName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(job->NormalTexture[i]->UVRepeat));
glUniform1i(glGetUniformLocation(shaderHandle, "NormalTextureType"), job->NormalTexture[0]->Texture->m_Type);
}
else {
glBindTexture(GL_TEXTURE_2D, m_NeutralNormalTexture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UniformName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
glUniform1i(glGetUniformLocation(shaderHandle, "NormalTextureType"), m_NeutralNormalTexture->m_Type);
}
texturePosition++;
}
@@ -1645,12 +1641,10 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptr<Model
if (job->NormalTexture.size() > 0 && job->NormalTexture[0]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->NormalTexture[0]->Texture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(job->NormalTexture[0]->UVRepeat));
glUniform1i(glGetUniformLocation(shaderHandle, "NormalTextureType"), job->NormalTexture[0]->Texture->m_Type);
}
else {
glBindTexture(GL_TEXTURE_2D, m_NeutralNormalTexture->m_Texture);
//glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
glUniform1i(glGetUniformLocation(shaderHandle, "NormalTextureType"), m_NeutralNormalTexture->m_Type);
glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
}
glActiveTexture(GL_TEXTURE3);
@@ -1682,60 +1676,57 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptr<Model
int texturePosition = GL_TEXTURE2;
//Bind 5 diffuse textures
std::string UVRepeatName = "DiffuseUVRepeat";
std::string UniformName = "DiffuseUVRepeat";
for (unsigned int i = 0; i < 3; i++) {
glActiveTexture(texturePosition);
if (job->DiffuseTexture.size() > i && job->DiffuseTexture[i]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->DiffuseTexture[i]->Texture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UVRepeatName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(job->DiffuseTexture[i]->UVRepeat));
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UniformName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(job->DiffuseTexture[i]->UVRepeat));
} else {
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UVRepeatName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UniformName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
}
texturePosition++;
}
//Bind 5 Normal textures
std::string textureType = "NormalTextureType";
UVRepeatName = "NormalUVRepeat";
UniformName = "NormalUVRepeat";
for (unsigned int i = 0; i < 3; i++) {
glActiveTexture(texturePosition);
if (job->NormalTexture.size() > i && job->NormalTexture[i]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->NormalTexture[i]->Texture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UVRepeatName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(job->NormalTexture[i]->UVRepeat));
glUniform1i(glGetUniformLocation(shaderHandle, std::string(textureType + ((char)(i + '1'))).c_str()), job->NormalTexture[i]->Texture->m_Type);
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UniformName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(job->NormalTexture[i]->UVRepeat));
} else {
glBindTexture(GL_TEXTURE_2D, m_NeutralNormalTexture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UVRepeatName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
glUniform1i(glGetUniformLocation(shaderHandle, std::string(textureType + ((char)(i + '1'))).c_str()), m_NeutralNormalTexture->m_Type);
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UniformName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
}
texturePosition++;
}
//Bind 5 Specular textures
UVRepeatName = "SpecularUVRepeat";
UniformName = "SpecularUVRepeat";
for (unsigned int i = 0; i < 3; i++) {
glActiveTexture(texturePosition);
if (job->SpecularTexture.size() > i && job->SpecularTexture[i]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->SpecularTexture[i]->Texture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UVRepeatName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(job->SpecularTexture[i]->UVRepeat));
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UniformName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(job->SpecularTexture[i]->UVRepeat));
} else {
glBindTexture(GL_TEXTURE_2D, m_GreyTexture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UVRepeatName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UniformName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
}
texturePosition++;
}
//Bind 5 Incandescence textures
UVRepeatName = "GlowUVRepeat";
UniformName = "GlowUVRepeat";
for (unsigned int i = 0; i < 3; i++) {
glActiveTexture(texturePosition);
if (job->IncandescenceTexture.size() > i && job->IncandescenceTexture[i]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture[i]->Texture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UVRepeatName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(job->IncandescenceTexture[i]->UVRepeat));
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UniformName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(job->IncandescenceTexture[i]->UVRepeat));
} else {
glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UVRepeatName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UniformName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
}
texturePosition++;
}
+2 -2
View File
@@ -96,10 +96,10 @@ PNG::~PNG()
void PNG::pngErrorFunction(png_structp png_ptr, png_const_charp error_msg)
{
LOG_WARNING("libpng error: %s", error_msg);
LOG_WARNING("%s", error_msg);
}
void PNG::pngWarningFunction(png_structp png_ptr, png_const_charp warning_msg)
{
LOG_WARNING("libpng warning: %s", warning_msg);
LOG_WARNING("%s", warning_msg);
}
+1 -1
View File
@@ -287,7 +287,7 @@ void RawModelCustom::ReadMaterialTextureProperties(RawModelCustom::TextureProper
}
texture.TexturePath = "Textures/";
texture.TexturePath += (fileData + offset);
texture.TexturePath += ".dds";
texture.TexturePath += ".png";
offset += nameLength;
if (offset + sizeof(glm::vec2) > fileByteSize) {
throw Resource::FailedLoadingException("Reading Material texture UVTiling failed");
+1 -1
View File
@@ -184,7 +184,7 @@ bool RenderSystem::isEntityVisible(EntityWrapper& entity)
}
// Hide things parented to local player if they have the HiddenFromLocalPlayer component
bool outOfBodyExperience = false; // ResourceManager::Load<ConfigFile>("Config.ini")->Get<bool>("Debug.OutOfBodyExperience", false);
bool outOfBodyExperience = ResourceManager::Load<ConfigFile>("Config.ini")->Get<bool>("Debug.OutOfBodyExperience", false);
if (
(entity.HasComponent("HiddenForLocalPlayer") || entity.FirstParentWithComponent("HiddenForLocalPlayer").Valid())
&& (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer))
+2 -1
View File
@@ -19,6 +19,7 @@ void Renderer::Initialize()
{
m_SSAO_Quality = m_Config->Get<int>("SSAO.Quality", 0);
m_GLOW_Quality = m_Config->Get<int>("GLOW.Quality", 0);
m_MSAA_Level = m_Config->Get<unsigned int>("MSAA.Level", 0);
InitializeWindow();
InitializeRenderPasses();
@@ -321,7 +322,7 @@ void Renderer::InitializeRenderPasses()
m_LightCullingPass = new LightCullingPass(this);
m_CubeMapPass = new CubeMapPass(this);
m_SSAOPass = new SSAOPass(this, m_Config);
m_ShadowPass = new ShadowPass(this, m_Config->Get<bool>("Shadows.Enable", false));
m_ShadowPass = new ShadowPass(this);
m_BlurHUDPass = new BlurHUD(this);
m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass, m_SSAOPass, m_ShadowPass, m_Config);
m_DrawScreenQuadPass = new DrawScreenQuadPass(this);
+17 -81
View File
@@ -1,84 +1,21 @@
#include "Rendering/ShadowPass.h"
ShadowPass::ShadowPass(IRenderer * renderer, int shadow_res_x, int shadow_res_y, bool useShadow)
ShadowPass::ShadowPass(IRenderer * renderer, int shadow_res_x, int shadow_res_y)
{
m_EnableShadows = useShadow;
if (useShadow) {
m_Renderer = renderer;
m_ResolutionSizeWidth = shadow_res_x;
m_ResolutionSizeHeight = shadow_res_y;
m_Renderer = renderer;
m_ResolutionSizeWidth = shadow_res_x;
m_ResolutionSizeHeight = shadow_res_y;
InitializeFrameBuffers();
InitializeShaderPrograms();
} else {
glGenTextures(1, &m_DepthMap);
glBindTexture(GL_TEXTURE_2D_ARRAY, m_DepthMap);
glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_DEPTH_COMPONENT16, 1, 1, m_CurrentNrOfSplits);
//glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, m_ResolutionSizeWidth, m_ResolutionSizeHeight, m_CurrentNrOfSplits, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
glTexParameterfv(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BORDER_COLOR, glm::vec4(1.f).data);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
m_DepthBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2DArray(&m_DepthMap, GL_DEPTH_ATTACHMENT)));
m_DepthBuffer.Generate();
m_DepthBuffer.Bind();
for (int i = 0; i < m_CurrentNrOfSplits; i++) {
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_DepthMap, 0, i);
glClear(GL_DEPTH_BUFFER_BIT);
}
m_DepthBuffer.Unbind();
}
InitializeFrameBuffers();
InitializeShaderPrograms();
}
ShadowPass::ShadowPass(IRenderer * renderer, bool useShadow)
ShadowPass::ShadowPass(IRenderer * renderer)
{
m_EnableShadows = useShadow;
if (useShadow) {
m_Renderer = renderer;
m_Renderer = renderer;
InitializeFrameBuffers();
InitializeShaderPrograms();
} else {
glGenTextures(1, &m_DepthMap);
glBindTexture(GL_TEXTURE_2D_ARRAY, m_DepthMap);
glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_DEPTH_COMPONENT16, 1, 1, m_CurrentNrOfSplits);
//glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, m_ResolutionSizeWidth, m_ResolutionSizeHeight, m_CurrentNrOfSplits, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
glTexParameterfv(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BORDER_COLOR, glm::vec4(1.f).data);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
m_DepthBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2DArray(&m_DepthMap, GL_DEPTH_ATTACHMENT)));
m_DepthBuffer.Generate();
m_DepthBuffer.Bind();
for (int i = 0; i < m_CurrentNrOfSplits; i++) {
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_DepthMap, 0, i);
glClear(GL_DEPTH_BUFFER_BIT);
}
m_DepthBuffer.Unbind();
}
InitializeFrameBuffers();
InitializeShaderPrograms();
}
ShadowPass::~ShadowPass()
@@ -183,6 +120,7 @@ float ShadowPass::FindRadius(ShadowFrustum& frustum)
radius = distance;
}
}
frustum.Radius = radius;
return radius;
}
@@ -230,17 +168,15 @@ void ShadowPass::InitializeShaderPrograms()
void ShadowPass::ClearBuffer()
{
if (m_EnableShadows) {
m_DepthBuffer.Bind();
m_DepthBuffer.Bind();
for (int i = 0; i < m_CurrentNrOfSplits; i++) {
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_DepthMap, 0, i);
for (int i = 0; i < m_CurrentNrOfSplits; i++) {
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_DepthMap, 0, i);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
m_DepthBuffer.Unbind();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
m_DepthBuffer.Unbind();
}
void ShadowPass::PointsToLightspace(ShadowFrustum& frustum, glm::mat4 v)
+9 -56
View File
@@ -2,21 +2,11 @@
Texture::Texture(std::string path)
{
std::string ext = boost::filesystem::path(path).extension().string();
Image* img;
if (ext == ".png") {
img = ResourceManager::Load<PNG, true>(path);
m_Type = TextureType::cPNG;
} else if (ext == ".dds") {
img = ResourceManager::Load<DDS, true>(path);
m_Type = TextureType::cDDS;
} else {
m_Type = TextureType::cInvalid;
throw Resource::FailedLoadingException("Texture extension is not .png nor .dds");
}
PNG* img = ResourceManager::Load<PNG, true>(path); //TODO: Make this threaded. Catch exeptions in all other load places.
this->Width = img->Width;
this->Height = img->Height;
this->Data = img->Data;
GLint format;
switch (img->Format) {
@@ -27,57 +17,20 @@ 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);
glTexImage2D(GL_TEXTURE_2D, 0, format, img->Width, img->Height, 0, format, GL_UNSIGNED_BYTE, img->Data);
glGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
if (!img->Compressed) {
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
}
unsigned int w = img->Width;
unsigned int h = img->Width;
unsigned char* data = img->Data;
for (int mipLevel = 0; mipLevel < 1 + img->MipMapLevels; mipLevel++) {
if (img->Compressed) {
//LOG_DEBUG("mipLevel: %i", mipLevel);
//LOG_DEBUG("w: %i", w);
//LOG_DEBUG("h: %i", h);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
GLERROR("Texture load");
std::size_t bpe = 16;
std::size_t numBlocksWide = std::max<std::size_t>(1, (w + 3) / 4);
std::size_t numBlocksHigh = std::max<std::size_t>(1, (h + 3) / 4);
std::size_t rowBytes = numBlocksWide * bpe;
std::size_t numRows = numBlocksHigh;
std::size_t numBytes = rowBytes * numBlocksHigh;
//LOG_DEBUG("numBytes: %i", numBytes);
glCompressedTexImage2D(GL_TEXTURE_2D, mipLevel, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, w, h, 0, numBytes, data);
data += numBytes;
} else {
glTexImage2D(GL_TEXTURE_2D, mipLevel, format, img->Width, img->Height, 0, format, GL_UNSIGNED_BYTE, img->Data);
}
w = w >> 1;
h = h >> 1;
}
//LOG_DEBUG("REMAINDER: %i", img->ByteSize - (data - img->Data));
// Generate mipmaps if the image file doesn't contain them
if (img->MipMapLevels == 0) {
glGenerateMipmap(GL_TEXTURE_2D);
}
if (ext == ".png") {
ResourceManager::Release("PNG", path);
} else if (ext == ".dds") {
ResourceManager::Release("DDS", path);
}
if (GLERROR("Texture load")) {
throw Resource::FailedLoadingException("GL texture generation failed");
}
ResourceManager::Release("PNG", path);
}
Texture::~Texture()
+1 -2
View File
@@ -54,9 +54,8 @@ Game::Game(int argc, char* argv[])
ResourceManager::RegisterType<Model>("Model");
ResourceManager::RegisterType<RawModel>("RawModel");
ResourceManager::RegisterType<Texture>("Texture");
ResourceManager::RegisterType<PNG>("PNG");
ResourceManager::RegisterType<TextureSprite>("TextureSprite");
ResourceManager::RegisterType<DDS>("DDS");
ResourceManager::RegisterType<PNG>("PNG");
ResourceManager::RegisterType<ShaderProgram>("ShaderProgram");
ResourceManager::RegisterType<EntityFile>("EntityFile");
ResourceManager::RegisterType<EntityXMLFile>("EntityXMLFile");
+2 -2
View File
@@ -21,7 +21,7 @@ void PlayerMovementSystem::Update(double dt)
{
updateMovementControllers(dt);
// Only do physics calculations on client and only for themselves.
if (IsClient) {
if (IsClient || true) {
if (LocalPlayer.Valid()){
updateVelocity(LocalPlayer, dt);
}
@@ -73,7 +73,7 @@ void PlayerMovementSystem::Update(double dt)
return;
}
for (auto cDash : *pool) {
if (cDash.EntityID != LocalPlayer.ID && (double)cDash["CoolDownMaxTimer"] - (double)cDash["CoolDownTimer"] < 0.5) {
if ((double)cDash["CoolDownMaxTimer"] - (double)cDash["CoolDownTimer"] < 0.5) {
// Spawn one afterimage for each player that Dashes.
EntityWrapper player(m_World, cDash.EntityID);
auto playerModel = player.FirstChildByName("PlayerModel");