Revert "Merge remote-tracking branch 'sandstranger/opengles'"
This reverts commitopenmw-38cc9cab6fd1
, reversing changes made toda856eed95
.
parent
ef68e2aec4
commit
8a3ec14bc6
@ -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)
|
|
@ -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 New Issue