mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 09:54:24 +02:00
Merging core
This commit is contained in:
commit
1a276924f0
82 changed files with 43292 additions and 794 deletions
|
@ -189,10 +189,6 @@ option(GET_OGLPLUS "Get OGLplus library automatically as external project" 1)
|
||||||
|
|
||||||
option(USE_NSIGHT "Attempt to find the nSight libraries" 1)
|
option(USE_NSIGHT "Attempt to find the nSight libraries" 1)
|
||||||
|
|
||||||
if (WIN32)
|
|
||||||
option(GET_GLEW "Get GLEW library automatically as external project" 1)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
option(GET_SDL2 "Get SDL2 library automatically as external project" 0)
|
option(GET_SDL2 "Get SDL2 library automatically as external project" 0)
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
|
|
34
cmake/externals/glew/CMakeLists.txt
vendored
34
cmake/externals/glew/CMakeLists.txt
vendored
|
@ -1,34 +0,0 @@
|
||||||
if (WIN32)
|
|
||||||
set(EXTERNAL_NAME glew)
|
|
||||||
|
|
||||||
include(ExternalProject)
|
|
||||||
ExternalProject_Add(
|
|
||||||
${EXTERNAL_NAME}
|
|
||||||
URL http://hifi-public.s3.amazonaws.com/dependencies/glew-1.10.0-win32.zip
|
|
||||||
URL_MD5 37514e4e595a3b3dc587eee8f7e8ec2f
|
|
||||||
CONFIGURE_COMMAND ""
|
|
||||||
BUILD_COMMAND ""
|
|
||||||
INSTALL_COMMAND ""
|
|
||||||
LOG_DOWNLOAD 1
|
|
||||||
)
|
|
||||||
|
|
||||||
# Hide this external target (for ide users)
|
|
||||||
set_target_properties(${EXTERNAL_NAME} PROPERTIES FOLDER "hidden/externals")
|
|
||||||
|
|
||||||
ExternalProject_Get_Property(${EXTERNAL_NAME} SOURCE_DIR)
|
|
||||||
|
|
||||||
string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER)
|
|
||||||
set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${SOURCE_DIR}/include CACHE PATH "List of glew include directories")
|
|
||||||
|
|
||||||
if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
|
|
||||||
set(_LIB_DIR ${SOURCE_DIR}/lib/Release/x64)
|
|
||||||
set(${EXTERNAL_NAME_UPPER}_DLL_PATH ${SOURCE_DIR}/bin/Release/x64 CACHE FILEPATH "Location of GLEW DLL")
|
|
||||||
else()
|
|
||||||
set(_LIB_DIR ${SOURCE_DIR}/lib/Release/Win32)
|
|
||||||
set(${EXTERNAL_NAME_UPPER}_DLL_PATH ${SOURCE_DIR}/bin/Release/Win32 CACHE FILEPATH "Location of GLEW DLL")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${_LIB_DIR}/glew32.lib CACHE FILEPATH "Location of GLEW release library")
|
|
||||||
set(${EXTERNAL_NAME_UPPER}_LIBRARY_DEBUG "" CACHE FILEPATH "Location of GLEW debug library")
|
|
||||||
|
|
||||||
endif ()
|
|
|
@ -12,7 +12,7 @@ macro(SETUP_HIFI_LIBRARY)
|
||||||
project(${TARGET_NAME})
|
project(${TARGET_NAME})
|
||||||
|
|
||||||
# grab the implemenation and header files
|
# grab the implemenation and header files
|
||||||
file(GLOB_RECURSE LIB_SRCS "src/*.h" "src/*.cpp")
|
file(GLOB_RECURSE LIB_SRCS "src/*.h" "src/*.cpp" "src/*.c")
|
||||||
list(APPEND ${TARGET_NAME}_SRCS ${LIB_SRCS})
|
list(APPEND ${TARGET_NAME}_SRCS ${LIB_SRCS})
|
||||||
|
|
||||||
# create a library and set the property so it can be referenced later
|
# create a library and set the property so it can be referenced later
|
||||||
|
|
|
@ -10,11 +10,6 @@ macro(SETUP_HIFI_OPENGL)
|
||||||
|
|
||||||
elseif (WIN32)
|
elseif (WIN32)
|
||||||
|
|
||||||
add_dependency_external_projects(glew)
|
|
||||||
find_package(GLEW REQUIRED)
|
|
||||||
target_include_directories(${TARGET_NAME} PUBLIC ${GLEW_INCLUDE_DIRS})
|
|
||||||
target_link_libraries(${TARGET_NAME} ${GLEW_LIBRARIES} opengl32.lib)
|
|
||||||
|
|
||||||
if (USE_NSIGHT)
|
if (USE_NSIGHT)
|
||||||
# try to find the Nsight package and add it to the build if we find it
|
# try to find the Nsight package and add it to the build if we find it
|
||||||
find_package(NSIGHT)
|
find_package(NSIGHT)
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
#
|
|
||||||
# FindGLEW.cmake
|
|
||||||
#
|
|
||||||
# Try to find GLEW library and include path.
|
|
||||||
# Once done this will define
|
|
||||||
#
|
|
||||||
# GLEW_FOUND
|
|
||||||
# GLEW_INCLUDE_DIRS
|
|
||||||
# GLEW_LIBRARIES
|
|
||||||
#
|
|
||||||
# Created on 2/6/2014 by Stephen Birarda
|
|
||||||
# Copyright 2014 High Fidelity, Inc.
|
|
||||||
#
|
|
||||||
# Adapted from FindGLEW.cmake available in the nvidia-texture-tools repository
|
|
||||||
# (https://code.google.com/p/nvidia-texture-tools/source/browse/trunk/cmake/FindGLEW.cmake?r=96)
|
|
||||||
#
|
|
||||||
# Distributed under the Apache License, Version 2.0.
|
|
||||||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
#
|
|
||||||
|
|
||||||
if (WIN32)
|
|
||||||
include("${MACRO_DIR}/HifiLibrarySearchHints.cmake")
|
|
||||||
hifi_library_search_hints("glew")
|
|
||||||
|
|
||||||
find_path(GLEW_INCLUDE_DIRS GL/glew.h PATH_SUFFIXES include HINTS ${GLEW_SEARCH_DIRS})
|
|
||||||
|
|
||||||
find_library(GLEW_LIBRARY_RELEASE glew32 PATH_SUFFIXES "lib/Release/Win32" "lib" HINTS ${GLEW_SEARCH_DIRS})
|
|
||||||
find_library(GLEW_LIBRARY_DEBUG glew32d PATH_SUFFIXES "lib/Debug/Win32" "lib" HINTS ${GLEW_SEARCH_DIRS})
|
|
||||||
|
|
||||||
find_path(GLEW_DLL_PATH glew32.dll PATH_SUFFIXES "bin/Release/Win32" HINTS ${GLEW_SEARCH_DIRS})
|
|
||||||
|
|
||||||
include(SelectLibraryConfigurations)
|
|
||||||
select_library_configurations(GLEW)
|
|
||||||
|
|
||||||
set(GLEW_LIBRARIES ${GLEW_LIBRARY})
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_INCLUDE_DIRS GLEW_LIBRARIES GLEW_DLL_PATH)
|
|
||||||
|
|
||||||
add_paths_to_fixup_libs(${GLEW_DLL_PATH})
|
|
||||||
elseif (APPLE)
|
|
||||||
else ()
|
|
||||||
find_path(GLEW_INCLUDE_DIR GL/glew.h)
|
|
||||||
find_library(GLEW_LIBRARY NAMES GLEW glew32 glew glew32s PATH_SUFFIXES lib64)
|
|
||||||
|
|
||||||
set(GLEW_INCLUDE_DIRS ${GLEW_INCLUDE_DIR})
|
|
||||||
set(GLEW_LIBRARIES ${GLEW_LIBRARY})
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(GLEW
|
|
||||||
REQUIRED_VARS GLEW_INCLUDE_DIR GLEW_LIBRARY)
|
|
||||||
|
|
||||||
mark_as_advanced(GLEW_INCLUDE_DIR GLEW_LIBRARY)
|
|
||||||
|
|
||||||
endif ()
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ var RAD_TO_DEG = 180.0 / PI;
|
||||||
var AZIMUTH_RATE = 90.0;
|
var AZIMUTH_RATE = 90.0;
|
||||||
var ALTITUDE_RATE = 200.0;
|
var ALTITUDE_RATE = 200.0;
|
||||||
var RADIUS_RATE = 1.0 / 100.0;
|
var RADIUS_RATE = 1.0 / 100.0;
|
||||||
var PAN_RATE = 50.0;
|
var PAN_RATE = 250.0;
|
||||||
|
|
||||||
var Y_AXIS = {
|
var Y_AXIS = {
|
||||||
x: 0,
|
x: 0,
|
||||||
|
@ -139,7 +139,7 @@ function handlePanMode(dx, dy) {
|
||||||
var right = Quat.getRight(Camera.getOrientation());
|
var right = Quat.getRight(Camera.getOrientation());
|
||||||
var distance = Vec3.length(vector);
|
var distance = Vec3.length(vector);
|
||||||
|
|
||||||
var dv = Vec3.sum(Vec3.multiply(up, -distance * dy / PAN_RATE), Vec3.multiply(right, distance * dx / PAN_RATE));
|
var dv = Vec3.sum(Vec3.multiply(up, distance * dy / PAN_RATE), Vec3.multiply(right, -distance * dx / PAN_RATE));
|
||||||
|
|
||||||
center = Vec3.sum(center, dv);
|
center = Vec3.sum(center, dv);
|
||||||
position = Vec3.sum(position, dv);
|
position = Vec3.sum(position, dv);
|
||||||
|
|
|
@ -19,7 +19,22 @@
|
||||||
|
|
||||||
const int MSECS_PER_FRAME_WHEN_THROTTLED = 66;
|
const int MSECS_PER_FRAME_WHEN_THROTTLED = 66;
|
||||||
|
|
||||||
GLCanvas::GLCanvas() : QGLWidget(QGL::NoDepthBuffer | QGL::NoStencilBuffer),
|
static QGLFormat& getDesiredGLFormat() {
|
||||||
|
// Specify an OpenGL 3.3 format using the Core profile.
|
||||||
|
// That is, no old-school fixed pipeline functionality
|
||||||
|
static QGLFormat glFormat;
|
||||||
|
static std::once_flag once;
|
||||||
|
std::call_once(once, [] {
|
||||||
|
glFormat.setVersion(4, 1);
|
||||||
|
glFormat.setProfile(QGLFormat::CoreProfile); // Requires >=Qt-4.8.0
|
||||||
|
glFormat.setSampleBuffers(false);
|
||||||
|
glFormat.setDepth(false);
|
||||||
|
glFormat.setStencil(false);
|
||||||
|
});
|
||||||
|
return glFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLCanvas::GLCanvas() : QGLWidget(getDesiredGLFormat()),
|
||||||
_throttleRendering(false),
|
_throttleRendering(false),
|
||||||
_idleRenderInterval(MSECS_PER_FRAME_WHEN_THROTTLED)
|
_idleRenderInterval(MSECS_PER_FRAME_WHEN_THROTTLED)
|
||||||
{
|
{
|
||||||
|
|
|
@ -119,19 +119,21 @@ void Circle3DOverlay::render(RenderArgs* args) {
|
||||||
|
|
||||||
float angle = startAt;
|
float angle = startAt;
|
||||||
float angleInRadians = glm::radians(angle);
|
float angleInRadians = glm::radians(angle);
|
||||||
glm::vec2 firstInnerPoint(cosf(angleInRadians) * innerRadius, sinf(angleInRadians) * innerRadius);
|
glm::vec2 mostRecentInnerPoint(cosf(angleInRadians) * innerRadius, sinf(angleInRadians) * innerRadius);
|
||||||
glm::vec2 firstOuterPoint(cosf(angleInRadians) * outerRadius, sinf(angleInRadians) * outerRadius);
|
glm::vec2 mostRecentOuterPoint(cosf(angleInRadians) * outerRadius, sinf(angleInRadians) * outerRadius);
|
||||||
|
|
||||||
points << firstInnerPoint << firstOuterPoint;
|
|
||||||
|
|
||||||
while (angle < endAt) {
|
while (angle < endAt) {
|
||||||
angleInRadians = glm::radians(angle);
|
angleInRadians = glm::radians(angle);
|
||||||
glm::vec2 thisInnerPoint(cosf(angleInRadians) * innerRadius, sinf(angleInRadians) * innerRadius);
|
glm::vec2 thisInnerPoint(cosf(angleInRadians) * innerRadius, sinf(angleInRadians) * innerRadius);
|
||||||
glm::vec2 thisOuterPoint(cosf(angleInRadians) * outerRadius, sinf(angleInRadians) * outerRadius);
|
glm::vec2 thisOuterPoint(cosf(angleInRadians) * outerRadius, sinf(angleInRadians) * outerRadius);
|
||||||
|
|
||||||
points << thisOuterPoint << thisInnerPoint;
|
points << mostRecentInnerPoint << mostRecentOuterPoint << thisOuterPoint; // first triangle
|
||||||
|
points << mostRecentInnerPoint << thisInnerPoint << thisOuterPoint; // second triangle
|
||||||
|
|
||||||
angle += SLICE_ANGLE;
|
angle += SLICE_ANGLE;
|
||||||
|
|
||||||
|
mostRecentInnerPoint = thisInnerPoint;
|
||||||
|
mostRecentOuterPoint = thisOuterPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the last slice portion....
|
// get the last slice portion....
|
||||||
|
@ -140,12 +142,13 @@ void Circle3DOverlay::render(RenderArgs* args) {
|
||||||
glm::vec2 lastInnerPoint(cosf(angleInRadians) * innerRadius, sinf(angleInRadians) * innerRadius);
|
glm::vec2 lastInnerPoint(cosf(angleInRadians) * innerRadius, sinf(angleInRadians) * innerRadius);
|
||||||
glm::vec2 lastOuterPoint(cosf(angleInRadians) * outerRadius, sinf(angleInRadians) * outerRadius);
|
glm::vec2 lastOuterPoint(cosf(angleInRadians) * outerRadius, sinf(angleInRadians) * outerRadius);
|
||||||
|
|
||||||
points << lastOuterPoint << lastInnerPoint;
|
points << mostRecentInnerPoint << mostRecentOuterPoint << lastOuterPoint; // first triangle
|
||||||
|
points << mostRecentInnerPoint << lastInnerPoint << lastOuterPoint; // second triangle
|
||||||
|
|
||||||
geometryCache->updateVertices(_quadVerticesID, points, color);
|
geometryCache->updateVertices(_quadVerticesID, points, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
geometryCache->renderVertices(batch, gpu::QUAD_STRIP, _quadVerticesID);
|
geometryCache->renderVertices(batch, gpu::TRIANGLES, _quadVerticesID);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (_lineVerticesID == GeometryCache::UNKNOWN_ID) {
|
if (_lineVerticesID == GeometryCache::UNKNOWN_ID) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ set(TARGET_NAME entities-renderer)
|
||||||
AUTOSCRIBE_SHADER_LIB(gpu model render)
|
AUTOSCRIBE_SHADER_LIB(gpu model render)
|
||||||
|
|
||||||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||||
setup_hifi_library(Widgets OpenGL Network Script)
|
setup_hifi_library(Widgets Network Script)
|
||||||
|
|
||||||
add_dependency_external_projects(glm)
|
add_dependency_external_projects(glm)
|
||||||
find_package(GLM REQUIRED)
|
find_package(GLM REQUIRED)
|
||||||
|
|
|
@ -11,10 +11,12 @@
|
||||||
|
|
||||||
uniform sampler2D colorMap;
|
uniform sampler2D colorMap;
|
||||||
|
|
||||||
varying vec4 varColor;
|
in vec4 _color;
|
||||||
varying vec2 varTexCoord;
|
in vec2 _texCoord0;
|
||||||
|
|
||||||
|
out vec4 outFragColor;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec4 color = texture2D(colorMap, varTexCoord);
|
vec4 color = texture(colorMap, _texCoord0);
|
||||||
gl_FragColor = color * varColor;
|
outFragColor = color * _color;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,19 +10,21 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
<@include gpu/Inputs.slh@>
|
||||||
|
|
||||||
<@include gpu/Transform.slh@>
|
<@include gpu/Transform.slh@>
|
||||||
|
|
||||||
<$declareStandardTransform()$>
|
<$declareStandardTransform()$>
|
||||||
|
|
||||||
varying vec4 varColor;
|
out vec4 _color;
|
||||||
varying vec2 varTexCoord;
|
out vec2 _texCoord0;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
// pass along the color & uvs to fragment shader
|
// pass along the color & uvs to fragment shader
|
||||||
varColor = gl_Color;
|
_color = inColor;
|
||||||
varTexCoord = gl_MultiTexCoord0.xy;
|
_texCoord0 = inTexCoord0.xy;
|
||||||
|
|
||||||
TransformCamera cam = getTransformCamera();
|
TransformCamera cam = getTransformCamera();
|
||||||
TransformObject obj = getTransformObject();
|
TransformObject obj = getTransformObject();
|
||||||
<$transformModelToClipPos(cam, obj, gl_Vertex, gl_Position)$>
|
<$transformModelToClipPos(cam, obj, inPosition, gl_Position)$>
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,10 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
varying vec4 varColor;
|
in vec4 _color;
|
||||||
|
|
||||||
|
out vec4 outFragColor;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
gl_FragColor = varColor;
|
outFragColor = _color;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,17 +8,19 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
<@include gpu/Inputs.slh@>
|
||||||
|
|
||||||
<@include gpu/Transform.slh@>
|
<@include gpu/Transform.slh@>
|
||||||
|
|
||||||
<$declareStandardTransform()$>
|
<$declareStandardTransform()$>
|
||||||
|
|
||||||
varying vec4 varColor;
|
out vec4 _color;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
// pass along the diffuse color
|
// pass along the diffuse color
|
||||||
varColor = gl_Color;
|
_color = inColor;
|
||||||
|
|
||||||
TransformCamera cam = getTransformCamera();
|
TransformCamera cam = getTransformCamera();
|
||||||
TransformObject obj = getTransformObject();
|
TransformObject obj = getTransformObject();
|
||||||
<$transformModelToClipPos(cam, obj, gl_Vertex, gl_Position)$>
|
<$transformModelToClipPos(cam, obj, inPosition, gl_Position)$>
|
||||||
}
|
}
|
|
@ -830,6 +830,56 @@ public:
|
||||||
std::vector<AttributeData> attributes;
|
std::vector<AttributeData> attributes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
gpu::BufferPointer FBXMeshPart::getTrianglesForQuads() const {
|
||||||
|
// if we've been asked for our triangulation of the original quads, but we don't yet have them
|
||||||
|
// then create them now.
|
||||||
|
if (!trianglesForQuadsAvailable) {
|
||||||
|
trianglesForQuadsAvailable = true;
|
||||||
|
|
||||||
|
quadsAsTrianglesIndicesBuffer = std::make_shared<gpu::Buffer>();
|
||||||
|
|
||||||
|
// QVector<int> quadIndices; // original indices from the FBX mesh
|
||||||
|
QVector<quint32> quadsAsTrianglesIndices; // triangle versions of quads converted when first needed
|
||||||
|
const int INDICES_PER_ORIGINAL_QUAD = 4;
|
||||||
|
const int INDICES_PER_TRIANGULATED_QUAD = 6;
|
||||||
|
int numberOfQuads = quadIndices.size() / INDICES_PER_ORIGINAL_QUAD;
|
||||||
|
|
||||||
|
quadsAsTrianglesIndices.resize(numberOfQuads * INDICES_PER_TRIANGULATED_QUAD);
|
||||||
|
|
||||||
|
int originalIndex = 0;
|
||||||
|
int triangulatedIndex = 0;
|
||||||
|
for (int fromQuad = 0; fromQuad < numberOfQuads; fromQuad++) {
|
||||||
|
int i0 = quadIndices[originalIndex + 0];
|
||||||
|
int i1 = quadIndices[originalIndex + 1];
|
||||||
|
int i2 = quadIndices[originalIndex + 2];
|
||||||
|
int i3 = quadIndices[originalIndex + 3];
|
||||||
|
|
||||||
|
// Sam's recommended triangle slices
|
||||||
|
// Triangle tri1 = { v0, v1, v3 };
|
||||||
|
// Triangle tri2 = { v1, v2, v3 };
|
||||||
|
// NOTE: Random guy on the internet's recommended triangle slices
|
||||||
|
// Triangle tri1 = { v0, v1, v2 };
|
||||||
|
// Triangle tri2 = { v2, v3, v0 };
|
||||||
|
|
||||||
|
quadsAsTrianglesIndices[triangulatedIndex + 0] = i0;
|
||||||
|
quadsAsTrianglesIndices[triangulatedIndex + 1] = i1;
|
||||||
|
quadsAsTrianglesIndices[triangulatedIndex + 2] = i3;
|
||||||
|
|
||||||
|
quadsAsTrianglesIndices[triangulatedIndex + 3] = i1;
|
||||||
|
quadsAsTrianglesIndices[triangulatedIndex + 4] = i2;
|
||||||
|
quadsAsTrianglesIndices[triangulatedIndex + 5] = i3;
|
||||||
|
|
||||||
|
originalIndex += INDICES_PER_ORIGINAL_QUAD;
|
||||||
|
triangulatedIndex += INDICES_PER_TRIANGULATED_QUAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
trianglesForQuadsIndicesCount = INDICES_PER_TRIANGULATED_QUAD * numberOfQuads;
|
||||||
|
quadsAsTrianglesIndicesBuffer->append(quadsAsTrianglesIndices.size() * sizeof(quint32), (gpu::Byte*)quadsAsTrianglesIndices.data());
|
||||||
|
|
||||||
|
}
|
||||||
|
return quadsAsTrianglesIndicesBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
void appendIndex(MeshData& data, QVector<int>& indices, int index) {
|
void appendIndex(MeshData& data, QVector<int>& indices, int index) {
|
||||||
if (index >= data.polygonIndices.size()) {
|
if (index >= data.polygonIndices.size()) {
|
||||||
return;
|
return;
|
||||||
|
@ -1089,7 +1139,6 @@ ExtractedMesh extractMesh(const FBXNode& object, unsigned int& meshIndex) {
|
||||||
appendIndex(data, part.quadIndices, beginIndex++);
|
appendIndex(data, part.quadIndices, beginIndex++);
|
||||||
appendIndex(data, part.quadIndices, beginIndex++);
|
appendIndex(data, part.quadIndices, beginIndex++);
|
||||||
appendIndex(data, part.quadIndices, beginIndex++);
|
appendIndex(data, part.quadIndices, beginIndex++);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
for (int nextIndex = beginIndex + 1;; ) {
|
for (int nextIndex = beginIndex + 1;; ) {
|
||||||
appendIndex(data, part.triangleIndices, beginIndex);
|
appendIndex(data, part.triangleIndices, beginIndex);
|
||||||
|
|
|
@ -109,8 +109,9 @@ public:
|
||||||
class FBXMeshPart {
|
class FBXMeshPart {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QVector<int> quadIndices;
|
QVector<int> quadIndices; // original indices from the FBX mesh
|
||||||
QVector<int> triangleIndices;
|
QVector<int> triangleIndices; // original indices from the FBX mesh
|
||||||
|
mutable gpu::BufferPointer quadsAsTrianglesIndicesBuffer;
|
||||||
|
|
||||||
glm::vec3 diffuseColor;
|
glm::vec3 diffuseColor;
|
||||||
glm::vec3 specularColor;
|
glm::vec3 specularColor;
|
||||||
|
@ -126,6 +127,10 @@ public:
|
||||||
|
|
||||||
QString materialID;
|
QString materialID;
|
||||||
model::MaterialPointer _material;
|
model::MaterialPointer _material;
|
||||||
|
mutable bool trianglesForQuadsAvailable = false;
|
||||||
|
mutable int trianglesForQuadsIndicesCount = 0;
|
||||||
|
|
||||||
|
gpu::BufferPointer getTrianglesForQuads() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A single mesh (with optional blendshapes) extracted from an FBX document.
|
/// A single mesh (with optional blendshapes) extracted from an FBX document.
|
||||||
|
|
|
@ -13,11 +13,9 @@ if (APPLE)
|
||||||
|
|
||||||
target_link_libraries(${TARGET_NAME} ${OpenGL})
|
target_link_libraries(${TARGET_NAME} ${OpenGL})
|
||||||
elseif (WIN32)
|
elseif (WIN32)
|
||||||
add_dependency_external_projects(glew)
|
add_definitions(-DGLEW_STATIC)
|
||||||
find_package(GLEW REQUIRED)
|
|
||||||
target_include_directories(${TARGET_NAME} PUBLIC ${GLEW_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
target_link_libraries(${TARGET_NAME} ${GLEW_LIBRARIES} opengl32.lib)
|
target_link_libraries(${TARGET_NAME} opengl32.lib)
|
||||||
|
|
||||||
if (USE_NSIGHT)
|
if (USE_NSIGHT)
|
||||||
# try to find the Nsight package and add it to the build if we find it
|
# try to find the Nsight package and add it to the build if we find it
|
||||||
|
@ -32,8 +30,6 @@ elseif (WIN32)
|
||||||
elseif (ANDROID)
|
elseif (ANDROID)
|
||||||
target_link_libraries(${TARGET_NAME} "-lGLESv3" "-lEGL")
|
target_link_libraries(${TARGET_NAME} "-lGLESv3" "-lEGL")
|
||||||
else ()
|
else ()
|
||||||
find_package(GLEW REQUIRED)
|
|
||||||
target_include_directories(${TARGET_NAME} PUBLIC ${GLEW_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
|
|
||||||
|
@ -41,6 +37,6 @@ else ()
|
||||||
include_directories(SYSTEM "${OPENGL_INCLUDE_DIR}")
|
include_directories(SYSTEM "${OPENGL_INCLUDE_DIR}")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}" "${OPENGL_LIBRARY}")
|
target_link_libraries(${TARGET_NAME} "${OPENGL_LIBRARY}")
|
||||||
|
|
||||||
endif (APPLE)
|
endif (APPLE)
|
||||||
|
|
19367
libraries/gpu/src/GL/glew.h
Normal file
19367
libraries/gpu/src/GL/glew.h
Normal file
File diff suppressed because it is too large
Load diff
1771
libraries/gpu/src/GL/glxew.h
Normal file
1771
libraries/gpu/src/GL/glxew.h
Normal file
File diff suppressed because it is too large
Load diff
1452
libraries/gpu/src/GL/wglew.h
Normal file
1452
libraries/gpu/src/GL/wglew.h
Normal file
File diff suppressed because it is too large
Load diff
19630
libraries/gpu/src/glew.c
Normal file
19630
libraries/gpu/src/glew.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -15,8 +15,9 @@
|
||||||
uniform sampler2D colorMap;
|
uniform sampler2D colorMap;
|
||||||
uniform vec4 color;
|
uniform vec4 color;
|
||||||
|
|
||||||
varying vec2 varTexcoord;
|
in vec2 varTexcoord;
|
||||||
|
out vec4 outFragColor;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
gl_FragColor = texture2D(colorMap, varTexcoord) * color;
|
outFragColor = texture(colorMap, varTexcoord) * color;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
uniform vec4 texcoordRect;
|
uniform vec4 texcoordRect;
|
||||||
|
|
||||||
varying vec2 varTexcoord;
|
out vec2 varTexcoord;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
const vec4 UNIT_QUAD[4] = vec4[4](
|
const vec4 UNIT_QUAD[4] = vec4[4](
|
||||||
|
|
|
@ -14,8 +14,9 @@
|
||||||
|
|
||||||
uniform sampler2D colorMap;
|
uniform sampler2D colorMap;
|
||||||
|
|
||||||
varying vec2 varTexcoord;
|
in vec2 varTexcoord;
|
||||||
|
out vec4 outFragColor;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
gl_FragColor = texture2D(colorMap, varTexcoord);
|
outFragColor = texture(colorMap, varTexcoord);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,9 @@
|
||||||
|
|
||||||
uniform sampler2D colorMap;
|
uniform sampler2D colorMap;
|
||||||
|
|
||||||
varying vec2 varTexcoord;
|
in vec2 varTexcoord;
|
||||||
|
out vec4 outFragColor;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
gl_FragColor = vec4(texture2D(colorMap, varTexcoord).xyz, 1.0);
|
outFragColor = vec4(texture(colorMap, varTexcoord).xyz, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
<$declareStandardTransform()$>
|
<$declareStandardTransform()$>
|
||||||
|
|
||||||
varying vec2 varTexcoord;
|
out vec2 varTexcoord;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
const vec4 UNIT_QUAD[4] = vec4[4](
|
const vec4 UNIT_QUAD[4] = vec4[4](
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
<$declareStandardTransform()$>
|
<$declareStandardTransform()$>
|
||||||
|
|
||||||
out vec2 _texcoord;
|
out vec2 varTexcoord;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
const vec4 UNIT_QUAD[4] = vec4[4](
|
const vec4 UNIT_QUAD[4] = vec4[4](
|
||||||
|
@ -34,5 +34,5 @@ void main(void) {
|
||||||
<$transformModelToWorldPos(obj, tc, tc)$>
|
<$transformModelToWorldPos(obj, tc, tc)$>
|
||||||
|
|
||||||
gl_Position = pos;
|
gl_Position = pos;
|
||||||
_texcoord = tc.xy;
|
varTexcoord = tc.xy;
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,9 +213,6 @@ enum Primitive {
|
||||||
TRIANGLES,
|
TRIANGLES,
|
||||||
TRIANGLE_STRIP,
|
TRIANGLE_STRIP,
|
||||||
TRIANGLE_FAN,
|
TRIANGLE_FAN,
|
||||||
QUADS,
|
|
||||||
QUAD_STRIP,
|
|
||||||
|
|
||||||
NUM_PRIMITIVES,
|
NUM_PRIMITIVES,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -74,14 +74,16 @@ void GLBackend::init() {
|
||||||
|
|
||||||
qCDebug(gpulogging) << "GL Renderer: " << QString((const char*) glGetString(GL_RENDERER));
|
qCDebug(gpulogging) << "GL Renderer: " << QString((const char*) glGetString(GL_RENDERER));
|
||||||
|
|
||||||
#ifdef WIN32
|
glewExperimental = true;
|
||||||
GLenum err = glewInit();
|
GLenum err = glewInit();
|
||||||
|
glGetError();
|
||||||
if (GLEW_OK != err) {
|
if (GLEW_OK != err) {
|
||||||
/* Problem: glewInit failed, something is seriously wrong. */
|
/* Problem: glewInit failed, something is seriously wrong. */
|
||||||
qCDebug(gpulogging, "Error: %s\n", glewGetErrorString(err));
|
qCDebug(gpulogging, "Error: %s\n", glewGetErrorString(err));
|
||||||
}
|
}
|
||||||
qCDebug(gpulogging, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
|
qCDebug(gpulogging, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
|
||||||
|
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
if (wglewGetExtension("WGL_EXT_swap_control")) {
|
if (wglewGetExtension("WGL_EXT_swap_control")) {
|
||||||
int swapInterval = wglGetSwapIntervalEXT();
|
int swapInterval = wglGetSwapIntervalEXT();
|
||||||
qCDebug(gpulogging, "V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF"));
|
qCDebug(gpulogging, "V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF"));
|
||||||
|
@ -89,13 +91,6 @@ void GLBackend::init() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_LINUX)
|
||||||
GLenum err = glewInit();
|
|
||||||
if (GLEW_OK != err) {
|
|
||||||
/* Problem: glewInit failed, something is seriously wrong. */
|
|
||||||
qCDebug(gpulogging, "Error: %s\n", glewGetErrorString(err));
|
|
||||||
}
|
|
||||||
qCDebug(gpulogging, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
|
|
||||||
|
|
||||||
// TODO: Write the correct code for Linux...
|
// TODO: Write the correct code for Linux...
|
||||||
/* if (wglewGetExtension("WGL_EXT_swap_control")) {
|
/* if (wglewGetExtension("WGL_EXT_swap_control")) {
|
||||||
int swapInterval = wglGetSwapIntervalEXT();
|
int swapInterval = wglGetSwapIntervalEXT();
|
||||||
|
@ -200,7 +195,6 @@ void GLBackend::do_draw(Batch& batch, uint32 paramOffset) {
|
||||||
GLenum mode = _primitiveToGLmode[primitiveType];
|
GLenum mode = _primitiveToGLmode[primitiveType];
|
||||||
uint32 numVertices = batch._params[paramOffset + 1]._uint;
|
uint32 numVertices = batch._params[paramOffset + 1]._uint;
|
||||||
uint32 startVertex = batch._params[paramOffset + 0]._uint;
|
uint32 startVertex = batch._params[paramOffset + 0]._uint;
|
||||||
|
|
||||||
glDrawArrays(mode, startVertex, numVertices);
|
glDrawArrays(mode, startVertex, numVertices);
|
||||||
(void) CHECK_GL_ERROR();
|
(void) CHECK_GL_ERROR();
|
||||||
}
|
}
|
||||||
|
@ -510,6 +504,7 @@ void Batch::_glLineWidth(GLfloat width) {
|
||||||
DO_IT_NOW(_glLineWidth, 1);
|
DO_IT_NOW(_glLineWidth, 1);
|
||||||
}
|
}
|
||||||
void GLBackend::do_glLineWidth(Batch& batch, uint32 paramOffset) {
|
void GLBackend::do_glLineWidth(Batch& batch, uint32 paramOffset) {
|
||||||
glLineWidth(batch._params[paramOffset]._float);
|
// FIXME CORE
|
||||||
|
//glLineWidth(batch._params[paramOffset]._float);
|
||||||
(void) CHECK_GL_ERROR();
|
(void) CHECK_GL_ERROR();
|
||||||
}
|
}
|
||||||
|
|
|
@ -327,8 +327,6 @@ protected:
|
||||||
bool _invalidProj;
|
bool _invalidProj;
|
||||||
bool _invalidViewport;
|
bool _invalidViewport;
|
||||||
|
|
||||||
GLenum _lastMode;
|
|
||||||
|
|
||||||
TransformStageState() :
|
TransformStageState() :
|
||||||
_transformObjectBuffer(0),
|
_transformObjectBuffer(0),
|
||||||
_transformCameraBuffer(0),
|
_transformCameraBuffer(0),
|
||||||
|
@ -339,8 +337,7 @@ protected:
|
||||||
_invalidModel(true),
|
_invalidModel(true),
|
||||||
_invalidView(true),
|
_invalidView(true),
|
||||||
_invalidProj(false),
|
_invalidProj(false),
|
||||||
_invalidViewport(false),
|
_invalidViewport(false) {}
|
||||||
_lastMode(GL_TEXTURE) {}
|
|
||||||
} _transform;
|
} _transform;
|
||||||
|
|
||||||
// Uniform Stage
|
// Uniform Stage
|
||||||
|
|
|
@ -35,71 +35,44 @@ void makeBindings(GLBackend::GLShader* shader) {
|
||||||
GLint loc = -1;
|
GLint loc = -1;
|
||||||
|
|
||||||
//Check for gpu specific attribute slotBindings
|
//Check for gpu specific attribute slotBindings
|
||||||
loc = glGetAttribLocation(glprogram, "position");
|
loc = glGetAttribLocation(glprogram, "inPosition");
|
||||||
if (loc >= 0) {
|
if (loc >= 0 && loc != gpu::Stream::POSITION) {
|
||||||
glBindAttribLocation(glprogram, gpu::Stream::POSITION, "position");
|
glBindAttribLocation(glprogram, gpu::Stream::POSITION, "inPosition");
|
||||||
}
|
}
|
||||||
|
|
||||||
loc = glGetAttribLocation(glprogram, "attribPosition");
|
loc = glGetAttribLocation(glprogram, "inNormal");
|
||||||
if (loc >= 0) {
|
if (loc >= 0 && loc != gpu::Stream::NORMAL) {
|
||||||
glBindAttribLocation(glprogram, gpu::Stream::POSITION, "attribPosition");
|
glBindAttribLocation(glprogram, gpu::Stream::NORMAL, "inNormal");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check for gpu specific attribute slotBindings
|
loc = glGetAttribLocation(glprogram, "inColor");
|
||||||
loc = glGetAttribLocation(glprogram, "gl_Vertex");
|
if (loc >= 0 && loc != gpu::Stream::COLOR) {
|
||||||
if (loc >= 0) {
|
glBindAttribLocation(glprogram, gpu::Stream::COLOR, "inColor");
|
||||||
glBindAttribLocation(glprogram, gpu::Stream::POSITION, "gl_Vertex");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loc = glGetAttribLocation(glprogram, "normal");
|
loc = glGetAttribLocation(glprogram, "inTexCoord0");
|
||||||
if (loc >= 0) {
|
if (loc >= 0 && loc != gpu::Stream::TEXCOORD) {
|
||||||
glBindAttribLocation(glprogram, gpu::Stream::NORMAL, "normal");
|
glBindAttribLocation(glprogram, gpu::Stream::TEXCOORD, "inTexCoord0");
|
||||||
}
|
|
||||||
loc = glGetAttribLocation(glprogram, "attribNormal");
|
|
||||||
if (loc >= 0) {
|
|
||||||
glBindAttribLocation(glprogram, gpu::Stream::NORMAL, "attribNormal");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loc = glGetAttribLocation(glprogram, "color");
|
loc = glGetAttribLocation(glprogram, "inTangent");
|
||||||
if (loc >= 0) {
|
if (loc >= 0 && loc != gpu::Stream::TANGENT) {
|
||||||
glBindAttribLocation(glprogram, gpu::Stream::COLOR, "color");
|
glBindAttribLocation(glprogram, gpu::Stream::TANGENT, "inTangent");
|
||||||
}
|
|
||||||
loc = glGetAttribLocation(glprogram, "attribColor");
|
|
||||||
if (loc >= 0) {
|
|
||||||
glBindAttribLocation(glprogram, gpu::Stream::COLOR, "attribColor");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loc = glGetAttribLocation(glprogram, "texcoord");
|
loc = glGetAttribLocation(glprogram, "inTexCoord1");
|
||||||
if (loc >= 0) {
|
if (loc >= 0 && loc != gpu::Stream::TEXCOORD1) {
|
||||||
glBindAttribLocation(glprogram, gpu::Stream::TEXCOORD, "texcoord");
|
glBindAttribLocation(glprogram, gpu::Stream::TEXCOORD1, "inTexCoord1");
|
||||||
}
|
|
||||||
loc = glGetAttribLocation(glprogram, "attribTexcoord");
|
|
||||||
if (loc >= 0) {
|
|
||||||
glBindAttribLocation(glprogram, gpu::Stream::TEXCOORD, "attribTexcoord");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loc = glGetAttribLocation(glprogram, "tangent");
|
loc = glGetAttribLocation(glprogram, "inSkinClusterIndex");
|
||||||
if (loc >= 0) {
|
if (loc >= 0 && loc != gpu::Stream::SKIN_CLUSTER_INDEX) {
|
||||||
glBindAttribLocation(glprogram, gpu::Stream::TANGENT, "tangent");
|
glBindAttribLocation(glprogram, gpu::Stream::SKIN_CLUSTER_INDEX, "inSkinClusterIndex");
|
||||||
}
|
}
|
||||||
|
|
||||||
loc = glGetAttribLocation(glprogram, "texcoord1");
|
loc = glGetAttribLocation(glprogram, "inSkinClusterWeight");
|
||||||
if (loc >= 0) {
|
if (loc >= 0 && loc != gpu::Stream::SKIN_CLUSTER_WEIGHT) {
|
||||||
glBindAttribLocation(glprogram, gpu::Stream::TEXCOORD1, "texcoord1");
|
glBindAttribLocation(glprogram, gpu::Stream::SKIN_CLUSTER_WEIGHT, "inSkinClusterWeight");
|
||||||
}
|
|
||||||
loc = glGetAttribLocation(glprogram, "attribTexcoord1");
|
|
||||||
if (loc >= 0) {
|
|
||||||
glBindAttribLocation(glprogram, gpu::Stream::TEXCOORD1, "texcoord1");
|
|
||||||
}
|
|
||||||
|
|
||||||
loc = glGetAttribLocation(glprogram, "clusterIndices");
|
|
||||||
if (loc >= 0) {
|
|
||||||
glBindAttribLocation(glprogram, gpu::Stream::SKIN_CLUSTER_INDEX, "clusterIndices");
|
|
||||||
}
|
|
||||||
|
|
||||||
loc = glGetAttribLocation(glprogram, "clusterWeights");
|
|
||||||
if (loc >= 0) {
|
|
||||||
glBindAttribLocation(glprogram, gpu::Stream::SKIN_CLUSTER_WEIGHT, "clusterWeights");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Link again to take into account the assigned attrib location
|
// Link again to take into account the assigned attrib location
|
||||||
|
@ -114,7 +87,6 @@ void makeBindings(GLBackend::GLShader* shader) {
|
||||||
// now assign the ubo binding, then DON't relink!
|
// now assign the ubo binding, then DON't relink!
|
||||||
|
|
||||||
//Check for gpu specific uniform slotBindings
|
//Check for gpu specific uniform slotBindings
|
||||||
#if (GPU_TRANSFORM_PROFILE == GPU_CORE)
|
|
||||||
loc = glGetUniformBlockIndex(glprogram, "transformObjectBuffer");
|
loc = glGetUniformBlockIndex(glprogram, "transformObjectBuffer");
|
||||||
if (loc >= 0) {
|
if (loc >= 0) {
|
||||||
glUniformBlockBinding(glprogram, loc, gpu::TRANSFORM_OBJECT_SLOT);
|
glUniformBlockBinding(glprogram, loc, gpu::TRANSFORM_OBJECT_SLOT);
|
||||||
|
@ -126,22 +98,6 @@ void makeBindings(GLBackend::GLShader* shader) {
|
||||||
glUniformBlockBinding(glprogram, loc, gpu::TRANSFORM_CAMERA_SLOT);
|
glUniformBlockBinding(glprogram, loc, gpu::TRANSFORM_CAMERA_SLOT);
|
||||||
shader->_transformCameraSlot = gpu::TRANSFORM_CAMERA_SLOT;
|
shader->_transformCameraSlot = gpu::TRANSFORM_CAMERA_SLOT;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
loc = glGetUniformLocation(glprogram, "transformObject_model");
|
|
||||||
if (loc >= 0) {
|
|
||||||
shader->_transformObject_model = loc;
|
|
||||||
}
|
|
||||||
|
|
||||||
loc = glGetUniformLocation(glprogram, "transformCamera_viewInverse");
|
|
||||||
if (loc >= 0) {
|
|
||||||
shader->_transformCamera_viewInverse = loc;
|
|
||||||
}
|
|
||||||
|
|
||||||
loc = glGetUniformLocation(glprogram, "transformCamera_viewport");
|
|
||||||
if (loc >= 0) {
|
|
||||||
shader->_transformCamera_viewport = loc;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLBackend::GLShader* compileShader(const Shader& shader) {
|
GLBackend::GLShader* compileShader(const Shader& shader) {
|
||||||
|
@ -635,8 +591,6 @@ bool isUnusedSlot(GLint binding) {
|
||||||
int makeUniformBlockSlots(GLuint glprogram, const Shader::BindingSet& slotBindings, Shader::SlotSet& buffers) {
|
int makeUniformBlockSlots(GLuint glprogram, const Shader::BindingSet& slotBindings, Shader::SlotSet& buffers) {
|
||||||
GLint buffersCount = 0;
|
GLint buffersCount = 0;
|
||||||
|
|
||||||
#if (GPU_FEATURE_PROFILE == GPU_CORE)
|
|
||||||
|
|
||||||
glGetProgramiv(glprogram, GL_ACTIVE_UNIFORM_BLOCKS, &buffersCount);
|
glGetProgramiv(glprogram, GL_ACTIVE_UNIFORM_BLOCKS, &buffersCount);
|
||||||
|
|
||||||
// fast exit
|
// fast exit
|
||||||
|
@ -689,7 +643,6 @@ int makeUniformBlockSlots(GLuint glprogram, const Shader::BindingSet& slotBindin
|
||||||
Element element(SCALAR, gpu::UINT32, gpu::UNIFORM_BUFFER);
|
Element element(SCALAR, gpu::UINT32, gpu::UNIFORM_BUFFER);
|
||||||
buffers.insert(Shader::Slot(name, binding, element, Resource::BUFFER));
|
buffers.insert(Shader::Slot(name, binding, element, Resource::BUFFER));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return buffersCount;
|
return buffersCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -750,11 +703,7 @@ bool GLBackend::makeProgram(Shader& shader, const Shader::BindingSet& slotBindin
|
||||||
Shader::SlotSet uniforms;
|
Shader::SlotSet uniforms;
|
||||||
Shader::SlotSet textures;
|
Shader::SlotSet textures;
|
||||||
Shader::SlotSet samplers;
|
Shader::SlotSet samplers;
|
||||||
#if (GPU_FEATURE_PROFILE == GPU_CORE)
|
|
||||||
makeUniformSlots(object->_program, slotBindings, uniforms, textures, samplers);
|
makeUniformSlots(object->_program, slotBindings, uniforms, textures, samplers);
|
||||||
#else
|
|
||||||
makeUniformSlots(object->_program, slotBindings, uniforms, textures, samplers, buffers);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Shader::SlotSet inputs;
|
Shader::SlotSet inputs;
|
||||||
makeInputSlots(object->_program, slotBindings, inputs);
|
makeInputSlots(object->_program, slotBindings, inputs);
|
||||||
|
|
|
@ -23,8 +23,6 @@ static const GLenum _primitiveToGLmode[gpu::NUM_PRIMITIVES] = {
|
||||||
GL_TRIANGLES,
|
GL_TRIANGLES,
|
||||||
GL_TRIANGLE_STRIP,
|
GL_TRIANGLE_STRIP,
|
||||||
GL_TRIANGLE_FAN,
|
GL_TRIANGLE_FAN,
|
||||||
GL_QUADS,
|
|
||||||
GL_QUAD_STRIP,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const GLenum _elementTypeToGLType[gpu::NUM_TYPES] = {
|
static const GLenum _elementTypeToGLType[gpu::NUM_TYPES] = {
|
||||||
|
|
|
@ -484,7 +484,8 @@ void GLBackend::syncPipelineStateCache() {
|
||||||
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
|
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
|
||||||
|
|
||||||
// Point size is always on
|
// Point size is always on
|
||||||
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
|
// FIXME CORE
|
||||||
|
//glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
|
||||||
glEnable(GL_PROGRAM_POINT_SIZE_EXT);
|
glEnable(GL_PROGRAM_POINT_SIZE_EXT);
|
||||||
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
|
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
|
||||||
|
|
||||||
|
@ -582,11 +583,12 @@ void GLBackend::do_setStateMultisampleEnable(bool enable) {
|
||||||
|
|
||||||
void GLBackend::do_setStateAntialiasedLineEnable(bool enable) {
|
void GLBackend::do_setStateAntialiasedLineEnable(bool enable) {
|
||||||
if (_pipeline._stateCache.antialisedLineEnable != enable) {
|
if (_pipeline._stateCache.antialisedLineEnable != enable) {
|
||||||
|
// FIXME CORE
|
||||||
if (enable) {
|
if (enable) {
|
||||||
glEnable(GL_POINT_SMOOTH);
|
// glEnable(GL_POINT_SMOOTH);
|
||||||
glEnable(GL_LINE_SMOOTH);
|
glEnable(GL_LINE_SMOOTH);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_POINT_SMOOTH);
|
// glDisable(GL_POINT_SMOOTH);
|
||||||
glDisable(GL_LINE_SMOOTH);
|
glDisable(GL_LINE_SMOOTH);
|
||||||
}
|
}
|
||||||
(void) CHECK_GL_ERROR();
|
(void) CHECK_GL_ERROR();
|
||||||
|
|
|
@ -73,14 +73,7 @@ void GLBackend::syncTransformStateCache() {
|
||||||
|
|
||||||
glGetIntegerv(GL_VIEWPORT, (GLint*) &_transform._viewport);
|
glGetIntegerv(GL_VIEWPORT, (GLint*) &_transform._viewport);
|
||||||
|
|
||||||
GLint currentMode;
|
|
||||||
glGetIntegerv(GL_MATRIX_MODE, ¤tMode);
|
|
||||||
_transform._lastMode = currentMode;
|
|
||||||
|
|
||||||
glGetFloatv(GL_PROJECTION_MATRIX, (float*) &_transform._projection);
|
|
||||||
|
|
||||||
Mat4 modelView;
|
Mat4 modelView;
|
||||||
glGetFloatv(GL_MODELVIEW_MATRIX, (float*) &modelView);
|
|
||||||
auto modelViewInv = glm::inverse(modelView);
|
auto modelViewInv = glm::inverse(modelView);
|
||||||
_transform._view.evalFromRawMatrix(modelViewInv);
|
_transform._view.evalFromRawMatrix(modelViewInv);
|
||||||
_transform._model.setIdentity();
|
_transform._model.setIdentity();
|
||||||
|
|
|
@ -18,15 +18,15 @@
|
||||||
#define GPU_LEGACY 0
|
#define GPU_LEGACY 0
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
#include <OpenGL/gl.h>
|
|
||||||
#include <OpenGL/glext.h>
|
|
||||||
|
|
||||||
#define GPU_FEATURE_PROFILE GPU_LEGACY
|
#include "../GL/glew.h"
|
||||||
#define GPU_TRANSFORM_PROFILE GPU_LEGACY
|
|
||||||
|
#define GPU_FEATURE_PROFILE GPU_CORE
|
||||||
|
#define GPU_TRANSFORM_PROFILE GPU_CORE
|
||||||
|
|
||||||
#elif defined(WIN32)
|
#elif defined(WIN32)
|
||||||
#include <GL/glew.h>
|
#include "../GL/glew.h"
|
||||||
#include <GL/wglew.h>
|
#include "../GL/wglew.h"
|
||||||
|
|
||||||
#define GPU_FEATURE_PROFILE GPU_CORE
|
#define GPU_FEATURE_PROFILE GPU_CORE
|
||||||
#define GPU_TRANSFORM_PROFILE GPU_CORE
|
#define GPU_TRANSFORM_PROFILE GPU_CORE
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include "../GL/glew.h"
|
||||||
|
|
||||||
#define GPU_FEATURE_PROFILE GPU_CORE
|
#define GPU_FEATURE_PROFILE GPU_CORE
|
||||||
#define GPU_TRANSFORM_PROFILE GPU_CORE
|
#define GPU_TRANSFORM_PROFILE GPU_CORE
|
||||||
|
|
|
@ -18,6 +18,4 @@ layout(location = 4) in vec4 inTangent;
|
||||||
layout(location = 5) in ivec4 inSkinClusterIndex;
|
layout(location = 5) in ivec4 inSkinClusterIndex;
|
||||||
layout(location = 6) in vec4 inSkinClusterWeight;
|
layout(location = 6) in vec4 inSkinClusterWeight;
|
||||||
layout(location = 7) in vec4 inTexCoord1;
|
layout(location = 7) in vec4 inTexCoord1;
|
||||||
layout(location = 9) in vec4 inInstanceScaleTranslate;
|
|
||||||
layout(location = 8) in mat4 inInstanceXfm;
|
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
|
|
@ -235,9 +235,9 @@ void main (void)
|
||||||
|
|
||||||
float fCos = dot(v3LightPos, v3Direction) / length(v3Direction);
|
float fCos = dot(v3LightPos, v3Direction) / length(v3Direction);
|
||||||
float fMiePhase = 1.5 * ((1.0 - g2) / (2.0 + g2)) * (1.0 + fCos*fCos) / pow(1.0 + g2 - 2.0*g*fCos, 1.5);
|
float fMiePhase = 1.5 * ((1.0 - g2) / (2.0 + g2)) * (1.0 + fCos*fCos) / pow(1.0 + g2 - 2.0*g*fCos, 1.5);
|
||||||
gl_FragColor.rgb = frontColor.rgb + fMiePhase * secondaryFrontColor.rgb;
|
outFragColor.rgb = frontColor.rgb + fMiePhase * secondaryFrontColor.rgb;
|
||||||
gl_FragColor.a = gl_FragColor.b;
|
outFragColor.a = outFragColor.b;
|
||||||
gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(1.0/2.2));
|
outFragColor.rgb = pow(outFragColor.rgb, vec3(1.0/2.2));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
!>
|
!>
|
||||||
|
|
|
@ -71,7 +71,7 @@ public:
|
||||||
LINE_STRIP,
|
LINE_STRIP,
|
||||||
TRIANGLES,
|
TRIANGLES,
|
||||||
TRIANGLE_STRIP,
|
TRIANGLE_STRIP,
|
||||||
QUADS,
|
QUADS, // NOTE: These must be translated to triangles before rendering
|
||||||
QUAD_STRIP,
|
QUAD_STRIP,
|
||||||
|
|
||||||
NUM_TOPOLOGIES,
|
NUM_TOPOLOGIES,
|
||||||
|
|
|
@ -8,8 +8,6 @@ qt5_add_resources(QT_RESOURCES_FILE "${CMAKE_CURRENT_SOURCE_DIR}/res/fonts/fonts
|
||||||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||||
setup_hifi_library(Widgets OpenGL Network Qml Quick Script)
|
setup_hifi_library(Widgets OpenGL Network Qml Quick Script)
|
||||||
|
|
||||||
setup_hifi_opengl()
|
|
||||||
|
|
||||||
add_dependency_external_projects(glm)
|
add_dependency_external_projects(glm)
|
||||||
find_package(GLM REQUIRED)
|
find_package(GLM REQUIRED)
|
||||||
target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS})
|
target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS})
|
||||||
|
|
|
@ -50,10 +50,10 @@ struct DeferredFragment {
|
||||||
|
|
||||||
DeferredFragment unpackDeferredFragment(vec2 texcoord) {
|
DeferredFragment unpackDeferredFragment(vec2 texcoord) {
|
||||||
DeferredFragment frag;
|
DeferredFragment frag;
|
||||||
frag.depthVal = texture2D(depthMap, texcoord).r;
|
frag.depthVal = texture(depthMap, texcoord).r;
|
||||||
frag.normalVal = texture2D(normalMap, texcoord);
|
frag.normalVal = texture(normalMap, texcoord);
|
||||||
frag.diffuseVal = texture2D(diffuseMap, texcoord);
|
frag.diffuseVal = texture(diffuseMap, texcoord);
|
||||||
frag.specularVal = texture2D(specularMap, texcoord);
|
frag.specularVal = texture(specularMap, texcoord);
|
||||||
|
|
||||||
// compute the view space position using the depth
|
// compute the view space position using the depth
|
||||||
float z = near / (frag.depthVal * depthScale - 1.0);
|
float z = near / (frag.depthVal * depthScale - 1.0);
|
||||||
|
|
|
@ -16,7 +16,9 @@
|
||||||
uniform samplerCube skyboxMap;
|
uniform samplerCube skyboxMap;
|
||||||
|
|
||||||
vec4 evalSkyboxLight(vec3 direction, float lod) {
|
vec4 evalSkyboxLight(vec3 direction, float lod) {
|
||||||
vec4 skytexel = textureLod(skyboxMap, direction, lod * textureQueryLevels(skyboxMap));
|
// FIXME
|
||||||
|
//vec4 skytexel = textureLod(skyboxMap, direction, lod * textureQueryLevels(skyboxMap));
|
||||||
|
vec4 skytexel = texture(skyboxMap, direction);
|
||||||
return skytexel;
|
return skytexel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1012,12 +1012,12 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, co
|
||||||
}
|
}
|
||||||
|
|
||||||
const int FLOATS_PER_VERTEX = 2; // vertices
|
const int FLOATS_PER_VERTEX = 2; // vertices
|
||||||
const int vertices = 4;
|
const int VERTICES = 4; // 1 quad = 4 vertices
|
||||||
|
|
||||||
if (!details.isCreated) {
|
if (!details.isCreated) {
|
||||||
|
|
||||||
details.isCreated = true;
|
details.isCreated = true;
|
||||||
details.vertices = vertices;
|
details.vertices = VERTICES;
|
||||||
details.vertexSize = FLOATS_PER_VERTEX;
|
details.vertexSize = FLOATS_PER_VERTEX;
|
||||||
|
|
||||||
auto verticesBuffer = std::make_shared<gpu::Buffer>();
|
auto verticesBuffer = std::make_shared<gpu::Buffer>();
|
||||||
|
@ -1037,11 +1037,12 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, co
|
||||||
details.stream->addBuffer(details.colorBuffer, 0, details.streamFormat->getChannels().at(1)._stride);
|
details.stream->addBuffer(details.colorBuffer, 0, details.streamFormat->getChannels().at(1)._stride);
|
||||||
|
|
||||||
|
|
||||||
float vertexBuffer[vertices * FLOATS_PER_VERTEX] = {
|
float vertexBuffer[VERTICES * FLOATS_PER_VERTEX] = {
|
||||||
minCorner.x, minCorner.y,
|
minCorner.x, minCorner.y,
|
||||||
maxCorner.x, minCorner.y,
|
maxCorner.x, minCorner.y,
|
||||||
|
minCorner.x, maxCorner.y,
|
||||||
maxCorner.x, maxCorner.y,
|
maxCorner.x, maxCorner.y,
|
||||||
minCorner.x, maxCorner.y };
|
};
|
||||||
|
|
||||||
const int NUM_COLOR_SCALARS_PER_QUAD = 4;
|
const int NUM_COLOR_SCALARS_PER_QUAD = 4;
|
||||||
int compactColor = ((int(color.x * 255.0f) & 0xFF)) |
|
int compactColor = ((int(color.x * 255.0f) & 0xFF)) |
|
||||||
|
@ -1050,14 +1051,13 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, co
|
||||||
((int(color.w * 255.0f) & 0xFF) << 24);
|
((int(color.w * 255.0f) & 0xFF) << 24);
|
||||||
int colors[NUM_COLOR_SCALARS_PER_QUAD] = { compactColor, compactColor, compactColor, compactColor };
|
int colors[NUM_COLOR_SCALARS_PER_QUAD] = { compactColor, compactColor, compactColor, compactColor };
|
||||||
|
|
||||||
|
|
||||||
details.verticesBuffer->append(sizeof(vertexBuffer), (gpu::Byte*) vertexBuffer);
|
details.verticesBuffer->append(sizeof(vertexBuffer), (gpu::Byte*) vertexBuffer);
|
||||||
details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);
|
details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
batch.setInputFormat(details.streamFormat);
|
batch.setInputFormat(details.streamFormat);
|
||||||
batch.setInputStream(0, *details.stream);
|
batch.setInputStream(0, *details.stream);
|
||||||
batch.draw(gpu::QUADS, 4, 0);
|
batch.draw(gpu::TRIANGLE_STRIP, 4, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeometryCache::renderUnitCube(gpu::Batch& batch) {
|
void GeometryCache::renderUnitCube(gpu::Batch& batch) {
|
||||||
|
@ -1102,23 +1102,25 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, co
|
||||||
}
|
}
|
||||||
|
|
||||||
const int FLOATS_PER_VERTEX = 2 * 2; // text coords & vertices
|
const int FLOATS_PER_VERTEX = 2 * 2; // text coords & vertices
|
||||||
const int vertices = 4;
|
const int VERTICES = 4; // 1 quad = 4 vertices
|
||||||
const int NUM_POS_COORDS = 2;
|
const int NUM_POS_COORDS = 2;
|
||||||
const int VERTEX_TEXCOORD_OFFSET = NUM_POS_COORDS * sizeof(float);
|
const int VERTEX_TEXCOORD_OFFSET = NUM_POS_COORDS * sizeof(float);
|
||||||
|
|
||||||
if (!details.isCreated) {
|
if (!details.isCreated) {
|
||||||
|
|
||||||
details.isCreated = true;
|
details.isCreated = true;
|
||||||
details.vertices = vertices;
|
details.vertices = VERTICES;
|
||||||
details.vertexSize = FLOATS_PER_VERTEX;
|
details.vertexSize = FLOATS_PER_VERTEX;
|
||||||
|
|
||||||
auto verticesBuffer = std::make_shared<gpu::Buffer>();
|
auto verticesBuffer = std::make_shared<gpu::Buffer>();
|
||||||
auto colorBuffer = std::make_shared<gpu::Buffer>();
|
auto colorBuffer = std::make_shared<gpu::Buffer>();
|
||||||
|
|
||||||
auto streamFormat = std::make_shared<gpu::Stream::Format>();
|
auto streamFormat = std::make_shared<gpu::Stream::Format>();
|
||||||
auto stream = std::make_shared<gpu::BufferStream>();
|
auto stream = std::make_shared<gpu::BufferStream>();
|
||||||
|
|
||||||
details.verticesBuffer = verticesBuffer;
|
details.verticesBuffer = verticesBuffer;
|
||||||
details.colorBuffer = colorBuffer;
|
details.colorBuffer = colorBuffer;
|
||||||
|
|
||||||
details.streamFormat = streamFormat;
|
details.streamFormat = streamFormat;
|
||||||
details.stream = stream;
|
details.stream = stream;
|
||||||
|
|
||||||
|
@ -1130,11 +1132,12 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, co
|
||||||
details.stream->addBuffer(details.colorBuffer, 0, details.streamFormat->getChannels().at(1)._stride);
|
details.stream->addBuffer(details.colorBuffer, 0, details.streamFormat->getChannels().at(1)._stride);
|
||||||
|
|
||||||
|
|
||||||
float vertexBuffer[vertices * FLOATS_PER_VERTEX] = {
|
float vertexBuffer[VERTICES * FLOATS_PER_VERTEX] = {
|
||||||
minCorner.x, minCorner.y, texCoordMinCorner.x, texCoordMinCorner.y,
|
minCorner.x, minCorner.y, texCoordMinCorner.x, texCoordMinCorner.y,
|
||||||
maxCorner.x, minCorner.y, texCoordMaxCorner.x, texCoordMinCorner.y,
|
maxCorner.x, minCorner.y, texCoordMaxCorner.x, texCoordMinCorner.y,
|
||||||
|
minCorner.x, maxCorner.y, texCoordMinCorner.x, texCoordMaxCorner.y,
|
||||||
maxCorner.x, maxCorner.y, texCoordMaxCorner.x, texCoordMaxCorner.y,
|
maxCorner.x, maxCorner.y, texCoordMaxCorner.x, texCoordMaxCorner.y,
|
||||||
minCorner.x, maxCorner.y, texCoordMinCorner.x, texCoordMaxCorner.y };
|
};
|
||||||
|
|
||||||
|
|
||||||
const int NUM_COLOR_SCALARS_PER_QUAD = 4;
|
const int NUM_COLOR_SCALARS_PER_QUAD = 4;
|
||||||
|
@ -1144,14 +1147,13 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, co
|
||||||
((int(color.w * 255.0f) & 0xFF) << 24);
|
((int(color.w * 255.0f) & 0xFF) << 24);
|
||||||
int colors[NUM_COLOR_SCALARS_PER_QUAD] = { compactColor, compactColor, compactColor, compactColor };
|
int colors[NUM_COLOR_SCALARS_PER_QUAD] = { compactColor, compactColor, compactColor, compactColor };
|
||||||
|
|
||||||
|
|
||||||
details.verticesBuffer->append(sizeof(vertexBuffer), (gpu::Byte*) vertexBuffer);
|
details.verticesBuffer->append(sizeof(vertexBuffer), (gpu::Byte*) vertexBuffer);
|
||||||
details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);
|
details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
batch.setInputFormat(details.streamFormat);
|
batch.setInputFormat(details.streamFormat);
|
||||||
batch.setInputStream(0, *details.stream);
|
batch.setInputStream(0, *details.stream);
|
||||||
batch.draw(gpu::QUADS, 4, 0);
|
batch.draw(gpu::TRIANGLE_STRIP, 4, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id) {
|
void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id) {
|
||||||
|
@ -1177,21 +1179,23 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, co
|
||||||
}
|
}
|
||||||
|
|
||||||
const int FLOATS_PER_VERTEX = 3; // vertices
|
const int FLOATS_PER_VERTEX = 3; // vertices
|
||||||
const int vertices = 4;
|
const int VERTICES = 4; // 1 quad = 4 vertices
|
||||||
|
|
||||||
if (!details.isCreated) {
|
if (!details.isCreated) {
|
||||||
|
|
||||||
details.isCreated = true;
|
details.isCreated = true;
|
||||||
details.vertices = vertices;
|
details.vertices = VERTICES;
|
||||||
details.vertexSize = FLOATS_PER_VERTEX;
|
details.vertexSize = FLOATS_PER_VERTEX;
|
||||||
|
|
||||||
auto verticesBuffer = std::make_shared<gpu::Buffer>();
|
auto verticesBuffer = std::make_shared<gpu::Buffer>();
|
||||||
auto colorBuffer = std::make_shared<gpu::Buffer>();
|
auto colorBuffer = std::make_shared<gpu::Buffer>();
|
||||||
|
|
||||||
auto streamFormat = std::make_shared<gpu::Stream::Format>();
|
auto streamFormat = std::make_shared<gpu::Stream::Format>();
|
||||||
auto stream = std::make_shared<gpu::BufferStream>();
|
auto stream = std::make_shared<gpu::BufferStream>();
|
||||||
|
|
||||||
details.verticesBuffer = verticesBuffer;
|
details.verticesBuffer = verticesBuffer;
|
||||||
details.colorBuffer = colorBuffer;
|
details.colorBuffer = colorBuffer;
|
||||||
|
|
||||||
details.streamFormat = streamFormat;
|
details.streamFormat = streamFormat;
|
||||||
details.stream = stream;
|
details.stream = stream;
|
||||||
|
|
||||||
|
@ -1202,11 +1206,12 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, co
|
||||||
details.stream->addBuffer(details.colorBuffer, 0, details.streamFormat->getChannels().at(1)._stride);
|
details.stream->addBuffer(details.colorBuffer, 0, details.streamFormat->getChannels().at(1)._stride);
|
||||||
|
|
||||||
|
|
||||||
float vertexBuffer[vertices * FLOATS_PER_VERTEX] = {
|
float vertexBuffer[VERTICES * FLOATS_PER_VERTEX] = {
|
||||||
minCorner.x, minCorner.y, minCorner.z,
|
minCorner.x, minCorner.y, minCorner.z,
|
||||||
maxCorner.x, minCorner.y, minCorner.z,
|
maxCorner.x, minCorner.y, minCorner.z,
|
||||||
|
minCorner.x, maxCorner.y, maxCorner.z,
|
||||||
maxCorner.x, maxCorner.y, maxCorner.z,
|
maxCorner.x, maxCorner.y, maxCorner.z,
|
||||||
minCorner.x, maxCorner.y, maxCorner.z };
|
};
|
||||||
|
|
||||||
const int NUM_COLOR_SCALARS_PER_QUAD = 4;
|
const int NUM_COLOR_SCALARS_PER_QUAD = 4;
|
||||||
int compactColor = ((int(color.x * 255.0f) & 0xFF)) |
|
int compactColor = ((int(color.x * 255.0f) & 0xFF)) |
|
||||||
|
@ -1215,14 +1220,13 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, co
|
||||||
((int(color.w * 255.0f) & 0xFF) << 24);
|
((int(color.w * 255.0f) & 0xFF) << 24);
|
||||||
int colors[NUM_COLOR_SCALARS_PER_QUAD] = { compactColor, compactColor, compactColor, compactColor };
|
int colors[NUM_COLOR_SCALARS_PER_QUAD] = { compactColor, compactColor, compactColor, compactColor };
|
||||||
|
|
||||||
|
|
||||||
details.verticesBuffer->append(sizeof(vertexBuffer), (gpu::Byte*) vertexBuffer);
|
details.verticesBuffer->append(sizeof(vertexBuffer), (gpu::Byte*) vertexBuffer);
|
||||||
details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);
|
details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);
|
||||||
}
|
}
|
||||||
|
|
||||||
batch.setInputFormat(details.streamFormat);
|
batch.setInputFormat(details.streamFormat);
|
||||||
batch.setInputStream(0, *details.stream);
|
batch.setInputStream(0, *details.stream);
|
||||||
batch.draw(gpu::QUADS, 4, 0);
|
batch.draw(gpu::TRIANGLE_STRIP, 4, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, const glm::vec3& bottomLeft,
|
void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, const glm::vec3& bottomLeft,
|
||||||
|
@ -1267,14 +1271,14 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, cons
|
||||||
}
|
}
|
||||||
|
|
||||||
const int FLOATS_PER_VERTEX = 3 + 2; // 3d vertices + text coords
|
const int FLOATS_PER_VERTEX = 3 + 2; // 3d vertices + text coords
|
||||||
const int vertices = 4;
|
const int VERTICES = 4; // 1 quad = 4 vertices
|
||||||
const int NUM_POS_COORDS = 3;
|
const int NUM_POS_COORDS = 3;
|
||||||
const int VERTEX_TEXCOORD_OFFSET = NUM_POS_COORDS * sizeof(float);
|
const int VERTEX_TEXCOORD_OFFSET = NUM_POS_COORDS * sizeof(float);
|
||||||
|
|
||||||
if (!details.isCreated) {
|
if (!details.isCreated) {
|
||||||
|
|
||||||
details.isCreated = true;
|
details.isCreated = true;
|
||||||
details.vertices = vertices;
|
details.vertices = VERTICES;
|
||||||
details.vertexSize = FLOATS_PER_VERTEX; // NOTE: this isn't used for BatchItemDetails maybe we can get rid of it
|
details.vertexSize = FLOATS_PER_VERTEX; // NOTE: this isn't used for BatchItemDetails maybe we can get rid of it
|
||||||
|
|
||||||
auto verticesBuffer = std::make_shared<gpu::Buffer>();
|
auto verticesBuffer = std::make_shared<gpu::Buffer>();
|
||||||
|
@ -1295,10 +1299,10 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, cons
|
||||||
details.stream->addBuffer(details.colorBuffer, 0, details.streamFormat->getChannels().at(1)._stride);
|
details.stream->addBuffer(details.colorBuffer, 0, details.streamFormat->getChannels().at(1)._stride);
|
||||||
|
|
||||||
|
|
||||||
float vertexBuffer[vertices * FLOATS_PER_VERTEX] = {
|
float vertexBuffer[VERTICES * FLOATS_PER_VERTEX] = {
|
||||||
topLeft.x, topLeft.y, topLeft.z, texCoordTopLeft.x, texCoordTopLeft.y,
|
|
||||||
bottomLeft.x, bottomLeft.y, bottomLeft.z, texCoordBottomLeft.x, texCoordBottomLeft.y,
|
bottomLeft.x, bottomLeft.y, bottomLeft.z, texCoordBottomLeft.x, texCoordBottomLeft.y,
|
||||||
bottomRight.x, bottomRight.y, bottomRight.z, texCoordBottomRight.x, texCoordBottomRight.y,
|
bottomRight.x, bottomRight.y, bottomRight.z, texCoordBottomRight.x, texCoordBottomRight.y,
|
||||||
|
topLeft.x, topLeft.y, topLeft.z, texCoordTopLeft.x, texCoordTopLeft.y,
|
||||||
topRight.x, topRight.y, topRight.z, texCoordTopRight.x, texCoordTopRight.y,
|
topRight.x, topRight.y, topRight.z, texCoordTopRight.x, texCoordTopRight.y,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1315,7 +1319,7 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, cons
|
||||||
|
|
||||||
batch.setInputFormat(details.streamFormat);
|
batch.setInputFormat(details.streamFormat);
|
||||||
batch.setInputStream(0, *details.stream);
|
batch.setInputStream(0, *details.stream);
|
||||||
batch.draw(gpu::QUADS, 4, 0);
|
batch.draw(gpu::TRIANGLE_STRIP, 4, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id) {
|
void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id) {
|
||||||
|
|
|
@ -2096,8 +2096,11 @@ void Model::renderPart(RenderArgs* args, int meshIndex, int partIndex, bool tran
|
||||||
}
|
}
|
||||||
|
|
||||||
if (part.quadIndices.size() > 0) {
|
if (part.quadIndices.size() > 0) {
|
||||||
batch.drawIndexed(gpu::QUADS, part.quadIndices.size(), offset);
|
batch.setIndexBuffer(gpu::UINT32, part.getTrianglesForQuads(), 0);
|
||||||
|
batch.drawIndexed(gpu::TRIANGLES, part.trianglesForQuadsIndicesCount, 0);
|
||||||
|
|
||||||
offset += part.quadIndices.size() * sizeof(int);
|
offset += part.quadIndices.size() * sizeof(int);
|
||||||
|
batch.setIndexBuffer(gpu::UINT32, (networkMesh._indexBuffer), 0); // restore this in case there are triangles too
|
||||||
}
|
}
|
||||||
|
|
||||||
if (part.triangleIndices.size() > 0) {
|
if (part.triangleIndices.size() > 0) {
|
||||||
|
|
|
@ -51,7 +51,8 @@ uniform vec3 v3LightPos;
|
||||||
uniform float g;
|
uniform float g;
|
||||||
uniform float g2;
|
uniform float g2;
|
||||||
|
|
||||||
varying vec3 position;
|
in vec3 position;
|
||||||
|
out vec4 outFragColor;
|
||||||
|
|
||||||
|
|
||||||
float scale(float fCos)
|
float scale(float fCos)
|
||||||
|
@ -97,7 +98,7 @@ void main (void)
|
||||||
v3SamplePoint += v3SampleRay;
|
v3SamplePoint += v3SampleRay;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, scale the Mie and Rayleigh colors and set up the varying variables for the pixel shader
|
// Finally, scale the Mie and Rayleigh colors and set up the in variables for the pixel shader
|
||||||
vec3 secondaryFrontColor = v3FrontColor * fKmESun;
|
vec3 secondaryFrontColor = v3FrontColor * fKmESun;
|
||||||
vec3 frontColor = v3FrontColor * (v3InvWavelength * fKrESun);
|
vec3 frontColor = v3FrontColor * (v3InvWavelength * fKrESun);
|
||||||
vec3 v3Direction = v3CameraPos - v3Pos;
|
vec3 v3Direction = v3CameraPos - v3Pos;
|
||||||
|
@ -106,6 +107,6 @@ void main (void)
|
||||||
float fMiePhase = 1.5 * ((1.0 - g2) / (2.0 + g2)) * (1.0 + fCos*fCos) / pow(1.0 + g2 - 2.0*g*fCos, 1.5);
|
float fMiePhase = 1.5 * ((1.0 - g2) / (2.0 + g2)) * (1.0 + fCos*fCos) / pow(1.0 + g2 - 2.0*g*fCos, 1.5);
|
||||||
|
|
||||||
vec3 finalColor = frontColor.rgb + fMiePhase * secondaryFrontColor.rgb;
|
vec3 finalColor = frontColor.rgb + fMiePhase * secondaryFrontColor.rgb;
|
||||||
gl_FragColor.a = finalColor.b;
|
outFragColor.a = finalColor.b;
|
||||||
gl_FragColor.rgb = pow(finalColor.rgb, vec3(1.0/2.2));
|
outFragColor.rgb = pow(finalColor.rgb, vec3(1.0/2.2));
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
// Copyright (c) 2004 Sean O'Neil
|
// Copyright (c) 2004 Sean O'Neil
|
||||||
//
|
//
|
||||||
|
|
||||||
|
<@include gpu/Inputs.slh@>
|
||||||
<@include gpu/Transform.slh@>
|
<@include gpu/Transform.slh@>
|
||||||
<$declareStandardTransform()$>
|
<$declareStandardTransform()$>
|
||||||
|
|
||||||
|
@ -53,12 +54,12 @@ uniform float fScaleOverScaleDepth; // fScale / fScaleDepth
|
||||||
const int nSamples = 2;
|
const int nSamples = 2;
|
||||||
const float fSamples = 2.0;
|
const float fSamples = 2.0;
|
||||||
|
|
||||||
varying vec3 position;
|
out vec3 position;
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
// Get the ray from the camera to the vertex, and its length (which is the far point of the ray passing through the atmosphere)
|
// Get the ray from the camera to the vertex, and its length (which is the far point of the ray passing through the atmosphere)
|
||||||
position = gl_Vertex.xyz * fOuterRadius;
|
position = inPosition.xyz * fOuterRadius;
|
||||||
|
|
||||||
// standard transform
|
// standard transform
|
||||||
TransformCamera cam = getTransformCamera();
|
TransformCamera cam = getTransformCamera();
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#version 120
|
<@include gpu/Config.slh@>
|
||||||
|
<$VERSION_HEADER$>
|
||||||
|
|
||||||
//
|
//
|
||||||
// For licensing information, see http://http.developer.nvidia.com/GPUGems/gpugems_app01.html:
|
// For licensing information, see http://http.developer.nvidia.com/GPUGems/gpugems_app01.html:
|
||||||
|
@ -53,7 +54,9 @@ uniform float g2;
|
||||||
const int nSamples = 2;
|
const int nSamples = 2;
|
||||||
const float fSamples = 2.0;
|
const float fSamples = 2.0;
|
||||||
|
|
||||||
varying vec3 position;
|
in vec3 position;
|
||||||
|
|
||||||
|
out vec4 outFragColor;
|
||||||
|
|
||||||
float scale(float fCos)
|
float scale(float fCos)
|
||||||
{
|
{
|
||||||
|
@ -110,6 +113,6 @@ void main (void)
|
||||||
vec3 secondaryColor = v3FrontColor * fKmESun;
|
vec3 secondaryColor = v3FrontColor * fKmESun;
|
||||||
|
|
||||||
vec3 finalColor = color + fMiePhase * secondaryColor;
|
vec3 finalColor = color + fMiePhase * secondaryColor;
|
||||||
gl_FragColor.a = finalColor.b;
|
outFragColor.a = finalColor.b;
|
||||||
gl_FragColor.rgb = pow(finalColor.rgb, vec3(1.0/2.2));
|
outFragColor.rgb = pow(finalColor.rgb, vec3(1.0/2.2));
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,16 +33,17 @@
|
||||||
// Copyright (c) 2004 Sean O'Neil
|
// Copyright (c) 2004 Sean O'Neil
|
||||||
//
|
//
|
||||||
|
|
||||||
|
<@include gpu/Inputs.slh@>
|
||||||
<@include gpu/Transform.slh@>
|
<@include gpu/Transform.slh@>
|
||||||
<$declareStandardTransform()$>
|
<$declareStandardTransform()$>
|
||||||
|
|
||||||
uniform float fOuterRadius; // The outer (atmosphere) radius
|
uniform float fOuterRadius; // The outer (atmosphere) radius
|
||||||
|
|
||||||
varying vec3 position;
|
out vec3 position;
|
||||||
|
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
position = gl_Vertex.xyz * fOuterRadius;
|
position = inPosition.xyz * fOuterRadius;
|
||||||
|
|
||||||
// standard transform
|
// standard transform
|
||||||
TransformCamera cam = getTransformCamera();
|
TransformCamera cam = getTransformCamera();
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
// Based on NVidia HBAO implementation in D3D11
|
// Based on NVidia HBAO implementation in D3D11
|
||||||
// http://www.nvidia.co.uk/object/siggraph-2008-HBAO.html
|
// http://www.nvidia.co.uk/object/siggraph-2008-HBAO.html
|
||||||
|
|
||||||
varying vec2 varTexcoord;
|
in vec2 varTexcoord;
|
||||||
|
|
||||||
uniform sampler2D depthTexture;
|
uniform sampler2D depthTexture;
|
||||||
uniform sampler2D normalTexture;
|
uniform sampler2D normalTexture;
|
||||||
|
@ -47,12 +47,15 @@ const float AOStrength = 1.9;
|
||||||
const float R = 0.3;
|
const float R = 0.3;
|
||||||
const float R2 = 0.3*0.3;
|
const float R2 = 0.3*0.3;
|
||||||
const float NegInvR2 = - 1.0 / (0.3*0.3);
|
const float NegInvR2 = - 1.0 / (0.3*0.3);
|
||||||
const float TanBias = tan(30.0 * PI / 180.0);
|
// can't use tan to initialize a const value
|
||||||
|
const float TanBias = 0.57735027; // tan(30.0 * PI / 180.0);
|
||||||
const float MaxRadiusPixels = 50.0;
|
const float MaxRadiusPixels = 50.0;
|
||||||
|
|
||||||
const int NumDirections = 6;
|
const int NumDirections = 6;
|
||||||
const int NumSamples = 4;
|
const int NumSamples = 4;
|
||||||
|
|
||||||
|
out vec4 outFragColor;
|
||||||
|
|
||||||
float ViewSpaceZFromDepth(float d){
|
float ViewSpaceZFromDepth(float d){
|
||||||
// [0,1] -> [-1,1] clip space
|
// [0,1] -> [-1,1] clip space
|
||||||
d = d * 2.0 - 1.0;
|
d = d * 2.0 - 1.0;
|
||||||
|
@ -67,14 +70,14 @@ vec3 UVToViewSpace(vec2 uv, float z){
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 GetViewPos(vec2 uv){
|
vec3 GetViewPos(vec2 uv){
|
||||||
float z = ViewSpaceZFromDepth(texture2D(depthTexture, uv).r);
|
float z = ViewSpaceZFromDepth(texture(depthTexture, uv).r);
|
||||||
return UVToViewSpace(uv, z);
|
return UVToViewSpace(uv, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 GetViewPosPoint(ivec2 uv){
|
vec3 GetViewPosPoint(ivec2 uv){
|
||||||
vec2 coord = vec2(gl_FragCoord.xy) + uv;
|
vec2 coord = vec2(gl_FragCoord.xy) + uv;
|
||||||
//float z = texelFetch(texture0, coord, 0).r;
|
//float z = texelFetch(texture0, coord, 0).r;
|
||||||
float z = texture2D(depthTexture, uv).r;
|
float z = texture(depthTexture, uv).r;
|
||||||
return UVToViewSpace(uv, z);
|
return UVToViewSpace(uv, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,5 +244,5 @@ void main(void){
|
||||||
ao = 1.0 - ao / numDirections * AOStrength;
|
ao = 1.0 - ao / numDirections * AOStrength;
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_FragColor = vec4(vec3(ao), 1.0);
|
outFragColor = vec4(vec3(ao), 1.0);
|
||||||
}
|
}
|
|
@ -12,13 +12,15 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
<@include gpu/Inputs.slh@>
|
||||||
|
|
||||||
<@include gpu/Transform.slh@>
|
<@include gpu/Transform.slh@>
|
||||||
|
|
||||||
<$declareStandardTransform()$>
|
<$declareStandardTransform()$>
|
||||||
|
|
||||||
varying vec2 varTexcoord;
|
out vec2 varTexcoord;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
varTexcoord = gl_MultiTexCoord0.xy;
|
varTexcoord = inTexCoord0.xy;
|
||||||
gl_Position = gl_Vertex;
|
gl_Position = inPosition;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
uniform mat4 texcoordMat;
|
uniform mat4 texcoordMat;
|
||||||
|
|
||||||
|
out vec4 _texCoord0;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
// standard transform
|
// standard transform
|
||||||
TransformCamera cam = getTransformCamera();
|
TransformCamera cam = getTransformCamera();
|
||||||
|
@ -27,6 +29,6 @@ void main(void) {
|
||||||
<$transformModelToClipPos(cam, obj, inPosition, gl_Position)$>;
|
<$transformModelToClipPos(cam, obj, inPosition, gl_Position)$>;
|
||||||
|
|
||||||
vec4 projected = gl_Position / gl_Position.w;
|
vec4 projected = gl_Position / gl_Position.w;
|
||||||
gl_TexCoord[0] = vec4(dot(projected, texcoordMat[0]) * gl_Position.w,
|
_texCoord0 = vec4(dot(projected, texcoordMat[0]) * gl_Position.w,
|
||||||
dot(projected, texcoordMat[1]) * gl_Position.w, 0.0, gl_Position.w);
|
dot(projected, texcoordMat[1]) * gl_Position.w, 0.0, gl_Position.w);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
<@include gpu/Inputs.slh@>
|
||||||
|
|
||||||
<@include gpu/Transform.slh@>
|
<@include gpu/Transform.slh@>
|
||||||
|
|
||||||
<$declareStandardTransform()$>
|
<$declareStandardTransform()$>
|
||||||
|
@ -19,8 +21,10 @@
|
||||||
uniform mat4 texcoordMat;
|
uniform mat4 texcoordMat;
|
||||||
uniform vec4 coneParam;
|
uniform vec4 coneParam;
|
||||||
|
|
||||||
|
out vec4 _texCoord0;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec4 coneVertex = gl_Vertex;
|
vec4 coneVertex = inPosition;
|
||||||
if (coneParam.w != 0.0) {
|
if (coneParam.w != 0.0) {
|
||||||
if(coneVertex.z >= 0.0) {
|
if(coneVertex.z >= 0.0) {
|
||||||
// Evaluate the true position of the spot volume
|
// Evaluate the true position of the spot volume
|
||||||
|
@ -42,6 +46,6 @@ void main(void) {
|
||||||
<$transformModelToClipPos(cam, obj, coneVertex, gl_Position)$>;
|
<$transformModelToClipPos(cam, obj, coneVertex, gl_Position)$>;
|
||||||
|
|
||||||
vec4 projected = gl_Position / gl_Position.w;
|
vec4 projected = gl_Position / gl_Position.w;
|
||||||
gl_TexCoord[0] = vec4(dot(projected, texcoordMat[0]) * gl_Position.w,
|
_texCoord0 = vec4(dot(projected, texcoordMat[0]) * gl_Position.w,
|
||||||
dot(projected, texcoordMat[1]) * gl_Position.w, 0.0, gl_Position.w);
|
dot(projected, texcoordMat[1]) * gl_Position.w, 0.0, gl_Position.w);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,28 +15,29 @@
|
||||||
<@include DeferredBufferWrite.slh@>
|
<@include DeferredBufferWrite.slh@>
|
||||||
|
|
||||||
// the interpolated normal
|
// the interpolated normal
|
||||||
//varying vec4 interpolatedNormal;
|
//in vec4 interpolatedNormal;
|
||||||
|
|
||||||
varying vec2 varTexcoord;
|
in vec2 varTexcoord;
|
||||||
varying vec2 varBlurTexcoords[14];
|
in vec2 varBlurTexcoords[14];
|
||||||
|
|
||||||
uniform sampler2D occlusionTexture;
|
uniform sampler2D occlusionTexture;
|
||||||
|
|
||||||
|
out vec4 outFragColor;
|
||||||
void main(void) {
|
void main(void) {
|
||||||
gl_FragColor = vec4(0.0);
|
outFragColor = vec4(0.0);
|
||||||
gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[0])*0.0044299121055113265;
|
outFragColor += texture(occlusionTexture, varBlurTexcoords[0])*0.0044299121055113265;
|
||||||
gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[1])*0.00895781211794;
|
outFragColor += texture(occlusionTexture, varBlurTexcoords[1])*0.00895781211794;
|
||||||
gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[2])*0.0215963866053;
|
outFragColor += texture(occlusionTexture, varBlurTexcoords[2])*0.0215963866053;
|
||||||
gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[3])*0.0443683338718;
|
outFragColor += texture(occlusionTexture, varBlurTexcoords[3])*0.0443683338718;
|
||||||
gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[4])*0.0776744219933;
|
outFragColor += texture(occlusionTexture, varBlurTexcoords[4])*0.0776744219933;
|
||||||
gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[5])*0.115876621105;
|
outFragColor += texture(occlusionTexture, varBlurTexcoords[5])*0.115876621105;
|
||||||
gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[6])*0.147308056121;
|
outFragColor += texture(occlusionTexture, varBlurTexcoords[6])*0.147308056121;
|
||||||
gl_FragColor += texture2D(occlusionTexture, varTexcoord)*0.159576912161;
|
outFragColor += texture(occlusionTexture, varTexcoord)*0.159576912161;
|
||||||
gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[7])*0.147308056121;
|
outFragColor += texture(occlusionTexture, varBlurTexcoords[7])*0.147308056121;
|
||||||
gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[8])*0.115876621105;
|
outFragColor += texture(occlusionTexture, varBlurTexcoords[8])*0.115876621105;
|
||||||
gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[9])*0.0776744219933;
|
outFragColor += texture(occlusionTexture, varBlurTexcoords[9])*0.0776744219933;
|
||||||
gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[10])*0.0443683338718;
|
outFragColor += texture(occlusionTexture, varBlurTexcoords[10])*0.0443683338718;
|
||||||
gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[11])*0.0215963866053;
|
outFragColor += texture(occlusionTexture, varBlurTexcoords[11])*0.0215963866053;
|
||||||
gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[12])*0.00895781211794;
|
outFragColor += texture(occlusionTexture, varBlurTexcoords[12])*0.00895781211794;
|
||||||
gl_FragColor += texture2D(occlusionTexture, varBlurTexcoords[13])*0.0044299121055113265;
|
outFragColor += texture(occlusionTexture, varBlurTexcoords[13])*0.0044299121055113265;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,16 +12,18 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
<@include gpu/Inputs.slh@>
|
||||||
|
|
||||||
<@include gpu/Transform.slh@>
|
<@include gpu/Transform.slh@>
|
||||||
|
|
||||||
<$declareStandardTransform()$>
|
<$declareStandardTransform()$>
|
||||||
|
|
||||||
varying vec2 varTexcoord;
|
out vec2 varTexcoord;
|
||||||
varying vec2 varBlurTexcoords[14];
|
out vec2 varBlurTexcoords[14];
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
varTexcoord = gl_MultiTexCoord0.xy;
|
varTexcoord = inTexCoord0.xy;
|
||||||
gl_Position = gl_Vertex;
|
gl_Position = inPosition;
|
||||||
|
|
||||||
varBlurTexcoords[0] = varTexcoord + vec2(-0.028, 0.0);
|
varBlurTexcoords[0] = varTexcoord + vec2(-0.028, 0.0);
|
||||||
varBlurTexcoords[1] = varTexcoord + vec2(-0.024, 0.0);
|
varBlurTexcoords[1] = varTexcoord + vec2(-0.024, 0.0);
|
||||||
|
|
|
@ -12,16 +12,18 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
<@include gpu/Inputs.slh@>
|
||||||
|
|
||||||
<@include gpu/Transform.slh@>
|
<@include gpu/Transform.slh@>
|
||||||
|
|
||||||
<$declareStandardTransform()$>
|
<$declareStandardTransform()$>
|
||||||
|
|
||||||
varying vec2 varTexcoord;
|
out vec2 varTexcoord;
|
||||||
varying vec2 varBlurTexcoords[14];
|
out vec2 varBlurTexcoords[14];
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
varTexcoord = gl_MultiTexCoord0.xy;
|
varTexcoord = inTexCoord0.xy;
|
||||||
gl_Position = gl_Vertex;
|
gl_Position = inPosition;
|
||||||
|
|
||||||
varBlurTexcoords[0] = varTexcoord + vec2(0.0, -0.028);
|
varBlurTexcoords[0] = varTexcoord + vec2(0.0, -0.028);
|
||||||
varBlurTexcoords[1] = varTexcoord + vec2(0.0, -0.024);
|
varBlurTexcoords[1] = varTexcoord + vec2(0.0, -0.024);
|
||||||
|
|
|
@ -14,11 +14,12 @@
|
||||||
|
|
||||||
<@include DeferredBufferWrite.slh@>
|
<@include DeferredBufferWrite.slh@>
|
||||||
|
|
||||||
varying vec2 varQuadPosition;
|
in vec2 varQuadPosition;
|
||||||
|
out vec4 outFragColor;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec2 center = vec2(0.0, 0.0);
|
vec2 center = vec2(0.0, 0.0);
|
||||||
float distFromCenter = distance( vec2(0.0, 0.0), varQuadPosition);
|
float distFromCenter = distance( vec2(0.0, 0.0), varQuadPosition);
|
||||||
float alpha = mix(0.0, 0.5, pow(distFromCenter,5.));
|
float alpha = mix(0.0, 0.5, pow(distFromCenter,5.));
|
||||||
gl_FragColor = vec4(1.0, 0.0, 0.0, alpha);
|
outFragColor = vec4(1.0, 0.0, 0.0, alpha);
|
||||||
}
|
}
|
|
@ -12,13 +12,15 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
<@include gpu/Inputs.slh@>
|
||||||
|
|
||||||
<@include gpu/Transform.slh@>
|
<@include gpu/Transform.slh@>
|
||||||
|
|
||||||
<$declareStandardTransform()$>
|
<$declareStandardTransform()$>
|
||||||
|
|
||||||
varying vec2 varQuadPosition;
|
out vec2 varQuadPosition;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
varQuadPosition = gl_Vertex.xy;
|
varQuadPosition = inPosition.xy;
|
||||||
gl_Position = gl_Vertex;
|
gl_Position = inPosition;
|
||||||
}
|
}
|
|
@ -19,7 +19,7 @@
|
||||||
uniform sampler2D diffuseMap;
|
uniform sampler2D diffuseMap;
|
||||||
|
|
||||||
in vec4 _position;
|
in vec4 _position;
|
||||||
in vec4 _normal;
|
in vec3 _normal;
|
||||||
in vec3 _color;
|
in vec3 _color;
|
||||||
in vec2 _texCoord0;
|
in vec2 _texCoord0;
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,9 @@ uniform sampler2D diffuseMap;
|
||||||
uniform sampler2D normalMap;
|
uniform sampler2D normalMap;
|
||||||
|
|
||||||
in vec4 _position;
|
in vec4 _position;
|
||||||
in vec4 _texCoord0;
|
in vec2 _texCoord0;
|
||||||
in vec4 _normal;
|
in vec3 _normal;
|
||||||
in vec4 _tangent;
|
in vec3 _tangent;
|
||||||
in vec3 _color;
|
in vec3 _color;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
|
|
|
@ -36,13 +36,13 @@ void main(void) {
|
||||||
vec3 normalizedNormal = normalize(_normal);
|
vec3 normalizedNormal = normalize(_normal);
|
||||||
vec3 normalizedTangent = normalize(_tangent);
|
vec3 normalizedTangent = normalize(_tangent);
|
||||||
vec3 normalizedBitangent = normalize(cross(normalizedNormal, normalizedTangent));
|
vec3 normalizedBitangent = normalize(cross(normalizedNormal, normalizedTangent));
|
||||||
vec3 localNormal = normalize(vec3(texture2D(normalMap, _texCoord0)) - vec3(0.5, 0.5, 0.5));
|
vec3 localNormal = normalize(vec3(texture(normalMap, _texCoord0)) - vec3(0.5, 0.5, 0.5));
|
||||||
vec4 viewNormal = vec4(normalizedTangent * localNormal.x +
|
vec4 viewNormal = vec4(normalizedTangent * localNormal.x +
|
||||||
normalizedBitangent * localNormal.y + normalizedNormal * localNormal.z, 0.0);
|
normalizedBitangent * localNormal.y + normalizedNormal * localNormal.z, 0.0);
|
||||||
|
|
||||||
// set the diffuse, normal, specular data
|
// set the diffuse, normal, specular data
|
||||||
vec4 diffuse = texture2D(diffuseMap, _texCoord0);
|
vec4 diffuse = texture(diffuseMap, _texCoord0);
|
||||||
vec3 specular = texture2D(specularMap, _texCoord0).rgb;
|
vec3 specular = texture(specularMap, _texCoord0).rgb;
|
||||||
|
|
||||||
Material mat = getMaterial();
|
Material mat = getMaterial();
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,14 @@
|
||||||
|
|
||||||
<@include DeferredBufferWrite.slh@>
|
<@include DeferredBufferWrite.slh@>
|
||||||
|
|
||||||
varying vec2 varTexcoord;
|
in vec2 varTexcoord;
|
||||||
|
out vec4 outFragColor;
|
||||||
|
|
||||||
uniform sampler2D blurredOcclusionTexture;
|
uniform sampler2D blurredOcclusionTexture;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec4 occlusionColor = texture2D(blurredOcclusionTexture, varTexcoord);
|
vec4 occlusionColor = texture(blurredOcclusionTexture, varTexcoord);
|
||||||
|
|
||||||
gl_FragColor = vec4(vec3(0.0), occlusionColor.r);
|
outFragColor = vec4(vec3(0.0), occlusionColor.r);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,17 +13,18 @@
|
||||||
|
|
||||||
uniform sampler2D diffuseMap;
|
uniform sampler2D diffuseMap;
|
||||||
|
|
||||||
varying vec2 varTexcoord;
|
in vec2 varTexcoord;
|
||||||
|
|
||||||
varying vec3 varEyeNormal;
|
in vec3 varEyeNormal;
|
||||||
|
|
||||||
varying vec4 varColor;
|
in vec4 varColor;
|
||||||
|
out vec4 outFragColor;
|
||||||
|
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec4 diffuse = texture2D(diffuseMap, varTexcoord.st);
|
vec4 diffuse = texture(diffuseMap, varTexcoord.st);
|
||||||
if (diffuse.a < 0.5) {
|
if (diffuse.a < 0.5) {
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
gl_FragColor = vec4(varColor * diffuse);
|
outFragColor = vec4(varColor * diffuse);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,31 +10,31 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
<@include gpu/Inputs.slh@>
|
||||||
|
|
||||||
<@include gpu/Transform.slh@>
|
<@include gpu/Transform.slh@>
|
||||||
|
|
||||||
<$declareStandardTransform()$>
|
<$declareStandardTransform()$>
|
||||||
|
|
||||||
//attribute vec2 texcoord;
|
out vec2 varTexcoord;
|
||||||
|
|
||||||
varying vec2 varTexcoord;
|
|
||||||
|
|
||||||
// interpolated eye position
|
// interpolated eye position
|
||||||
varying vec4 varEyePosition;
|
out vec4 varEyePosition;
|
||||||
|
|
||||||
// the interpolated normal
|
// the interpolated normal
|
||||||
varying vec3 varEyeNormal;
|
out vec3 varEyeNormal;
|
||||||
|
|
||||||
varying vec4 varColor;
|
out vec4 varColor;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
varTexcoord = gl_MultiTexCoord0.xy;
|
varTexcoord = inTexCoord0.xy;
|
||||||
|
|
||||||
// pass along the color
|
// pass along the color
|
||||||
varColor = gl_Color;
|
varColor = inColor;
|
||||||
|
|
||||||
// standard transform
|
// standard transform
|
||||||
TransformCamera cam = getTransformCamera();
|
TransformCamera cam = getTransformCamera();
|
||||||
TransformObject obj = getTransformObject();
|
TransformObject obj = getTransformObject();
|
||||||
<$transformModelToEyeAndClipPos(cam, obj, gl_Vertex, varEyePosition, gl_Position)$>
|
<$transformModelToEyeAndClipPos(cam, obj, inPosition, varEyePosition, gl_Position)$>
|
||||||
<$transformModelToEyeDir(cam, obj, gl_Normal, varEyeNormal.xyz)$>
|
<$transformModelToEyeDir(cam, obj, inNormal.xyz, varEyeNormal.xyz)$>
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,8 @@ uniform bool Outline;
|
||||||
uniform vec4 Color;
|
uniform vec4 Color;
|
||||||
|
|
||||||
// the interpolated normal
|
// the interpolated normal
|
||||||
varying vec4 interpolatedNormal;
|
in vec3 _normal;
|
||||||
|
in vec2 _texCoord0;
|
||||||
|
|
||||||
const float gamma = 2.2;
|
const float gamma = 2.2;
|
||||||
const float smoothing = 256.0;
|
const float smoothing = 256.0;
|
||||||
|
@ -24,7 +25,7 @@ const float outlineExpansion = 0.2;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
// retrieve signed distance
|
// retrieve signed distance
|
||||||
float sdf = texture2D(Font, gl_TexCoord[0].xy).g;
|
float sdf = texture(Font, gl_TexCoord[0].xy).g;
|
||||||
if (Outline) {
|
if (Outline) {
|
||||||
if (sdf > interiorCutoff) {
|
if (sdf > interiorCutoff) {
|
||||||
sdf = 1.0 - sdf;
|
sdf = 1.0 - sdf;
|
||||||
|
@ -47,6 +48,6 @@ void main() {
|
||||||
|
|
||||||
// final color
|
// final color
|
||||||
gl_FragData[0] = vec4(Color.rgb, Color.a * a);
|
gl_FragData[0] = vec4(Color.rgb, Color.a * a);
|
||||||
gl_FragData[1] = vec4(normalize(interpolatedNormal.xyz), 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 0.5);
|
gl_FragData[1] = vec4(normalize(_normal.xyz), 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 0.5);
|
||||||
gl_FragData[2] = vec4(Color.rgb, gl_FrontMaterial.shininess / 128.0);
|
gl_FragData[2] = vec4(Color.rgb, gl_FrontMaterial.shininess / 128.0);
|
||||||
}
|
}
|
|
@ -9,21 +9,23 @@
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
<@include gpu/Inputs.slh@>
|
||||||
|
|
||||||
<@include gpu/Transform.slh@>
|
<@include gpu/Transform.slh@>
|
||||||
|
|
||||||
<$declareStandardTransform()$>
|
<$declareStandardTransform()$>
|
||||||
|
|
||||||
// the interpolated normal
|
// the interpolated normal
|
||||||
varying vec4 interpolatedNormal;
|
out vec3 _normal;
|
||||||
|
out vec2 _texCoord0;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
_texCoord0 = inTexCoord0.xy;
|
||||||
|
|
||||||
// standard transform
|
// standard transform
|
||||||
TransformCamera cam = getTransformCamera();
|
TransformCamera cam = getTransformCamera();
|
||||||
TransformObject obj = getTransformObject();
|
TransformObject obj = getTransformObject();
|
||||||
<$transformModelToClipPos(cam, obj, gl_Vertex, gl_Position)$>
|
<$transformModelToClipPos(cam, obj, inPosition, gl_Position)$>
|
||||||
<$transformModelToEyeDir(cam, obj, gl_Normal, interpolatedNormal.xyz)$>
|
<$transformModelToEyeDir(cam, obj, inNormal.xyz, _normal.xyz)$>
|
||||||
|
|
||||||
interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0);
|
|
||||||
}
|
}
|
|
@ -18,15 +18,17 @@
|
||||||
uniform sampler2D originalTexture;
|
uniform sampler2D originalTexture;
|
||||||
|
|
||||||
// the interpolated normal
|
// the interpolated normal
|
||||||
varying vec4 interpolatedNormal;
|
in vec3 _normal;
|
||||||
|
in vec4 _texCoord0;
|
||||||
|
in vec4 _color;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec4 texel = texture2D(originalTexture, gl_TexCoord[0].st);
|
vec4 texel = texture(originalTexture, _texCoord0.st);
|
||||||
|
|
||||||
packDeferredFragmentLightmap(
|
packDeferredFragmentLightmap(
|
||||||
normalize(interpolatedNormal.xyz),
|
normalize(_normal),
|
||||||
glowIntensity * texel.a,
|
glowIntensity * texel.a,
|
||||||
gl_Color.rgb,
|
_color.rgb,
|
||||||
DEFAULT_SPECULAR, DEFAULT_SHININESS,
|
DEFAULT_SPECULAR, DEFAULT_SHININESS,
|
||||||
texel.rgb);
|
texel.rgb);
|
||||||
}
|
}
|
|
@ -35,7 +35,7 @@ void main(void) {
|
||||||
vec4 interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0);
|
vec4 interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0);
|
||||||
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
|
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
|
||||||
mat4 clusterMatrix = clusterMatrices[inSkinClusterIndex[i]];
|
mat4 clusterMatrix = clusterMatrices[inSkinClusterIndex[i]];
|
||||||
float clusterWeight = inSkinClusterWeight[i].x;
|
float clusterWeight = inSkinClusterWeight[i];
|
||||||
position += clusterMatrix * inPosition * clusterWeight;
|
position += clusterMatrix * inPosition * clusterWeight;
|
||||||
interpolatedNormal += clusterMatrix * vec4(inNormal.xyz, 0.0) * clusterWeight;
|
interpolatedNormal += clusterMatrix * vec4(inNormal.xyz, 0.0) * clusterWeight;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ void main(void) {
|
||||||
vec4 interpolatedTangent = vec4(0.0, 0.0, 0.0, 0.0);
|
vec4 interpolatedTangent = vec4(0.0, 0.0, 0.0, 0.0);
|
||||||
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
|
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
|
||||||
mat4 clusterMatrix = clusterMatrices[inSkinClusterIndex[i]];
|
mat4 clusterMatrix = clusterMatrices[inSkinClusterIndex[i]];
|
||||||
float clusterWeight = inSkinClusterWeight[i].x;
|
float clusterWeight = inSkinClusterWeight[i];
|
||||||
position += clusterMatrix * inPosition * clusterWeight;
|
position += clusterMatrix * inPosition * clusterWeight;
|
||||||
interpolatedNormal += clusterMatrix * vec4(inNormal.xyz, 0.0) * clusterWeight;
|
interpolatedNormal += clusterMatrix * vec4(inNormal.xyz, 0.0) * clusterWeight;
|
||||||
interpolatedTangent += clusterMatrix * vec4(inTangent.xyz, 0.0) * clusterWeight;
|
interpolatedTangent += clusterMatrix * vec4(inTangent.xyz, 0.0) * clusterWeight;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
<@include gpu/Inputs.slh@>
|
||||||
<@include gpu/Transform.slh@>
|
<@include gpu/Transform.slh@>
|
||||||
<$declareStandardTransform()$>
|
<$declareStandardTransform()$>
|
||||||
|
|
||||||
|
@ -20,15 +21,12 @@ const int INDICES_PER_VERTEX = 4;
|
||||||
|
|
||||||
uniform mat4 clusterMatrices[MAX_CLUSTERS];
|
uniform mat4 clusterMatrices[MAX_CLUSTERS];
|
||||||
|
|
||||||
attribute vec4 clusterIndices;
|
|
||||||
attribute vec4 clusterWeights;
|
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
|
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
|
||||||
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
|
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
|
||||||
mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])];
|
mat4 clusterMatrix = clusterMatrices[inSkinClusterIndex[i]];
|
||||||
float clusterWeight = clusterWeights[i];
|
float clusterWeight = inSkinClusterWeight[i];
|
||||||
position += clusterMatrix * gl_Vertex * clusterWeight;
|
position += clusterMatrix * inPosition * clusterWeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
// standard transform
|
// standard transform
|
||||||
|
|
|
@ -23,5 +23,9 @@ out vec4 _fragColor;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec4 color = texture(colorMap, _texCoord0);
|
vec4 color = texture(colorMap, _texCoord0);
|
||||||
_fragColor = color * _color;
|
// FIXME CORE this isn't working
|
||||||
|
//_fragColor = color * _color;
|
||||||
|
//_fragColor = vec4(color.rgb, color.a * _color.a);
|
||||||
|
//_fragColor = vec4(color.rgb * _color.rgb, color.a);
|
||||||
|
_fragColor = color;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,9 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
varying vec4 varColor;
|
in vec4 varColor;
|
||||||
|
out vec4 outFragColor;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
gl_FragColor = varColor; //vec4(varColor, 1.0);
|
outFragColor = varColor; //vec4(varColor, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,21 +12,23 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
<@include gpu/Inputs.slh@>
|
||||||
|
|
||||||
<@include gpu/Transform.slh@>
|
<@include gpu/Transform.slh@>
|
||||||
|
|
||||||
<$declareStandardTransform()$>
|
<$declareStandardTransform()$>
|
||||||
|
|
||||||
varying vec3 varPosition;
|
out vec3 varPosition;
|
||||||
varying vec4 varColor;
|
out vec4 varColor;
|
||||||
|
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
varColor = gl_Color.rgba;
|
varColor = inColor.rgba;
|
||||||
|
|
||||||
// standard transform
|
// standard transform
|
||||||
TransformCamera cam = getTransformCamera();
|
TransformCamera cam = getTransformCamera();
|
||||||
TransformObject obj = getTransformObject();
|
TransformObject obj = getTransformObject();
|
||||||
<$transformModelToClipPos(cam, obj, gl_Vertex, gl_Position)$>
|
<$transformModelToClipPos(cam, obj, inPosition, gl_Position)$>
|
||||||
varPosition = gl_Vertex.xyz;
|
varPosition = inPosition.xyz;
|
||||||
gl_PointSize = gl_Color.a;
|
gl_PointSize = inColor.a;
|
||||||
}
|
}
|
|
@ -7,9 +7,9 @@
|
||||||
//
|
//
|
||||||
// Created by Bradley Austin Davis on 2015/06/19
|
// Created by Bradley Austin Davis on 2015/06/19
|
||||||
|
|
||||||
varying vec2 varTexcoord;
|
in vec2 varTexcoord;
|
||||||
varying vec3 varNomral;
|
in vec3 varNomral;
|
||||||
varying vec3 varPosition;
|
in vec3 varPosition;
|
||||||
|
|
||||||
uniform float iGlobalTime;
|
uniform float iGlobalTime;
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ const float latitudeDist = PI / 2.0 / float(latitudeCount);
|
||||||
const int meridianCount = 4;
|
const int meridianCount = 4;
|
||||||
const float merdianDist = PI / float(meridianCount);
|
const float merdianDist = PI / float(meridianCount);
|
||||||
|
|
||||||
|
out vec4 outFragColor;
|
||||||
|
|
||||||
float clampLine(float val, float target) {
|
float clampLine(float val, float target) {
|
||||||
return clamp((1.0 - abs((val - target)) - 0.998) * 500.0, 0.0, 1.0);
|
return clamp((1.0 - abs((val - target)) - 0.998) * 500.0, 0.0, 1.0);
|
||||||
|
@ -58,6 +59,6 @@ void mainVR( out vec4 fragColor, in vec2 fragCoord, in vec3 fragRayOri, in vec3
|
||||||
}
|
}
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
mainVR(gl_FragColor, gl_FragCoord.xy, vec3(0.0), normalize(varPosition));
|
mainVR(outFragColor, gl_FragCoord.xy, vec3(0.0), normalize(varPosition));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,12 @@ struct TextureVertex {
|
||||||
TextureVertex(const glm::vec2& pos, const glm::vec2& tex) : pos(pos), tex(tex) {}
|
TextureVertex(const glm::vec2& pos, const glm::vec2& tex) : pos(pos), tex(tex) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const int NUMBER_OF_INDICES_PER_QUAD = 6; // 1 quad = 2 triangles
|
||||||
|
static const int VERTICES_PER_QUAD = 4; // 1 quad = 4 vertices
|
||||||
|
|
||||||
struct QuadBuilder {
|
struct QuadBuilder {
|
||||||
TextureVertex vertices[4];
|
TextureVertex vertices[VERTICES_PER_QUAD];
|
||||||
|
|
||||||
QuadBuilder(const glm::vec2& min, const glm::vec2& size,
|
QuadBuilder(const glm::vec2& min, const glm::vec2& size,
|
||||||
const glm::vec2& texMin, const glm::vec2& texSize) {
|
const glm::vec2& texMin, const glm::vec2& texSize) {
|
||||||
// min = bottomLeft
|
// min = bottomLeft
|
||||||
|
@ -27,10 +31,10 @@ struct QuadBuilder {
|
||||||
texMin + glm::vec2(0.0f, texSize.y));
|
texMin + glm::vec2(0.0f, texSize.y));
|
||||||
vertices[1] = TextureVertex(min + glm::vec2(size.x, 0.0f),
|
vertices[1] = TextureVertex(min + glm::vec2(size.x, 0.0f),
|
||||||
texMin + texSize);
|
texMin + texSize);
|
||||||
vertices[2] = TextureVertex(min + size,
|
vertices[2] = TextureVertex(min + glm::vec2(0.0f, size.y),
|
||||||
texMin + glm::vec2(texSize.x, 0.0f));
|
|
||||||
vertices[3] = TextureVertex(min + glm::vec2(0.0f, size.y),
|
|
||||||
texMin);
|
texMin);
|
||||||
|
vertices[3] = TextureVertex(min + size,
|
||||||
|
texMin + glm::vec2(texSize.x, 0.0f));
|
||||||
}
|
}
|
||||||
QuadBuilder(const Glyph& glyph, const glm::vec2& offset) :
|
QuadBuilder(const Glyph& glyph, const glm::vec2& offset) :
|
||||||
QuadBuilder(offset + glm::vec2(glyph.offset.x, glyph.offset.y - glyph.size.y), glyph.size,
|
QuadBuilder(offset + glm::vec2(glyph.offset.x, glyph.offset.y - glyph.size.y), glyph.size,
|
||||||
|
@ -249,6 +253,9 @@ void Font::setupGPU() {
|
||||||
void Font::rebuildVertices(float x, float y, const QString& str, const glm::vec2& bounds) {
|
void Font::rebuildVertices(float x, float y, const QString& str, const glm::vec2& bounds) {
|
||||||
_verticesBuffer = std::make_shared<gpu::Buffer>();
|
_verticesBuffer = std::make_shared<gpu::Buffer>();
|
||||||
_numVertices = 0;
|
_numVertices = 0;
|
||||||
|
_indicesBuffer = std::make_shared<gpu::Buffer>();
|
||||||
|
_numIndices = 0;
|
||||||
|
|
||||||
_lastStringRendered = str;
|
_lastStringRendered = str;
|
||||||
_lastBounds = bounds;
|
_lastBounds = bounds;
|
||||||
|
|
||||||
|
@ -284,11 +291,29 @@ void Font::rebuildVertices(float x, float y, const QString& str, const glm::vec2
|
||||||
if (!isNewLine) {
|
if (!isNewLine) {
|
||||||
for (auto c : token) {
|
for (auto c : token) {
|
||||||
auto glyph = _glyphs[c];
|
auto glyph = _glyphs[c];
|
||||||
|
quint16 verticesOffset = _numVertices;
|
||||||
|
|
||||||
QuadBuilder qd(glyph, advance - glm::vec2(0.0f, _ascent));
|
QuadBuilder qd(glyph, advance - glm::vec2(0.0f, _ascent));
|
||||||
_verticesBuffer->append(sizeof(QuadBuilder), (const gpu::Byte*)&qd);
|
_verticesBuffer->append(sizeof(QuadBuilder), (const gpu::Byte*)&qd);
|
||||||
_numVertices += 4;
|
_numVertices += 4;
|
||||||
|
|
||||||
|
// Sam's recommended triangle slices
|
||||||
|
// Triangle tri1 = { v0, v1, v3 };
|
||||||
|
// Triangle tri2 = { v1, v2, v3 };
|
||||||
|
// NOTE: Random guy on the internet's recommended triangle slices
|
||||||
|
// Triangle tri1 = { v0, v1, v2 };
|
||||||
|
// Triangle tri2 = { v2, v3, v0 };
|
||||||
|
quint16 indices[NUMBER_OF_INDICES_PER_QUAD];
|
||||||
|
indices[0] = verticesOffset + 0;
|
||||||
|
indices[1] = verticesOffset + 1;
|
||||||
|
indices[2] = verticesOffset + 3;
|
||||||
|
indices[3] = verticesOffset + 1;
|
||||||
|
indices[4] = verticesOffset + 2;
|
||||||
|
indices[5] = verticesOffset + 3;
|
||||||
|
_indicesBuffer->append(sizeof(indices), (const gpu::Byte*)indices);
|
||||||
|
_numIndices += NUMBER_OF_INDICES_PER_QUAD;
|
||||||
|
|
||||||
|
|
||||||
// Advance by glyph size
|
// Advance by glyph size
|
||||||
advance.x += glyph.d;
|
advance.x += glyph.d;
|
||||||
}
|
}
|
||||||
|
@ -318,5 +343,6 @@ void Font::drawString(gpu::Batch& batch, float x, float y, const QString& str, c
|
||||||
|
|
||||||
batch.setInputFormat(_format);
|
batch.setInputFormat(_format);
|
||||||
batch.setInputBuffer(0, _verticesBuffer, 0, _format->getChannels().at(0)._stride);
|
batch.setInputBuffer(0, _verticesBuffer, 0, _format->getChannels().at(0)._stride);
|
||||||
batch.draw(gpu::QUADS, _numVertices, 0);
|
batch.setIndexBuffer(gpu::UINT16, _indicesBuffer, 0);
|
||||||
|
batch.drawIndexed(gpu::TRIANGLES, _numIndices, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,8 +64,10 @@ private:
|
||||||
gpu::TexturePointer _texture;
|
gpu::TexturePointer _texture;
|
||||||
gpu::Stream::FormatPointer _format;
|
gpu::Stream::FormatPointer _format;
|
||||||
gpu::BufferPointer _verticesBuffer;
|
gpu::BufferPointer _verticesBuffer;
|
||||||
|
gpu::BufferPointer _indicesBuffer;
|
||||||
gpu::BufferStreamPointer _stream;
|
gpu::BufferStreamPointer _stream;
|
||||||
unsigned int _numVertices = 0;
|
unsigned int _numVertices = 0;
|
||||||
|
unsigned int _numIndices = 0;
|
||||||
|
|
||||||
int _fontLoc = -1;
|
int _fontLoc = -1;
|
||||||
int _outlineLoc = -1;
|
int _outlineLoc = -1;
|
||||||
|
|
|
@ -11,9 +11,10 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
varying vec4 varColor;
|
in vec4 varColor;
|
||||||
|
out vec4 outFragColor;
|
||||||
|
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
|
outFragColor = vec4(1.0, 1.0, 1.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,10 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
varying vec4 varColor;
|
in vec4 varColor;
|
||||||
|
out vec4 outFragColor;
|
||||||
|
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
gl_FragColor = varColor;
|
outFragColor = varColor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
<$declareStandardTransform()$>
|
<$declareStandardTransform()$>
|
||||||
|
|
||||||
varying vec4 varColor;
|
out vec4 varColor;
|
||||||
|
|
||||||
uniform vec3 inBoundPos;
|
uniform vec3 inBoundPos;
|
||||||
uniform vec3 inBoundDim;
|
uniform vec3 inBoundDim;
|
||||||
|
|
|
@ -5,12 +5,8 @@ set(TARGET_NAME render-utils-test)
|
||||||
setup_hifi_project(Quick Gui OpenGL)
|
setup_hifi_project(Quick Gui OpenGL)
|
||||||
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
|
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
|
||||||
|
|
||||||
#include_oglplus()
|
|
||||||
|
|
||||||
# link in the shared libraries
|
# link in the shared libraries
|
||||||
link_hifi_libraries(render-utils gpu shared)
|
link_hifi_libraries(render-utils gpu shared)
|
||||||
|
|
||||||
|
|
||||||
include_directories("${PROJECT_BINARY_DIR}/../../libraries/render-utils/")
|
|
||||||
message(${PROJECT_BINARY_DIR})
|
message(${PROJECT_BINARY_DIR})
|
||||||
copy_dlls_beside_windows_executable()
|
copy_dlls_beside_windows_executable()
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
@ -38,58 +38,9 @@
|
||||||
|
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
|
|
||||||
|
|
||||||
#include "gpu/Batch.h"
|
#include "gpu/Batch.h"
|
||||||
#include "gpu/Context.h"
|
#include "gpu/Context.h"
|
||||||
|
|
||||||
#include "../model/Skybox_vert.h"
|
|
||||||
#include "..//model/Skybox_frag.h"
|
|
||||||
|
|
||||||
#include "simple_vert.h"
|
|
||||||
#include "simple_frag.h"
|
|
||||||
#include "simple_textured_frag.h"
|
|
||||||
|
|
||||||
#include "deferred_light_vert.h"
|
|
||||||
#include "deferred_light_limited_vert.h"
|
|
||||||
|
|
||||||
#include "directional_light_frag.h"
|
|
||||||
#include "directional_light_shadow_map_frag.h"
|
|
||||||
#include "directional_light_cascaded_shadow_map_frag.h"
|
|
||||||
|
|
||||||
#include "directional_ambient_light_frag.h"
|
|
||||||
#include "directional_ambient_light_shadow_map_frag.h"
|
|
||||||
#include "directional_ambient_light_cascaded_shadow_map_frag.h"
|
|
||||||
|
|
||||||
#include "directional_skybox_light_frag.h"
|
|
||||||
#include "directional_skybox_light_shadow_map_frag.h"
|
|
||||||
#include "directional_skybox_light_cascaded_shadow_map_frag.h"
|
|
||||||
|
|
||||||
#include "point_light_frag.h"
|
|
||||||
#include "spot_light_frag.h"
|
|
||||||
|
|
||||||
#include "standardTransformPNTC_vert.h"
|
|
||||||
#include "standardDrawTexture_frag.h"
|
|
||||||
|
|
||||||
#include "model_vert.h"
|
|
||||||
#include "model_shadow_vert.h"
|
|
||||||
#include "model_normal_map_vert.h"
|
|
||||||
#include "model_lightmap_vert.h"
|
|
||||||
#include "model_lightmap_normal_map_vert.h"
|
|
||||||
#include "skin_model_vert.h"
|
|
||||||
#include "skin_model_shadow_vert.h"
|
|
||||||
#include "skin_model_normal_map_vert.h"
|
|
||||||
|
|
||||||
#include "model_frag.h"
|
|
||||||
#include "model_shadow_frag.h"
|
|
||||||
#include "model_normal_map_frag.h"
|
|
||||||
#include "model_normal_specular_map_frag.h"
|
|
||||||
#include "model_specular_map_frag.h"
|
|
||||||
#include "model_lightmap_frag.h"
|
|
||||||
#include "model_lightmap_normal_map_frag.h"
|
|
||||||
#include "model_lightmap_normal_specular_map_frag.h"
|
|
||||||
#include "model_lightmap_specular_map_frag.h"
|
|
||||||
#include "model_translucent_frag.h"
|
|
||||||
|
|
||||||
class RateCounter {
|
class RateCounter {
|
||||||
std::vector<float> times;
|
std::vector<float> times;
|
||||||
QElapsedTimer timer;
|
QElapsedTimer timer;
|
||||||
|
@ -179,7 +130,6 @@ public:
|
||||||
gpu::Context::init<gpu::GLBackend>();
|
gpu::Context::init<gpu::GLBackend>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
QOpenGLDebugLogger* logger = new QOpenGLDebugLogger(this);
|
QOpenGLDebugLogger* logger = new QOpenGLDebugLogger(this);
|
||||||
logger->initialize(); // initializes in the current context, i.e. ctx
|
logger->initialize(); // initializes in the current context, i.e. ctx
|
||||||
|
@ -252,46 +202,6 @@ void QTestWindow::draw() {
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
glViewport(0, 0, _size.width() * devicePixelRatio(), _size.height() * devicePixelRatio());
|
glViewport(0, 0, _size.width() * devicePixelRatio(), _size.height() * devicePixelRatio());
|
||||||
|
|
||||||
static std::once_flag once;
|
|
||||||
std::call_once(once, [&]{
|
|
||||||
testShaderBuild(Skybox_vert, Skybox_frag);
|
|
||||||
testShaderBuild(simple_vert, simple_frag);
|
|
||||||
testShaderBuild(simple_vert, simple_textured_frag);
|
|
||||||
testShaderBuild(deferred_light_vert, directional_light_frag);
|
|
||||||
testShaderBuild(deferred_light_vert, directional_light_shadow_map_frag);
|
|
||||||
testShaderBuild(deferred_light_vert, directional_light_cascaded_shadow_map_frag);
|
|
||||||
testShaderBuild(deferred_light_vert, directional_ambient_light_frag);
|
|
||||||
testShaderBuild(deferred_light_vert, directional_ambient_light_shadow_map_frag);
|
|
||||||
testShaderBuild(deferred_light_vert, directional_ambient_light_cascaded_shadow_map_frag);
|
|
||||||
testShaderBuild(deferred_light_vert, directional_skybox_light_frag);
|
|
||||||
testShaderBuild(deferred_light_vert, directional_skybox_light_shadow_map_frag);
|
|
||||||
testShaderBuild(deferred_light_vert, directional_skybox_light_cascaded_shadow_map_frag);
|
|
||||||
testShaderBuild(deferred_light_limited_vert, point_light_frag);
|
|
||||||
testShaderBuild(deferred_light_limited_vert, spot_light_frag);
|
|
||||||
testShaderBuild(standardTransformPNTC_vert, standardDrawTexture_frag);
|
|
||||||
|
|
||||||
testShaderBuild(model_vert, model_frag);
|
|
||||||
testShaderBuild(model_normal_map_vert, model_normal_map_frag);
|
|
||||||
testShaderBuild(model_vert, model_specular_map_frag);
|
|
||||||
testShaderBuild(model_normal_map_vert, model_normal_specular_map_frag);
|
|
||||||
testShaderBuild(model_vert, model_translucent_frag);
|
|
||||||
testShaderBuild(model_normal_map_vert, model_translucent_frag);
|
|
||||||
testShaderBuild(model_lightmap_vert, model_lightmap_frag);
|
|
||||||
testShaderBuild(model_lightmap_normal_map_vert, model_lightmap_normal_map_frag);
|
|
||||||
testShaderBuild(model_lightmap_vert, model_lightmap_specular_map_frag);
|
|
||||||
testShaderBuild(model_lightmap_normal_map_vert, model_lightmap_normal_specular_map_frag);
|
|
||||||
|
|
||||||
testShaderBuild(skin_model_vert, model_frag);
|
|
||||||
testShaderBuild(skin_model_normal_map_vert, model_normal_map_frag);
|
|
||||||
testShaderBuild(skin_model_vert, model_specular_map_frag);
|
|
||||||
testShaderBuild(skin_model_normal_map_vert, model_normal_specular_map_frag);
|
|
||||||
testShaderBuild(skin_model_vert, model_translucent_frag);
|
|
||||||
testShaderBuild(skin_model_normal_map_vert, model_translucent_frag);
|
|
||||||
|
|
||||||
testShaderBuild(model_shadow_vert, model_shadow_frag);
|
|
||||||
});
|
|
||||||
// renderText();
|
|
||||||
|
|
||||||
_context->swapBuffers(this);
|
_context->swapBuffers(this);
|
||||||
glFinish();
|
glFinish();
|
||||||
|
|
||||||
|
|
21
tests/shaders/CMakeLists.txt
Normal file
21
tests/shaders/CMakeLists.txt
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
set(TARGET_NAME shaders-test)
|
||||||
|
|
||||||
|
# This is not a testcase -- just set it up as a regular hifi project
|
||||||
|
setup_hifi_project(Quick Gui OpenGL)
|
||||||
|
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
|
||||||
|
|
||||||
|
#include_oglplus()
|
||||||
|
|
||||||
|
# link in the shared libraries
|
||||||
|
link_hifi_libraries(shared octree environment gpu model render fbx networking entities
|
||||||
|
script-engine physics
|
||||||
|
render-utils entities-renderer)
|
||||||
|
|
||||||
|
include_directories("${PROJECT_BINARY_DIR}/../../libraries/gpu/")
|
||||||
|
include_directories("${PROJECT_BINARY_DIR}/../../libraries/render-utils/")
|
||||||
|
include_directories("${PROJECT_BINARY_DIR}/../../libraries/entities-renderer/")
|
||||||
|
include_directories("${PROJECT_BINARY_DIR}/../../libraries/model/")
|
||||||
|
|
||||||
|
message(${PROJECT_BINARY_DIR})
|
||||||
|
copy_dlls_beside_windows_executable()
|
370
tests/shaders/src/main.cpp
Normal file
370
tests/shaders/src/main.cpp
Normal file
|
@ -0,0 +1,370 @@
|
||||||
|
//
|
||||||
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <memory>
|
||||||
|
#include <mutex>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include <QWindow>
|
||||||
|
#include <QtGlobal>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QImage>
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
#include <gpu/Context.h>
|
||||||
|
#include <gpu/GLBackend.h>
|
||||||
|
|
||||||
|
#include <QOpenGLBuffer>
|
||||||
|
#include <QOpenGLContext>
|
||||||
|
#include <QOpenGLDebugLogger>
|
||||||
|
#include <QOpenGLShaderProgram>
|
||||||
|
#include <QOpenGLTexture>
|
||||||
|
#include <QOpenGLVertexArrayObject>
|
||||||
|
#include <QResizeEvent>
|
||||||
|
#include <QTime>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QWindow>
|
||||||
|
#include <QElapsedTimer>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
|
||||||
|
#include <PathUtils.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include "gpu/Batch.h"
|
||||||
|
#include "gpu/Context.h"
|
||||||
|
|
||||||
|
#include "../model/Skybox_vert.h"
|
||||||
|
#include "../model/Skybox_frag.h"
|
||||||
|
|
||||||
|
#include "simple_vert.h"
|
||||||
|
#include "simple_frag.h"
|
||||||
|
#include "simple_textured_frag.h"
|
||||||
|
|
||||||
|
#include "deferred_light_vert.h"
|
||||||
|
#include "deferred_light_limited_vert.h"
|
||||||
|
|
||||||
|
#include "directional_light_frag.h"
|
||||||
|
#include "directional_light_shadow_map_frag.h"
|
||||||
|
#include "directional_light_cascaded_shadow_map_frag.h"
|
||||||
|
|
||||||
|
#include "directional_ambient_light_frag.h"
|
||||||
|
#include "directional_ambient_light_shadow_map_frag.h"
|
||||||
|
#include "directional_ambient_light_cascaded_shadow_map_frag.h"
|
||||||
|
|
||||||
|
#include "directional_skybox_light_frag.h"
|
||||||
|
#include "directional_skybox_light_shadow_map_frag.h"
|
||||||
|
#include "directional_skybox_light_cascaded_shadow_map_frag.h"
|
||||||
|
|
||||||
|
#include "point_light_frag.h"
|
||||||
|
#include "spot_light_frag.h"
|
||||||
|
|
||||||
|
#include "standardTransformPNTC_vert.h"
|
||||||
|
#include "standardDrawTexture_frag.h"
|
||||||
|
|
||||||
|
#include "model_vert.h"
|
||||||
|
#include "model_shadow_vert.h"
|
||||||
|
#include "model_normal_map_vert.h"
|
||||||
|
#include "model_lightmap_vert.h"
|
||||||
|
#include "model_lightmap_normal_map_vert.h"
|
||||||
|
#include "skin_model_vert.h"
|
||||||
|
#include "skin_model_shadow_vert.h"
|
||||||
|
#include "skin_model_normal_map_vert.h"
|
||||||
|
|
||||||
|
#include "model_frag.h"
|
||||||
|
#include "model_shadow_frag.h"
|
||||||
|
#include "model_normal_map_frag.h"
|
||||||
|
#include "model_normal_specular_map_frag.h"
|
||||||
|
#include "model_specular_map_frag.h"
|
||||||
|
#include "model_lightmap_frag.h"
|
||||||
|
#include "model_lightmap_normal_map_frag.h"
|
||||||
|
#include "model_lightmap_normal_specular_map_frag.h"
|
||||||
|
#include "model_lightmap_specular_map_frag.h"
|
||||||
|
#include "model_translucent_frag.h"
|
||||||
|
|
||||||
|
#include "untextured_particle_frag.h"
|
||||||
|
#include "untextured_particle_vert.h"
|
||||||
|
#include "textured_particle_frag.h"
|
||||||
|
#include "textured_particle_vert.h"
|
||||||
|
|
||||||
|
#include "ambient_occlusion_vert.h"
|
||||||
|
#include "ambient_occlusion_frag.h"
|
||||||
|
#include "gaussian_blur_vertical_vert.h"
|
||||||
|
#include "gaussian_blur_horizontal_vert.h"
|
||||||
|
#include "gaussian_blur_frag.h"
|
||||||
|
#include "occlusion_blend_frag.h"
|
||||||
|
|
||||||
|
#include "hit_effect_vert.h"
|
||||||
|
#include "hit_effect_frag.h"
|
||||||
|
|
||||||
|
#include "overlay3D_vert.h"
|
||||||
|
#include "overlay3D_frag.h"
|
||||||
|
|
||||||
|
#include "SkyFromSpace_vert.h"
|
||||||
|
#include "SkyFromSpace_frag.h"
|
||||||
|
#include "SkyFromAtmosphere_vert.h"
|
||||||
|
#include "SkyFromAtmosphere_frag.h"
|
||||||
|
|
||||||
|
#include "DrawTransformUnitQuad_vert.h"
|
||||||
|
#include "DrawTexcoordRectTransformUnitQuad_vert.h"
|
||||||
|
#include "DrawViewportQuadTransformTexcoord_vert.h"
|
||||||
|
#include "DrawTexture_frag.h"
|
||||||
|
#include "DrawTextureOpaque_frag.h"
|
||||||
|
#include "DrawColoredTexture_frag.h"
|
||||||
|
|
||||||
|
|
||||||
|
class RateCounter {
|
||||||
|
std::vector<float> times;
|
||||||
|
QElapsedTimer timer;
|
||||||
|
public:
|
||||||
|
RateCounter() {
|
||||||
|
timer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
times.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int count() const {
|
||||||
|
return times.size() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
float elapsed() const {
|
||||||
|
if (times.size() < 1) {
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
float elapsed = *times.rbegin() - *times.begin();
|
||||||
|
return elapsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void increment() {
|
||||||
|
times.push_back(timer.elapsed() / 1000.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
float rate() const {
|
||||||
|
if (elapsed() == 0.0f) {
|
||||||
|
return NAN;
|
||||||
|
}
|
||||||
|
return (float) count() / elapsed();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const QString& getQmlDir() {
|
||||||
|
static QString dir;
|
||||||
|
if (dir.isEmpty()) {
|
||||||
|
QDir path(__FILE__);
|
||||||
|
path.cdUp();
|
||||||
|
dir = path.cleanPath(path.absoluteFilePath("../../../interface/resources/qml/")) + "/";
|
||||||
|
qDebug() << "Qml Path: " << dir;
|
||||||
|
}
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a simple OpenGL window that renders text in various ways
|
||||||
|
class QTestWindow : public QWindow {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
QOpenGLContext* _context{ nullptr };
|
||||||
|
QSize _size;
|
||||||
|
//TextRenderer* _textRenderer[4];
|
||||||
|
RateCounter fps;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void renderText();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void resizeWindow(const QSize& size) {
|
||||||
|
_size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
QTestWindow() {
|
||||||
|
setSurfaceType(QSurface::OpenGLSurface);
|
||||||
|
|
||||||
|
QSurfaceFormat format;
|
||||||
|
// Qt Quick may need a depth and stencil buffer. Always make sure these are available.
|
||||||
|
format.setDepthBufferSize(16);
|
||||||
|
format.setStencilBufferSize(8);
|
||||||
|
format.setVersion(4, 1);
|
||||||
|
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile);
|
||||||
|
format.setOption(QSurfaceFormat::DebugContext);
|
||||||
|
|
||||||
|
setFormat(format);
|
||||||
|
|
||||||
|
_context = new QOpenGLContext;
|
||||||
|
_context->setFormat(format);
|
||||||
|
_context->create();
|
||||||
|
|
||||||
|
show();
|
||||||
|
makeCurrent();
|
||||||
|
|
||||||
|
gpu::Context::init<gpu::GLBackend>();
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
QOpenGLDebugLogger* logger = new QOpenGLDebugLogger(this);
|
||||||
|
logger->initialize(); // initializes in the current context, i.e. ctx
|
||||||
|
logger->enableMessages();
|
||||||
|
connect(logger, &QOpenGLDebugLogger::messageLogged, this, [&](const QOpenGLDebugMessage & debugMessage) {
|
||||||
|
qDebug() << debugMessage;
|
||||||
|
});
|
||||||
|
// logger->startLogging(QOpenGLDebugLogger::SynchronousLogging);
|
||||||
|
}
|
||||||
|
qDebug() << (const char*)glGetString(GL_VERSION);
|
||||||
|
|
||||||
|
//_textRenderer[0] = TextRenderer::getInstance(SANS_FONT_FAMILY, 12, false);
|
||||||
|
//_textRenderer[1] = TextRenderer::getInstance(SERIF_FONT_FAMILY, 12, false,
|
||||||
|
// TextRenderer::SHADOW_EFFECT);
|
||||||
|
//_textRenderer[2] = TextRenderer::getInstance(MONO_FONT_FAMILY, 48, -1,
|
||||||
|
// false, TextRenderer::OUTLINE_EFFECT);
|
||||||
|
//_textRenderer[3] = TextRenderer::getInstance(INCONSOLATA_FONT_FAMILY, 24);
|
||||||
|
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
glClearColor(0.2f, 0.2f, 0.2f, 1);
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
makeCurrent();
|
||||||
|
|
||||||
|
// setFramePosition(QPoint(-1000, 0));
|
||||||
|
resize(QSize(800, 600));
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~QTestWindow() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw();
|
||||||
|
void makeCurrent() {
|
||||||
|
_context->makeCurrent(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void resizeEvent(QResizeEvent* ev) override {
|
||||||
|
resizeWindow(ev->size());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void testShaderBuild(const char* vs_src, const char * fs_src) {
|
||||||
|
auto vs = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(vs_src)));
|
||||||
|
auto fs = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(fs_src)));
|
||||||
|
auto pr = gpu::ShaderPointer(gpu::Shader::createProgram(vs, fs));
|
||||||
|
gpu::Shader::makeProgram(*pr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QTestWindow::draw() {
|
||||||
|
if (!isVisible()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
makeCurrent();
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
glViewport(0, 0, _size.width() * devicePixelRatio(), _size.height() * devicePixelRatio());
|
||||||
|
|
||||||
|
static std::once_flag once;
|
||||||
|
std::call_once(once, [&]{
|
||||||
|
testShaderBuild(DrawTransformUnitQuad_vert, DrawTexture_frag);
|
||||||
|
testShaderBuild(DrawTexcoordRectTransformUnitQuad_vert, DrawTexture_frag);
|
||||||
|
testShaderBuild(DrawViewportQuadTransformTexcoord_vert, DrawTexture_frag);
|
||||||
|
testShaderBuild(DrawTransformUnitQuad_vert, DrawTextureOpaque_frag);
|
||||||
|
testShaderBuild(DrawTransformUnitQuad_vert, DrawColoredTexture_frag);
|
||||||
|
|
||||||
|
testShaderBuild(Skybox_vert, Skybox_frag);
|
||||||
|
testShaderBuild(simple_vert, simple_frag);
|
||||||
|
testShaderBuild(simple_vert, simple_textured_frag);
|
||||||
|
testShaderBuild(deferred_light_vert, directional_light_frag);
|
||||||
|
testShaderBuild(deferred_light_vert, directional_light_shadow_map_frag);
|
||||||
|
testShaderBuild(deferred_light_vert, directional_light_cascaded_shadow_map_frag);
|
||||||
|
testShaderBuild(deferred_light_vert, directional_ambient_light_frag);
|
||||||
|
testShaderBuild(deferred_light_vert, directional_ambient_light_shadow_map_frag);
|
||||||
|
testShaderBuild(deferred_light_vert, directional_ambient_light_cascaded_shadow_map_frag);
|
||||||
|
testShaderBuild(deferred_light_vert, directional_skybox_light_frag);
|
||||||
|
testShaderBuild(deferred_light_vert, directional_skybox_light_shadow_map_frag);
|
||||||
|
testShaderBuild(deferred_light_vert, directional_skybox_light_cascaded_shadow_map_frag);
|
||||||
|
testShaderBuild(deferred_light_limited_vert, point_light_frag);
|
||||||
|
testShaderBuild(deferred_light_limited_vert, spot_light_frag);
|
||||||
|
testShaderBuild(standardTransformPNTC_vert, standardDrawTexture_frag);
|
||||||
|
|
||||||
|
testShaderBuild(model_vert, model_frag);
|
||||||
|
testShaderBuild(model_normal_map_vert, model_normal_map_frag);
|
||||||
|
testShaderBuild(model_vert, model_specular_map_frag);
|
||||||
|
testShaderBuild(model_normal_map_vert, model_normal_specular_map_frag);
|
||||||
|
testShaderBuild(model_vert, model_translucent_frag);
|
||||||
|
testShaderBuild(model_normal_map_vert, model_translucent_frag);
|
||||||
|
testShaderBuild(model_lightmap_vert, model_lightmap_frag);
|
||||||
|
testShaderBuild(model_lightmap_normal_map_vert, model_lightmap_normal_map_frag);
|
||||||
|
testShaderBuild(model_lightmap_vert, model_lightmap_specular_map_frag);
|
||||||
|
testShaderBuild(model_lightmap_normal_map_vert, model_lightmap_normal_specular_map_frag);
|
||||||
|
|
||||||
|
testShaderBuild(skin_model_vert, model_frag);
|
||||||
|
testShaderBuild(skin_model_normal_map_vert, model_normal_map_frag);
|
||||||
|
testShaderBuild(skin_model_vert, model_specular_map_frag);
|
||||||
|
testShaderBuild(skin_model_normal_map_vert, model_normal_specular_map_frag);
|
||||||
|
testShaderBuild(skin_model_vert, model_translucent_frag);
|
||||||
|
testShaderBuild(skin_model_normal_map_vert, model_translucent_frag);
|
||||||
|
|
||||||
|
testShaderBuild(model_shadow_vert, model_shadow_frag);
|
||||||
|
testShaderBuild(untextured_particle_vert, untextured_particle_frag);
|
||||||
|
testShaderBuild(textured_particle_vert, textured_particle_frag);
|
||||||
|
|
||||||
|
testShaderBuild(gaussian_blur_vertical_vert, gaussian_blur_frag);
|
||||||
|
testShaderBuild(gaussian_blur_horizontal_vert, gaussian_blur_frag);
|
||||||
|
testShaderBuild(ambient_occlusion_vert, ambient_occlusion_frag);
|
||||||
|
testShaderBuild(ambient_occlusion_vert, occlusion_blend_frag);
|
||||||
|
|
||||||
|
testShaderBuild(hit_effect_vert, hit_effect_frag);
|
||||||
|
|
||||||
|
testShaderBuild(overlay3D_vert, overlay3D_frag);
|
||||||
|
|
||||||
|
testShaderBuild(SkyFromSpace_vert, SkyFromSpace_frag);
|
||||||
|
testShaderBuild(SkyFromAtmosphere_vert, SkyFromAtmosphere_frag);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
_context->swapBuffers(this);
|
||||||
|
glFinish();
|
||||||
|
|
||||||
|
fps.increment();
|
||||||
|
if (fps.elapsed() >= 2.0f) {
|
||||||
|
qDebug() << "FPS: " << fps.rate();
|
||||||
|
fps.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
|
||||||
|
if (!message.isEmpty()) {
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
OutputDebugStringA(message.toLocal8Bit().constData());
|
||||||
|
OutputDebugStringA("\n");
|
||||||
|
#else
|
||||||
|
std::cout << message.toLocal8Bit().constData() << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char * LOG_FILTER_RULES = R"V0G0N(
|
||||||
|
hifi.gpu=true
|
||||||
|
)V0G0N";
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
QGuiApplication app(argc, argv);
|
||||||
|
qInstallMessageHandler(messageHandler);
|
||||||
|
QLoggingCategory::setFilterRules(LOG_FILTER_RULES);
|
||||||
|
QTestWindow window;
|
||||||
|
QTimer timer;
|
||||||
|
timer.setInterval(1);
|
||||||
|
app.connect(&timer, &QTimer::timeout, &app, [&] {
|
||||||
|
window.draw();
|
||||||
|
});
|
||||||
|
timer.start();
|
||||||
|
app.exec();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "main.moc"
|
|
@ -7,10 +7,7 @@ setup_hifi_project(Widgets OpenGL Network Qml Quick Script)
|
||||||
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
|
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
add_dependency_external_projects(glew)
|
target_link_libraries(${TARGET_NAME} wsock32.lib opengl32.lib Winmm.lib)
|
||||||
find_package(GLEW REQUIRED)
|
|
||||||
target_include_directories(${TARGET_NAME} PRIVATE ${GLEW_INCLUDE_DIRS})
|
|
||||||
target_link_libraries(${TARGET_NAME} ${GLEW_LIBRARIES} wsock32.lib opengl32.lib Winmm.lib)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# link in the shared libraries
|
# link in the shared libraries
|
||||||
|
|
Loading…
Reference in a new issue