Skip to content

Instantly share code, notes, and snippets.

/* OpenSceneGraph example, osgdrawinstanced.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2016 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.
*
@gwaldron
gwaldron / gist:6df90cedc1c1d0011e1ee9616d8b1154
Last active June 14, 2018 15:12
Async Elevation Query Example
/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2016 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.
*
#include <osgEarth/SpatialReference>
#include <osgEarth/Notify>
#include <osgEarth/GeoData>
using namespace osgEarth;
double square(double d) { return d*d; }
int
main(int argc, char** argv)
@gwaldron
gwaldron / gist:4207c5262d3fb4a17d5a1e392e0ffeb9
Last active August 22, 2017 18:19
How to use TerrainEngineNode::createTile(model)
#include <osgViewer/Viewer>
#include <osgEarth/Notify>
#include <osgEarthUtil/ExampleResources>
#include <osgEarth/MapNode>
#include <osgEarth/TerrainEngineNode>
#include <osgGA/TrackballManipulator>
#include <osgEarth/NodeUtils>
using namespace osgEarth;
using namespace osgEarth::Util;
@gwaldron
gwaldron / gist:408c137e8a9c902c5df9f56fb0d3a1b7
Last active April 13, 2024 09:16
KML asynchronous load in osgEarth
#include <osgViewer/Viewer>
#include <osgEarthUtil/EarthManipulator>
#include <osgEarthUtil/ExampleResources>
#include <osgEarth/MapNode>
#include <osgEarth/ModelLayer>
#include <osgEarthDrivers/kml/KML>
#include <osg/ProxyNode>
using namespace osgEarth;
using namespace osgEarth::Util;
@gwaldron
gwaldron / UserFunctions-frag.glsl
Created February 21, 2018 14:36
SilverLining/osgEarth LogarithmicDepthBuffer integration (with fragment depth)
// Allow overriding of the final sky fragment color
void overrideSkyFragColor(inout vec4 finalColor)
{
}
// Allows overriding of the fog color, fog blend factor, underlying cloud color, and alpha blending of the cloud.
void overrideStratusLighting(in vec3 fogColor, in float fogFactor, in vec3 cloudColor, in float cloudFade, inout vec4 finalColor)
{
}
@gwaldron
gwaldron / user-functions.glsl
Created February 23, 2018 17:28
Triton/osgEarth LogarithmicDepthBuffer integration (with fragment depth)
#ifdef OPENGL32
out vec4 fragColor;
#endif
// Light, view, and normal vectors are all in world space.
// This function may be used to modify the ambient, diffuse, and specular light computed by Triton's fragment shaders.
void user_lighting(in vec3 L
, in vec3 vVertex_World_Space, in vec3 vNormal_World_Space
, in vec4 vVertex_Projection_Space
/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2016 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.
*
@gwaldron
gwaldron / gist:9d65c35a5d940965429f401331b72420
Last active September 14, 2018 12:09
Broken mipmapping with glTexStorage enabled
#include <osgViewer/Viewer>
#include <osg/Texture2DArray>
#include <osgDB/ReadFile>
#include <osg/Geometry>
#include <iostream>
const char* vert =
"#version 330 compatibility\n"
"out vec4 coord;\n"
"void main() {\n"