Created
October 24, 2015 03:50
-
-
Save shirish47/ef699ff2eef49b1127aa to your computer and use it in GitHub Desktop.
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
void stestingApp::setup() | |
{ | |
mCam.lookAt(vec3(3, 2, 4), vec3(0)); | |
try { | |
mGlsl = gl::GlslProg::create(gl::GlslProg::Format().vertex(loadAsset("sh.vert")).fragment(loadAsset("sh.frag"))); | |
} | |
catch (gl::GlslProgCompileExc ex) { | |
console() <<"Shader Creation failed: "<< ex.what() << endl; | |
quit(); | |
} | |
float sun = 100.0f; | |
float kr = 0.01f; | |
float km = 0.03f; | |
float fpi = 4 * 3.14f; | |
mGlsl->uniform("v3LightPosition", vec3(12, 10, -1));//v3 | |
mGlsl->uniform("v3InvWavelength", vec3(0.3, 0.7, 1.0));//1/pow(wl,4) | |
mGlsl->uniform("cameraPosition", vec3(3,2,4));// camera's position | |
mGlsl->uniform("fCameraHeight2", 4.3f);// fCameraHeight^2 | |
mGlsl->uniform("fOuterRadius", 20.0f);// The outer (atmosphere) radius | |
mGlsl->uniform("fOuterRadius2", 400.0f);// fOuterRadius^2 | |
mGlsl->uniform("fInnerRadius", 10.0f);// The inner (planetary) radius | |
mGlsl->uniform("fInnerRadius2", 100.0f);// fInnerRadius^2 | |
mGlsl->uniform("fKrESun", kr*sun);// Kr * ESun | |
mGlsl->uniform("fKmESun", km*sun);// Km * ESun | |
mGlsl->uniform("fKr4PI", kr*fpi);// Km * 4 * PI | |
mGlsl->uniform("fKm4PI", km*fpi);// Km * 4 * PI | |
mGlsl->uniform("fScale", 1.0f/(20-10));// 1 / (fOuterRadius - fInnerRadius) | |
mGlsl->uniform("fScaleDepth", 10.0f);// The scale depth (i.e. the altitude at which the atmosphere's average density is found) | |
mGlsl->uniform("fScaleOverScaleDepth", 0.01f);// fScale / fScaleDepth | |
// mGlsl->uniform("v3LightDirection", vec3(1, 1, 0.1)); | |
mCube = gl::Batch::create(geom::Sphere(), mGlsl); | |
gl::enableDepthWrite(); | |
gl::enableDepthRead(); | |
} | |
void stestingApp::draw() | |
{ | |
gl::clear(Color(0.2f, 0.2f, 0.2f)); | |
gl::color(1, 0, 0); | |
gl::setMatrices(mCam); | |
mCube->draw(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment