Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,56 @@ endif()
find_package(OpenSceneGraph REQUIRED osgDB osgViewer osgGA osgUtil)
find_package(SDL2 REQUIRED)
find_package(OpenGL REQUIRED)
find_package(MyGUI REQUIRED)

# MyGUI isn't in Homebrew any more, so on macOS a fresh checkout has nothing
# for FindMyGUI to locate. AUTO tries the system first and falls back to
# FetchContent when nothing turns up; ON skips the search and always fetches;
# OFF keeps the old behaviour and errors out if MyGUI isn't installed.
set(OPENDF_FETCH_MYGUI AUTO CACHE STRING
"Fetch and build MyGUI in-tree when not found (ON/OFF/AUTO)")
set_property(CACHE OPENDF_FETCH_MYGUI PROPERTY STRINGS AUTO ON OFF)

if(NOT OPENDF_FETCH_MYGUI STREQUAL "ON")
if(OPENDF_FETCH_MYGUI STREQUAL "OFF")
find_package(MyGUI REQUIRED)
else()
find_package(MyGUI QUIET)
endif()
endif()

if(NOT MyGUI_FOUND)
message(STATUS "MyGUI not found -- fetching MyGUI 3.4.4 in-tree")
include(FetchContent)
# Matches the macOS CI build exactly: only MyGUIEngine, dummy render
# platform, no obsolete delegates. Forced into the cache because MyGUI's
# own CMake reads these before we add_subdirectory it, and because our
# AUTO detection below has to see MYGUI_DONT_USE_OBSOLETE=ON so the
# library and opendf agree about widget layout.
set(MYGUI_RENDERSYSTEM 1 CACHE STRING "" FORCE) # 1 = Dummy, the smallest platform (0 isn't a valid value)
set(MYGUI_DONT_USE_OBSOLETE ON CACHE BOOL "" FORCE)
set(MYGUI_DISABLE_PLUGINS TRUE CACHE BOOL "" FORCE) # skips the whole Plugins tree
foreach(_opt DEMOS TOOLS PLUGINS DOCS UNITTESTS TEST_APP WRAPPER)
set(MYGUI_BUILD_${_opt} OFF CACHE BOOL "" FORCE)
endforeach()
FetchContent_Declare(mygui
GIT_REPOSITORY https://github.com/MyGUI/mygui.git
GIT_TAG MyGUI3.4.4
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(mygui)
# opendf includes MyGUI as <MYGUI/MyGUI_Foo.h>, which only exists once
# MyGUI is installed. The in-tree layout is MyGUIEngine/include/MyGUI_Foo.h
# (flat, no MYGUI/ prefix), so synthesize the prefix with a symlink and
# point the include dir at its parent.
file(MAKE_DIRECTORY "${mygui_BINARY_DIR}/opendf-include-shim")
file(CREATE_LINK
"${mygui_SOURCE_DIR}/MyGUIEngine/include"
"${mygui_BINARY_DIR}/opendf-include-shim/MYGUI"
SYMBOLIC COPY_ON_ERROR)
set(MyGUI_LIBRARIES MyGUIEngine)
set(MyGUI_INCLUDE_DIRS "${mygui_BINARY_DIR}/opendf-include-shim")
set(MyGUI_FOUND TRUE)
endif()

# MyGUI's EventPair is either a CompositeEvent (obsolete delegates enabled) or a
# bare Event, depending on MYGUI_DONT_USE_OBSOLETE. That choice changes the layout
Expand Down
8 changes: 3 additions & 5 deletions data/shaders/combiner.frag
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
#version 130
#version 120
#extension GL_ARB_texture_rectangle : enable

uniform sampler2DRect ColorTex;
uniform sampler2DRect DiffuseTex;
uniform sampler2DRect SpecularTex;

in vec4 TexCoord0;

out vec4 ColorOutput;
varying vec4 TexCoord0;

void main()
{
vec3 color = texture2DRect(ColorTex, TexCoord0.xy).rgb;
vec3 diffuse = texture2DRect(DiffuseTex, TexCoord0.xy).rgb;
vec3 specular = texture2DRect(SpecularTex, TexCoord0.xy).rgb;

ColorOutput = vec4(color*diffuse + specular, 1.0);
gl_FragColor = vec4(color*diffuse + specular, 1.0);
}
13 changes: 4 additions & 9 deletions data/shaders/combiner.vert
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#version 130
#version 120

uniform mat4 osg_ProjectionMatrix;

in vec4 osg_Vertex;
in vec4 osg_MultiTexCoord0;

out vec4 TexCoord0;
varying vec4 TexCoord0;

void main()
{
gl_Position = osg_ProjectionMatrix * osg_Vertex;
TexCoord0 = osg_MultiTexCoord0;
gl_Position = gl_ProjectionMatrix * gl_Vertex;
TexCoord0 = gl_MultiTexCoord0;
}
12 changes: 5 additions & 7 deletions data/shaders/dir_light.frag
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#version 130
#version 120
#extension GL_ARB_texture_rectangle : enable
#extension GL_ARB_draw_buffers : require

in vec3 localLightDir;
varying vec3 localLightDir;

uniform vec4 ambient_color;
uniform vec4 diffuse_color;
Expand All @@ -11,9 +12,6 @@ uniform sampler2DRect ColorTex;
uniform sampler2DRect NormalTex;
uniform sampler2DRect PosTex;

out vec4 DiffuseData;
out vec4 SpecularData;

void main()
{
vec4 c_viewspace = texture2DRect(ColorTex, gl_FragCoord.xy);
Expand All @@ -37,6 +35,6 @@ void main()
float amount = max(0.0, dot(h_viewspace, n_viewspace));
vec3 spec = specular_color.rgb * s_viewspace * pow(amount, 32.0) * c_viewspace.a;

DiffuseData = vec4(diff, 1.0);
SpecularData = vec4(spec, 1.0);
gl_FragData[0] = vec4(diff, 1.0);
gl_FragData[1] = vec4(spec, 1.0);
}
13 changes: 4 additions & 9 deletions data/shaders/dir_light.vert
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
#version 130

uniform mat4 osg_ProjectionMatrix;
uniform mat4 osg_ModelViewMatrix;
#version 120

uniform vec3 light_direction;

in vec4 osg_Vertex;

out vec3 localLightDir;
varying vec3 localLightDir;

void main()
{
localLightDir = mat3(osg_ModelViewMatrix) * light_direction;
localLightDir = mat3(gl_ModelViewMatrix) * light_direction;

// Vertex position in main camera Screen space.
gl_Position = osg_ProjectionMatrix * osg_Vertex;
gl_Position = gl_ProjectionMatrix * gl_Vertex;
}
31 changes: 14 additions & 17 deletions data/shaders/object.frag
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
#version 130
#version 120
#extension GL_EXT_texture_array : require
#extension GL_ARB_draw_buffers : require

uniform vec4 illumination_color;

uniform sampler2DArray diffuseTex;

in vec3 pos_viewspace;
in vec3 n_viewspace;
in vec3 t_viewspace;
in vec3 b_viewspace;
in vec4 TexCoords;
in vec4 Color;

out vec4 ColorData;
out vec4 NormalData;
out vec4 PositionData;
out vec4 IlluminationData;
varying vec3 pos_viewspace;
varying vec3 n_viewspace;
varying vec3 t_viewspace;
varying vec3 b_viewspace;
varying vec4 TexCoords;
varying vec4 Color;

void main()
{
vec4 color = vec4(texture(diffuseTex, TexCoords.xyz).rgb, 0.0);
vec4 color = vec4(texture2DArray(diffuseTex, TexCoords.xyz).rgb, 0.0);
vec4 nn = vec4(0.5, 0.5, 1.0, 1.0);

mat3 nmat = mat3(normalize(t_viewspace),
normalize(b_viewspace),
normalize(n_viewspace));

ColorData = color * vec4(Color.rgb, 1.0);
NormalData = vec4(nmat*(nn.xyz - vec3(0.5)) + vec3(0.5), nn.w);
PositionData = vec4(pos_viewspace, gl_FragCoord.z);
IlluminationData = illumination_color;
gl_FragData[0] = color * vec4(Color.rgb, 1.0);
gl_FragData[1] = vec4(nmat*(nn.xyz - vec3(0.5)) + vec3(0.5), nn.w);
gl_FragData[2] = vec4(pos_viewspace, gl_FragCoord.z);
gl_FragData[3] = illumination_color;
}
36 changes: 14 additions & 22 deletions data/shaders/object.vert
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
#version 130
#version 120

uniform mat4 osg_ModelViewProjectionMatrix;
uniform mat4 osg_ModelViewMatrix;

in vec4 osg_Vertex;
in vec3 osg_Normal;
in vec3 osg_MultiTexCoord1; // Binormal
in vec4 osg_Color;
in vec4 osg_MultiTexCoord0;

out vec3 pos_viewspace;
out vec3 n_viewspace;
out vec3 t_viewspace;
out vec3 b_viewspace;
out vec4 TexCoords;
out vec4 Color;
varying vec3 pos_viewspace;
varying vec3 n_viewspace;
varying vec3 t_viewspace;
varying vec3 b_viewspace;
varying vec4 TexCoords;
varying vec4 Color;

void main()
{
gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;
TexCoords = osg_MultiTexCoord0;
Color = osg_Color;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
TexCoords = gl_MultiTexCoord0;
Color = gl_Color;

pos_viewspace = (osg_ModelViewMatrix * osg_Vertex).xyz;
pos_viewspace = (gl_ModelViewMatrix * gl_Vertex).xyz;

n_viewspace = normalize(mat3(osg_ModelViewMatrix) * osg_Normal);
b_viewspace = normalize(mat3(osg_ModelViewMatrix) * osg_MultiTexCoord1);
n_viewspace = normalize(gl_NormalMatrix * gl_Normal);
// meshmanager packs the binormal into texcoord unit 1 (see setTexCoordArray(1, ...))
b_viewspace = normalize(mat3(gl_ModelViewMatrix) * gl_MultiTexCoord1.xyz);
t_viewspace = cross(n_viewspace, b_viewspace);
}
8 changes: 3 additions & 5 deletions data/shaders/quad_rect.frag
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#version 130
#version 120
#extension GL_ARB_texture_rectangle : enable

uniform sampler2DRect TexImage;

in vec4 TexCoord0;

out vec4 ColorOutput;
varying vec4 TexCoord0;

void main()
{
ColorOutput = texture2DRect(TexImage, TexCoord0.xy);
gl_FragColor = texture2DRect(TexImage, TexCoord0.xy);
}
13 changes: 4 additions & 9 deletions data/shaders/quad_rect.vert
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#version 130
#version 120

uniform mat4 osg_ProjectionMatrix;

in vec4 osg_Vertex;
in vec4 osg_MultiTexCoord0;

out vec4 TexCoord0;
varying vec4 TexCoord0;

void main()
{
gl_Position = osg_ProjectionMatrix * osg_Vertex;
TexCoord0 = osg_MultiTexCoord0;
gl_Position = gl_ProjectionMatrix * gl_Vertex;
TexCoord0 = gl_MultiTexCoord0;
}
10 changes: 4 additions & 6 deletions data/shaders/quad_ui.frag
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#version 130
#version 120

uniform sampler2D TexImage;

in vec4 Color;
in vec4 TexCoord0;

out vec4 ColorOutput;
varying vec4 Color;
varying vec4 TexCoord0;

void main()
{
ColorOutput = texture2D(TexImage, TexCoord0.xy) * Color;
gl_FragColor = texture2D(TexImage, TexCoord0.xy) * Color;
}
18 changes: 6 additions & 12 deletions data/shaders/quad_ui.vert
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
#version 130
#version 120

uniform mat4 osg_ProjectionMatrix;

in vec4 osg_Vertex;
in vec4 osg_Color;
in vec4 osg_MultiTexCoord0;

out vec4 Color;
out vec4 TexCoord0;
varying vec4 Color;
varying vec4 TexCoord0;

void main()
{
gl_Position = osg_ProjectionMatrix * osg_Vertex;
TexCoord0 = osg_MultiTexCoord0;
Color = osg_Color;
gl_Position = gl_ProjectionMatrix * gl_Vertex;
TexCoord0 = gl_MultiTexCoord0;
Color = gl_Color;
}
31 changes: 14 additions & 17 deletions data/shaders/sprite.frag
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
#version 130
#version 120
#extension GL_EXT_texture_array : require
#extension GL_ARB_draw_buffers : require

uniform vec4 illumination_color;

uniform sampler2DArray diffuseTex;

in vec3 pos_viewspace;
in vec3 n_viewspace;
in vec3 t_viewspace;
in vec3 b_viewspace;
in vec4 TexCoords;
in vec4 Color;

out vec4 ColorData;
out vec4 NormalData;
out vec4 PositionData;
out vec4 IlluminationData;
varying vec3 pos_viewspace;
varying vec3 n_viewspace;
varying vec3 t_viewspace;
varying vec3 b_viewspace;
varying vec4 TexCoords;
varying vec4 Color;

void main()
{
vec4 color = texture(diffuseTex, TexCoords.xyz);
vec4 color = texture2DArray(diffuseTex, TexCoords.xyz);
color.a = ((color.a < 0.5) ? 1.0 : 0.0);
vec4 nn = vec4(0.5, 0.5, 1.0, 1.0);

mat3 nmat = mat3(normalize(t_viewspace),
normalize(b_viewspace),
normalize(n_viewspace));

ColorData = color * vec4(Color.rgb, 1.0);
NormalData = vec4(nmat*(nn.xyz - vec3(0.5)) + vec3(0.5), nn.w);
PositionData = vec4(pos_viewspace, gl_FragCoord.z);
IlluminationData = illumination_color;
gl_FragData[0] = color * vec4(Color.rgb, 1.0);
gl_FragData[1] = vec4(nmat*(nn.xyz - vec3(0.5)) + vec3(0.5), nn.w);
gl_FragData[2] = vec4(pos_viewspace, gl_FragCoord.z);
gl_FragData[3] = illumination_color;
}
Loading
Loading