Skip to content

Commit

Permalink
port to Ogre 13 (without RTSS)
Browse files Browse the repository at this point in the history
Joint effort by Petr Ohlidal (@only-a-ptr), @tritonas00, @AnotherFoxGuy


⬆️ Updated mygui, pagedgeometry and caelum
🐛 Fixed missing MyGUI shaders
🐛 Fixed MyGUI rendering issue
🔧 Build OGRE with resourcemanager_strict=off
updated rtshader media
🐛 Fixed cmake not accepting `CMAKE_CONFIGURATION_TYPES`
fixed odef lights scenenode
🐛 Fixed Caelum not loading os files
Caelum time slider: restored original code (it works with latest Ogre master branch)
🐛 Fixed Imgui inverted colours on DirectX 9
fixed survey map texture updating
⬆️ Update OGRE to 13.5
updated rtshader media for Ogre 13.5
🔧 Implement PSSM3 properly
⬆️ Update OGRE to 13.5.1
Fixed crash on loading 2nd terrain w/envmap enabled
⬆️ Update OGRE to 13.5.3
Fixed crash on 2nd map load (procedural road material conflict)
Media: fix corrupted DDS texture crashing under D3D9
  • Loading branch information
ohlidalp committed Dec 28, 2022
1 parent aab166c commit b25c8ee
Show file tree
Hide file tree
Showing 203 changed files with 5,282 additions and 8,034 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.16)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_SOURCE_DIR}/cmake/find-modules)

set(CMAKE_CONFIGURATION_TYPES "Debug" "Release" CACHE STRING "Configuration types")

include(CMakeDependentOption)
include(Macros)
include(FeatureSummary)
Expand Down Expand Up @@ -73,8 +75,6 @@ option(${_PREFIX}FORCE_SYSTEM_DEPENDENCIES "Force the use of system packages")
if (WIN32)
add_definitions("/D_CRT_SECURE_NO_WARNINGS /wd4005 /wd4996 /wd4251 /wd4275 /wd4099 /nologo")

set(CMAKE_CONFIGURATION_TYPES "Debug" "Release" CACHE STRING "Configuration types")

set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MP /GL /Ox /Ob2 /Oi /Ot /Oy /fp:fast /GS- /MP /Zi")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MP /Zi")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MP /Od /Zi /Gy /fp:except /GF- /GS /Ob0")
Expand Down
41 changes: 34 additions & 7 deletions cmake/DependenciesConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,22 @@ endif ()

set(ROR_FEAT_TIMING OFF)

if (USE_PACKAGE_MANAGER)
conan_add_remote(NAME ror-conan
URL https://git.anotherfoxguy.com/api/packages/rorbot/conan
VERIFY_SSL True
)
endif ()

# Some pkg-config files are broken, that is why they are commented out

add_external_lib(
OGRE
ogre3d/1.11.6.1@anotherfoxguy/stable
ogre3d/13.5.3@anotherfoxguy/stable
CONAN_OPTIONS ogre3d:resourcemanager_strict=off # ogre3d:rendersystem_vulkan=True
REQUIRED
# PKG_CONFIG "OGRE = 1.11.6"
FIND_PACKAGE_OPTIONS 1.11 COMPONENTS Bites Overlay Paging RTShaderSystem MeshLodGenerator Terrain
FIND_PACKAGE_OPTIONS 13 COMPONENTS Bites Overlay Paging RTShaderSystem MeshLodGenerator Terrain
)

