MERGE STK into scripting branch
22
.travis.yml
@ -6,20 +6,26 @@
|
||||
language: cpp
|
||||
compiler:
|
||||
- gcc
|
||||
#- clang
|
||||
git:
|
||||
submodules: false
|
||||
# - clang
|
||||
#branches:
|
||||
# only:
|
||||
# - master
|
||||
before_install:
|
||||
# UPDATE REPOS
|
||||
# Update repos
|
||||
- sudo apt-get update -qq
|
||||
# INSTALL DEPENDENCIES
|
||||
- sudo apt-get install autoconf automake build-essential cmake libogg-dev libvorbis-dev libopenal-dev libxxf86vm-dev libgl1-mesa-dev libglu1-mesa-dev libcurl4-openssl-dev libfribidi-dev libbluetooth-dev
|
||||
# Install dependencies
|
||||
- sudo apt-get install build-essential cmake libogg-dev libvorbis-dev libopenal-dev libxxf86vm-dev libcurl4-openssl-dev libfribidi-dev libbluetooth-dev
|
||||
# Install mesa from an other repo (a newer version is required)
|
||||
- sudo apt-add-repository "deb http://archive.ubuntu.com/ubuntu quantal main restricted"
|
||||
- sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 3B4FE6ACC0B21F32
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev
|
||||
script:
|
||||
# BUILD COMMANDS
|
||||
- ./tools/build-linux-travis.sh
|
||||
# Build commands
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DCHECK_ASSETS=off
|
||||
- make VERBOSE=1 -j 4
|
||||
notifications:
|
||||
irc:
|
||||
channels:
|
||||
|
@ -3,7 +3,7 @@ project(SuperTuxKart)
|
||||
set(PROJECT_VERSION "0.8.1")
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.1)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
|
||||
|
||||
include(BuildTypeSTKRelease)
|
||||
if (NOT CMAKE_BUILD_TYPE)
|
||||
@ -13,8 +13,11 @@ endif()
|
||||
|
||||
option(USE_WIIUSE "Support for wiimote input devices" ON)
|
||||
option(USE_FRIBIDI "Support for right-to-left languages" ON)
|
||||
option(CHECK_ASSETS "Check if assets are installed in ../stk-assets" ON)
|
||||
|
||||
if(UNIX)
|
||||
option(USE_CPP2011 "Activate C++ 2011 mode (GCC only)" OFF)
|
||||
option(USE_XRANDR "Use xrandr instead of vidmode" OFF)
|
||||
endif()
|
||||
if(MSVC)
|
||||
# Normally hide the option to build wiiuse on VS, since it depends
|
||||
@ -59,10 +62,12 @@ if(USE_WIIUSE)
|
||||
include_directories("${PROJECT_SOURCE_DIR}/lib/wiiuse")
|
||||
endif()
|
||||
|
||||
|
||||
# Build the angelscript library
|
||||
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/angelscript/projects/cmake")
|
||||
include_directories("${PROJECT_SOURCE_DIR}/lib/angelscript/include")
|
||||
|
||||
|
||||
# Set include paths
|
||||
include_directories(${STK_SOURCE_DIR})
|
||||
|
||||
@ -94,8 +99,6 @@ else()
|
||||
include_directories(${OPENAL_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
# OggVorbis
|
||||
if(APPLE)
|
||||
# In theory it would be cleaner to let CMake detect the right dependencies. In practice, this means that if a OSX user has
|
||||
@ -120,9 +123,14 @@ if(USE_FRIBIDI)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Xrandr
|
||||
if(UNIX AND USE_XRANDR)
|
||||
find_package(Xrandr REQUIRED)
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
if(USE_CPP2011)
|
||||
add_definitions("-std=gnu++11")
|
||||
add_definitions("-std=c++0x")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -138,6 +146,7 @@ else()
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
# Set some compiler options
|
||||
if(UNIX)
|
||||
add_definitions(-Wall)
|
||||
@ -189,8 +198,6 @@ if(APPLE)
|
||||
find_library(AUDIOUNIT_LIBRARY AudioUnit)
|
||||
find_library(COCOA_LIBRARY Cocoa)
|
||||
|
||||
|
||||
|
||||
target_link_libraries(supertuxkart
|
||||
${IOKIT_LIBRARY}
|
||||
${QUICKTIME_LIBRARY}
|
||||
@ -226,8 +233,6 @@ else()
|
||||
target_link_libraries(supertuxkart ${PTHREAD_LIBRARY})
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
# CURL
|
||||
if(WIN32)
|
||||
target_link_libraries(supertuxkart ${PROJECT_SOURCE_DIR}/dependencies/lib/libcurldll.a)
|
||||
@ -236,7 +241,6 @@ else()
|
||||
include_directories(${CURL_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
|
||||
# Common library dependencies
|
||||
target_link_libraries(supertuxkart
|
||||
bulletdynamics
|
||||
@ -261,9 +265,6 @@ if(APPLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/Library/Frameworks/OpenAL.framework/Versions/A/Headers")
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
|
||||
if(USE_FRIBIDI)
|
||||
target_link_libraries(supertuxkart ${FRIBIDI_LIBRARIES})
|
||||
add_definitions(-DENABLE_BIDI)
|
||||
@ -289,17 +290,20 @@ if(USE_WIIUSE)
|
||||
|
||||
endif()
|
||||
|
||||
# Xrandr
|
||||
if(UNIX AND USE_XRANDR)
|
||||
target_link_libraries(supertuxkart ${XRANDR_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
target_link_libraries(supertuxkart iphlpapi.lib)
|
||||
add_custom_command(TARGET supertuxkart POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
"${PROJECT_SOURCE_DIR}/dependencies/dll"
|
||||
$<TARGET_FILE_DIR:supertuxkart>)
|
||||
add_custom_target(stkshaders SOURCES ${STK_SHADERS})
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
|
||||
# Optional tools
|
||||
add_subdirectory(tools/font_tool)
|
||||
|
||||
@ -321,13 +325,47 @@ else()
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
# ==== Checking if data folder exists ====
|
||||
if(NOT IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data)
|
||||
message( FATAL_ERROR "${CMAKE_CURRENT_SOURCE_DIR}/data folder doesn't exist" )
|
||||
endif()
|
||||
|
||||
# ==== Checking if stk-assets folder exists ====
|
||||
if(CHECK_ASSETS)
|
||||
if((IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/karts) AND
|
||||
(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/library) AND
|
||||
(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/music) AND
|
||||
(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/sfx) AND
|
||||
(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/textures) AND
|
||||
(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/tracks))
|
||||
message(STATUS "Assets found in data directory")
|
||||
elseif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../stk-assets)
|
||||
set(STK_ASSETS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../stk-assets/)
|
||||
message(STATUS "Assets found")
|
||||
elseif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../supertuxkart-assets)
|
||||
set(STK_ASSETS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../supertuxkart-assets/)
|
||||
message(STATUS "Assets found")
|
||||
else()
|
||||
set (CUR_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
get_filename_component(PARENT_DIR ${CUR_DIR} PATH)
|
||||
message( FATAL_ERROR "${PARENT_DIR}/stk-assets folder doesn't exist. "
|
||||
"Please download the stk-assets, or disable this test with -DCHECK_ASSETS=off." )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
# ==== Install target ====
|
||||
install(TARGETS supertuxkart RUNTIME DESTINATION ${STK_INSTALL_BINARY_DIR} BUNDLE DESTINATION .)
|
||||
install(DIRECTORY ${STK_DATA_DIR} DESTINATION ${STK_INSTALL_DATA_DIR} PATTERN ".svn" EXCLUDE)
|
||||
install(DIRECTORY ${STK_DATA_DIR} DESTINATION ${STK_INSTALL_DATA_DIR} PATTERN ".svn" EXCLUDE PATTERN ".git" EXCLUDE)
|
||||
if(STK_ASSETS_DIR AND CHECK_ASSETS)
|
||||
install(DIRECTORY ${STK_ASSETS_DIR} DESTINATION ${STK_INSTALL_DATA_DIR}/data PATTERN ".svn" EXCLUDE PATTERN ".git" EXCLUDE)
|
||||
endif()
|
||||
install(FILES ${PROJECT_BINARY_DIR}/supertuxkart.desktop DESTINATION share/applications)
|
||||
install(FILES data/supertuxkart_32.png data/supertuxkart_128.png DESTINATION share/pixmaps)
|
||||
install(FILES data/supertuxkart.appdata DESTINATION share/appdata)
|
||||
|
||||
|
||||
set(PREFIX ${CMAKE_INSTALL_PREFIX})
|
||||
configure_file(data/supertuxkart_desktop.template supertuxkart.desktop)
|
||||
add_dependencies(supertuxkart supertuxkart.desktop)
|
||||
|
18
cmake/FindXrandr.cmake
Normal file
@ -0,0 +1,18 @@
|
||||
find_path(XRANDR_INCLUDE_DIR NAMES X11/extensions/Xrandr.h
|
||||
PATH_SUFFIXES X11/extensions
|
||||
DOC "The XRANDR include directory"
|
||||
)
|
||||
|
||||
find_library(XRANDR_LIBRARY NAMES Xrandr
|
||||
DOC "The XRANDR library"
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(XRANDR DEFAULT_MSG XRANDR_LIBRARY XRANDR_INCLUDE_DIR)
|
||||
|
||||
if(XRANDR_FOUND)
|
||||
set( XRANDR_LIBRARIES ${XRANDR_LIBRARY} )
|
||||
set( XRANDR_INCLUDE_DIRS ${XRANDR_INCLUDE_DIR} )
|
||||
endif()
|
||||
|
||||
mark_as_advanced(XRANDR_INCLUDE_DIR XRANDR_LIBRARY)
|
BIN
data/CREDITS
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0"?>
|
||||
<achievements>
|
||||
<achievement id="1" check-type="all-at-least" reset-after-race="no"
|
||||
<achievement id="1" check-type="all-at-least" reset-type="never"
|
||||
title="Christoffel Columbus" description="Play every official track at least once." >
|
||||
<farm goal="1"/>
|
||||
<scotland goal="1"/>
|
||||
@ -13,17 +13,39 @@
|
||||
<hacienda goal="1"/>
|
||||
<jungle goal="1"/>
|
||||
</achievement>
|
||||
<achievement id="2" check-type="all-at-least" reset-after-race="no"
|
||||
<achievement id="2" check-type="all-at-least" reset-type="never"
|
||||
title="Strike!" description="Hit 10 karts with a bowling-ball.">
|
||||
<ball goal="10"/>
|
||||
</achievement>
|
||||
<achievement id="3" check-type="one-at-least" reset-after-race="yes"
|
||||
title="Arch Enemy" description="Hit the same kart at least 5 times in one race">
|
||||
<achievement id="3" check-type="one-at-least" reset-type="race"
|
||||
title="Arch Enemy" description="Hit the same kart at least 5 times in one race.">
|
||||
<hit goal="5"/>
|
||||
</achievement>
|
||||
<achievement id="4" check-type="all-at-least" reset-after-race="yes"
|
||||
title="Marathoner" description="Make a race with 5 laps or more">
|
||||
<achievement id="4" check-type="all-at-least" reset-type="race"
|
||||
title="Marathoner" description="Make a race with 5 laps or more.">
|
||||
<laps goal="5"/>
|
||||
</achievement>
|
||||
<achievement id="5" check-type="all-at-least" reset-type="lap"
|
||||
title="Skid-row" description="Make 5 skidding in a single lap.">
|
||||
<skidding goal="5"/>
|
||||
</achievement>
|
||||
<achievement id="6" check-type="all-at-least" reset-type="never"
|
||||
title="Gold driver" description="Win in all single player modes, against at least 3 opponents.">
|
||||
<standard goal="1"/>
|
||||
<std_timetrial goal="1"/>
|
||||
<follow_leader goal="1"/>
|
||||
<opponents goal="3"/>
|
||||
</achievement>
|
||||
<achievement id="7" check-type="all-at-least" reset-type="race"
|
||||
title="Powerup Love" description="Use 10 or more powerups in a race.">
|
||||
<poweruplover goal="10"/>
|
||||
</achievement>
|
||||
<achievement id="8" check-type="all-at-least" reset-type="never"
|
||||
title="Unstoppable" description="Win 5 single races in a row.">
|
||||
<wins goal="5"/>
|
||||
</achievement>
|
||||
<achievement id="9" check-type="all-at-least" reset-after-race="yes"
|
||||
title="Banana Lover" description="Collect at least 5 bananas in one race.">
|
||||
<banana goal="5"/>
|
||||
</achievement>
|
||||
</achievements>
|
||||
|
||||
|
32
data/gfx/droplet.xml
Normal file
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0"?>
|
||||
<particles emitter="sphere" radius="5">
|
||||
|
||||
<spreading angle="45" />
|
||||
|
||||
<velocity x="0.000"
|
||||
y="0.005"
|
||||
z="0.000" />
|
||||
|
||||
<material file="particle_water.png" />
|
||||
|
||||
<!-- Amount of particles emitted per second -->
|
||||
<rate min="5"
|
||||
max="10" />
|
||||
|
||||
<!-- Minimal and maximal lifetime of a particle, in milliseconds. -->
|
||||
<lifetime min="1000"
|
||||
max="2000" />
|
||||
|
||||
<!-- Size of the particles -->
|
||||
<size min="4.0"
|
||||
max="7.2"
|
||||
x-increase-factor="2.6"
|
||||
y-increase-factor="2.6" />
|
||||
|
||||
<color min="255 255 255"
|
||||
max="255 255 255" />
|
||||
|
||||
<fadeout time="3000" />
|
||||
|
||||
|
||||
</particles>
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0"?>
|
||||
<particles emitter="point">
|
||||
<particles emitter="box" box_x="12.0" box_y="0.5" box_z="12.0">
|
||||
|
||||
<spreading angle="24" />
|
||||
|
||||
@ -10,21 +10,23 @@
|
||||
<material file="waterparticles.png" />
|
||||
|
||||
<!-- Amount of particles emitted per second -->
|
||||
<rate min="10"
|
||||
max="30" />
|
||||
<rate min="5"
|
||||
max="20" />
|
||||
|
||||
<!-- Minimal and maximal lifetime of a particle, in milliseconds. -->
|
||||
<lifetime min="500"
|
||||
max="1000" />
|
||||
<lifetime min="1000"
|
||||
max="4000" />
|
||||
|
||||
<!-- Size of the particles -->
|
||||
<size min="0.6"
|
||||
max="6.2" />
|
||||
<size min="5.0"
|
||||
max="10.0"
|
||||
x-increase-factor="2.6"
|
||||
y-increase-factor="2.6" />
|
||||
|
||||
<color min="255 255 255"
|
||||
max="255 255 255" />
|
||||
|
||||
<fadeout time="300" />
|
||||
<fadeout time="5000" />
|
||||
|
||||
|
||||
</particles>
|
||||
|
@ -6,16 +6,64 @@
|
||||
|
||||
<spacer height="20" width="10" />
|
||||
|
||||
<!--
|
||||
<div layout="horizontal-row" width="100%" height="fit">
|
||||
<checkbox id="pixelshaders"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Pixel Shaders (requires restart)" I18N="Video settings"/>
|
||||
<label text="Pixel Shaders" I18N="Video settings"/>
|
||||
</div>
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
-->
|
||||
|
||||
<div layout="horizontal-row" width="100%" proportion="1">
|
||||
<checkbox id="dynamiclight"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Advanced pipeline (lights, etc.)" I18N="Video settings"/>
|
||||
</div>
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" height="fit">
|
||||
<spacer width="50" height="10" />
|
||||
<div layout="horizontal-row" width="100%" proportion="1">
|
||||
<spacer width="70" height="10" />
|
||||
<label text="Shadows" I18N="Video settings"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<gauge id="shadows" min_value="0" max_value="2" width="50%"/>
|
||||
</div>
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" proportion="1">
|
||||
<spacer width="70" height="10"/>
|
||||
|
||||
<div layout="horizontal-row" proportion="1" height="fit">
|
||||
<checkbox id="bloom"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Bloom" I18N="Video settings"/>
|
||||
</div>
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" proportion="1" height="fit">
|
||||
<checkbox id="lightshaft"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Light shaft (God rays)" I18N="Video settings"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" proportion="1">
|
||||
<spacer width="70" height="10"/>
|
||||
<checkbox id="ssao"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Ambient Occlusion" I18N="Video settings"/>
|
||||
</div>
|
||||
|
||||
<spacer height="20" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" proportion="1">
|
||||
<div layout="horizontal-row" proportion="1" height="fit">
|
||||
<checkbox id="motionblur"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Motion blur" I18N="Video settings"/>
|
||||
@ -23,34 +71,35 @@
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" height="fit">
|
||||
<spacer width="50" height="10" />
|
||||
<div layout="horizontal-row" proportion="1" height="fit">
|
||||
<checkbox id="texture_compression"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Texture compression" I18N="Video settings"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" proportion="1">
|
||||
<div layout="horizontal-row" proportion="1" height="fit">
|
||||
<checkbox id="glow"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Glow (outlines)" I18N="Video settings"/>
|
||||
</div>
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" proportion="1" height="fit">
|
||||
<checkbox id="mlaa"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Anti-aliasing" I18N="Video settings"/>
|
||||
</div>
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" height="fit">
|
||||
<spacer width="50" height="10" />
|
||||
<label text="Ambient Occlusion" I18N="Video settings"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<gauge id="ssao" min_value="0" max_value="2" width="50%"/>
|
||||
</div>
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" height="fit">
|
||||
<spacer width="50" height="10" />
|
||||
<label text="Shadows (requires restart)" I18N="Video settings"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<gauge id="shadows" min_value="0" max_value="2" width="50%"/>
|
||||
</div>
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" height="fit">
|
||||
<div layout="horizontal-row" width="100%" proportion="1">
|
||||
<div layout="horizontal-row" proportion="1" height="fit">
|
||||
<checkbox id="weather_gfx"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Weather Effects" I18N="Video settings"/>
|
||||
@ -58,15 +107,53 @@
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" height="fit">
|
||||
<div layout="horizontal-row" proportion="1" height="fit">
|
||||
<checkbox id="anim_gfx"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Animated Scenery" I18N="Video settings"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" height="fit">
|
||||
<div layout="horizontal-row" width="100%" proportion="1">
|
||||
<div layout="horizontal-row" proportion="1" height="fit">
|
||||
<checkbox id="ubo"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Uniform buffer objects" I18N="Video settings"/>
|
||||
</div>
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" proportion="1" height="fit">
|
||||
<checkbox id="dof"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Depth of field" I18N="Video settings"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" proportion="1">
|
||||
<div layout="horizontal-row" proportion="1" height="fit">
|
||||
<checkbox id="hd-textures"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Use high definition textures" I18N="Video settings"/>
|
||||
</div>
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
<!--
|
||||
<div layout="horizontal-row" proportion="1" height="fit">
|
||||
<checkbox id="anim_gfx"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<label text="Animated Scenery" I18N="Video settings"/>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
|
||||
<spacer height="20" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" proportion="1">
|
||||
<label text="Animated Characters" I18N="Video settings" width="40%"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<gauge id="steering_animations" min_value="0" max_value="2" width="50%" />
|
||||
@ -74,26 +161,19 @@
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
|
||||
<div layout="horizontal-row" width="100%" height="fit">
|
||||
<div layout="horizontal-row" width="100%" proportion="1">
|
||||
<label text="Texture filtering" I18N="Video settings" width="40%"/>
|
||||
<spacer width="10" height="10"/>
|
||||
<gauge id="filtering" min_value="0" max_value="5" width="50%" />
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<div layout="horizontal-row" width="100%" height="fit">
|
||||
<label text="Anti-aliasing (requires restart)" I18N="Video settings" width="40%" />
|
||||
<spacer width="10" height="10"/>
|
||||
<gauge id="antialiasing" min_value="0" max_value="3" width="50%"/>
|
||||
</div>
|
||||
|
||||
<spacer height="4" width="10" />
|
||||
-->
|
||||
<spacer height="10" width="10" />
|
||||
|
||||
<label text="* Restart STK to apply new settings" width="100%" text_align="center" I18N="Video settings"/>
|
||||
|
||||
<spacer proportion="1"/>
|
||||
|
||||
<button id="close" text="Close" align="center"/>
|
||||
<button id="close" text="Apply" align="center"/>
|
||||
</div>
|
||||
|
||||
</stkgui>
|
||||
|
6
data/gui/debug_slider.stkgui
Normal file
@ -0,0 +1,6 @@
|
||||
<stkgui>
|
||||
<div x="2%" y="10%" width="96%" height="80%" layout="vertical-row" >
|
||||
<label id="title" width="100%"/>
|
||||
<gauge id="value_slider" min_value="0" max_value="100" width="100%" />
|
||||
</div>
|
||||
</stkgui>
|
BIN
data/gui/down.png
Normal file
After Width: | Height: | Size: 4.0 KiB |
54
data/gui/edit_track.stkgui
Normal file
@ -0,0 +1,54 @@
|
||||
<stkgui>
|
||||
|
||||
<div x="2%" y="1%" width="96%" height="98%" layout="vertical-row" padding="10">
|
||||
|
||||
<header id="selected_track" width="80%" height="30"
|
||||
I18N="No neeed to translate this, it will be overwritten by the track name"
|
||||
text="" align="center" text_align="center" />
|
||||
|
||||
<spacer height="20" />
|
||||
|
||||
<!-- Track selection -->
|
||||
<box width="100%" height="60%" layout="vertical-row">
|
||||
<ribbon_grid id="tracks" proportion="1" width="100%" height="100%" square_items="true"
|
||||
label_location="each" align="center" child_width="240" child_height="160" />
|
||||
</box>
|
||||
|
||||
<!-- Populated dynamically at runtime -->
|
||||
<tabs width="100%" height="30" id="trackgroups"> </tabs>
|
||||
|
||||
<spacer height="50" />
|
||||
|
||||
<!-- Laps and reverse -->
|
||||
<div width="100%" height="100" layout="horizontal-row" align="center">
|
||||
|
||||
<spacer proportion="1" />
|
||||
|
||||
<label id="laps_label" text_align="left"
|
||||
I18N="In the edit track screen" text="Number of laps:" />
|
||||
<spacer width="20" />
|
||||
<spinner id="laps" proportion="1" width="100" min_value="1"
|
||||
max_value="99" wrap_around="false" />
|
||||
|
||||
<spacer proportion="1" />
|
||||
|
||||
<label id="reverse_label" text_align="left"
|
||||
I18N="In the edit track screen" text="Reverse:" />
|
||||
<spacer width="20" />
|
||||
<checkbox id="reverse" />
|
||||
|
||||
<spacer proportion="1" />
|
||||
</div>
|
||||
|
||||
<!-- Dialog buttons -->
|
||||
<div width="100%" height="60" layout="horizontal-row">
|
||||
<spacer proportion="2" />
|
||||
<button id="ok" text="OK" proportion="1" />
|
||||
<spacer proportion="1" />
|
||||
<button id="cancel" text="Cancel" proportion="1" />
|
||||
<spacer proportion="2" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</stkgui>
|
21
data/gui/enter_gp_name_dialog.stkgui
Normal file
@ -0,0 +1,21 @@
|
||||
<stkgui>
|
||||
|
||||
<div x="2%" y="10%" width="96%" height="80%" layout="vertical-row" >
|
||||
|
||||
<label id="title" width="100%" text_align="center" word_wrap="true"
|
||||
I18N="In the 'add new grand prix' dialog"
|
||||
text="Please enter the name of the grand prix" proportion="1" />
|
||||
|
||||
<spacer height="25" width="10" />
|
||||
|
||||
<textbox id="textfield" width="75%" I18N="In the 'add new grand prix' dialog" align="center"/>
|
||||
|
||||
<spacer height="20" width="20" />
|
||||
|
||||
<button id="cancel" I18N="When configuring input" text="Press ESC to cancel" align="center"/>
|
||||
|
||||
<spacer height="15" width="20" />
|
||||
|
||||
</div>
|
||||
|
||||
</stkgui>
|
BIN
data/gui/gp_add_track.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
data/gui/gp_copy.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
data/gui/gp_edit.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
data/gui/gp_edit_track.png
Normal file
After Width: | Height: | Size: 9.3 KiB |
BIN
data/gui/gp_new.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
data/gui/gp_remove.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
data/gui/gp_remove_track.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
data/gui/gp_rename.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
data/gui/gp_save.png
Normal file
After Width: | Height: | Size: 5.5 KiB |
35
data/gui/gpedit.stkgui
Normal file
@ -0,0 +1,35 @@
|
||||
<stkgui>
|
||||
|
||||
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png" />
|
||||
|
||||
<div x="2%" y="1%" width="96%" height="98%" layout="vertical-row">
|
||||
|
||||
<header id="title" width="80%" I18N="Title in edit grand prix screen"
|
||||
text="Edit Grand Prix" align="center" text_align="center" />
|
||||
|
||||
<spacer width="100%" height="2%" />
|
||||
|
||||
<box proportion="5" width="98%" align="center" layout="vertical-row" padding="6">
|
||||
<list id="tracks" x="0" y="0" width="100%" height="100%" keep_selection="true" />
|
||||
</box>
|
||||
|
||||
<spacer width="100%" height="2%" />
|
||||
|
||||
<buttonbar proportion="1" id="menu" height="135" width="100%" align="center">
|
||||
<icon-button id="up" width="128" height="128" icon="gui/up.png"
|
||||
I18N="Menu item" text="Move up" />
|
||||
<icon-button id="down" width="128" height="128" icon="gui/down.png"
|
||||
I18N="Menu item" text="Move down" />
|
||||
<icon-button id="add" width="128" height="128" icon="gui/gp_add_track.png"
|
||||
I18N="Menu item" text="Add" />
|
||||
<icon-button id="edit" width="128" height="128" icon="gui/gp_edit_track.png"
|
||||
I18N="Menu item" text="Edit" />
|
||||
<icon-button id="remove" width="128" height="128" icon="gui/gp_remove_track.png"
|
||||
I18N="Menu item" text="Remove" />
|
||||
<icon-button id="save" width="128" height="128" icon="gui/gp_save.png"
|
||||
I18N="Menu item" text="Save" />
|
||||
</buttonbar>
|
||||
|
||||
</div>
|
||||
|
||||
</stkgui>
|
BIN
data/gui/gpeditor.png
Normal file
After Width: | Height: | Size: 16 KiB |
45
data/gui/gpeditor.stkgui
Normal file
@ -0,0 +1,45 @@
|
||||
<stkgui>
|
||||
|
||||
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
|
||||
|
||||
<div x="2%" y="1%" width="96%" height="98%" layout="vertical-row" >
|
||||
|
||||
<header width="80%" I18N="Title in grand prix editor screen" text="Grand Prix editor"
|
||||
align="center" text_align="center" />
|
||||
|
||||
<spacer height="20" />
|
||||
|
||||
<box proportion="4" width="100%" layout="vertical-row">
|
||||
<ribbon_grid id="gplist" proportion="1" width="100%" square_items="true"
|
||||
label_location="each" align="left" max_rows="2" child_width="160"
|
||||
child_height="120" keep_selection="true" />
|
||||
</box>
|
||||
|
||||
<spacer height="10" />
|
||||
|
||||
<box proportion="2" width="100%" layout="vertical-row">
|
||||
<label id="gpname" text_align="center" width="100%"
|
||||
I18N="In the grand prix editor screen" text="" />
|
||||
<ribbon_grid id="tracks" proportion="1" width="100%" square_items="true"
|
||||
label_location="each" align="left" max_rows="1"
|
||||
child_width="160" child_height="120" />
|
||||
</box>
|
||||
|
||||
<spacer height="20" />
|
||||
|
||||
<buttonbar proportion="1" id="menu" height="135" width="100%" align="center">
|
||||
<icon-button id="new" width="128" height="128" icon="gui/gp_new.png"
|
||||
I18N="Menu item" text="New" />
|
||||
<icon-button id="copy" width="128" height="128" icon="gui/gp_copy.png"
|
||||
I18N="Menu item" text="Copy" />
|
||||
<icon-button id="edit" width="128" height="128" icon="gui/gp_edit.png"
|
||||
I18N="Menu item" text="Edit" />
|
||||
<icon-button id="remove" width="128" height="128" icon="gui/gp_remove.png"
|
||||
I18N="Menu item" text="Remove" />
|
||||
<icon-button id="rename" width="128" height="128" icon="gui/gp_rename.png"
|
||||
I18N="Menu item" text="Rename" />
|
||||
</buttonbar>
|
||||
|
||||
</div>
|
||||
|
||||
</stkgui>
|
@ -35,13 +35,15 @@
|
||||
|
||||
<spacer width="10" height="10" />
|
||||
|
||||
<buttonbar id="menu_bottomrow" x="0" y="0" width="30%" height="100%" align="center">
|
||||
<buttonbar id="menu_bottomrow" x="0" y="0" width="38%" height="100%" align="center">
|
||||
<icon-button id="options" width="64" height="64" icon="gui/main_options.png" extend_label="50"
|
||||
I18N="Main menu button" text="Options" label_location="hover"/>
|
||||
<icon-button id="help" width="64" height="64" icon="gui/main_help.png" extend_label="50"
|
||||
I18N="Main menu button" text="Help" label_location="hover"/>
|
||||
<icon-button id="startTutorial" width="64" height="64" icon="gui/tutorial.png" extend_label="150"
|
||||
I18N="Main menu button" text="Tutorial" label_location="hover"/>
|
||||
<icon-button id="gpEditor" width="64" height="64" icon="gui/gpeditor.png" extend_label="150"
|
||||
I18N="Main menu button" text="Grand Prix Editor" label_location="hover"/>
|
||||
<icon-button id="about" width="64" height="64" icon="gui/main_about.png" extend_label="50"
|
||||
I18N="Main menu button" text="About" label_location="hover"/>
|
||||
<icon-button id="quit" width="64" height="64" icon="gui/main_quit.png" extend_label="50"
|
||||
|
@ -39,6 +39,6 @@ or collect any achievements while being online."
|
||||
</box>
|
||||
</div>
|
||||
|
||||
<icon-button id="back" x="0" y="0" height="15%" icon="gui/back.png"/>
|
||||
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
|
||||
|
||||
</stkgui>
|
||||
|
BIN
data/gui/scroll_down.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
data/gui/scroll_up.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
data/gui/up.png
Normal file
After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 111 KiB |
@ -11,5 +11,6 @@ varying vec2 uv;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
FragColor = texture(tex, uv);
|
||||
vec4 color = texture(tex, uv);
|
||||
FragColor = vec4(color.rgb, color.a);
|
||||
}
|
||||
|
@ -9,14 +9,14 @@ varying vec2 uv;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
vec3 getCIEYxy(vec3 rgbColor);
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 weights = vec3(0.2126, 0.7152, 0.0722); // ITU-R BT. 709
|
||||
vec3 col = texture(tex, uv).xyz;
|
||||
float luma = dot(weights, col);
|
||||
float luma = getCIEYxy(col).x;
|
||||
|
||||
col *= smoothstep(1., 2., luma);
|
||||
col *= smoothstep(1., 10., luma);
|
||||
|
||||
FragColor = vec4(col, 1.0);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ varying vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = texture(tex, uv);
|
||||
FragColor.a *= transparency;
|
||||
vec4 Color = texture(tex, uv);
|
||||
Color.a *= transparency;
|
||||
FragColor = vec4(Color.rgb * Color.a, Color.a);
|
||||
}
|
||||
|
@ -1,32 +0,0 @@
|
||||
uniform sampler2D Albedo;
|
||||
uniform sampler2D DiffuseMap;
|
||||
uniform sampler2D SpecularMap;
|
||||
uniform sampler2D SSAO;
|
||||
uniform vec2 screen;
|
||||
uniform vec3 ambient;
|
||||
uniform sampler2D caustictex;
|
||||
uniform vec2 dir;
|
||||
uniform vec2 dir2;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 tc = gl_FragCoord.xy / screen;
|
||||
vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz;
|
||||
vec3 SpecularComponent = texture(SpecularMap, tc).xyz;
|
||||
vec4 color = texture(Albedo, uv);
|
||||
float ao = texture(SSAO, tc).x;
|
||||
|
||||
float caustic = texture(caustictex, uv + dir).x;
|
||||
float caustic2 = texture(caustictex, (uv.yx + dir2 * vec2(-0.6, 0.3)) * vec2(0.6)).x;
|
||||
|
||||
vec3 LightFactor = ao * ambient + DiffuseComponent + SpecularComponent + caustic * caustic2 * 10;
|
||||
FragColor = vec4(color.xyz * LightFactor, 1.);
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D oldtex;
|
||||
uniform vec2 pixel;
|
||||
uniform vec2 multi;
|
||||
uniform int size;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
float res = 0.0;
|
||||
vec2 tc = gl_TexCoord[0].xy;
|
||||
// tc.y = 1.0 - tc.y;
|
||||
tc *= multi;
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
float col = texture(tex, tc).x;
|
||||
res = max(col, res);
|
||||
|
||||
tc += pixel;
|
||||
}
|
||||
|
||||
float old = texture(oldtex, gl_TexCoord[0].xy).x;
|
||||
|
||||
FragColor = vec4(mix(old, res, 0.7));
|
||||
}
|
@ -1,3 +1,7 @@
|
||||
//#define DOF_ENABLED
|
||||
|
||||
#ifdef DOF_ENABLED
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D dtex;
|
||||
uniform vec3 inlevel;
|
||||
@ -12,7 +16,203 @@ varying vec2 uv;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
#define PI 3.14159265
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
// TEST
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
||||
float width = 1920; //texture width
|
||||
float height = 1080; //texture height
|
||||
|
||||
vec2 texel = vec2(1.0/width,1.0/height);
|
||||
|
||||
//------------------------------------------
|
||||
//user variables
|
||||
|
||||
int samples = 3; //samples on the first ring
|
||||
int rings = 5; //ring count
|
||||
|
||||
bool autofocus = false; //use autofocus in shader? disable if you use external focalDepth value
|
||||
float focalDepth = 0.1;
|
||||
vec2 focus = vec2(0.5,0.5); // autofocus point on screen (0.0,0.0 - left lower corner, 1.0,1.0 - upper right)
|
||||
float range = 150.0; //focal range
|
||||
float maxblur = 1.25; //clamp value of max blur
|
||||
|
||||
float threshold = 0.9; //highlight threshold;
|
||||
float gain = 10.0; //highlight gain;
|
||||
|
||||
float bias = 0.4; //bokeh edge bias
|
||||
float fringe = 0.5; //bokeh chromatic aberration/fringing
|
||||
|
||||
bool noise = true; //use noise instead of pattern for sample dithering
|
||||
float namount = 0.0001; //dither amount
|
||||
|
||||
bool depthblur = false; //blur the depth buffer?
|
||||
float dbsize = 2.0; //depthblursize
|
||||
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
// Function
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
||||
vec3 color(vec2 coords,float blur) //processing the sample
|
||||
{
|
||||
vec3 col = vec3(0.0);
|
||||
|
||||
col.r = texture2D(tex,coords + vec2(0.0,1.0)*texel*fringe*blur).r;
|
||||
col.g = texture2D(tex,coords + vec2(-0.866,-0.5)*texel*fringe*blur).g;
|
||||
col.b = texture2D(tex,coords + vec2(0.866,-0.5)*texel*fringe*blur).b;
|
||||
|
||||
vec3 lumcoeff = vec3(0.299,0.587,0.114);
|
||||
float lum = dot(col.rgb, lumcoeff);
|
||||
float thresh = max((lum-threshold)*gain, 0.0);
|
||||
return col+mix(vec3(0.0),col,thresh*blur);
|
||||
}
|
||||
|
||||
vec2 rand(in vec2 coord) //generating noise/pattern texture for dithering
|
||||
{
|
||||
float noiseX = ((fract(1.0-coord.s*(width/2.0))*0.25)+(fract(coord.t*(height/2.0))*0.75))*2.0-1.0;
|
||||
float noiseY = ((fract(1.0-coord.s*(width/2.0))*0.75)+(fract(coord.t*(height/2.0))*0.25))*2.0-1.0;
|
||||
|
||||
if (noise)
|
||||
{
|
||||
noiseX = clamp(fract(sin(dot(coord ,vec2(12.9898,78.233))) * 43758.5453),0.0,1.0)*2.0-1.0;
|
||||
noiseY = clamp(fract(sin(dot(coord ,vec2(12.9898,78.233)*2.0)) * 43758.5453),0.0,1.0)*2.0-1.0;
|
||||
}
|
||||
return vec2(noiseX,noiseY);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
//float depth = texture2D(dtex,uv).x;
|
||||
|
||||
float curdepth = texture(dtex, uv).x;
|
||||
vec4 FragPos = invprojm * (2.0f * vec4(uv, curdepth, 1.0f) - 1.0f);
|
||||
FragPos /= FragPos.w;
|
||||
|
||||
float depth = clamp((FragPos.z/180), 0., 1.);
|
||||
|
||||
|
||||
float blur = 0.0;
|
||||
|
||||
|
||||
blur = clamp((abs(depth - focalDepth)/range)*100.0,-maxblur,maxblur);
|
||||
|
||||
vec2 noise = rand(uv)*namount*blur;
|
||||
|
||||
float w = (1.0/width)*blur+noise.x;
|
||||
float h = (1.0/height)*blur+noise.y;
|
||||
|
||||
vec3 col = texture2D(tex, uv).rgb;
|
||||
vec3 colDof = col;
|
||||
float s = 1.0;
|
||||
|
||||
int ringsamples;
|
||||
|
||||
for (int i = 1; i <= rings; i += 1)
|
||||
{
|
||||
ringsamples = i * samples;
|
||||
|
||||
for (int j = 0 ; j < ringsamples ; j += 1)
|
||||
{
|
||||
float step = PI*2.0 / float(ringsamples);
|
||||
float pw = (cos(float(j)*step)*float(i));
|
||||
float ph = (sin(float(j)*step)*float(i));
|
||||
float p = 1.0;
|
||||
|
||||
colDof += color(uv + vec2(pw*w,ph*h),blur)*mix(1.0,(float(i))/(float(rings)),bias)*p;
|
||||
s += 1.0*mix(1.0,(float(i))/(float(rings)),bias)*p;
|
||||
}
|
||||
}
|
||||
colDof /= s;
|
||||
|
||||
// get color correction values
|
||||
float inBlack = inlevel.x;
|
||||
float inWhite = inlevel.z;
|
||||
float inGamma = inlevel.y;
|
||||
|
||||
float outBlack = outlevel.x;
|
||||
float outWhite = outlevel.y;
|
||||
|
||||
vec3 colOut = (pow(((col.rgb * 255.0) - inBlack) / (inWhite - inBlack),
|
||||
vec3(1.0 / inGamma)) * (outWhite - outBlack) + outBlack) / 255.0;
|
||||
|
||||
depth = (1 - depth);
|
||||
vec3 final = colOut * depth + colDof.rgb * (1 - depth);
|
||||
|
||||
vec2 inTex = uv - 0.5;
|
||||
float vignette = 1 - dot(inTex, inTex);
|
||||
|
||||
vignette = clamp(pow(vignette, 0.8), 0., 1.) ;
|
||||
vignette = vignette + vignette - 0.5;
|
||||
final.rgb *= clamp(vignette, 0., 1.15);
|
||||
|
||||
FragColor.rgb = final;
|
||||
FragColor.a = 1.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
void main()
|
||||
{
|
||||
vec2 texc = uv;
|
||||
//texc.y = 1.0 - texc.y;
|
||||
|
||||
|
||||
vec4 col = texture(tex, texc);
|
||||
float curdepth = texture(dtex, uv).x;
|
||||
|
||||
vec2 inTex = uv - 0.5;
|
||||
float vignette = 1 - dot(inTex, inTex);
|
||||
|
||||
vec4 FragPos = invprojm * (2.0f * vec4(uv, curdepth, 1.0f) - 1.0f);
|
||||
FragPos /= FragPos.w;
|
||||
|
||||
//col = col / (1 - col);
|
||||
|
||||
float inBlack = inlevel.x;
|
||||
float inWhite = inlevel.z;
|
||||
float inGamma = inlevel.y;
|
||||
|
||||
float outBlack = outlevel.x;
|
||||
float outWhite = outlevel.y;
|
||||
|
||||
float depth1 = clamp((FragPos.z/180), 0., 1.);
|
||||
|
||||
vec3 colOut = (pow(((col.rgb * 255.0) - inBlack) / (inWhite - inBlack),
|
||||
vec3(1.0 / inGamma)) * (outWhite - outBlack) + outBlack) / 255.0;
|
||||
|
||||
depth1 = (1 - depth1);
|
||||
vec3 final = colOut * depth1 + col.rgb * (1 - depth1);
|
||||
|
||||
vignette = clamp(pow(vignette, 0.8), 0., 1.) ;
|
||||
vignette = vignette + vignette - 0.5;
|
||||
final.rgb *= clamp(vignette, 0., 1.15);
|
||||
FragColor = vec4(final, 1.0);
|
||||
|
||||
|
||||
}*/
|
||||
|
||||
#else
|
||||
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D dtex;
|
||||
uniform vec3 inlevel;
|
||||
uniform vec2 outlevel;
|
||||
uniform mat4 invprojm;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
@ -21,14 +221,14 @@ void main()
|
||||
float curdepth = texture(dtex, uv).x;
|
||||
vec4 FragPos = invprojm * (2.0 * vec4(uv, curdepth, 1.0f) - 1.0f);
|
||||
FragPos /= FragPos.w;
|
||||
float depth = clamp(FragPos.z / 180, 0, 1);
|
||||
float depth = clamp(FragPos.z / 180, 0., 1.);
|
||||
depth = (1 - depth);
|
||||
|
||||
// Compute the vignette
|
||||
vec2 inside = uv - 0.5;
|
||||
float vignette = 1 - dot(inside, inside);
|
||||
vignette = clamp(pow(vignette, 0.8), 0, 1);
|
||||
vignette = clamp(vignette + vignette - 0.5, 0, 1.15);
|
||||
vignette = clamp(pow(vignette, 0.8), 0., 1.);
|
||||
vignette = clamp(vignette + vignette - 0.5, 0., 1.15);
|
||||
|
||||
float inBlack = inlevel.x;
|
||||
float inWhite = inlevel.z;
|
||||
@ -45,3 +245,4 @@ void main()
|
||||
FragColor = vec4(colFinal * vignette, 1.0);
|
||||
//FragColor = vec4(vec3(depth), 1.0);
|
||||
}
|
||||
#endif
|
@ -1,10 +1,5 @@
|
||||
uniform sampler2D Albedo;
|
||||
uniform sampler2D Detail;
|
||||
uniform sampler2D DiffuseMap;
|
||||
uniform sampler2D SpecularMap;
|
||||
uniform sampler2D SSAO;
|
||||
uniform vec2 screen;
|
||||
uniform vec3 ambient;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
@ -16,17 +11,13 @@ varying vec2 uv_bis;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
|
||||
vec3 getLightFactor(float specMapValue);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 tc = gl_FragCoord.xy / screen;
|
||||
vec4 color = texture(Albedo, uv);
|
||||
vec4 detail = texture(Detail, uv_bis);
|
||||
color *= detail;
|
||||
vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz;
|
||||
vec3 SpecularComponent = texture(SpecularMap, tc).xyz;
|
||||
float ao = texture(SSAO, tc).x;
|
||||
vec3 LightFactor = ao * ambient + DiffuseComponent + SpecularComponent * (1. - color.a);
|
||||
FragColor = vec4(color.xyz * LightFactor * ao, 1.);
|
||||
vec3 LightFactor = getLightFactor(1. - color.a);
|
||||
FragColor = vec4(color.xyz * LightFactor, 1.);
|
||||
}
|
||||
|
@ -14,12 +14,7 @@ varying vec2 uv;
|
||||
#define Spec gl_FragData[1]
|
||||
#endif
|
||||
|
||||
vec3 DecodeNormal(vec2 n)
|
||||
{
|
||||
float z = dot(n, n) * 2. - 1.;
|
||||
vec2 xy = normalize(n) * sqrt(1. - z * z);
|
||||
return vec3(xy,z);
|
||||
}
|
||||
vec3 DecodeNormal(vec2 n);
|
||||
|
||||
mat4 getMatrix(float L[9])
|
||||
{
|
||||
@ -47,6 +42,6 @@ void main(void)
|
||||
float g = dot(extendednormal, gmat * extendednormal);
|
||||
float b = dot(extendednormal, bmat * extendednormal);
|
||||
|
||||
Diff = 0.25 * vec4(r, g, b, .1);
|
||||
Diff = max(0.25 * vec4(r, g, b, .1), vec4(0.));
|
||||
Spec = vec4(0.);
|
||||
}
|
||||
|
@ -1,10 +1,19 @@
|
||||
uniform sampler2D displacement_tex;
|
||||
uniform sampler2D mask_tex;
|
||||
uniform sampler2D color_tex;
|
||||
uniform vec2 screen;
|
||||
uniform vec2 dir;
|
||||
uniform vec2 dir2;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
in vec2 uv_bis;
|
||||
|
86
data/shaders/dof.frag
Normal file
@ -0,0 +1,86 @@
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D dtex;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
float focalDepth = 10.;
|
||||
float maxblur = 1.;
|
||||
float range = 100.;
|
||||
|
||||
void main()
|
||||
{
|
||||
float curdepth = texture(dtex, uv).x;
|
||||
vec4 FragPos = InverseProjectionMatrix * (2.0f * vec4(uv, curdepth, 1.0f) - 1.0f);
|
||||
FragPos /= FragPos.w;
|
||||
|
||||
float depth = FragPos.z;
|
||||
float blur = clamp(abs(depth - focalDepth) / range, -maxblur, maxblur);
|
||||
|
||||
vec2 offset = 10. / screen;
|
||||
|
||||
vec4 col = texture(tex, uv);
|
||||
vec4 colOriginal = col;
|
||||
// Weight from here http://artmartinsh.blogspot.fr/2010/02/glsl-lens-blur-filter-with-bokeh.html
|
||||
|
||||
col += texture(tex, uv + (vec2(0.0, 0.4) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(0.15, 0.37) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(0.29,0.29) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(-0.37,0.15) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(0.4, 0.0) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(0.37, -0.15) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(0.29, -0.29) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(-0.15, -0.37) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(0.0, -0.4) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(-0.15, 0.37) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(-0.29, 0.29) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(0.37, 0.15) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(-0.4, 0.0) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(-0.37, -0.15) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(-0.29, -0.29) * offset) * blur);
|
||||
col += texture(tex, uv + (vec2(0.15, -0.37) * offset) * blur);
|
||||
|
||||
col += texture(tex, uv + (vec2(0.15, 0.37) * offset) * blur * 0.9);
|
||||
col += texture(tex, uv + (vec2(-0.37, 0.15) * offset) * blur * 0.9);
|
||||
col += texture(tex, uv + (vec2(0.37, -0.15) * offset) * blur * 0.9);
|
||||
col += texture(tex, uv + (vec2(-0.15, -0.37) * offset) * blur * 0.9);
|
||||
col += texture(tex, uv + (vec2(-0.15, 0.37) * offset) * blur * 0.9);
|
||||
col += texture(tex, uv + (vec2(0.37, 0.15) * offset) * blur * 0.9);
|
||||
col += texture(tex, uv + (vec2(-0.37, -0.15) * offset) * blur * 0.9);
|
||||
col += texture(tex, uv + (vec2(0.15, -0.37) * offset) * blur * 0.9);
|
||||
|
||||
col += texture(tex, uv + (vec2(0.29, 0.29) * offset) * blur * 0.7);
|
||||
col += texture(tex, uv + (vec2(0.4, 0.0) * offset) * blur * 0.7);
|
||||
col += texture(tex, uv + (vec2(0.29, -0.29) * offset) * blur * 0.7);
|
||||
col += texture(tex, uv + (vec2(0.0, -0.4) * offset) * blur * 0.7);
|
||||
col += texture(tex, uv + (vec2(-0.29, 0.29) * offset) * blur * 0.7);
|
||||
col += texture(tex, uv + (vec2(-0.4, 0.0) * offset) * blur * 0.7);
|
||||
col += texture(tex, uv + (vec2(-0.29, -0.29) * offset) * blur * 0.7);
|
||||
col += texture(tex, uv + (vec2(0.0, 0.4) * offset) * blur *0.7);
|
||||
|
||||
col += texture(tex, uv + (vec2(0.29, 0.29) * offset) * blur * 0.4);
|
||||
col += texture(tex, uv + (vec2(0.4, 0.0) * offset) * blur * 0.4);
|
||||
col += texture(tex, uv + (vec2(0.29, -0.29) * offset) * blur * 0.4);
|
||||
col += texture(tex, uv + (vec2(0.0, -0.4) * offset) * blur * 0.4);
|
||||
col += texture(tex, uv + (vec2(-0.29, 0.29) * offset) * blur * 0.4);
|
||||
col += texture(tex, uv + (vec2(-0.4, 0.0) * offset) * blur * 0.4);
|
||||
col += texture(tex, uv + (vec2(-0.29, -0.29) * offset) * blur * 0.4);
|
||||
col += texture(tex, uv + (vec2(0.0, 0.4) * offset) * blur * 0.4);
|
||||
|
||||
col = vec4(col.rgb / 41.0, col.a);
|
||||
depth = clamp((FragPos.z/280), 0., 1.);
|
||||
depth = (1 - depth);
|
||||
vec3 final = colOriginal.rgb * depth + col.rgb * (1 - depth);
|
||||
|
||||
FragColor = vec4(final, 1.);
|
||||
}
|
@ -1,5 +1,12 @@
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 ViewMatrix;
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
in vec2 quadcorner;
|
||||
in vec2 texcoord;
|
||||
@ -12,6 +19,7 @@ in float anglespeed;
|
||||
|
||||
out float lf;
|
||||
out vec2 tc;
|
||||
out vec3 pc;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
@ -57,4 +65,5 @@ void main(void)
|
||||
|
||||
vec4 viewpos = ViewMatrix * vec4(newposition + newquadcorner, 1.0);
|
||||
gl_Position = ProjectionMatrix * viewpos;
|
||||
pc = vec3(1.);
|
||||
}
|
||||
|
@ -6,27 +6,34 @@ uniform float endH;
|
||||
uniform float start;
|
||||
uniform float end;
|
||||
uniform vec3 col;
|
||||
uniform mat4 ipvmat;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
#define FragColor gl_FragColor
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
|
||||
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
|
||||
|
||||
void main()
|
||||
{
|
||||
float z = texture(tex, uv).x;
|
||||
|
||||
vec3 tmp = vec3(uv, z);
|
||||
tmp = tmp * 2.0 - 1.0;
|
||||
|
||||
vec4 xpos = vec4(tmp, 1.0);
|
||||
xpos = ipvmat * xpos;
|
||||
xpos.xyz /= xpos.w;
|
||||
vec4 xpos = getPosFromUVDepth(vec3(uv, z), InverseProjectionMatrix);
|
||||
|
||||
float dist = length(xpos.xyz);
|
||||
float fog = smoothstep(start, end, dist);
|
||||
|
31
data/shaders/gaussian17taph.frag
Normal file
@ -0,0 +1,31 @@
|
||||
// From http://http.developer.nvidia.com/GPUGems3/gpugems3_ch40.html
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 pixel;
|
||||
uniform float sigma = 5.;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
float X = uv.x;
|
||||
float Y = uv.y;
|
||||
|
||||
|
||||
float g0, g1, g2;
|
||||
g0 = 1.0 / (sqrt(2.0 * 3.14) * sigma);
|
||||
g1 = exp(-0.5 / (sigma * sigma));
|
||||
g2 = g1 * g1;
|
||||
vec4 sum = texture(tex, vec2(X, Y)) * g0;
|
||||
g0 *= g1;
|
||||
g1 *= g2;
|
||||
for (int i = 1; i < 9; i++) {
|
||||
sum += texture(tex, vec2(X - i * pixel.x, Y)) * g0;
|
||||
sum += texture(tex, vec2(X + i * pixel.x, Y)) * g0;
|
||||
g0 *= g1;
|
||||
g1 *= g2;
|
||||
}
|
||||
|
||||
FragColor = sum;
|
||||
}
|
32
data/shaders/gaussian17tapv.frag
Normal file
@ -0,0 +1,32 @@
|
||||
// From http://http.developer.nvidia.com/GPUGems3/gpugems3_ch40.html
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 pixel;
|
||||
uniform float sigma = 5.;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
float X = uv.x;
|
||||
float Y = uv.y;
|
||||
|
||||
|
||||
float g0, g1, g2;
|
||||
g0 = 1.0 / (sqrt(2.0 * 3.14) * sigma);
|
||||
g1 = exp(-0.5 / (sigma * sigma));
|
||||
g2 = g1 * g1;
|
||||
vec4 sum = texture(tex, vec2(X, Y)) * g0;
|
||||
g0 *= g1;
|
||||
g1 *= g2;
|
||||
for (int i = 1; i < 9; i++) {
|
||||
sum += texture(tex, vec2(X, Y - i * pixel.y)) * g0;
|
||||
sum += texture(tex, vec2(X, Y + i * pixel.y)) * g0;
|
||||
g0 *= g1;
|
||||
g1 *= g2;
|
||||
}
|
||||
|
||||
FragColor = sum;
|
||||
}
|
||||
|
34
data/shaders/grass_pass2.frag
Normal file
@ -0,0 +1,34 @@
|
||||
uniform sampler2D Albedo;
|
||||
uniform vec3 SunDir;
|
||||
uniform mat4 invproj;
|
||||
uniform sampler2D dtex;
|
||||
uniform vec2 screen;
|
||||
|
||||
in vec3 nor;
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
vec3 getLightFactor(float specMapValue);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 texc = gl_FragCoord.xy / screen;
|
||||
float z = texture(dtex, texc).x;
|
||||
|
||||
vec4 xpos = 2.0 * vec4(texc, z, 1.0) - 1.0f;
|
||||
xpos = invproj * xpos;
|
||||
xpos /= xpos.w;
|
||||
vec3 eyedir = normalize(xpos.xyz);
|
||||
|
||||
// Inspired from http://http.developer.nvidia.com/GPUGems3/gpugems3_ch16.html
|
||||
float fEdotL = max(0., dot(SunDir, eyedir));
|
||||
float fPowEdotL = pow(fEdotL, 4.);
|
||||
|
||||
float fLdotNBack = max(0., - dot(nor, SunDir) * 0.6 + 0.4);
|
||||
float scattering = mix(fPowEdotL, fLdotNBack, .5);
|
||||
|
||||
vec4 color = texture(Albedo, uv);
|
||||
if (color.a < 0.5) discard;
|
||||
vec3 LightFactor = scattering + getLightFactor(1.);
|
||||
FragColor = vec4(color.xyz * LightFactor, 1.);
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
uniform vec3 windDir;
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 Position;
|
||||
in vec2 Texcoord;
|
||||
in vec4 Color;
|
||||
out vec2 uv;
|
||||
#else
|
||||
attribute vec3 Position;
|
||||
attribute vec2 Texcoord;
|
||||
attribute vec4 Color;
|
||||
varying vec2 uv;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
uv = Texcoord;
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position + windDir * Color.r, 1.);
|
||||
}
|
36
data/shaders/instanced_grass.vert
Normal file
@ -0,0 +1,36 @@
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
uniform vec3 windDir;
|
||||
|
||||
|
||||
in vec3 Origin;
|
||||
in vec3 Orientation;
|
||||
in vec3 Scale;
|
||||
|
||||
in vec3 Position;
|
||||
in vec3 Normal;
|
||||
in vec2 Texcoord;
|
||||
in vec4 Color;
|
||||
|
||||
out vec3 nor;
|
||||
out vec2 uv;
|
||||
|
||||
mat4 getWorldMatrix(vec3 translation, vec3 rotation, vec3 scale);
|
||||
mat4 getInverseWorldMatrix(vec3 translation, vec3 rotation, vec3 scale);
|
||||
|
||||
void main()
|
||||
{
|
||||
mat4 ModelMatrix = getWorldMatrix(Origin + windDir * Color.r, Orientation, Scale);
|
||||
mat4 TransposeInverseModelView = transpose(getInverseWorldMatrix(Origin + windDir * Color.r, Orientation, Scale) * InverseViewMatrix);
|
||||
gl_Position = ProjectionMatrix * ViewMatrix * ModelMatrix * vec4(Position, 1.);
|
||||
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
|
||||
uv = Texcoord;
|
||||
}
|
39
data/shaders/instanced_object_pass.vert
Normal file
@ -0,0 +1,39 @@
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
in vec3 Origin;
|
||||
in vec3 Orientation;
|
||||
in vec3 Scale;
|
||||
|
||||
in vec3 Position;
|
||||
in vec3 Normal;
|
||||
in vec2 Texcoord;
|
||||
|
||||
out vec3 nor;
|
||||
out vec2 uv;
|
||||
|
||||
mat4 getWorldMatrix(vec3 translation, vec3 rotation, vec3 scale);
|
||||
mat4 getInverseWorldMatrix(vec3 translation, vec3 rotation, vec3 scale);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale);
|
||||
mat4 TransposeInverseModelView = transpose(getInverseWorldMatrix(Origin, Orientation, Scale) * InverseViewMatrix);
|
||||
gl_Position = ProjectionMatrix * ViewMatrix * ModelMatrix * vec4(Position, 1.);
|
||||
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
|
||||
uv = Texcoord;
|
||||
}
|
39
data/shaders/instanciedshadow.vert
Normal file
@ -0,0 +1,39 @@
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
};
|
||||
|
||||
in vec3 Origin;
|
||||
in vec3 Orientation;
|
||||
in vec3 Scale;
|
||||
|
||||
in vec3 Position;
|
||||
in vec2 Texcoord;
|
||||
|
||||
#ifdef VSLayer
|
||||
out vec2 uv;
|
||||
#else
|
||||
out vec2 tc;
|
||||
out int layerId;
|
||||
#endif
|
||||
|
||||
mat4 getWorldMatrix(vec3 translation, vec3 rotation, vec3 scale);
|
||||
mat4 getInverseWorldMatrix(vec3 translation, vec3 rotation, vec3 scale);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale);
|
||||
#ifdef VSLayer
|
||||
gl_Layer = gl_InstanceID & 3;
|
||||
gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * vec4(Position, 1.);
|
||||
uv = Texcoord;
|
||||
#else
|
||||
layerId = gl_InstanceID & 3;
|
||||
gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * vec4(Position, 1.);
|
||||
tc = Texcoord;
|
||||
#endif
|
||||
}
|
13
data/shaders/linearizedepth.frag
Normal file
@ -0,0 +1,13 @@
|
||||
uniform sampler2D tex;
|
||||
uniform float zn;
|
||||
uniform float zf;
|
||||
|
||||
in vec2 uv;
|
||||
out float Depth;
|
||||
|
||||
void main()
|
||||
{
|
||||
float d = texture(tex, uv).x;
|
||||
float c0 = zn * zf, c1 = zn - zf, c2 = zf;
|
||||
Depth = c0 / (d * c1 + c2);
|
||||
}
|
14
data/shaders/logluminance.frag
Normal file
@ -0,0 +1,14 @@
|
||||
uniform sampler2D tex;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
float delta = .0001;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 weight = vec3(0.2125f, 0.7154f, 0.0721f);
|
||||
vec3 col = texture(tex, uv).xyz;
|
||||
float luma = dot(col, weight);
|
||||
FragColor = vec4(log(luma + delta));
|
||||
}
|
@ -1,14 +1,13 @@
|
||||
#version 330 compatibility
|
||||
#define MAX_SEARCH_STEPS 8.0
|
||||
#define MAX_DISTANCE 33.0
|
||||
|
||||
#extension GL_ARB_shader_texture_lod: enable
|
||||
|
||||
uniform sampler2D edgesMap;
|
||||
uniform sampler2D areaMap;
|
||||
|
||||
uniform vec2 PIXEL_SIZE;
|
||||
|
||||
#define MAX_SEARCH_STEPS 8.0
|
||||
#define MAX_DISTANCE 33.0
|
||||
|
||||
in vec2 uv;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
/**
|
||||
@ -17,7 +16,7 @@ out vec4 FragColor;
|
||||
* bit.
|
||||
*/
|
||||
vec4 tex2Doffset(sampler2D map, vec2 texcoord, vec2 offset) {
|
||||
return texture2DLod(map, texcoord + PIXEL_SIZE * offset, 0.0);
|
||||
return textureLod(map, texcoord + PIXEL_SIZE * offset, 0.0);
|
||||
}
|
||||
|
||||
float SearchXLeft(vec2 texcoord) {
|
||||
@ -73,24 +72,24 @@ vec2 Area(vec2 distance, float e1, float e2) {
|
||||
float areaSize = MAX_DISTANCE * 5.0;
|
||||
vec2 pixcoord = MAX_DISTANCE * round(4.0 * vec2(e1, e2)) + distance;
|
||||
vec2 texcoord = pixcoord / (areaSize - 1.0);
|
||||
return texture2DLod(areaMap, texcoord, 0.0).ra;
|
||||
return textureLod(areaMap, texcoord, 0.0).ra;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 areas = vec4(0.0);
|
||||
|
||||
vec2 e = texture(edgesMap, gl_TexCoord[0].xy).rg;
|
||||
vec2 e = texture(edgesMap, uv).rg;
|
||||
|
||||
if (e.g != 0.0) { // Edge at north
|
||||
|
||||
// Search distances to the left and to the right:
|
||||
vec2 d = vec2(SearchXLeft(gl_TexCoord[0].xy), SearchXRight(gl_TexCoord[0].xy));
|
||||
vec2 d = vec2(SearchXLeft(uv), SearchXRight(uv));
|
||||
|
||||
// Now fetch the crossing edges. Instead of sampling between edgels, we
|
||||
// sample at 0.25, to be able to discern what value has each edgel:
|
||||
vec4 coords = vec4(d.x, 0.25, d.y + 1.0, 0.25) * PIXEL_SIZE.xyxy + gl_TexCoord[0].xyxy;
|
||||
float e1 = texture2DLod(edgesMap, coords.xy, 0.0).r;
|
||||
float e2 = texture2DLod(edgesMap, coords.zw, 0.0).r;
|
||||
vec4 coords = vec4(d.x, 0.25, d.y + 1.0, 0.25) * PIXEL_SIZE.xyxy + uv.xyxy;
|
||||
float e1 = textureLod(edgesMap, coords.xy, 0.0).r;
|
||||
float e2 = textureLod(edgesMap, coords.zw, 0.0).r;
|
||||
|
||||
// Ok, we know how this pattern looks like, now it is time for getting
|
||||
// the actual area:
|
||||
@ -100,12 +99,12 @@ void main() {
|
||||
if (e.r != 0.0) { // Edge at west
|
||||
|
||||
// Search distances to the top and to the bottom:
|
||||
vec2 d = vec2(SearchYUp(gl_TexCoord[0].xy), SearchYDown(gl_TexCoord[0].xy));
|
||||
vec2 d = vec2(SearchYUp(uv), SearchYDown(uv));
|
||||
|
||||
// Now fetch the crossing edges (yet again):
|
||||
vec4 coords = vec4(-0.25, d.x, -0.25, d.y - 1.0) * PIXEL_SIZE.xyxy + gl_TexCoord[0].xyxy;
|
||||
float e1 = texture2DLod(edgesMap, coords.xy, 0.0).g;
|
||||
float e2 = texture2DLod(edgesMap, coords.zw, 0.0).g;
|
||||
vec4 coords = vec4(-0.25, d.x, -0.25, d.y - 1.0) * PIXEL_SIZE.xyxy + uv.xyxy;
|
||||
float e1 = textureLod(edgesMap, coords.xy, 0.0).g;
|
||||
float e2 = textureLod(edgesMap, coords.zw, 0.0).g;
|
||||
|
||||
// Get the area for this direction:
|
||||
areas.ba = Area(abs(d), e1, e2);
|
||||
|
@ -1,8 +1,8 @@
|
||||
#version 330 compatibility
|
||||
uniform sampler2D colorMapG;
|
||||
|
||||
in vec4 offset[2];
|
||||
in vec2 uv;
|
||||
|
||||
uniform sampler2D colorMapG;
|
||||
const float threshold = 0.1;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
@ -1,11 +1,11 @@
|
||||
#version 330 compatibility
|
||||
in vec4 offset[2];
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform sampler2D blendMap;
|
||||
uniform sampler2D colorMap;
|
||||
|
||||
in vec4 offset[2];
|
||||
in vec2 uv;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main() {
|
||||
// Fetch the blending weights for current pixel:
|
||||
vec4 topLeft = texture(blendMap, uv);
|
||||
@ -37,5 +37,5 @@ void main() {
|
||||
color = mix(C, Cright, a.a) * w.a + color;
|
||||
|
||||
// Normalize the resulting color and we are finished!
|
||||
FragColor = color / sum;
|
||||
FragColor = vec4(color / sum);
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
#version 330 compatibility
|
||||
uniform vec2 PIXEL_SIZE;
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
|
||||
in vec2 Position;
|
||||
in vec2 Texcoord;
|
||||
|
||||
out vec4 offset[2];
|
||||
out vec2 uv;
|
||||
|
||||
void main() {
|
||||
gl_Position = ModelViewProjectionMatrix * gl_Vertex;
|
||||
vec4 invy = gl_MultiTexCoord0;
|
||||
gl_Position = vec4(Position, 0., 1.);
|
||||
vec4 invy = vec4(Texcoord, Texcoord);
|
||||
// invy.y = 1.0 - invy.y;
|
||||
uv = invy.st;
|
||||
|
||||
|
@ -1,12 +0,0 @@
|
||||
uniform sampler2D tex1;
|
||||
uniform sampler2D tex2;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 col1 = texture(tex1, gl_TexCoord[0].xy);
|
||||
vec4 col2 = vec4(vec3(texture(tex2, gl_TexCoord[0].xy).x), 1.0);
|
||||
|
||||
FragColor = col1 * col2;
|
||||
}
|
@ -1,33 +1,24 @@
|
||||
uniform sampler2D normalMap;
|
||||
uniform sampler2D DiffuseForAlpha;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 tangent;
|
||||
in vec3 bitangent;
|
||||
in vec2 uv;
|
||||
out vec2 EncodedNormal;
|
||||
#else
|
||||
varying vec3 tangent;
|
||||
varying vec3 bitangent;
|
||||
varying vec2 uv;
|
||||
#define EncodedNormal gl_FragColor.xy
|
||||
#endif
|
||||
out vec3 EncodedNormal;
|
||||
|
||||
|
||||
// from Crytek "a bit more deferred CryEngine"
|
||||
vec2 EncodeNormal(vec3 n)
|
||||
{
|
||||
return normalize(n.xy) * sqrt(n.z * 0.5 + 0.5);
|
||||
}
|
||||
vec2 EncodeNormal(vec3 n);
|
||||
|
||||
void main()
|
||||
{
|
||||
// normal in Tangent Space
|
||||
vec3 TS_normal = 2.0 * texture (normalMap, uv).rgb - 1.0;
|
||||
vec3 TS_normal = 2.0 * texture(normalMap, uv).rgb - 1.0;
|
||||
float alpha = texture(DiffuseForAlpha, uv).a;
|
||||
// Because of interpolation, we need to renormalize
|
||||
vec3 Frag_tangent = normalize(tangent);
|
||||
vec3 Frag_normal = normalize(cross(Frag_tangent, bitangent));
|
||||
vec3 Frag_bitangent = cross(Frag_normal, Frag_tangent);
|
||||
|
||||
vec3 FragmentNormal = TS_normal.x * Frag_tangent + TS_normal.y * Frag_bitangent - TS_normal.z * Frag_normal;
|
||||
EncodedNormal = 0.5 * EncodeNormal(normalize(FragmentNormal)) + 0.5;
|
||||
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(FragmentNormal)) + 0.5;
|
||||
EncodedNormal.z = exp2(10. * (1. - alpha) + 1.);
|
||||
}
|
||||
|
@ -1,6 +1,14 @@
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform mat4 TransposeInverseModelView;
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
};
|
||||
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform mat4 InverseModelMatrix;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 Position;
|
||||
@ -23,6 +31,8 @@ varying vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
mat4 ModelViewProjectionMatrix = ProjectionMatrix * ViewMatrix * ModelMatrix;
|
||||
mat4 TransposeInverseModelView = transpose(InverseModelMatrix * InverseViewMatrix);
|
||||
uv = Texcoord;
|
||||
tangent = (TransposeInverseModelView * vec4(Tangent, 1.)).xyz;
|
||||
bitangent = (TransposeInverseModelView * vec4(Bitangent, 1.)).xyz;
|
||||
|
57
data/shaders/object_pass.vert
Normal file
@ -0,0 +1,57 @@
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform mat4 InverseModelMatrix;
|
||||
|
||||
uniform mat4 TextureMatrix =
|
||||
mat4(1., 0., 0., 0.,
|
||||
0., 1., 0., 0.,
|
||||
0., 0., 1., 0.,
|
||||
0., 0., 0., 1.);
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 Position;
|
||||
in vec2 Texcoord;
|
||||
in vec2 SecondTexcoord;
|
||||
in vec3 Normal;
|
||||
in vec4 Color;
|
||||
out vec3 nor;
|
||||
out vec2 uv;
|
||||
out vec2 uv_bis;
|
||||
out vec4 color;
|
||||
#else
|
||||
attribute vec3 Position;
|
||||
attribute vec3 Normal;
|
||||
attribute vec2 Texcoord;
|
||||
attribute vec2 SecondTexcoord;
|
||||
varying vec3 nor;
|
||||
varying vec2 uv;
|
||||
varying vec2 uv_bis;
|
||||
#endif
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
color = Color.zyxw;
|
||||
mat4 ModelViewProjectionMatrix = ProjectionMatrix * ViewMatrix * ModelMatrix;
|
||||
mat4 TransposeInverseModelView = transpose(InverseModelMatrix * InverseViewMatrix);
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
|
||||
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
|
||||
uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy;
|
||||
uv_bis = SecondTexcoord;
|
||||
}
|
@ -1,20 +1,19 @@
|
||||
uniform sampler2D tex;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 nor;
|
||||
out vec2 EncodedNormal;
|
||||
in vec2 uv;
|
||||
out vec3 EncodedNormal;
|
||||
#else
|
||||
varying vec3 nor;
|
||||
#define EncodedNormal gl_FragColor.xy
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// from Crytek "a bit more deferred CryEngine"
|
||||
vec2 EncodeNormal(vec3 n)
|
||||
{
|
||||
return normalize(n.xy) * sqrt(n.z * 0.5 + 0.5);
|
||||
}
|
||||
vec2 EncodeNormal(vec3 n);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
EncodedNormal = 0.5 * EncodeNormal(normalize(nor)) + 0.5;
|
||||
vec4 col = texture(tex, uv);
|
||||
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(nor)) + 0.5;
|
||||
EncodedNormal.z = exp2(10. * (1. - col.a) + 1.);
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform mat4 TransposeInverseModelView;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 Position;
|
||||
in vec3 Normal;
|
||||
out vec3 nor;
|
||||
#else
|
||||
attribute vec3 Position;
|
||||
attribute vec3 Normal;
|
||||
varying vec3 nor;
|
||||
#endif
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
|
||||
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
|
||||
}
|
@ -1,9 +1,4 @@
|
||||
uniform sampler2D Albedo;
|
||||
uniform sampler2D DiffuseMap;
|
||||
uniform sampler2D SpecularMap;
|
||||
uniform sampler2D SSAO;
|
||||
uniform vec2 screen;
|
||||
uniform vec3 ambient;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
@ -13,15 +8,11 @@ varying vec2 uv;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
vec3 getLightFactor(float specMapValue);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 tc = gl_FragCoord.xy / screen;
|
||||
vec4 color = texture(Albedo, uv);
|
||||
vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz;
|
||||
vec3 SpecularComponent = texture(SpecularMap, tc).xyz;
|
||||
float ao = texture(SSAO, tc).x;
|
||||
vec3 LightFactor = ao * ambient + DiffuseComponent + SpecularComponent * (1. - color.a);
|
||||
FragColor = vec4(color.xyz * LightFactor * (0.4 + ao*0.6), 1.);
|
||||
//FragColor = vec4(color.xyz * LightFactor, 1.);
|
||||
vec3 LightFactor = getLightFactor(1.);
|
||||
FragColor = vec4(color.xyz * LightFactor, 1.);
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform mat4 TextureMatrix =
|
||||
mat4(1., 0., 0., 0.,
|
||||
0., 1., 0., 0.,
|
||||
0., 0., 1., 0.,
|
||||
0., 0., 0., 1.);
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 Position;
|
||||
in vec2 Texcoord;
|
||||
in vec2 SecondTexcoord;
|
||||
out vec2 uv;
|
||||
out vec2 uv_bis;
|
||||
#else
|
||||
attribute vec3 Position;
|
||||
attribute vec2 Texcoord;
|
||||
attribute vec2 SecondTexcoord;
|
||||
varying vec2 uv;
|
||||
varying vec2 uv_bis;
|
||||
#endif
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy;
|
||||
uv_bis = SecondTexcoord;
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
|
||||
}
|
@ -2,22 +2,31 @@ uniform sampler2D Albedo;
|
||||
uniform sampler2D DiffuseMap;
|
||||
uniform sampler2D SpecularMap;
|
||||
uniform sampler2D SSAO;
|
||||
uniform vec2 screen;
|
||||
uniform vec3 ambient;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 normal;
|
||||
in vec3 nor;
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
varying vec3 normal;
|
||||
varying vec3 nor;
|
||||
varying vec2 uv;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
float rim = 1.0 - dot(normal, vec3(0., 0., -1));
|
||||
rim = smoothstep(0.5, 1.5, rim) * 0.35;
|
||||
float rim = 1.0 - dot(nor, vec3(0., 0., -1));
|
||||
rim = smoothstep(0.5, 1.5, rim) * 0.15;
|
||||
|
||||
vec4 color = texture(Albedo, uv);
|
||||
vec2 tc = gl_FragCoord.xy / screen;
|
||||
|
@ -1,25 +0,0 @@
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform mat4 TransposeInverseModelView;
|
||||
uniform mat4 TextureMatrix;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 Position;
|
||||
in vec3 Normal;
|
||||
in vec2 Texcoord;
|
||||
in vec4 Color;
|
||||
out vec2 uv;
|
||||
out vec3 normal;
|
||||
#else
|
||||
attribute vec3 Position;
|
||||
attribute vec3 Normal;
|
||||
attribute vec2 Texcoord;
|
||||
attribute vec4 Color;
|
||||
varying vec2 uv;
|
||||
varying vec3 normal;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
normal = (TransposeInverseModelView * vec4(Normal, 0)).xyz;
|
||||
uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy;
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
|
||||
}
|
@ -1,7 +1,23 @@
|
||||
uniform samplerCube tex;
|
||||
uniform mat4 invproj;
|
||||
uniform vec2 screen;
|
||||
uniform mat4 TransposeViewMatrix;
|
||||
// See http://www.ozone3d.net/tutorials/glsl_texturing_p04.php for ref
|
||||
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
uniform sampler2D tex;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 nor;
|
||||
@ -11,17 +27,18 @@ varying vec3 nor;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
|
||||
vec3 getLightFactor(float specMapValue);
|
||||
|
||||
void main() {
|
||||
vec3 fpos = gl_FragCoord.xyz / vec3(screen, 1.);
|
||||
vec4 xpos = 2.0 * vec4(fpos, 1.0) - 1.0;
|
||||
xpos = invproj * xpos;
|
||||
vec3 texc = gl_FragCoord.xyz / vec3(screen, 1.);
|
||||
vec3 u = getPosFromUVDepth(texc, InverseProjectionMatrix).xyz;
|
||||
vec3 r = reflect(u, nor);
|
||||
|
||||
xpos.xyz /= xpos.w;
|
||||
vec3 viewSampleDir = reflect(xpos.xyz, nor);
|
||||
// Convert sampleDir in world space (where tex was generated)
|
||||
vec4 sampleDir = TransposeViewMatrix * vec4(viewSampleDir, 0.);
|
||||
vec4 detail0 = texture(tex, sampleDir.xyz);
|
||||
float m = 2.0 * sqrt(r.x * r.x + r.y * r.y + (r.z + 1.0) * (r.z + 1.0));
|
||||
r.y = - r.y;
|
||||
vec4 detail0 = texture(tex, r.xy / m + .5);
|
||||
vec3 LightFactor = getLightFactor(1.);
|
||||
|
||||
FragColor = vec4(detail0.xyz, 1.);
|
||||
FragColor = vec4(detail0.xyz * LightFactor, 1.);
|
||||
}
|
||||
|
@ -3,24 +3,20 @@ uniform sampler2D tex;
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 nor;
|
||||
in vec2 uv;
|
||||
out vec2 EncodedNormal;
|
||||
out vec3 EncodedNormal;
|
||||
#else
|
||||
varying vec3 nor;
|
||||
varying vec2 uv;
|
||||
#define EncodedNormal gl_FragColor.xy
|
||||
#endif
|
||||
|
||||
|
||||
// from Crytek "a bit more deferred CryEngine"
|
||||
vec2 EncodeNormal(vec3 n)
|
||||
{
|
||||
return normalize(n.xy) * sqrt(n.z * 0.5 + 0.5);
|
||||
}
|
||||
vec2 EncodeNormal(vec3 n);
|
||||
|
||||
void main() {
|
||||
vec4 col = texture(tex, uv);
|
||||
if (col.a < 0.5)
|
||||
discard;
|
||||
EncodedNormal = 0.5 * EncodeNormal(normalize(nor)) + 0.5;
|
||||
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(nor)) + 0.5;
|
||||
EncodedNormal.z = 1.;
|
||||
}
|
||||
|
||||
|
@ -1,30 +0,0 @@
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform mat4 TransposeInverseModelView;
|
||||
uniform mat4 TextureMatrix =
|
||||
mat4(1., 0., 0., 0.,
|
||||
0., 1., 0., 0.,
|
||||
0., 0., 1., 0.,
|
||||
0., 0., 0., 1.);
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 Position;
|
||||
in vec3 Normal;
|
||||
in vec2 Texcoord;
|
||||
out vec3 nor;
|
||||
out vec2 uv;
|
||||
#else
|
||||
attribute vec3 Position;
|
||||
attribute vec3 Normal;
|
||||
attribute vec2 Texcoord;
|
||||
varying vec3 nor;
|
||||
varying vec2 uv;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy;
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
|
||||
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
|
||||
}
|
@ -1,9 +1,4 @@
|
||||
uniform sampler2D Albedo;
|
||||
uniform sampler2D DiffuseMap;
|
||||
uniform sampler2D SpecularMap;
|
||||
uniform sampler2D SSAO;
|
||||
uniform vec2 screen;
|
||||
uniform vec3 ambient;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
@ -13,15 +8,12 @@ varying vec2 uv;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
vec3 getLightFactor(float specMapValue);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 color = texture(Albedo, uv);
|
||||
if (color.a < 0.5) discard;
|
||||
vec2 tc = gl_FragCoord.xy / screen;
|
||||
vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz;
|
||||
vec3 SpecularComponent = texture(SpecularMap, tc).xyz;
|
||||
float ao = texture(SSAO, tc).x;
|
||||
vec3 LightFactor = ao * ambient + DiffuseComponent + SpecularComponent;
|
||||
vec3 LightFactor = getLightFactor(1.);
|
||||
FragColor = vec4(color.xyz * LightFactor, 1.);
|
||||
}
|
||||
|
@ -1,11 +1,21 @@
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D dtex;
|
||||
uniform mat4 invproj;
|
||||
uniform vec2 screen;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
in float lf;
|
||||
in vec2 tc;
|
||||
out vec4 color;
|
||||
in vec3 pc;
|
||||
out vec4 FragColor;
|
||||
|
||||
|
||||
void main(void)
|
||||
@ -18,6 +28,6 @@ void main(void)
|
||||
vec4 EnvPos = invproj * (2. * vec4(xy, EnvZ, 1.0) - 1.);
|
||||
EnvPos /= EnvPos.w;
|
||||
float alpha = clamp((EnvPos.z - FragmentPos.z) * 0.3, 0., 1.);
|
||||
color = texture(tex, tc);
|
||||
color.a *= alpha * smoothstep(1., 0.8, lf);
|
||||
vec4 color = texture(tex, tc) * vec4(pc, 1.0);
|
||||
FragColor = color * alpha * smoothstep(1., 0.8, lf);
|
||||
}
|
||||
|
@ -1,5 +1,14 @@
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 ViewMatrix;
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
uniform vec3 color_from;
|
||||
uniform vec3 color_to;
|
||||
|
||||
in vec2 quadcorner;
|
||||
in vec2 texcoord;
|
||||
@ -9,11 +18,13 @@ in float size;
|
||||
|
||||
out float lf;
|
||||
out vec2 tc;
|
||||
out vec3 pc;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
tc = texcoord;
|
||||
lf = lifetime;
|
||||
pc = color_from + (color_to - color_from) * lifetime;
|
||||
vec3 newposition = position;
|
||||
|
||||
vec4 viewpos = ViewMatrix * vec4(newposition, 1.0);
|
||||
|
@ -1,4 +1,4 @@
|
||||
#version 330
|
||||
#version 140
|
||||
uniform sampler2D tex;
|
||||
|
||||
in vec2 uv;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Passthrough shader for drawQuad()
|
||||
#version 330
|
||||
#version 140
|
||||
|
||||
in vec3 Position;
|
||||
in vec2 Texcoord;
|
||||
|
@ -1,60 +0,0 @@
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 pixel;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
// Separated penumbra, horizontal
|
||||
|
||||
void main()
|
||||
{
|
||||
float sum = 0.0;
|
||||
vec4 tmp;
|
||||
float X = uv.x;
|
||||
float Y = uv.y;
|
||||
float width = 0.0;
|
||||
float zsum = 0.00001;
|
||||
|
||||
tmp = texture(tex, vec2(X - 5.13333 * pixel.x, Y));
|
||||
sum += tmp.x * 0.00640869;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
tmp = texture(tex, vec2(X - 3.26667 * pixel.x, Y));
|
||||
sum += tmp.x * 0.083313;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
tmp = texture(tex, vec2(X - 1.4 * pixel.x, Y));
|
||||
sum += tmp.x * 0.305481;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
tmp = texture(tex, vec2(X, Y));
|
||||
sum += tmp.x * 0.209473;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
tmp = texture(tex, vec2(X + 1.4 * pixel.x, Y));
|
||||
sum += tmp.x * 0.305481;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
tmp = texture(tex, vec2(X + 3.26667 * pixel.x, Y));
|
||||
sum += tmp.x * 0.083313;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
tmp = texture(tex, vec2(X + 5.13333 * pixel.x, Y));
|
||||
sum += tmp.x * 0.00640869;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
float hasz = step(0.7, zsum);
|
||||
FragColor = vec4(sum, (width / zsum) * hasz, hasz, 1.0);
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 pixel;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
|
||||
// Separated penumbra, vertical
|
||||
|
||||
void main()
|
||||
{
|
||||
float sum = 0.0;
|
||||
vec4 tmp;
|
||||
float X = uv.x;
|
||||
float Y = uv.y;
|
||||
float width = 0.0;
|
||||
float zsum = 0.00001;
|
||||
|
||||
tmp = texture(tex, vec2(X, Y - 5.13333 * pixel.y));
|
||||
sum += tmp.x * 0.00640869;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
tmp = texture(tex, vec2(X, Y - 3.26667 * pixel.y));
|
||||
sum += tmp.x * 0.083313;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
tmp = texture(tex, vec2(X, Y - 1.4 * pixel.y));
|
||||
sum += tmp.x * 0.305481;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
tmp = texture(tex, vec2(X, Y));
|
||||
sum += tmp.x * 0.209473;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
tmp = texture(tex, vec2(X, Y + 1.4 * pixel.y));
|
||||
sum += tmp.x * 0.305481;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
tmp = texture(tex, vec2(X, Y + 3.26667 * pixel.y));
|
||||
sum += tmp.x * 0.083313;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
tmp = texture(tex, vec2(X, Y + 5.13333 * pixel.y));
|
||||
sum += tmp.x * 0.00640869;
|
||||
zsum += tmp.z;
|
||||
width += tmp.y;
|
||||
|
||||
float hasz = step(0.7, zsum);
|
||||
FragColor = vec4(sum, (width / zsum) * hasz, hasz, 1.0);
|
||||
}
|
@ -1,54 +1,60 @@
|
||||
uniform sampler2D ntex;
|
||||
uniform sampler2D dtex;
|
||||
uniform float spec;
|
||||
uniform mat4 invproj;
|
||||
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform vec2 screen;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
flat in vec3 center;
|
||||
flat in float energy;
|
||||
flat in vec3 col;
|
||||
flat in float radius;
|
||||
|
||||
out vec4 Diffuse;
|
||||
out vec4 Specular;
|
||||
|
||||
vec3 DecodeNormal(vec2 n)
|
||||
{
|
||||
float z = dot(n, n) * 2. - 1.;
|
||||
vec2 xy = normalize(n) * sqrt(1. - z * z);
|
||||
return vec3(xy,z);
|
||||
}
|
||||
vec3 DecodeNormal(vec2 n);
|
||||
vec3 getSpecular(vec3 normal, vec3 eyedir, vec3 lightdir, vec3 color, float roughness);
|
||||
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
|
||||
|
||||
void main() {
|
||||
void main()
|
||||
{
|
||||
vec2 texc = gl_FragCoord.xy / screen;
|
||||
float z = texture(dtex, texc).x;
|
||||
vec3 norm = normalize(DecodeNormal(2. * texture(ntex, texc).xy - 1.));
|
||||
float roughness = texture(ntex, texc).z;
|
||||
|
||||
vec4 xpos = 2.0 * vec4(texc, z, 1.0) - 1.0f;
|
||||
xpos = invproj * xpos;
|
||||
xpos /= xpos.w;
|
||||
vec3 eyedir = normalize(xpos.xyz);
|
||||
|
||||
vec3 diffuse = vec3(0.), specular = vec3(0.);
|
||||
vec4 xpos = getPosFromUVDepth(vec3(texc, z), InverseProjectionMatrix);
|
||||
vec3 eyedir = -normalize(xpos.xyz);
|
||||
|
||||
vec4 pseudocenter = ViewMatrix * vec4(center.xyz, 1.0);
|
||||
pseudocenter /= pseudocenter.w;
|
||||
vec3 light_pos = pseudocenter.xyz;
|
||||
vec3 light_col = col.xyz;
|
||||
float d = distance(light_pos, xpos.xyz);
|
||||
float att = energy * 200. / (4. * 3.14 * d * d);
|
||||
float spec_att = (energy + 10.) * 200. / (4. * 3.14 * d * d);
|
||||
float att = energy * 20. / (1. + d * d);
|
||||
att *= (radius - d) / radius;
|
||||
if (att <= 0.) discard;
|
||||
|
||||
// Light Direction
|
||||
vec3 L = normalize(xpos.xyz - light_pos);
|
||||
vec3 L = -normalize(xpos.xyz - light_pos);
|
||||
|
||||
float NdotL = max(0.0, dot(norm, -L));
|
||||
diffuse += NdotL * light_col * att;
|
||||
// Reflected light dir
|
||||
vec3 R = reflect(-L, norm);
|
||||
float RdotE = max(0.0, dot(R, eyedir));
|
||||
specular += pow(RdotE, spec) * light_col * spec_att;
|
||||
float NdotL = max(0., dot(norm, L));
|
||||
|
||||
Diffuse = vec4(diffuse, 1.);
|
||||
Specular = vec4(specular , 1.);
|
||||
Diffuse = vec4(NdotL * light_col * att, 1.);
|
||||
Specular = vec4(getSpecular(norm, eyedir, L, light_col, roughness) * NdotL * att, 1.);
|
||||
}
|
||||
|
@ -1,38 +1,125 @@
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
in vec3 Position;
|
||||
in float Energy;
|
||||
in vec3 Color;
|
||||
|
||||
in vec2 Corner;
|
||||
in float Radius;
|
||||
|
||||
flat out vec3 center;
|
||||
flat out float energy;
|
||||
flat out vec3 col;
|
||||
flat out float radius;
|
||||
|
||||
const float zNear = 1.;
|
||||
|
||||
// Code borrowed from https://software.intel.com/en-us/articles/deferred-rendering-for-current-and-future-rendering-pipelines
|
||||
// Maths explanations are found here http://www.gamasutra.com/view/feature/131351/the_mechanics_of_robust_stencil_.php?page=6
|
||||
|
||||
vec2 UpdateClipRegionRoot(float nc, /* Tangent plane x/y normal coordinate (view space) */
|
||||
float lc, /* Light x/y coordinate (view space) */
|
||||
float lz, /* Light z coordinate (view space) */
|
||||
float lightRadius,
|
||||
float cameraScale /* Project scale for coordinate (_11 or _22 for x/y respectively) */)
|
||||
{
|
||||
float nz = (lightRadius - nc * lc) / lz;
|
||||
float pz = (lc * lc + lz * lz - lightRadius * lightRadius) /
|
||||
(lz - (nz / nc) * lc);
|
||||
|
||||
if (pz > 0.) {
|
||||
float c = -nz * cameraScale / nc;
|
||||
if (nc > 0.) // Left side boundary
|
||||
return vec2(c, 1.);
|
||||
else // Right side boundary
|
||||
return vec2(-1., c);
|
||||
}
|
||||
return vec2(-1., 1.);
|
||||
}
|
||||
|
||||
vec2 UpdateClipRegion(float lc, /* Light x/y coordinate (view space) */
|
||||
float lz, /* Light z coordinate (view space) */
|
||||
float lightRadius,
|
||||
float cameraScale /* Project scale for coordinate (_11 or _22 for x/y respectively) */)
|
||||
{
|
||||
float rSq = lightRadius * lightRadius;
|
||||
float lcSqPluslzSq = lc * lc + lz * lz;
|
||||
float d = rSq * lc * lc - lcSqPluslzSq * (rSq - lz * lz);
|
||||
|
||||
// The camera is inside lignt bounding sphere, quad fits whole screen
|
||||
if (d <= 0.)
|
||||
return vec2(-1., 1.);
|
||||
|
||||
float a = lightRadius * lc;
|
||||
float b = sqrt(d);
|
||||
float nx0 = (a + b) / lcSqPluslzSq;
|
||||
float nx1 = (a - b) / lcSqPluslzSq;
|
||||
|
||||
vec2 clip0 = UpdateClipRegionRoot(nx0, lc, lz, lightRadius, cameraScale);
|
||||
vec2 clip1 = UpdateClipRegionRoot(nx1, lc, lz, lightRadius, cameraScale);
|
||||
return vec2(max(clip0.x, clip1.x), min(clip0.y, clip1.y));
|
||||
}
|
||||
|
||||
// Returns bounding box [min.x, max.x, min.y, max.y] in clip [-1, 1] space.
|
||||
vec4 ComputeClipRegion(vec3 lightPosView, float lightRadius)
|
||||
{
|
||||
if (lightPosView.z + lightRadius >= zNear) {
|
||||
vec2 clipX = UpdateClipRegion(lightPosView.x, lightPosView.z, lightRadius, ProjectionMatrix[0][0]);
|
||||
vec2 clipY = UpdateClipRegion(lightPosView.y, lightPosView.z, lightRadius, ProjectionMatrix[1][1]);
|
||||
|
||||
return vec4(clipX, clipY);
|
||||
}
|
||||
|
||||
return vec4(0.);
|
||||
}
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
// Beyond that value, light is too attenuated
|
||||
float r = 40 * Energy;
|
||||
vec4 Center = ViewMatrix * vec4(Position, 1.);
|
||||
Center /= Center.w;
|
||||
|
||||
vec2 ProjectedCornerPosition;
|
||||
vec4 clip = ComputeClipRegion(Center.xyz, Radius);
|
||||
switch (gl_VertexID)
|
||||
{
|
||||
case 0:
|
||||
ProjectedCornerPosition = clip.xz;
|
||||
break;
|
||||
case 1:
|
||||
ProjectedCornerPosition = clip.xw;
|
||||
break;
|
||||
case 2:
|
||||
ProjectedCornerPosition = clip.yz;
|
||||
break;
|
||||
case 3:
|
||||
ProjectedCornerPosition = clip.yw;
|
||||
break;
|
||||
}
|
||||
|
||||
// Work out nearest depth for quad Z
|
||||
// Clamp to near plane in case this light intersects the near plane... don't want our quad to be clipped
|
||||
float quadDepth = max(zNear, Center.z - Radius);
|
||||
|
||||
// Project quad depth into clip space
|
||||
vec4 quadClip = ProjectionMatrix * vec4(0., 0., quadDepth, 1.0f);
|
||||
gl_Position = vec4(ProjectedCornerPosition, quadClip.z / quadClip.w, 1.);
|
||||
|
||||
col = Color;
|
||||
center = Position;
|
||||
energy = Energy;
|
||||
vec4 Center = ViewMatrix * vec4(Position, 1.);
|
||||
if (Center.z > zNear) // Light is in front of the cam
|
||||
{
|
||||
vec3 UnitCenter = normalize(-Center.xyz);
|
||||
float clampedR = min(r, Center.z - 1.);
|
||||
float cosTheta = dot(UnitCenter, vec3(0., 0., -1));
|
||||
float d = clampedR / cosTheta;
|
||||
Center.xyz += d * UnitCenter;
|
||||
}
|
||||
else if (Center.z + r > zNear) // Light is behind the cam but in range
|
||||
{
|
||||
Center.z = zNear;
|
||||
// TODO: Change r so that we make the screen aligned quad fits light range.
|
||||
}
|
||||
col = Color;
|
||||
gl_Position = ProjectionMatrix * (Center + r * vec4(Corner, 0., 0.));
|
||||
radius = Radius;
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D normals_and_depth;
|
||||
uniform mat4 invproj;
|
||||
uniform vec2 screen;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 xy = gl_FragCoord.xy / screen;
|
||||
float FragZ = gl_FragCoord.z;
|
||||
float EnvZ = texture(normals_and_depth, xy).a;
|
||||
vec4 FragmentPos = invproj * (2. * vec4(xy, FragZ, 1.0) - 1.);
|
||||
FragmentPos /= FragmentPos.w;
|
||||
vec4 EnvPos = invproj * (2. * vec4(xy, EnvZ, 1.0) - 1.);
|
||||
EnvPos /= EnvPos.w;
|
||||
float len = dot(vec3(1.0), abs(texture(normals_and_depth, xy).xyz));
|
||||
float alpha = (len < 0.2) ? 1. : clamp((EnvPos.z - FragmentPos.z) * 0.3, 0., 1.);
|
||||
FragColor = texture(tex, gl_PointCoord.xy);
|
||||
FragColor.a *= alpha;
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
uniform float screenw;
|
||||
|
||||
void main()
|
||||
{
|
||||
const float size = 0.5;
|
||||
|
||||
vec4 eyepos = gl_Vertex;
|
||||
vec4 projCorner = gl_ProjectionMatrix * vec4(vec2(size), eyepos.z, eyepos.w);
|
||||
|
||||
gl_PointSize = screenw * projCorner.x / projCorner.w;
|
||||
gl_Position = gl_ProjectionMatrix * eyepos;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
uniform float time;
|
||||
uniform vec3 campos;
|
||||
uniform mat4 viewm;
|
||||
|
||||
in vec3 initialPosition;
|
||||
out vec3 currentPosition;
|
||||
|
||||
void main()
|
||||
{
|
||||
// This simulation will run accurately for a bit under five days.
|
||||
vec4 start = vec4(initialPosition, 1.0);
|
||||
start.y -= time;
|
||||
|
||||
// How many times has it fell?
|
||||
float count = floor(start.y / 24.0);
|
||||
start.x += sin(count);
|
||||
start.z += cos(count);
|
||||
|
||||
vec2 signs = sign(start.xz);
|
||||
start.xz = mod(start.xz, 17.5) * signs;
|
||||
|
||||
start.y = mod(start.y, 24.0) - 3.0;
|
||||
|
||||
start.xyz += campos;
|
||||
|
||||
currentPosition = (viewm * start).xyz;
|
||||
gl_Position = vec4(0.);
|
||||
}
|
@ -1,23 +1,19 @@
|
||||
uniform mat4 ModelViewProjectionMatrix[4];
|
||||
|
||||
layout(triangles) in;
|
||||
layout(triangle_strip, max_vertices=12) out;
|
||||
layout(triangle_strip, max_vertices=3) out;
|
||||
|
||||
in vec2 tc[3];
|
||||
in int layerId[3];
|
||||
|
||||
out vec2 uv;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
for (int j = 0; j<4; j++)
|
||||
{
|
||||
gl_Layer = j;
|
||||
gl_Layer = layerId[0];
|
||||
for(int i=0; i<3; i++)
|
||||
{
|
||||
uv = tc[i];
|
||||
gl_Position = ModelViewProjectionMatrix[j] * gl_in[i].gl_Position;
|
||||
gl_Position = gl_in[i].gl_Position;
|
||||
EmitVertex();
|
||||
}
|
||||
EndPrimitive();
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,33 @@
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
};
|
||||
|
||||
uniform mat4 ModelMatrix;
|
||||
|
||||
in vec3 Position;
|
||||
in vec2 Texcoord;
|
||||
|
||||
|
||||
#ifdef VSLayer
|
||||
out vec2 uv;
|
||||
#else
|
||||
out vec2 tc;
|
||||
|
||||
out int layerId;
|
||||
#endif
|
||||
|
||||
void main(void)
|
||||
{
|
||||
#ifdef VSLayer
|
||||
gl_Layer = gl_InstanceID & 3;
|
||||
uv = Texcoord;
|
||||
gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * vec4(Position, 1.);
|
||||
#else
|
||||
layerId = gl_InstanceID & 3;
|
||||
tc = Texcoord;
|
||||
gl_Position = vec4(Position, 1.);
|
||||
gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * vec4(Position, 1.);
|
||||
#endif
|
||||
}
|
||||
|
@ -1,47 +0,0 @@
|
||||
uniform sampler2D halft; // half is a reserved word
|
||||
uniform sampler2D quarter;
|
||||
uniform sampler2D eighth;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 val[3];
|
||||
val[0] = texture(halft, uv).xyz;
|
||||
val[1] = texture(quarter, uv).xyz;
|
||||
val[2] = texture(eighth, uv).xyz;
|
||||
|
||||
// Find the first level with a penumbra value
|
||||
int i;
|
||||
float q = 0.0;
|
||||
float outval = 1.0;
|
||||
|
||||
float hasshadow = dot(vec3(1.0), vec3(val[0].z, val[1].z, val[2].z));
|
||||
|
||||
if (hasshadow > 0.9)
|
||||
{
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
if (val[i].z > 0.9)
|
||||
{
|
||||
q = val[i].y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
q *= 8.0;
|
||||
q = max(1.0, q);
|
||||
q = log2(q);
|
||||
q = min(1.9, q);
|
||||
|
||||
// q is now between 0 and 1.9.
|
||||
int down = int(floor(q));
|
||||
int up = down + 1;
|
||||
float interp = q - float(down);
|
||||
|
||||
outval = 1.0 - mix(val[down].x, val[up].x, interp);
|
||||
}
|
||||
|
||||
FragColor = vec4(vec3(outval), 1.0);
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
uniform sampler2D ntex;
|
||||
uniform sampler2D ctex;
|
||||
uniform vec3 campos;
|
||||
uniform int low;
|
||||
|
||||
in vec3 wpos;
|
||||
in vec2 texc;
|
||||
out vec4 FragColor;
|
||||
|
||||
float luminanceImp()
|
||||
{
|
||||
// A full-res fetch kills on low-end
|
||||
if (low > 0) return 1.0;
|
||||
|
||||
const vec3 weights = vec3(0.2126, 0.7152, 0.0722); // ITU-R BT. 709
|
||||
vec3 col = texture(ctex, texc).xyz;
|
||||
|
||||
float luma = dot(weights, col);
|
||||
|
||||
// Dark surfaces need less resolution
|
||||
float f = smoothstep(0.1, 0.4, luma);
|
||||
f = max(0.05, f);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
float normalImp(vec3 normal)
|
||||
{
|
||||
vec3 camdir = normalize(campos - wpos);
|
||||
vec3 N = normalize(normal);
|
||||
|
||||
// Boost surfaces facing the viewer directly
|
||||
float f = 2.0 * max(0.0, dot(N, camdir));
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
float depthImp(float linearz)
|
||||
{
|
||||
/* const float skip = 0.7;
|
||||
|
||||
float f = min(linearz, skip);
|
||||
f *= 1.0/skip;*/
|
||||
|
||||
float z = log(1.0 + linearz * 9.0) / log(10.0);
|
||||
|
||||
float f = 1.0 - (z * 0.9);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 ntmp = texture(ntex, texc);
|
||||
vec3 normal = ntmp.xyz * 2.0 - 1.0;
|
||||
float linearz = ntmp.a;
|
||||
|
||||
float importance = normalImp(normal) * depthImp(linearz) * luminanceImp();
|
||||
importance = clamp(importance, 0.0, 1.0);
|
||||
|
||||
float low = step(0.001, importance);
|
||||
|
||||
// Quantize it
|
||||
const float steps = 16.0;
|
||||
importance *= steps;
|
||||
importance = ceil(importance) * low;
|
||||
importance /= steps;
|
||||
|
||||
FragColor = vec4(importance);
|
||||
gl_FragDepth = 1.0 - importance;
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
uniform sampler2D dtex;
|
||||
uniform mat4 ipvmat;
|
||||
uniform mat4 shadowmat;
|
||||
|
||||
out vec3 wpos;
|
||||
out vec2 texc;
|
||||
|
||||
float decdepth(vec4 rgba) {
|
||||
return dot(rgba, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0));
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
texc = gl_Vertex.xy / vec2(32767.0);
|
||||
float z = decdepth(vec4(texture(dtex, texc).xyz, 0.0));
|
||||
|
||||
vec3 tmp = vec3(texc, z);
|
||||
tmp = tmp * 2.0 - 1.0;
|
||||
|
||||
vec4 xpos = vec4(tmp, 1.0);
|
||||
xpos = ipvmat * xpos;
|
||||
xpos.xyz /= xpos.w;
|
||||
|
||||
wpos = xpos.xyz;
|
||||
|
||||
// Now we have this pixel's world-space position. Convert to shadow space.
|
||||
vec4 pos = shadowmat * vec4(xpos.xyz, 1.0);
|
||||
|
||||
gl_Position = pos;
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
uniform sampler2D tex;
|
||||
uniform int hastex;
|
||||
uniform int viz;
|
||||
uniform int wireframe;
|
||||
uniform float objectid;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
vec4 encdepth(float v) {
|
||||
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
|
||||
enc = fract(enc);
|
||||
enc -= enc.yzww * vec4(1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0);
|
||||
return enc;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
if (hastex != 0) {
|
||||
float alpha = texture(tex, uv).a;
|
||||
|
||||
if (alpha < 0.5)
|
||||
discard;
|
||||
}
|
||||
|
||||
if (viz < 1)
|
||||
{
|
||||
FragColor = vec4(encdepth(gl_FragCoord.z).xyz, objectid);
|
||||
}
|
||||
else {
|
||||
if (wireframe > 0)
|
||||
FragColor = vec4(1.0);
|
||||
else
|
||||
FragColor = texture(tex, uv);
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +0,0 @@
|
||||
uniform sampler2D warpx;
|
||||
uniform sampler2D warpy;
|
||||
|
||||
out vec2 uv;
|
||||
|
||||
float decdepth(vec4 rgba) {
|
||||
return dot(rgba, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0));
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||
uv = gl_MultiTexCoord0.xy;
|
||||
|
||||
vec2 tc = pos.xy * vec2(0.5) + vec2(0.5);
|
||||
|
||||
float movex = decdepth(texture(warpx, tc));
|
||||
float movey = decdepth(texture(warpy, tc));
|
||||
|
||||
float dx = movex * 2.0 - 1.0;
|
||||
float dy = movey * 2.0 - 1.0;
|
||||
|
||||
dx *= 2.0;
|
||||
dy *= 2.0;
|
||||
|
||||
gl_Position = pos + vec4(dx, dy, vec2(0.0));
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
uniform sampler2D tex;
|
||||
uniform int size;
|
||||
uniform vec2 pixel;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
vec4 encdepth(float v) {
|
||||
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
|
||||
enc = fract(enc);
|
||||
enc -= enc.yzww * vec4(1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0);
|
||||
return enc;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 origtc = gl_TexCoord[0].xy;
|
||||
|
||||
// Get total sum
|
||||
float first = 1.0, last = 0.0;
|
||||
float lower = 0.0;
|
||||
float total = 0.0;
|
||||
vec2 tc = 0.5 * pixel;
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
float col = texture(tex, tc).x;
|
||||
|
||||
lower += col * step(tc.x, origtc.x);
|
||||
total += col;
|
||||
|
||||
if (col > 0.0001)
|
||||
{
|
||||
first = min(first, tc.x);
|
||||
last = max(last, tc.x);
|
||||
}
|
||||
|
||||
tc += pixel;
|
||||
}
|
||||
|
||||
float res = (lower / total) - origtc.x;
|
||||
|
||||
// Outside the edges?
|
||||
if (origtc.x <= first)
|
||||
{
|
||||
res = origtc.x * -2.1;
|
||||
}
|
||||
else if (origtc.x >= last)
|
||||
{
|
||||
res = (1.0 - origtc.x) * 2.1;
|
||||
}
|
||||
|
||||
res = res * 0.5 + 0.5;
|
||||
res = clamp(res, 0.01, 0.99);
|
||||
|
||||
FragColor = encdepth(res);
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
uniform sampler2D tex;
|
||||
uniform int size;
|
||||
uniform vec2 pixel;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
vec4 encdepth(float v) {
|
||||
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
|
||||
enc = fract(enc);
|
||||
enc -= enc.yzww * vec4(1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0);
|
||||
return enc;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 origtc = gl_TexCoord[0].xy;
|
||||
|
||||
// Get total sum
|
||||
float first = 1.0, last = 0.0;
|
||||
float lower = 0.0;
|
||||
float total = 0.0;
|
||||
vec2 tc = pixel * 0.5;
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
float col = texture(tex, tc).x;
|
||||
|
||||
lower += col * step(tc.y, origtc.y);
|
||||
total += col;
|
||||
|
||||
if (col > 0.0001)
|
||||
{
|
||||
first = min(first, tc.y);
|
||||
last = max(last, tc.y);
|
||||
}
|
||||
|
||||
tc += pixel;
|
||||
}
|
||||
|
||||
float res = (lower / total) - origtc.y;
|
||||
|
||||
// Outside the edges?
|
||||
if (origtc.y <= first)
|
||||
{
|
||||
res = origtc.y * -2.1;
|
||||
}
|
||||
else if (origtc.y >= last)
|
||||
{
|
||||
res = (1.0 - origtc.y) * 2.1;
|
||||
}
|
||||
|
||||
res = res * 0.5 + 0.5;
|
||||
res = clamp(res, 0.01, 0.99);
|
||||
|
||||
FragColor = encdepth(res);
|
||||
}
|
@ -1,7 +1,21 @@
|
||||
uniform samplerCube tex;
|
||||
uniform mat4 InvProjView;
|
||||
uniform vec2 screen;
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
uniform samplerCube tex;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
out vec4 FragColor;
|
||||
@ -14,7 +28,7 @@ void main(void)
|
||||
{
|
||||
vec3 eyedir = gl_FragCoord.xyz / vec3(screen, 1.);
|
||||
eyedir = 2.0 * eyedir - 1.0;
|
||||
vec4 tmp = (InvProjView * vec4(eyedir, 1.));
|
||||
vec4 tmp = (InverseViewMatrix * InverseProjectionMatrix * vec4(eyedir, 1.));
|
||||
eyedir = tmp.xyz / tmp.w;
|
||||
vec4 color = texture(tex, eyedir);
|
||||
FragColor = vec4(color.xyz, 1.);
|
||||
|
@ -6,9 +6,18 @@ uniform sampler2D tex_detail3;
|
||||
uniform sampler2D DiffuseMap;
|
||||
uniform sampler2D SpecularMap;
|
||||
uniform sampler2D SSAO;
|
||||
uniform vec2 screen;
|
||||
uniform vec3 ambient;
|
||||
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
in vec2 uv_bis;
|
||||
|
@ -1,41 +0,0 @@
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2013 the SuperTuxKart team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform mat4 TransposeInverseModelView;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 Position;
|
||||
in vec2 Texcoord;
|
||||
in vec2 SecondTexcoord;
|
||||
out vec2 uv;
|
||||
out vec2 uv_bis;
|
||||
#else
|
||||
attribute vec3 Position;
|
||||
attribute vec2 Texcoord;
|
||||
attribute vec2 SecondTexcoord;
|
||||
varying vec2 uv;
|
||||
varying vec2 uv_bis;
|
||||
#endif
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
uv = Texcoord;
|
||||
uv_bis = SecondTexcoord;
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
|
||||
}
|
@ -1,73 +1,80 @@
|
||||
uniform sampler2D ntex;
|
||||
// From paper http://graphics.cs.williams.edu/papers/AlchemyHPG11/
|
||||
// and improvements here http://graphics.cs.williams.edu/papers/SAOHPG12/
|
||||
|
||||
uniform sampler2D dtex;
|
||||
uniform sampler2D noise_texture;
|
||||
uniform mat4 invprojm;
|
||||
uniform mat4 projm;
|
||||
uniform vec4 samplePoints[16];
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
out float AO;
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
#define AO gl_FragColor.x
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
vec2 screen;
|
||||
};
|
||||
#endif
|
||||
|
||||
const float strengh = 4.;
|
||||
const float radius = .4f;
|
||||
in vec2 uv;
|
||||
out float AO;
|
||||
|
||||
const float sigma = 1.;
|
||||
const float tau = 7.;
|
||||
const float beta = 0.001;
|
||||
const float epsilon = .00001;
|
||||
const float radius = 1.;
|
||||
const float k = 1.5;
|
||||
|
||||
#define SAMPLES 16
|
||||
|
||||
const float invSamples = strengh / SAMPLES;
|
||||
const float invSamples = 1. / SAMPLES;
|
||||
|
||||
vec3 rand(vec2 co)
|
||||
vec3 getXcYcZc(int x, int y, float zC)
|
||||
{
|
||||
return texture(noise_texture, co*20.16).xyz;
|
||||
}
|
||||
|
||||
vec3 DecodeNormal(vec2 n)
|
||||
{
|
||||
float z = dot(n, n) * 2. - 1.;
|
||||
vec2 xy = normalize(n) * sqrt(1. - z * z);
|
||||
return vec3(xy,z);
|
||||
// We use perspective symetric projection matrix hence P(0,2) = P(1, 2) = 0
|
||||
float xC= (1. - 2 * (float(x) + 0.5) / screen.x) * zC / ProjectionMatrix[0][0];
|
||||
float yC= (1. + 2 * (float(y) + 0.5) / screen.y) * zC / ProjectionMatrix[1][1];
|
||||
return vec3(xC, yC, zC);
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 cur = texture(ntex, uv);
|
||||
float curdepth = texture(dtex, uv).x;
|
||||
vec4 FragPos = invprojm * (2.0f * vec4(uv, curdepth, 1.0f) - 1.0f);
|
||||
FragPos /= FragPos.w;
|
||||
float lineardepth = textureLod(dtex, uv, 0.).x;
|
||||
int x = int(gl_FragCoord.x), y = int(gl_FragCoord.y);
|
||||
vec3 FragPos = getXcYcZc(x, y, lineardepth);
|
||||
|
||||
// get the normal of current fragment
|
||||
vec3 norm = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
|
||||
// Workaround for nvidia and skyboxes
|
||||
float len = dot(vec3(1.0), abs(cur.xyz));
|
||||
if (len < 0.2 || curdepth > 0.9955) discard;
|
||||
// Make a tangent as random as possible
|
||||
vec3 randvect = rand(uv);
|
||||
vec3 tangent = normalize(cross(norm, randvect));
|
||||
vec3 bitangent = cross(norm, tangent);
|
||||
vec3 ddx = dFdx(FragPos);
|
||||
vec3 ddy = dFdy(FragPos);
|
||||
vec3 norm = -normalize(cross(ddy, ddx));
|
||||
|
||||
float r = radius / FragPos.z;
|
||||
float phi = 30. * (x ^ y) + 10. * x * y;
|
||||
float bl = 0.0;
|
||||
|
||||
for(int i = 0; i < SAMPLES; ++i) {
|
||||
vec3 sampleDir = samplePoints[i].x * tangent + samplePoints[i].y * bitangent + samplePoints[i].z * norm;
|
||||
sampleDir *= samplePoints[i].w;
|
||||
vec4 samplePos = FragPos + radius * vec4(sampleDir, 0.0);
|
||||
vec4 sampleProj = projm * samplePos;
|
||||
sampleProj /= sampleProj.w;
|
||||
float alpha = (i + .5) * invSamples;
|
||||
float theta = 2. * 3.14 * tau * alpha + phi;
|
||||
float h = r * alpha;
|
||||
vec2 offset = h * vec2(cos(theta), sin(theta)) * screen;
|
||||
|
||||
bool isInsideTexture = (sampleProj.x > -1.) && (sampleProj.x < 1.) && (sampleProj.y > -1.) && (sampleProj.y < 1.);
|
||||
// get the depth of the occluder fragment
|
||||
float occluderFragmentDepth = texture(dtex, (sampleProj.xy * 0.5) + 0.5).x;
|
||||
// Position of the occluder fragment in worldSpace
|
||||
vec4 occluderPos = invprojm * vec4(sampleProj.xy, 2.0 * occluderFragmentDepth - 1.0, 1.0f);
|
||||
occluderPos /= occluderPos.w;
|
||||
float m = round(log2(h) + 6);
|
||||
ivec2 ioccluder_uv = ivec2(x, y) + ivec2(offset);
|
||||
|
||||
bool isOccluded = isInsideTexture && (sampleProj.z > (2. * occluderFragmentDepth - 1.0)) && (distance(FragPos, occluderPos) < radius);
|
||||
bl += isOccluded ? smoothstep(radius, 0, distance(samplePos, FragPos)) : 0.;
|
||||
if (ioccluder_uv.x < 0 || ioccluder_uv.x > screen.x || ioccluder_uv.y < 0 || ioccluder_uv.y > screen.y) continue;
|
||||
|
||||
float LinearoccluderFragmentDepth = textureLod(dtex, vec2(ioccluder_uv) / screen, m).x;
|
||||
vec3 OccluderPos = getXcYcZc(ioccluder_uv.x, ioccluder_uv.y, LinearoccluderFragmentDepth);
|
||||
|
||||
vec3 vi = OccluderPos - FragPos;
|
||||
bl += max(0, dot(vi, norm) - FragPos.z * beta) / (dot(vi, vi) + epsilon);
|
||||
}
|
||||
|
||||
AO = 1.0 - bl * invSamples;
|
||||
AO = max(pow(1.0 - 2. * sigma * bl * invSamples, k), 0.);
|
||||
}
|
@ -8,6 +8,22 @@ uniform mat4 invproj;
|
||||
//uniform int hasclouds;
|
||||
//uniform vec2 wind;
|
||||
|
||||
#ifdef UBO_DISABLED
|
||||
uniform mat4 ViewMatrix;
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 InverseViewMatrix;
|
||||
uniform mat4 InverseProjectionMatrix;
|
||||
#else
|
||||
layout (std140) uniform MatrixesData
|
||||
{
|
||||
mat4 ViewMatrix;
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 InverseViewMatrix;
|
||||
mat4 InverseProjectionMatrix;
|
||||
mat4 ShadowViewProjMatrixes[4];
|
||||
};
|
||||
#endif
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
out vec4 Diff;
|
||||
@ -19,18 +35,13 @@ varying vec2 uv;
|
||||
#endif
|
||||
|
||||
|
||||
vec3 DecodeNormal(vec2 n)
|
||||
{
|
||||
float z = dot(n, n) * 2. - 1.;
|
||||
vec2 xy = normalize(n) * sqrt(1. - z * z);
|
||||
return vec3(xy,z);
|
||||
}
|
||||
vec3 DecodeNormal(vec2 n);
|
||||
vec3 getSpecular(vec3 normal, vec3 eyedir, vec3 lightdir, vec3 color, float roughness);
|
||||
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
|
||||
|
||||
void main() {
|
||||
float z = texture(dtex, uv).x;
|
||||
vec4 xpos = 2.0 * vec4(uv, z, 1.0) - 1.0;
|
||||
xpos = invproj * xpos;
|
||||
xpos.xyz /= xpos.w;
|
||||
vec4 xpos = getPosFromUVDepth(vec3(uv, z), InverseProjectionMatrix);
|
||||
|
||||
if (z < 0.03)
|
||||
{
|
||||
@ -41,14 +52,15 @@ void main() {
|
||||
}
|
||||
|
||||
vec3 norm = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
|
||||
float roughness = texture(ntex, uv).z;
|
||||
vec3 eyedir = -normalize(xpos.xyz);
|
||||
|
||||
// Normalized on the cpu
|
||||
vec3 L = direction;
|
||||
|
||||
float NdotL = max(0.0, dot(norm, L));
|
||||
vec3 R = reflect(L, norm);
|
||||
float RdotE = max(0.0, dot(R, normalize(xpos.xyz)));
|
||||
float Specular = pow(RdotE, 200);
|
||||
float NdotL = max(0., dot(norm, L));
|
||||
|
||||
vec3 Specular = getSpecular(norm, eyedir, L, col, roughness) * NdotL;
|
||||
|
||||
vec3 outcol = NdotL * col;
|
||||
|
||||
@ -62,5 +74,5 @@ void main() {
|
||||
}*/
|
||||
|
||||
Diff = vec4(NdotL * col, 1.);
|
||||
Spec = vec4(Specular * col, 1.);
|
||||
Spec = vec4(Specular, 1.);
|
||||
}
|
||||
|