mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-29 08:15:35 +00:00
Revert "Merge remote-tracking branch 'sandstranger/opengles'"
This reverts commitcc9cab6fd1
, reversing changes made toda856eed95
.
This commit is contained in:
parent
ef68e2aec4
commit
8a3ec14bc6
15 changed files with 70 additions and 659 deletions
|
@ -47,20 +47,8 @@ include(OpenMWMacros)
|
||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID)
|
||||||
set(CMAKE_FIND_ROOT_PATH ${OPENMW_DEPENDENCIES_DIR} "${CMAKE_FIND_ROOT_PATH}")
|
set(CMAKE_FIND_ROOT_PATH ${OPENMW_DEPENDENCIES_DIR} "${CMAKE_FIND_ROOT_PATH}")
|
||||||
set(OSG_PLUGINS_DIR ${OSG_PLUGINS_DIR})
|
|
||||||
add_definitions (-DOSG_PLUGINS_DIR)
|
|
||||||
set(OPENGLES TRUE CACHE BOOL "enable opengl es support for android" FORCE)
|
|
||||||
endif (ANDROID)
|
endif (ANDROID)
|
||||||
|
|
||||||
option(OPENGLES "enable opengl es support" FALSE )
|
|
||||||
|
|
||||||
if (OPENGLES)
|
|
||||||
INCLUDE(cmake/FindOpenGLES.cmake)
|
|
||||||
INCLUDE(cmake/FindOpenGLES2.cmake)
|
|
||||||
add_definitions (-DOPENGLES)
|
|
||||||
INCLUDE_DIRECTORIES(${OPENGLES_INCLUDE_DIR})
|
|
||||||
endif (OPENGLES)
|
|
||||||
|
|
||||||
# doxygen main page
|
# doxygen main page
|
||||||
|
|
||||||
configure_file ("${OpenMW_SOURCE_DIR}/docs/mainpage.hpp.cmake" "${OpenMW_BINARY_DIR}/docs/mainpage.hpp")
|
configure_file ("${OpenMW_SOURCE_DIR}/docs/mainpage.hpp.cmake" "${OpenMW_BINARY_DIR}/docs/mainpage.hpp")
|
||||||
|
@ -157,21 +145,21 @@ if (WIN32)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
if (NOT ANDROID)
|
|
||||||
set(DESIRED_QT_VERSION 4 CACHE STRING "The QT version OpenMW should use (4 or 5)")
|
|
||||||
message(STATUS "Using Qt${DESIRED_QT_VERSION}")
|
|
||||||
|
|
||||||
if (DESIRED_QT_VERSION MATCHES 4)
|
set(DESIRED_QT_VERSION 4 CACHE STRING "The QT version OpenMW should use (4 or 5)")
|
||||||
find_package(Qt4 REQUIRED COMPONENTS QtCore QtGui QtNetwork QtOpenGL)
|
message(STATUS "Using Qt${DESIRED_QT_VERSION}")
|
||||||
else()
|
|
||||||
find_package(Qt5Widgets REQUIRED)
|
if (DESIRED_QT_VERSION MATCHES 4)
|
||||||
find_package(Qt5Core REQUIRED)
|
find_package(Qt4 REQUIRED COMPONENTS QtCore QtGui QtNetwork QtOpenGL)
|
||||||
find_package(Qt5Network REQUIRED)
|
else()
|
||||||
find_package(Qt5OpenGL REQUIRED)
|
find_package(Qt5Widgets REQUIRED)
|
||||||
# Instruct CMake to run moc automatically when needed.
|
find_package(Qt5Core REQUIRED)
|
||||||
#set(CMAKE_AUTOMOC ON)
|
find_package(Qt5Network REQUIRED)
|
||||||
endif()
|
find_package(Qt5OpenGL REQUIRED)
|
||||||
|
# Instruct CMake to run moc automatically when needed.
|
||||||
|
#set(CMAKE_AUTOMOC ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Fix for not visible pthreads functions for linker with glibc 2.15
|
# Fix for not visible pthreads functions for linker with glibc 2.15
|
||||||
if (UNIX AND NOT APPLE)
|
if (UNIX AND NOT APPLE)
|
||||||
find_package (Threads)
|
find_package (Threads)
|
||||||
|
@ -201,11 +189,7 @@ IF(BOOST_STATIC)
|
||||||
set(Boost_USE_STATIC_LIBS ON)
|
set(Boost_USE_STATIC_LIBS ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT ANDROID)
|
find_package(OpenSceneGraph 3.2.0 REQUIRED osgDB osgViewer osgText osgGA osgAnimation osgParticle osgQt osgUtil osgFX)
|
||||||
find_package(OpenSceneGraph 3.2.0 REQUIRED osgDB osgViewer osgText osgGA osgAnimation osgParticle osgQt osgUtil osgFX)
|
|
||||||
else()
|
|
||||||
find_package(OpenSceneGraph 3.2.0 REQUIRED osgDB osgViewer osgText osgGA osgAnimation osgParticle osgUtil osgFX)
|
|
||||||
endif()
|
|
||||||
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS})
|
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS})
|
||||||
|
|
||||||
if(OSG_STATIC)
|
if(OSG_STATIC)
|
||||||
|
|
|
@ -134,50 +134,18 @@ target_link_libraries(openmw
|
||||||
)
|
)
|
||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID)
|
||||||
set (OSG_PLUGINS
|
|
||||||
-Wl,--whole-archive
|
|
||||||
${OSG_PLUGINS_DIR}/libosgdb_dds.a
|
|
||||||
${OSG_PLUGINS_DIR}/libosgdb_bmp.a
|
|
||||||
${OSG_PLUGINS_DIR}/libosgdb_tga.a
|
|
||||||
${OSG_PLUGINS_DIR}/libosgdb_gif.a
|
|
||||||
${OSG_PLUGINS_DIR}/libosgdb_jpeg.a
|
|
||||||
${OSG_PLUGINS_DIR}/libosgdb_png.a
|
|
||||||
-Wl,--no-whole-archive
|
|
||||||
)
|
|
||||||
target_link_libraries(openmw
|
target_link_libraries(openmw
|
||||||
EGL
|
EGL
|
||||||
android
|
android
|
||||||
log
|
log
|
||||||
dl
|
dl
|
||||||
MyGUIEngineStatic
|
MyGUIEngineStatic
|
||||||
|
cpufeatures
|
||||||
BulletCollision
|
BulletCollision
|
||||||
LinearMath
|
LinearMath
|
||||||
z
|
|
||||||
osg
|
|
||||||
osgDB
|
|
||||||
osgAnimation
|
|
||||||
osgText
|
|
||||||
osgUtil
|
|
||||||
osgShadow
|
|
||||||
${OPENSCENEGRAPH_LIBRARIES}
|
|
||||||
${OSG_PLUGINS}
|
|
||||||
${Boost_SYSTEM_LIBRARY}
|
|
||||||
${Boost_THREAD_LIBRARY}
|
|
||||||
${Boost_FILESYSTEM_LIBRARY}
|
|
||||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
|
||||||
jpeg
|
|
||||||
gif
|
|
||||||
png
|
|
||||||
)
|
)
|
||||||
endif (ANDROID)
|
endif (ANDROID)
|
||||||
|
|
||||||
if (OPENGLES)
|
|
||||||
target_link_libraries(openmw
|
|
||||||
${OPENGLES_gl_LIBRARY}
|
|
||||||
${OPENGLES2_gl_LIBRARY}
|
|
||||||
)
|
|
||||||
endif (OPENGLES)
|
|
||||||
|
|
||||||
if (USE_SYSTEM_TINYXML)
|
if (USE_SYSTEM_TINYXML)
|
||||||
target_link_libraries(openmw ${TINYXML_LIBRARIES})
|
target_link_libraries(openmw ${TINYXML_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include "../../SDL_internal.h"
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
#include "SDL_main.h"
|
#include "SDL_main.h"
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if (defined(__APPLE__) || (defined(__linux) && !defined(ANDROID)) || (defined(__unix) && !defined(ANDROID)) || defined(__posix))
|
#if (defined(__APPLE__) || defined(__linux) || defined(__unix) || defined(__posix))
|
||||||
#define USE_CRASH_CATCHER 1
|
#define USE_CRASH_CATCHER 1
|
||||||
#else
|
#else
|
||||||
#define USE_CRASH_CATCHER 0
|
#define USE_CRASH_CATCHER 0
|
||||||
|
|
|
@ -24,11 +24,6 @@
|
||||||
|
|
||||||
#include "vismask.hpp"
|
#include "vismask.hpp"
|
||||||
|
|
||||||
#ifdef OPENGLES
|
|
||||||
#include <GLES/gl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -45,11 +45,6 @@
|
||||||
#include "vismask.hpp"
|
#include "vismask.hpp"
|
||||||
#include "renderbin.hpp"
|
#include "renderbin.hpp"
|
||||||
|
|
||||||
#ifdef OPENGLES
|
|
||||||
#include <GLES/gl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -40,10 +40,6 @@
|
||||||
#include "ripplesimulation.hpp"
|
#include "ripplesimulation.hpp"
|
||||||
#include "renderbin.hpp"
|
#include "renderbin.hpp"
|
||||||
|
|
||||||
#ifdef OPENGLES
|
|
||||||
#include <GLES/gl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -579,13 +575,10 @@ void Water::createShaderWaterStateSet(osg::Node* node, Reflection* reflection, R
|
||||||
// use a define map to conditionally compile the shader
|
// use a define map to conditionally compile the shader
|
||||||
std::map<std::string, std::string> defineMap;
|
std::map<std::string, std::string> defineMap;
|
||||||
defineMap.insert(std::make_pair(std::string("@refraction_enabled"), std::string(refraction ? "1" : "0")));
|
defineMap.insert(std::make_pair(std::string("@refraction_enabled"), std::string(refraction ? "1" : "0")));
|
||||||
#ifdef OPENGLES
|
|
||||||
osg::ref_ptr<osg::Shader> vertexShader (readShader(osg::Shader::VERTEX, mResourcePath + "/shaders/watergles_vertex.glsl", defineMap));
|
|
||||||
osg::ref_ptr<osg::Shader> fragmentShader (readShader(osg::Shader::FRAGMENT, mResourcePath + "/shaders/watergles_fragment.glsl", defineMap));
|
|
||||||
#else
|
|
||||||
osg::ref_ptr<osg::Shader> vertexShader (readShader(osg::Shader::VERTEX, mResourcePath + "/shaders/water_vertex.glsl", defineMap));
|
osg::ref_ptr<osg::Shader> vertexShader (readShader(osg::Shader::VERTEX, mResourcePath + "/shaders/water_vertex.glsl", defineMap));
|
||||||
osg::ref_ptr<osg::Shader> fragmentShader (readShader(osg::Shader::FRAGMENT, mResourcePath + "/shaders/water_fragment.glsl", defineMap));
|
osg::ref_ptr<osg::Shader> fragmentShader (readShader(osg::Shader::FRAGMENT, mResourcePath + "/shaders/water_fragment.glsl", defineMap));
|
||||||
#endif
|
|
||||||
osg::ref_ptr<osg::Texture2D> normalMap (new osg::Texture2D(readPngImage(mResourcePath + "/shaders/water_nm.png")));
|
osg::ref_ptr<osg::Texture2D> normalMap (new osg::Texture2D(readPngImage(mResourcePath + "/shaders/water_nm.png")));
|
||||||
normalMap->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
|
normalMap->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
|
||||||
normalMap->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
|
normalMap->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
|
||||||
|
|
|
@ -1,94 +0,0 @@
|
||||||
#-------------------------------------------------------------------
|
|
||||||
# This file is part of the CMake build system for OGRE
|
|
||||||
# (Object-oriented Graphics Rendering Engine)
|
|
||||||
# For the latest info, see http://www.ogre3d.org/
|
|
||||||
#
|
|
||||||
# The contents of this file are placed in the public domain. Feel
|
|
||||||
# free to make use of it in any way you like.
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
|
|
||||||
# - Try to find OpenGLES
|
|
||||||
# Once done this will define
|
|
||||||
#
|
|
||||||
# OPENGLES_FOUND - system has OpenGLES
|
|
||||||
# OPENGLES_INCLUDE_DIR - the GL include directory
|
|
||||||
# OPENGLES_LIBRARIES - Link these to use OpenGLES
|
|
||||||
|
|
||||||
IF (WIN32)
|
|
||||||
IF (CYGWIN)
|
|
||||||
|
|
||||||
FIND_PATH(OPENGLES_INCLUDE_DIR GLES/gl.h )
|
|
||||||
|
|
||||||
FIND_LIBRARY(OPENGLES_gl_LIBRARY libgles_cm )
|
|
||||||
|
|
||||||
ELSE (CYGWIN)
|
|
||||||
|
|
||||||
IF(BORLAND)
|
|
||||||
SET (OPENGLES_gl_LIBRARY import32 CACHE STRING "OpenGL ES 1.x library for win32")
|
|
||||||
ELSE(BORLAND)
|
|
||||||
#MS compiler - todo - fix the following line:
|
|
||||||
SET (OPENGLES_gl_LIBRARY ${OGRE_SOURCE_DIR}/Dependencies/lib/release/libgles_cm.lib CACHE STRING "OpenGL ES 1.x library for win32")
|
|
||||||
ENDIF(BORLAND)
|
|
||||||
|
|
||||||
ENDIF (CYGWIN)
|
|
||||||
|
|
||||||
ELSE (WIN32)
|
|
||||||
|
|
||||||
IF (APPLE)
|
|
||||||
|
|
||||||
#create_search_paths(/Developer/Platforms)
|
|
||||||
#findpkg_framework(OpenGLES)
|
|
||||||
#set(OPENGLES_gl_LIBRARY "-framework OpenGLES")
|
|
||||||
|
|
||||||
ELSE(APPLE)
|
|
||||||
|
|
||||||
FIND_PATH(OPENGLES_INCLUDE_DIR GLES/gl.h
|
|
||||||
/opt/vc/include
|
|
||||||
/opt/graphics/OpenGL/include
|
|
||||||
/usr/openwin/share/include
|
|
||||||
/usr/X11R6/include
|
|
||||||
/usr/include
|
|
||||||
)
|
|
||||||
|
|
||||||
FIND_LIBRARY(OPENGLES_gl_LIBRARY
|
|
||||||
NAMES GLES_CM GLESv1_CM
|
|
||||||
PATHS /opt/vc/lib
|
|
||||||
/opt/graphics/OpenGL/lib
|
|
||||||
/usr/openwin/lib
|
|
||||||
/usr/shlib /usr/X11R6/lib
|
|
||||||
/usr/lib
|
|
||||||
)
|
|
||||||
|
|
||||||
# On Unix OpenGL most certainly always requires X11.
|
|
||||||
# Feel free to tighten up these conditions if you don't
|
|
||||||
# think this is always true.
|
|
||||||
|
|
||||||
#IF (OPENGLES_gl_LIBRARY)
|
|
||||||
# IF(NOT X11_FOUND)
|
|
||||||
# INCLUDE(FindX11)
|
|
||||||
# ENDIF(NOT X11_FOUND)
|
|
||||||
# IF (X11_FOUND)
|
|
||||||
# SET (OPENGLES_LIBRARIES ${X11_LIBRARIES})
|
|
||||||
# ENDIF (X11_FOUND)
|
|
||||||
#ENDIF (OPENGLES_gl_LIBRARY)
|
|
||||||
|
|
||||||
ENDIF(APPLE)
|
|
||||||
ENDIF (WIN32)
|
|
||||||
|
|
||||||
SET( OPENGLES_FOUND "NO" )
|
|
||||||
IF(OPENGLES_gl_LIBRARY)
|
|
||||||
|
|
||||||
SET( OPENGLES_LIBRARIES ${OPENGLES_gl_LIBRARY} ${OPENGLES_LIBRARIES})
|
|
||||||
|
|
||||||
SET( OPENGLES_FOUND "YES" )
|
|
||||||
|
|
||||||
ENDIF(OPENGLES_gl_LIBRARY)
|
|
||||||
|
|
||||||
MARK_AS_ADVANCED(
|
|
||||||
OPENGLES_INCLUDE_DIR
|
|
||||||
OPENGLES_gl_LIBRARY
|
|
||||||
)
|
|
||||||
|
|
||||||
INCLUDE(FindPackageHandleStandardArgs)
|
|
||||||
|
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENGLES REQUIRED_VARS OPENGLES_LIBRARIES OPENGLES_INCLUDE_DIR)
|
|
|
@ -1,170 +0,0 @@
|
||||||
#-------------------------------------------------------------------
|
|
||||||
# This file is part of the CMake build system for OGRE
|
|
||||||
# (Object-oriented Graphics Rendering Engine)
|
|
||||||
# For the latest info, see http://www.ogre3d.org/
|
|
||||||
#
|
|
||||||
# The contents of this file are placed in the public domain. Feel
|
|
||||||
# free to make use of it in any way you like.
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
|
|
||||||
# - Try to find OpenGLES and EGL
|
|
||||||
# If using ARM Mali emulation you can specify the parent directory that contains the bin and include directories by
|
|
||||||
# setting the MALI_SDK_ROOT variable in the environment.
|
|
||||||
#
|
|
||||||
# For AMD emulation use the AMD_SDK_ROOT variable
|
|
||||||
#
|
|
||||||
# Once done this will define
|
|
||||||
#
|
|
||||||
# OPENGLES2_FOUND - system has OpenGLES
|
|
||||||
# OPENGLES2_INCLUDE_DIR - the GL include directory
|
|
||||||
# OPENGLES2_LIBRARIES - Link these to use OpenGLES
|
|
||||||
#
|
|
||||||
# EGL_FOUND - system has EGL
|
|
||||||
# EGL_INCLUDE_DIR - the EGL include directory
|
|
||||||
# EGL_LIBRARIES - Link these to use EGL
|
|
||||||
|
|
||||||
#include(FindPkgMacros)
|
|
||||||
|
|
||||||
IF (WIN32)
|
|
||||||
IF (CYGWIN)
|
|
||||||
|
|
||||||
FIND_PATH(OPENGLES2_INCLUDE_DIR GLES2/gl2.h )
|
|
||||||
|
|
||||||
FIND_LIBRARY(OPENGLES2_gl_LIBRARY libGLESv2 )
|
|
||||||
|
|
||||||
ELSE (CYGWIN)
|
|
||||||
|
|
||||||
IF(BORLAND)
|
|
||||||
SET (OPENGLES2_gl_LIBRARY import32 CACHE STRING "OpenGL ES 2.x library for win32")
|
|
||||||
ELSE(BORLAND)
|
|
||||||
#getenv_path(AMD_SDK_ROOT)
|
|
||||||
#getenv_path(MALI_SDK_ROOT)
|
|
||||||
|
|
||||||
SET(POWERVR_SDK_PATH "C:/Imagination/PowerVR/GraphicsSDK/SDK_3.1/Builds")
|
|
||||||
FIND_PATH(OPENGLES2_INCLUDE_DIR GLES2/gl2.h
|
|
||||||
${ENV_AMD_SDK_ROOT}/include
|
|
||||||
${ENV_MALI_SDK_ROOT}/include
|
|
||||||
${POWERVR_SDK_PATH}/Include
|
|
||||||
"C:/Imagination Technologies/PowerVR Insider SDK/OGLES2_WINDOWS_X86EMULATION_2.10/Builds/OGLES2/Include"
|
|
||||||
)
|
|
||||||
|
|
||||||
FIND_PATH(EGL_INCLUDE_DIR EGL/egl.h
|
|
||||||
${ENV_AMD_SDK_ROOT}/include
|
|
||||||
${ENV_MALI_SDK_ROOT}/include
|
|
||||||
${POWERVR_SDK_PATH}/Include
|
|
||||||
"C:/Imagination Technologies/PowerVR Insider SDK/OGLES2_WINDOWS_X86EMULATION_2.10/Builds/OGLES2/Include"
|
|
||||||
)
|
|
||||||
|
|
||||||
FIND_LIBRARY(OPENGLES2_gl_LIBRARY
|
|
||||||
NAMES libGLESv2
|
|
||||||
PATHS ${ENV_AMD_SDK_ROOT}/x86
|
|
||||||
${ENV_MALI_SDK_ROOT}/bin
|
|
||||||
${POWERVR_SDK_PATH}/Windows/x86_32/Lib
|
|
||||||
"C:/Imagination Technologies/PowerVR Insider SDK/OGLES2_WINDOWS_X86EMULATION_2.10/Builds/OGLES2/WindowsX86/Lib"
|
|
||||||
)
|
|
||||||
|
|
||||||
FIND_LIBRARY(EGL_egl_LIBRARY
|
|
||||||
NAMES libEGL
|
|
||||||
PATHS ${ENV_AMD_SDK_ROOT}/x86
|
|
||||||
${ENV_MALI_SDK_ROOT}/bin
|
|
||||||
${POWERVR_SDK_PATH}/Windows/x86_32/Lib
|
|
||||||
"C:/Imagination Technologies/PowerVR Insider SDK/OGLES2_WINDOWS_X86EMULATION_2.10/Builds/OGLES2/WindowsX86/Lib"
|
|
||||||
)
|
|
||||||
ENDIF(BORLAND)
|
|
||||||
|
|
||||||
ENDIF (CYGWIN)
|
|
||||||
|
|
||||||
ELSE (WIN32)
|
|
||||||
|
|
||||||
IF (APPLE)
|
|
||||||
|
|
||||||
#create_search_paths(/Developer/Platforms)
|
|
||||||
#findpkg_framework(OpenGLES2)
|
|
||||||
#set(OPENGLES2_gl_LIBRARY "-framework OpenGLES")
|
|
||||||
|
|
||||||
ELSE(APPLE)
|
|
||||||
#getenv_path(AMD_SDK_ROOT)
|
|
||||||
#getenv_path(MALI_SDK_ROOT)
|
|
||||||
|
|
||||||
FIND_PATH(OPENGLES2_INCLUDE_DIR GLES2/gl2.h
|
|
||||||
${ENV_AMD_SDK_ROOT}/include
|
|
||||||
${ENV_MALI_SDK_ROOT}/include
|
|
||||||
/opt/Imagination/PowerVR/GraphicsSDK/SDK_3.1/Builds/Include
|
|
||||||
/opt/vc/include
|
|
||||||
/usr/openwin/share/include
|
|
||||||
/opt/graphics/OpenGL/include /usr/X11R6/include
|
|
||||||
/usr/include
|
|
||||||
)
|
|
||||||
|
|
||||||
FIND_LIBRARY(OPENGLES2_gl_LIBRARY
|
|
||||||
NAMES GLESv2
|
|
||||||
PATHS ${ENV_AMD_SDK_ROOT}/x86
|
|
||||||
${ENV_MALI_SDK_ROOT}/bin
|
|
||||||
/opt/Imagination/PowerVR/GraphicsSDK/SDK_3.1/Builds/Linux/x86_32/Lib
|
|
||||||
/opt/vc/lib
|
|
||||||
/opt/graphics/OpenGL/lib
|
|
||||||
/usr/openwin/lib
|
|
||||||
/usr/shlib /usr/X11R6/lib
|
|
||||||
/usr/lib
|
|
||||||
)
|
|
||||||
|
|
||||||
FIND_PATH(EGL_INCLUDE_DIR EGL/egl.h
|
|
||||||
${ENV_AMD_SDK_ROOT}/include
|
|
||||||
${ENV_MALI_SDK_ROOT}/include
|
|
||||||
/opt/Imagination/PowerVR/GraphicsSDK/SDK_3.1/Builds/Include
|
|
||||||
/opt/vc/include
|
|
||||||
/usr/openwin/share/include
|
|
||||||
/opt/graphics/OpenGL/include /usr/X11R6/include
|
|
||||||
/usr/include
|
|
||||||
)
|
|
||||||
|
|
||||||
FIND_LIBRARY(EGL_egl_LIBRARY
|
|
||||||
NAMES EGL
|
|
||||||
PATHS ${ENV_AMD_SDK_ROOT}/x86
|
|
||||||
${ENV_MALI_SDK_ROOT}/bin
|
|
||||||
/opt/Imagination/PowerVR/GraphicsSDK/SDK_3.1/Builds/Linux/x86_32/Lib
|
|
||||||
/opt/vc/lib
|
|
||||||
/opt/graphics/OpenGL/lib
|
|
||||||
/usr/openwin/lib
|
|
||||||
/usr/shlib /usr/X11R6/lib
|
|
||||||
/usr/lib
|
|
||||||
)
|
|
||||||
|
|
||||||
# On Unix OpenGL most certainly always requires X11.
|
|
||||||
# Feel free to tighten up these conditions if you don't
|
|
||||||
# think this is always true.
|
|
||||||
# It's not true on OSX.
|
|
||||||
|
|
||||||
#IF (OPENGLES2_gl_LIBRARY)
|
|
||||||
# IF(NOT X11_FOUND)
|
|
||||||
# INCLUDE(FindX11)
|
|
||||||
# ENDIF(NOT X11_FOUND)
|
|
||||||
# IF (X11_FOUND)
|
|
||||||
# IF (NOT APPLE)
|
|
||||||
# SET (OPENGLES2_LIBRARIES ${X11_LIBRARIES})
|
|
||||||
# ENDIF (NOT APPLE)
|
|
||||||
# ENDIF (X11_FOUND)
|
|
||||||
#ENDIF (OPENGLES2_gl_LIBRARY)
|
|
||||||
|
|
||||||
ENDIF(APPLE)
|
|
||||||
ENDIF (WIN32)
|
|
||||||
|
|
||||||
SET( OPENGLES2_FOUND "YES" )
|
|
||||||
IF(OPENGLES2_gl_LIBRARY AND EGL_egl_LIBRARY)
|
|
||||||
|
|
||||||
SET( OPENGLES2_LIBRARIES ${OPENGLES2_gl_LIBRARY} ${OPENGLES2_LIBRARIES})
|
|
||||||
SET( EGL_LIBRARIES ${EGL_egl_LIBRARY} ${EGL_LIBRARIES})
|
|
||||||
SET( OPENGLES2_FOUND "YES" )
|
|
||||||
|
|
||||||
ENDIF(OPENGLES2_gl_LIBRARY AND EGL_egl_LIBRARY)
|
|
||||||
|
|
||||||
MARK_AS_ADVANCED(
|
|
||||||
OPENGLES2_INCLUDE_DIR
|
|
||||||
OPENGLES2_gl_LIBRARY
|
|
||||||
EGL_INCLUDE_DIR
|
|
||||||
EGL_egl_LIBRARY
|
|
||||||
)
|
|
||||||
|
|
||||||
INCLUDE(FindPackageHandleStandardArgs)
|
|
||||||
|
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENGLES2 REQUIRED_VARS OPENGLES2_LIBRARIES OPENGLES2_INCLUDE_DIR)
|
|
|
@ -20,9 +20,8 @@ else (GIT_CHECKOUT)
|
||||||
configure_file(${VERSION_IN_FILE} ${VERSION_FILE})
|
configure_file(${VERSION_IN_FILE} ${VERSION_FILE})
|
||||||
endif (GIT_CHECKOUT)
|
endif (GIT_CHECKOUT)
|
||||||
|
|
||||||
if (NOT ANDROID)
|
find_package(OpenGL REQUIRED)
|
||||||
find_package(OpenGL REQUIRED)
|
|
||||||
endif()
|
|
||||||
# source files
|
# source files
|
||||||
|
|
||||||
add_component_dir (settings
|
add_component_dir (settings
|
||||||
|
@ -138,31 +137,31 @@ add_component_dir (version
|
||||||
set (ESM_UI ${CMAKE_SOURCE_DIR}/files/ui/contentselector.ui
|
set (ESM_UI ${CMAKE_SOURCE_DIR}/files/ui/contentselector.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
if (NOT ANDROID)
|
add_component_qt_dir (contentselector
|
||||||
add_component_qt_dir (contentselector
|
model/modelitem model/esmfile
|
||||||
model/modelitem model/esmfile
|
model/naturalsort model/contentmodel
|
||||||
model/naturalsort model/contentmodel
|
model/loadordererror
|
||||||
model/loadordererror
|
view/combobox view/contentselector
|
||||||
view/combobox view/contentselector
|
)
|
||||||
)
|
add_component_qt_dir (config
|
||||||
add_component_qt_dir (config
|
gamesettings
|
||||||
gamesettings
|
launchersettings
|
||||||
launchersettings
|
settingsbase
|
||||||
settingsbase
|
)
|
||||||
)
|
|
||||||
|
|
||||||
add_component_qt_dir (process
|
add_component_qt_dir (process
|
||||||
processinvoker
|
processinvoker
|
||||||
)
|
)
|
||||||
if (DESIRED_QT_VERSION MATCHES 4)
|
|
||||||
include(${QT_USE_FILE})
|
if (DESIRED_QT_VERSION MATCHES 4)
|
||||||
QT4_WRAP_UI(ESM_UI_HDR ${ESM_UI})
|
include(${QT_USE_FILE})
|
||||||
QT4_WRAP_CPP(MOC_SRCS ${COMPONENT_MOC_FILES})
|
QT4_WRAP_UI(ESM_UI_HDR ${ESM_UI})
|
||||||
else()
|
QT4_WRAP_CPP(MOC_SRCS ${COMPONENT_MOC_FILES})
|
||||||
QT5_WRAP_UI(ESM_UI_HDR ${ESM_UI})
|
else()
|
||||||
QT5_WRAP_CPP(MOC_SRCS ${COMPONENT_MOC_FILES})
|
QT5_WRAP_UI(ESM_UI_HDR ${ESM_UI})
|
||||||
endif()
|
QT5_WRAP_CPP(MOC_SRCS ${COMPONENT_MOC_FILES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" AND NOT APPLE)
|
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" AND NOT APPLE)
|
||||||
add_definitions(-fPIC)
|
add_definitions(-fPIC)
|
||||||
|
@ -173,46 +172,32 @@ include_directories(${BULLET_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
add_library(components STATIC ${COMPONENT_FILES} ${MOC_SRCS} ${ESM_UI_HDR})
|
add_library(components STATIC ${COMPONENT_FILES} ${MOC_SRCS} ${ESM_UI_HDR})
|
||||||
|
|
||||||
if (NOT ANDROID)
|
target_link_libraries(components
|
||||||
target_link_libraries(components
|
${Boost_SYSTEM_LIBRARY}
|
||||||
${Boost_SYSTEM_LIBRARY}
|
${Boost_FILESYSTEM_LIBRARY}
|
||||||
${Boost_FILESYSTEM_LIBRARY}
|
${Boost_THREAD_LIBRARY}
|
||||||
${Boost_THREAD_LIBRARY}
|
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
||||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
${OPENSCENEGRAPH_LIBRARIES}
|
||||||
${OPENSCENEGRAPH_LIBRARIES}
|
${BULLET_LIBRARIES}
|
||||||
${BULLET_LIBRARIES}
|
${SDL2_LIBRARY}
|
||||||
${SDL2_LIBRARY}
|
# For MyGUI platform
|
||||||
# For MyGUI platform
|
${OPENGL_gl_LIBRARY}
|
||||||
${OPENGL_gl_LIBRARY}
|
${MYGUI_LIBRARIES}
|
||||||
${MYGUI_LIBRARIES}
|
)
|
||||||
)
|
|
||||||
else()
|
|
||||||
target_link_libraries(components
|
|
||||||
${Boost_SYSTEM_LIBRARY}
|
|
||||||
${Boost_FILESYSTEM_LIBRARY}
|
|
||||||
${Boost_THREAD_LIBRARY}
|
|
||||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
|
||||||
${OPENSCENEGRAPH_LIBRARIES}
|
|
||||||
${BULLET_LIBRARIES}
|
|
||||||
${SDL2_LIBRARY}
|
|
||||||
${MYGUI_LIBRARIES}
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_link_libraries(components
|
target_link_libraries(components
|
||||||
${Boost_LOCALE_LIBRARY})
|
${Boost_LOCALE_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT ANDROID)
|
if (DESIRED_QT_VERSION MATCHES 4)
|
||||||
if (DESIRED_QT_VERSION MATCHES 4)
|
target_link_libraries(components
|
||||||
target_link_libraries(components
|
${QT_QTCORE_LIBRARY}
|
||||||
${QT_QTCORE_LIBRARY}
|
${QT_QTGUI_LIBRARY})
|
||||||
${QT_QTGUI_LIBRARY})
|
else()
|
||||||
else()
|
qt5_use_modules(components Widgets Core)
|
||||||
qt5_use_modules(components Widgets Core)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (GIT_CHECKOUT)
|
if (GIT_CHECKOUT)
|
||||||
add_dependencies (components git-version)
|
add_dependencies (components git-version)
|
||||||
endif (GIT_CHECKOUT)
|
endif (GIT_CHECKOUT)
|
||||||
|
|
|
@ -17,10 +17,6 @@
|
||||||
#include <components/resource/texturemanager.hpp>
|
#include <components/resource/texturemanager.hpp>
|
||||||
|
|
||||||
#include "myguitexture.hpp"
|
#include "myguitexture.hpp"
|
||||||
|
|
||||||
#ifdef OPENGLES
|
|
||||||
#include <GLES/gl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MYGUI_PLATFORM_LOG_SECTION "Platform"
|
#define MYGUI_PLATFORM_LOG_SECTION "Platform"
|
||||||
#define MYGUI_PLATFORM_LOG(level, text) MYGUI_LOGGING(MYGUI_PLATFORM_LOG_SECTION, level, text)
|
#define MYGUI_PLATFORM_LOG(level, text) MYGUI_LOGGING(MYGUI_PLATFORM_LOG_SECTION, level, text)
|
||||||
|
|
|
@ -217,9 +217,6 @@ namespace SDLUtil
|
||||||
|
|
||||||
void SDLCursorManager::_createCursorFromResource(const std::string& name, int rotDegrees, osg::Image* image, Uint8 size_x, Uint8 size_y, Uint8 hotspot_x, Uint8 hotspot_y)
|
void SDLCursorManager::_createCursorFromResource(const std::string& name, int rotDegrees, osg::Image* image, Uint8 size_x, Uint8 size_y, Uint8 hotspot_x, Uint8 hotspot_y)
|
||||||
{
|
{
|
||||||
#ifdef ANDROID
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
if (mCursorMap.find(name) != mCursorMap.end())
|
if (mCursorMap.find(name) != mCursorMap.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,11 @@
|
||||||
# Copy resource files into the build directory
|
# Copy resource files into the build directory
|
||||||
set(SDIR ${CMAKE_CURRENT_SOURCE_DIR})
|
set(SDIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
set(DDIR ${OpenMW_BINARY_DIR}/resources/shaders)
|
set(DDIR ${OpenMW_BINARY_DIR}/resources/shaders)
|
||||||
if (OPENGLES)
|
|
||||||
set(SHADER_FILES
|
set(SHADER_FILES
|
||||||
watergles_vertex.glsl
|
water_vertex.glsl
|
||||||
watergles_fragment.glsl
|
water_fragment.glsl
|
||||||
water_nm.png
|
water_nm.png
|
||||||
)
|
)
|
||||||
else()
|
|
||||||
set(SHADER_FILES
|
|
||||||
water_vertex.glsl
|
|
||||||
water_fragment.glsl
|
|
||||||
water_nm.png
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
copy_all_files(${CMAKE_CURRENT_SOURCE_DIR} ${DDIR} "${SHADER_FILES}")
|
copy_all_files(${CMAKE_CURRENT_SOURCE_DIR} ${DDIR} "${SHADER_FILES}")
|
||||||
|
|
|
@ -1,209 +0,0 @@
|
||||||
#version 100
|
|
||||||
precision mediump float;
|
|
||||||
precision mediump int;
|
|
||||||
|
|
||||||
struct osg_LightSourceParameters {
|
|
||||||
mediump vec4 ambient;
|
|
||||||
mediump vec4 diffuse;
|
|
||||||
mediump vec4 specular;
|
|
||||||
mediump vec4 position;
|
|
||||||
mediump vec4 halfVector;
|
|
||||||
mediump vec3 spotDirection;
|
|
||||||
mediump float spotExponent;
|
|
||||||
mediump float spotCutoff;
|
|
||||||
mediump float spotCosCutoff;
|
|
||||||
mediump float constantAttenuation;
|
|
||||||
mediump float linearAttenuation;
|
|
||||||
mediump float quadraticAttenuation;
|
|
||||||
};
|
|
||||||
uniform osg_LightSourceParameters osg_LightSource[1];
|
|
||||||
|
|
||||||
#define REFRACTION @refraction_enabled
|
|
||||||
|
|
||||||
// Inspired by Blender GLSL Water by martinsh ( http://devlog-martinsh.blogspot.de/2012/07/waterundewater-shader-wip.html )
|
|
||||||
|
|
||||||
// tweakables -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
|
||||||
|
|
||||||
const float VISIBILITY = 1200.0; // how far you can look through water
|
|
||||||
|
|
||||||
const float BIG_WAVES_X = 0.1; // strength of big waves
|
|
||||||
const float BIG_WAVES_Y = 0.1;
|
|
||||||
|
|
||||||
const float MID_WAVES_X = 0.1; // strength of middle sized waves
|
|
||||||
const float MID_WAVES_Y = 0.1;
|
|
||||||
|
|
||||||
const float SMALL_WAVES_X = 0.1; // strength of small waves
|
|
||||||
const float SMALL_WAVES_Y = 0.1;
|
|
||||||
|
|
||||||
const float WAVE_CHOPPYNESS = 0.05; // wave choppyness
|
|
||||||
const float WAVE_SCALE = 75.0; // overall wave scale
|
|
||||||
|
|
||||||
const float BUMP = 0.5; // overall water surface bumpiness
|
|
||||||
const float REFL_BUMP = 0.10; // reflection distortion amount
|
|
||||||
const float REFR_BUMP = 0.07; // refraction distortion amount
|
|
||||||
|
|
||||||
const float SCATTER_AMOUNT = 0.3; // amount of sunlight scattering
|
|
||||||
const vec3 SCATTER_COLOUR = vec3(0.0,1.0,0.95); // colour of sunlight scattering
|
|
||||||
|
|
||||||
const vec3 SUN_EXT = vec3(0.45, 0.55, 0.68); //sunlight extinction
|
|
||||||
|
|
||||||
const float SPEC_HARDNESS = 256.0; // specular highlights hardness
|
|
||||||
|
|
||||||
const vec2 WIND_DIR = vec2(0.5, -0.8);
|
|
||||||
const float WIND_SPEED = 0.2;
|
|
||||||
|
|
||||||
const vec3 WATER_COLOR = vec3(0.090195, 0.115685, 0.12745);
|
|
||||||
|
|
||||||
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
|
|
||||||
|
|
||||||
float fresnel_dielectric(vec3 Incoming, vec3 Normal, float eta)
|
|
||||||
{
|
|
||||||
float c = abs(dot(Incoming, Normal));
|
|
||||||
float g = eta * eta - 1.0 + c * c;
|
|
||||||
float result;
|
|
||||||
|
|
||||||
if(g > 0.0) {
|
|
||||||
g = sqrt(g);
|
|
||||||
float A =(g - c)/(g + c);
|
|
||||||
float B =(c *(g + c)- 1.0)/(c *(g - c)+ 1.0);
|
|
||||||
result = 0.5 * A * A *(1.0 + B * B);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
result = 1.0;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
varying vec3 screenCoordsPassthrough;
|
|
||||||
varying vec4 position;
|
|
||||||
varying float depthPassthrough;
|
|
||||||
|
|
||||||
uniform sampler2D normalMap;
|
|
||||||
|
|
||||||
uniform sampler2D reflectionMap;
|
|
||||||
#if REFRACTION
|
|
||||||
uniform sampler2D refractionMap;
|
|
||||||
uniform sampler2D refractionDepthMap;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uniform float osg_SimulationTime;
|
|
||||||
|
|
||||||
uniform float near;
|
|
||||||
uniform float far;
|
|
||||||
uniform vec3 nodePosition;
|
|
||||||
|
|
||||||
void main(void)
|
|
||||||
{
|
|
||||||
vec3 worldPos = position.xyz + nodePosition.xyz;
|
|
||||||
vec2 UV = worldPos.xy / (8192.0*5.0) * 3.0;
|
|
||||||
UV.y *= -1.0;
|
|
||||||
|
|
||||||
float shadow = 1.0;
|
|
||||||
|
|
||||||
vec2 screenCoords = screenCoordsPassthrough.xy / screenCoordsPassthrough.z;
|
|
||||||
screenCoords.y = (1.0-screenCoords.y);
|
|
||||||
|
|
||||||
vec2 nCoord = vec2(0.0,0.0);
|
|
||||||
|
|
||||||
#define waterTimer osg_SimulationTime
|
|
||||||
|
|
||||||
nCoord = UV * (WAVE_SCALE * 0.05) + WIND_DIR * waterTimer * (WIND_SPEED*0.04);
|
|
||||||
vec3 normal0 = 2.0 * texture2D(normalMap, nCoord + vec2(-waterTimer*0.015,-waterTimer*0.005)).rgb - 1.0;
|
|
||||||
nCoord = UV * (WAVE_SCALE * 0.1) + WIND_DIR * waterTimer * (WIND_SPEED*0.08)-(normal0.xy/normal0.zz)*WAVE_CHOPPYNESS;
|
|
||||||
vec3 normal1 = 2.0 * texture2D(normalMap, nCoord + vec2(+waterTimer*0.020,+waterTimer*0.015)).rgb - 1.0;
|
|
||||||
|
|
||||||
nCoord = UV * (WAVE_SCALE * 0.25) + WIND_DIR * waterTimer * (WIND_SPEED*0.07)-(normal1.xy/normal1.zz)*WAVE_CHOPPYNESS;
|
|
||||||
vec3 normal2 = 2.0 * texture2D(normalMap, nCoord + vec2(-waterTimer*0.04,-waterTimer*0.03)).rgb - 1.0;
|
|
||||||
nCoord = UV * (WAVE_SCALE * 0.5) + WIND_DIR * waterTimer * (WIND_SPEED*0.09)-(normal2.xy/normal2.z)*WAVE_CHOPPYNESS;
|
|
||||||
vec3 normal3 = 2.0 * texture2D(normalMap, nCoord + vec2(+waterTimer*0.03,+waterTimer*0.04)).rgb - 1.0;
|
|
||||||
|
|
||||||
nCoord = UV * (WAVE_SCALE* 1.0) + WIND_DIR * waterTimer * (WIND_SPEED*0.4)-(normal3.xy/normal3.zz)*WAVE_CHOPPYNESS;
|
|
||||||
vec3 normal4 = 2.0 * texture2D(normalMap, nCoord + vec2(-waterTimer*0.02,+waterTimer*0.1)).rgb - 1.0;
|
|
||||||
nCoord = UV * (WAVE_SCALE * 2.0) + WIND_DIR * waterTimer * (WIND_SPEED*0.7)-(normal4.xy/normal4.zz)*WAVE_CHOPPYNESS;
|
|
||||||
vec3 normal5 = 2.0 * texture2D(normalMap, nCoord + vec2(+waterTimer*0.1,-waterTimer*0.06)).rgb - 1.0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
vec3 normal = (normal0 * BIG_WAVES_X + normal1 * BIG_WAVES_Y +
|
|
||||||
normal2 * MID_WAVES_X + normal3 * MID_WAVES_Y +
|
|
||||||
normal4 * SMALL_WAVES_X + normal5 * SMALL_WAVES_Y);
|
|
||||||
|
|
||||||
normal = normalize(vec3(normal.x * BUMP, normal.y * BUMP, normal.z));
|
|
||||||
|
|
||||||
normal = vec3(-normal.x, -normal.y, normal.z);
|
|
||||||
|
|
||||||
// normal for sunlight scattering
|
|
||||||
vec3 lNormal = (normal0 * BIG_WAVES_X*0.5 + normal1 * BIG_WAVES_Y*0.5 +
|
|
||||||
normal2 * MID_WAVES_X*0.2 + normal3 * MID_WAVES_Y*0.2 +
|
|
||||||
normal4 * SMALL_WAVES_X*0.1 + normal5 * SMALL_WAVES_Y*0.1).xyz;
|
|
||||||
lNormal = normalize(vec3(lNormal.x * BUMP, lNormal.y * BUMP, lNormal.z));
|
|
||||||
lNormal = vec3(-lNormal.x, -lNormal.y, lNormal.z);
|
|
||||||
|
|
||||||
|
|
||||||
vec3 lVec = normalize((gl_ModelViewMatrixInverse * vec4(osg_LightSource[0].position.xyz, 0.0)).xyz);
|
|
||||||
|
|
||||||
vec3 cameraPos = (gl_ModelViewMatrixInverse * vec4(0.0,0.0,0.0,1.0)).xyz;
|
|
||||||
vec3 vVec = normalize(position.xyz - cameraPos.xyz);
|
|
||||||
|
|
||||||
float isUnderwater = (cameraPos.z > 0.0) ? 0.0 : 1.0;
|
|
||||||
|
|
||||||
// sunlight scattering
|
|
||||||
vec3 pNormal = vec3(0.0,0.0,1.0);
|
|
||||||
vec3 lR = reflect(lVec, lNormal);
|
|
||||||
vec3 llR = reflect(lVec, pNormal);
|
|
||||||
|
|
||||||
float sunHeight = lVec.z;
|
|
||||||
float sunFade = length(gl_LightModel.ambient.xyz);
|
|
||||||
|
|
||||||
float s = clamp(dot(lR, vVec)*2.0-1.2, 0.0, 1.0);
|
|
||||||
float lightScatter = shadow * clamp(dot(lVec,lNormal)*0.7+0.3, 0.0, 1.0) * s * SCATTER_AMOUNT * sunFade * clamp(1.0-exp(-sunHeight), 0.0, 1.0);
|
|
||||||
vec3 scatterColour = mix(vec3(SCATTER_COLOUR)*vec3(1.0,0.4,0.0), SCATTER_COLOUR, clamp(1.0-exp(-sunHeight*SUN_EXT), 0.0, 1.0));
|
|
||||||
|
|
||||||
// fresnel
|
|
||||||
float ior = (cameraPos.z>0.0)?(1.333/1.0):(1.0/1.333); //air to water; water to air
|
|
||||||
float fresnel = fresnel_dielectric(vVec, normal, ior);
|
|
||||||
|
|
||||||
fresnel = clamp(fresnel, 0.0, 1.0);
|
|
||||||
|
|
||||||
// reflection
|
|
||||||
vec3 reflection = texture2D(reflectionMap, screenCoords+(normal.xy*REFL_BUMP)).rgb;
|
|
||||||
|
|
||||||
// refraction
|
|
||||||
#if REFRACTION
|
|
||||||
vec3 refraction = texture2D(refractionMap, screenCoords-(normal.xy*REFR_BUMP)).rgb;
|
|
||||||
|
|
||||||
// brighten up the refraction underwater
|
|
||||||
refraction = (cameraPos.z < 0.0) ? clamp(refraction * 1.5, 0.0, 1.0) : refraction;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// specular
|
|
||||||
vec3 R = reflect(vVec, normal);
|
|
||||||
float specular = pow(max(dot(R, lVec), 0.0),SPEC_HARDNESS) * shadow;
|
|
||||||
|
|
||||||
vec3 waterColor = WATER_COLOR;
|
|
||||||
waterColor = waterColor * length(gl_LightModel.ambient.xyz);
|
|
||||||
#if REFRACTION
|
|
||||||
float refractionDepth = texture2D(refractionDepthMap, screenCoords-(normal.xy*REFR_BUMP)).x;
|
|
||||||
float z_n = 2.0 * refractionDepth - 1.0;
|
|
||||||
refractionDepth = 2.0 * near * far / (far + near - z_n * (far - near));
|
|
||||||
|
|
||||||
float waterDepth = refractionDepth - depthPassthrough;
|
|
||||||
|
|
||||||
if (cameraPos.z > 0.0)
|
|
||||||
refraction = mix(refraction, waterColor, clamp(waterDepth/VISIBILITY, 0.0, 1.0));
|
|
||||||
|
|
||||||
gl_FragData[0].xyz = mix( mix(refraction, scatterColour, lightScatter), reflection, fresnel) + specular * osg_LightSource[0].specular.xyz;
|
|
||||||
#else
|
|
||||||
gl_FragData[0].xyz = mix(reflection, waterColor, (1.0-fresnel)*0.5) + specular * osg_LightSource[0].specular.xyz;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// fog
|
|
||||||
float fogValue = clamp((depthPassthrough - gl_Fog.start) * gl_Fog.scale, 0.0, 1.0);
|
|
||||||
gl_FragData[0].xyz = mix(gl_FragData[0].xyz, gl_Fog.color.xyz, fogValue);
|
|
||||||
|
|
||||||
#if REFRACTION
|
|
||||||
gl_FragData[0].w = 1.0;
|
|
||||||
#else
|
|
||||||
gl_FragData[0].w = clamp(fresnel*2.0 + specular, 0.0, 1.0);
|
|
||||||
#endif
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
#version 100
|
|
||||||
precision mediump float;
|
|
||||||
precision mediump int;
|
|
||||||
|
|
||||||
varying vec3 screenCoordsPassthrough;
|
|
||||||
varying vec4 position;
|
|
||||||
varying float depthPassthrough;
|
|
||||||
|
|
||||||
void main(void)
|
|
||||||
{
|
|
||||||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
|
||||||
|
|
||||||
mat4 scalemat = mat4(0.5, 0.0, 0.0, 0.0,
|
|
||||||
0.0, -0.5, 0.0, 0.0,
|
|
||||||
0.0, 0.0, 0.5, 0.0,
|
|
||||||
0.5, 0.5, 0.5, 1.0);
|
|
||||||
|
|
||||||
vec4 texcoordProj = ((scalemat) * ( gl_Position));
|
|
||||||
screenCoordsPassthrough = vec3(texcoordProj.x, texcoordProj.y, texcoordProj.w);
|
|
||||||
|
|
||||||
position = gl_Vertex;
|
|
||||||
|
|
||||||
depthPassthrough = gl_Position.z;
|
|
||||||
}
|
|
Loading…
Reference in a new issue