-
Notifications
You must be signed in to change notification settings - Fork 790
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
7,560 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
|
||
set(TARGET_GLSL | ||
Corey.vert.glsl | ||
Corey.elevation.glsl | ||
Corey.gs.glsl | ||
Corey.ImageLayer.glsl | ||
Corey.NormalMap.glsl | ||
Corey.Morphing.glsl | ||
Corey.Tessellation.glsl | ||
Corey.SDK.glsl | ||
Corey.vert.GL4.glsl | ||
Corey.ImageLayer.GL4.glsl | ||
Corey.NormalMap.GL4.glsl | ||
Corey.Tessellation.GL4.glsl | ||
Corey.SDK.GL4.glsl | ||
Corey.GL4.glsl) | ||
|
||
set(TARGET_IN | ||
Shaders.cpp.in) | ||
|
||
set(SHADERS_CPP "${CMAKE_CURRENT_BINARY_DIR}/AutoGenShaders.cpp") | ||
|
||
configure_shaders( | ||
Shaders.cpp.in | ||
${SHADERS_CPP} | ||
${TARGET_GLSL} ) | ||
|
||
SET(TARGET_LIBRARIES_VARS OSG_LIBRARY OSGDB_LIBRARY OSGUTIL_LIBRARY OSGTEXT_LIBRARY OPENTHREADS_LIBRARY OPENGL_gl_LIBRARY) | ||
|
||
SET(TARGET_SRC | ||
CreateTileImplementation.cpp | ||
DrawState.cpp | ||
DrawTileCommand.cpp | ||
CoreyTerrainEngineNode.cpp | ||
CoreyTerrainEngineDriver.cpp | ||
LayerDrawable.cpp | ||
SelectionInfo.cpp | ||
TerrainCuller.cpp | ||
TerrainRenderData.cpp | ||
TileGeometry.cpp | ||
TileNode.cpp | ||
${SHADERS_CPP} | ||
) | ||
|
||
SET(TARGET_H | ||
Common | ||
CoreyTerrainEngineNode | ||
CreateTileImplementation | ||
DrawState | ||
DrawTileCommand | ||
EngineData | ||
LayerDrawable | ||
RenderBindings | ||
SelectionInfo | ||
Shaders | ||
TerrainCuller | ||
TerrainRenderData | ||
TileRenderModel | ||
TileGeometry | ||
TileNode | ||
) | ||
|
||
IF(TRACY_FOUND) | ||
INCLUDE_DIRECTORIES(${TRACY_INCLUDE_DIR}) | ||
LIST(APPEND TARGET_LIBRARIES_VARS TRACY_LIBRARY ) | ||
ENDIF(TRACY_FOUND) | ||
|
||
setup_plugin(osgearth_engine_corey) | ||
|
||
# to install public driver includes: | ||
SET(LIB_NAME engine_corey) | ||
SET(LIB_PUBLIC_HEADERS ${TARGET_H}) | ||
INCLUDE(ModuleInstallOsgEarthDriverIncludes OPTIONAL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* -*-c++-*- */ | ||
/* osgEarth - Geospatial SDK for OpenSceneGraph | ||
* Copyright 2008-2014 Pelican Mapping | ||
* http://osgearth.org | ||
* | ||
* osgEarth is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
*/ | ||
#ifndef OSGEARTH_DRIVERS_Corey_TERRAIN_ENGINE_COMMON_H | ||
#define OSGEARTH_DRIVERS_Corey_TERRAIN_ENGINE_COMMON_H 1 | ||
|
||
#include <osgEarth/Common> | ||
|
||
#define ARENA_LOAD_TILE "oe.rex.loadtile" | ||
#define ARENA_CREATE_CHILD "oe.rex.createchild" | ||
|
||
#endif // OSGEARTH_DRIVERS_Corey_TERRAIN_ENGINE_COMMON_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#define MAX_NUM_SHARED_SAMPLERS 16 | ||
|
||
struct oe_rex_Shared { | ||
vec2 morphConstants[49]; | ||
float padding[2]; | ||
}; | ||
struct oe_rex_Tile { | ||
vec4 tileKey; | ||
mat4 modelViewMatrix; | ||
mat4 colorMat; | ||
mat4 parentMat; | ||
mat4 elevMat; | ||
mat4 normalMat; | ||
mat4 landcoverMat; | ||
mat4 sharedMat[MAX_NUM_SHARED_SAMPLERS]; | ||
int colorIndex; | ||
int parentIndex; | ||
int elevIndex; | ||
int normalIndex; | ||
int landcoverIndex; | ||
int sharedIndex[MAX_NUM_SHARED_SAMPLERS]; | ||
int drawOrder; | ||
float padding[2]; | ||
}; | ||
layout(binding = 29, std430) readonly buffer RexTextureArena { | ||
uint64_t oe_terrain_tex[]; | ||
}; | ||
layout(binding = 30, std430) readonly buffer RexSharedDataBuffer { | ||
oe_rex_Shared oe_shared; | ||
}; | ||
layout(binding = 31, std430) readonly buffer RexTileBuffer { | ||
oe_rex_Tile oe_tile[]; | ||
}; | ||
|
||
#if defined(VP_STAGE_VERTEX) || defined(VP_STAGE_TESSEVALUATION) | ||
flat out int oe_tileID; | ||
#elif defined(VP_STAGE_FRAGMENT) | ||
flat in int oe_tileID; | ||
#else | ||
int oe_tileID; | ||
#endif |
143 changes: 143 additions & 0 deletions
143
src/osgEarthDrivers/engine_corey/Corey.ImageLayer.GL4.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
#pragma include RexEngine.GL4.glsl | ||
#pragma vp_name Corey Engine - ImageLayer/VS | ||
#pragma vp_function oe_rex_imageLayer_VS, vertex_view, 0.4 | ||
|
||
// Stage globals | ||
vec4 oe_layer_tilec; | ||
|
||
// outputs | ||
out vec2 oe_color_uv; | ||
out vec2 oe_parent_uv; | ||
flat out uint64_t oe_color_handle; | ||
flat out uint64_t oe_parent_handle; | ||
flat out int oe_draw_order; | ||
|
||
void oe_rex_imageLayer_VS(inout vec4 vertexView) | ||
{ | ||
oe_color_uv = (oe_tile[oe_tileID].colorMat * oe_layer_tilec).st; | ||
int colorIndex = oe_tile[oe_tileID].colorIndex; | ||
oe_color_handle = (colorIndex >= 0) ? oe_terrain_tex[colorIndex] : 0; | ||
|
||
oe_parent_uv = (oe_tile[oe_tileID].parentMat * oe_layer_tilec).st; | ||
int parentIndex = oe_tile[oe_tileID].parentIndex; | ||
oe_parent_handle = (parentIndex >= 0) ? oe_terrain_tex[parentIndex] : 0; | ||
|
||
oe_draw_order = oe_tile[oe_tileID].drawOrder; | ||
} | ||
|
||
|
||
[break] | ||
#pragma include RexEngine.GL4.glsl | ||
|
||
#pragma vp_name Corey Engine - Fragment | ||
#pragma vp_function oe_rex_imageLayer_FS, fragment_coloring, 0.5 | ||
|
||
#pragma import_defines(OE_TERRAIN_RENDER_IMAGERY) | ||
#pragma import_defines(OE_TERRAIN_MORPH_IMAGERY) | ||
#pragma import_defines(OE_TERRAIN_BLEND_IMAGERY) | ||
#pragma import_defines(OE_TERRAIN_CAST_SHADOWS) | ||
#pragma import_defines(OE_IS_PICK_CAMERA) | ||
#pragma import_defines(OE_IS_SHADOW_CAMERA) | ||
#pragma import_defines(OE_IS_DEPTH_CAMERA) | ||
|
||
//uniform sampler2D oe_layer_tex; | ||
uniform int oe_layer_uid; | ||
uniform int oe_layer_order; | ||
|
||
#ifdef OE_TERRAIN_MORPH_IMAGERY | ||
in vec2 oe_parent_uv; | ||
flat in uint64_t oe_parent_handle; | ||
in float oe_rex_morphFactor; | ||
#endif | ||
|
||
// inputs | ||
in vec2 oe_color_uv; | ||
flat in uint64_t oe_color_handle; | ||
in vec4 oe_layer_tilec; | ||
in float oe_layer_opacity; | ||
flat in int oe_terrain_vertexMarker; | ||
flat in int oe_draw_order; | ||
|
||
#define VERTEX_VISIBLE 1 | ||
#define VERTEX_BOUNDARY 2 | ||
#define VERTEX_HAS_ELEVATION 4 | ||
#define VERTEX_SKIRT 8 | ||
|
||
void oe_rex_imageLayer_FS(inout vec4 color) | ||
{ | ||
// if the provoking vertex is marked for discard, skip it: | ||
if ((oe_terrain_vertexMarker & VERTEX_VISIBLE) == 0) | ||
{ | ||
discard; | ||
return; | ||
} | ||
|
||
// If this is a shadow camera and the terrain doesn't cast shadows, no render: | ||
#if defined(OE_IS_SHADOW_CAMERA) && !defined(OE_TERRAIN_CAST_SHADOWS) | ||
discard; | ||
return; | ||
#endif | ||
|
||
// If this is a depth-only camera, skip terrain skirt geometry: | ||
#if defined(OE_IS_DEPTH_CAMERA) | ||
if ((oe_terrain_vertexMarker & VERTEX_SKIRT) != 0) | ||
{ | ||
discard; | ||
return; | ||
} | ||
#endif // OE_IS_DEPTH_CAMERA | ||
|
||
// if this is a picking camera, reset the color to all zeros: | ||
#ifdef OE_IS_PICK_CAMERA | ||
color = vec4(0); | ||
return; | ||
#endif | ||
|
||
// If imagery rendering is disabled, we're done: | ||
#ifndef OE_TERRAIN_RENDER_IMAGERY | ||
return; | ||
#endif | ||
|
||
// whether this layer contains texel color (UID<0 means no texture) | ||
bool isTexelLayer = oe_color_handle > 0UL; | ||
|
||
vec4 texel = color; | ||
|
||
if (isTexelLayer) | ||
{ | ||
texel = texture(sampler2D(oe_color_handle), oe_color_uv); | ||
|
||
#ifdef OE_TERRAIN_MORPH_IMAGERY | ||
|
||
if (oe_parent_handle != 0UL) | ||
{ | ||
// sample the parent texture and blend for the morphing. | ||
// We have to clamp oe_rex_morphFactor here even though it's clamped in the | ||
// vertex shader. Reason unknown. | ||
vec4 texelParent = texture(sampler2D(oe_parent_handle), oe_parent_uv); | ||
texel = mix(texel, texelParent, clamp(oe_rex_morphFactor, 0.0, 1.0)); | ||
} | ||
|
||
#endif | ||
|
||
// intergrate the layer opacity: | ||
texel.a = texel.a * oe_layer_opacity; | ||
color.a = 1.0; | ||
} | ||
|
||
#ifdef OE_TERRAIN_BLEND_IMAGERY | ||
// If this is a first image layer, blend with the incoming terrain color. | ||
// Otherwise, apply directly and let GL blending do the rest. | ||
if (isTexelLayer && (oe_draw_order == 0)) | ||
{ | ||
color.rgb = texel.rgb*texel.a + color.rgb*(1.0 - texel.a); | ||
} | ||
else | ||
{ | ||
color = texel; | ||
} | ||
#else | ||
// No blending? The output is just the texel value. | ||
color = texel; | ||
#endif // OE_TERRAIN_BLEND_IMAGERY | ||
} |
Oops, something went wrong.