add_external_lib(
Expand All @@ -28,17 +36,37 @@ add_external_lib(
FIND_PACKAGE_OPTIONS CONFIG
)


# TTTTTTTTTTTTTTTTTTTTTTT OOOOOOOOO DDDDDDDDDDDDD OOOOOOOOO
# T:::::::::::::::::::::T OO:::::::::OO D::::::::::::DDD OO:::::::::OO
# T:::::::::::::::::::::T OO:::::::::::::OO D:::::::::::::::DD OO:::::::::::::OO
# T:::::TT:::::::TT:::::TO:::::::OOO:::::::ODDD:::::DDDDD:::::D O:::::::OOO:::::::O
# TTTTTT T:::::T TTTTTTO::::::O O::::::O D:::::D D:::::D O::::::O O::::::O
# T:::::T O:::::O O:::::O D:::::D D:::::DO:::::O O:::::O
# T:::::T O:::::O O:::::O D:::::D D:::::DO:::::O O:::::O
# T:::::T O:::::O O:::::O D:::::D D:::::DO:::::O O:::::O
# T:::::T O:::::O O:::::O D:::::D D:::::DO:::::O O:::::O
# T:::::T O:::::O O:::::O D:::::D D:::::DO:::::O O:::::O
# T:::::T O:::::O O:::::O D:::::D D:::::DO:::::O O:::::O
# T:::::T O::::::O O::::::O D:::::D D:::::D O::::::O O::::::O
# TT:::::::TT O:::::::OOO:::::::ODDD:::::DDDDD:::::D O:::::::OOO:::::::O
# T:::::::::T OO:::::::::::::OO D:::::::::::::::DD OO:::::::::::::OO
# T:::::::::T OO:::::::::OO D::::::::::::DDD OO:::::::::OO
# TTTTTTTTTTT OOOOOOOOO DDDDDDDDDDDDD OOOOOOOOO
#
# TODO: Needs to reverted back to "ois/1.4@rigsofrods/custom", but this package as to be updated first

add_external_lib(
OIS
ois/1.4.1@rigsofrods/custom
ois/1.5.1@anotherfoxguy/stable
REQUIRED
PKG_CONFIG "ois >= 1.4"
FIND_PACKAGE
)

add_external_lib(
MyGUI
mygui/3.4.0@anotherfoxguy/stable
mygui/3.4.1@anotherfoxguy/stable
REQUIRED
# PKG_CONFIG "MYGUI = 3.4.0"
FIND_PACKAGE
Expand Down Expand Up @@ -67,14 +95,13 @@ add_external_lib(

add_external_lib(
Caelum
# Temporary switch back to the rigs of rods version, since the OGRE version is broken
ogre3d-caelum/0.6.3.1@anotherfoxguy/stable
ogre3d-caelum/2022.08@anotherfoxguy/stable
# PKG_CONFIG "Caelum >= 0.6.3"
FIND_PACKAGE
)
add_external_lib(
PagedGeometry
ogre3d-pagedgeometry/1.2.0@anotherfoxguy/stable
ogre3d-pagedgeometry/2022.08@anotherfoxguy/stable
# PKG_CONFIG "PagedGeometry >= 1.2"
FIND_PACKAGE
SYMBOL PAGED
Expand Down
38 changes: 38 additions & 0 deletions resources/OgreCore/DefaultShaders.metal
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "OgreUnifiedShader.h"

struct RasterizerData
{
vec4 pos [[position]];
vec2 uv;
};

struct Vertex
{
IN(vec3 pos, POSITION);
IN(vec2 uv, TEXCOORD0);
};

struct Uniform
{
mat4 mvpMtx;
mat4 texMtx;
};

// first 15 slots are reserved for the vertex attributes
#define UNIFORM_INDEX_START 16

vertex RasterizerData default_vp(Vertex in [[stage_in]],
constant Uniform& u [[buffer(UNIFORM_INDEX_START)]])
{
RasterizerData out;
out.pos = u.mvpMtx * vec4(in.pos, 1);
out.uv = (u.texMtx * vec4(in.uv,1,1)).xy;
return out;
}

fragment half4 default_fp(RasterizerData in [[stage_in]],
metal::texture2d<half> tex [[texture(0)]],
metal::sampler s [[sampler(0)]])
{
return tex.sample(s, in.uv);
}
86 changes: 86 additions & 0 deletions resources/OgreCore/GLSL_GL3Support.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// This file is part of the OGRE project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at https://www.ogre3d.org/licensing.

// @public-api

#if __VERSION__ == 100
mat2 transpose(mat2 m)
{
return mat2(m[0][0], m[1][0],
m[0][1], m[1][1]);
}

mat3 transpose(mat3 m)
{
return mat3(m[0][0], m[1][0], m[2][0],
m[0][1], m[1][1], m[2][1],
m[0][2], m[1][2], m[2][2]);
}

mat4 transpose(mat4 m)
{
return mat4(m[0][0], m[1][0], m[2][0], m[3][0],
m[0][1], m[1][1], m[2][1], m[3][1],
m[0][2], m[1][2], m[2][2], m[3][2],
m[0][3], m[1][3], m[2][3], m[3][3]);
}
#endif

#if __VERSION__ > 120 || defined(OGRE_GLSLANG)
#define texture1D texture
#define texture2D texture
#define texture3D texture
#define texture2DArray texture
#define textureCube texture
#define shadow2D texture
#define shadow2DProj textureProj
#define texture2DProj textureProj
#define texture2DLod textureLod
#define textureCubeLod textureLod

#if defined(OGRE_GLSLANG) || (__VERSION__ > 150 && defined(OGRE_VERTEX_SHADER)) || __VERSION__ >= 410
#define IN(decl, loc) layout(location = loc) in decl;
#else
#define IN(decl, loc) in decl;
#endif

#if defined(OGRE_GLSLANG) || (__VERSION__ > 150 && defined(OGRE_FRAGMENT_SHADER)) || __VERSION__ >= 410
#define OUT(decl, loc) layout(location = loc) out decl;
#else
#define OUT(decl, loc) out decl;
#endif

#else

#ifdef OGRE_VERTEX_SHADER
#define IN(decl, loc) attribute decl;
#define OUT(decl, loc) varying decl;
#else
#define IN(decl, loc) varying decl;
#define OUT(decl, loc) out decl;
#endif

#endif

#if defined(OGRE_FRAGMENT_SHADER) && (defined(OGRE_GLSLANG) || (__VERSION__ > 130))
#define gl_FragColor FragColor
OUT(vec4 FragColor, 0)
#endif

#ifdef VULKAN

#ifdef OGRE_VERTEX_SHADER
#define OGRE_UNIFORMS_BEGIN layout(binding = 0, row_major) uniform OgreUniforms {
#else
#define OGRE_UNIFORMS_BEGIN layout(binding = 1, row_major) uniform OgreUniforms {
#endif

#define OGRE_UNIFORMS_END };

#else

#define OGRE_UNIFORMS_BEGIN
#define OGRE_UNIFORMS_END

#endif
97 changes: 97 additions & 0 deletions resources/OgreCore/HLSL_SM4Support.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// This file is part of the OGRE project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at https://www.ogre3d.org/licensing.

// @public-api

#if OGRE_HLSL >= 4

// SM4 separates sampler into Texture and SamplerState

#define sampler1D Sampler1D
#define sampler2D Sampler2D
#define sampler3D Sampler3D
#define samplerCUBE SamplerCube

struct Sampler1D
{
Texture1D t;
SamplerState s;
};
struct Sampler2D
{
Texture2D t;
SamplerState s;
};
struct Sampler3D
{
Texture3D t;
SamplerState s;
};
struct SamplerCube
{
TextureCube t;
SamplerState s;
};

float4 tex1D(Sampler1D s, float v) { return s.t.Sample(s.s, v); }
float4 tex2D(Sampler2D s, float2 v) { return s.t.Sample(s.s, v); }
float4 tex3D(Sampler3D s, float3 v) { return s.t.Sample(s.s, v); }
float4 texCUBE(SamplerCube s, float3 v) { return s.t.Sample(s.s, v); }

float4 tex2D(Sampler2D s, float2 v, float2 ddx, float2 ddy) { return s.t.SampleGrad(s.s, v, ddx, ddy); }
float4 tex2Dproj(Sampler2D s, float4 v) { return s.t.Sample(s.s, v.xy/v.w); }
float4 tex2Dlod(Sampler2D s, float4 v) { return s.t.SampleLevel(s.s, v.xy, v.w); }

#define SAMPLER1D(name, reg) \
Texture1D name ## Tex : register(t ## reg);\
SamplerState name ## State : register(s ## reg);\
static Sampler1D name = {name ## Tex, name ## State}

#define SAMPLER2D(name, reg) \
Texture2D name ## Tex : register(t ## reg);\
SamplerState name ## State : register(s ## reg);\
static Sampler2D name = {name ## Tex, name ## State}

#define SAMPLER3D(name, reg) \
Texture3D name ## Tex : register(t ## reg);\
SamplerState name ## State : register(s ## reg);\
static Sampler3D name = {name ## Tex, name ## State}

#define SAMPLERCUBE(name, reg) \
TextureCube name ## Tex : register(t ## reg);\
SamplerState name ## State : register(s ## reg);\
static SamplerCube name = {name ## Tex, name ## State}

// the following are not available in D3D9, but provided for convenience
struct Sampler2DShadow
{
Texture2D t;
SamplerComparisonState s;
};
struct Sampler2DArray
{
Texture2DArray t;
SamplerState s;
};

#define SAMPLER2DSHADOW(name, reg) \
Texture2D name ## Tex : register(t ## reg);\
SamplerComparisonState name ## State : register(s ## reg);\
static Sampler2DShadow name = {name ## Tex, name ## State}

#define SAMPLER2DARRAY(name, reg) \
Texture2DArray name ## Tex : register(t ## reg);\
SamplerState name ## State : register(s ## reg);\
static Sampler2DArray name = {name ## Tex, name ## State}

float tex2Dcmp(Sampler2DShadow s, float3 v) { return s.t.SampleCmpLevelZero(s.s, v.xy, v.z); }
float4 tex2DARRAY(Sampler2DArray s, float3 v) { return s.t.Sample(s.s, v); }
#else

#define SAMPLER1D(name, reg) sampler1D name : register(s ## reg)
#define SAMPLER2D(name, reg) sampler2D name : register(s ## reg)
#define SAMPLER3D(name, reg) sampler3D name : register(s ## reg)
#define SAMPLERCUBE(name, reg) samplerCUBE name : register(s ## reg)

#endif
Loading

0 comments on commit b25c8ee

Please sign in to comment.