本文整理汇总了C++中gl::BatchRef::getGlslProg方法的典型用法代码示例。如果您正苦于以下问题:C++ BatchRef::getGlslProg方法的具体用法?C++ BatchRef::getGlslProg怎么用?C++ BatchRef::getGlslProg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gl::BatchRef
的用法示例。
在下文中一共展示了BatchRef::getGlslProg方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scopedDepth
void ImageBasedLighting_05App::draw()
{
gl::clear( Color( 0, 0, 0 ) );
gl::setMatrices( mCam );
// enable depth testing
gl::ScopedDepth scopedDepth( true );
// bind the cubemap textures
gl::ScopedTextureBind scopedTexBind0( mTextureRadianceMap, 0 );
gl::ScopedTextureBind scopedTexBind1( mTextureIrradianceMap, 1 );
gl::ScopedTextureBind scopedTexBind2( mNormalMap, 2 );
gl::ScopedTextureBind scopedTexBind3( mRoughnessMap, 3 );
gl::ScopedTextureBind scopedTexBind4( mMetallicMap, 4 );
gl::ScopedTextureBind scopedTexBind5( mColorMap, 5 );
gl::ScopedTextureBind scopedTexBind6( mAOMap, 6 );
gl::ScopedTextureBind scopedTexBind7( mSpecularMap, 7 );
auto shader = mBatchModel->getGlslProg();
shader->uniform( "uRadianceMap", 0 );
shader->uniform( "uIrradianceMap", 1 );
shader->uniform( "uNormalMap", 2 );
shader->uniform( "uRoughnessMap", 3 );
shader->uniform( "uMetallicMap", 4 );
shader->uniform( "uColorMap", 5 );
shader->uniform( "uAOMap", 6 );
shader->uniform( "uSpecularMap", 7);
// sends the base color, the specular opacity,
// the light position, color and radius to the shader
// shader->uniform( "uBaseColor", mBaseColor );
// shader->uniform( "uSpecular", mSpecular );
// shader->uniform( "uNormalMapScale",mNormalMapScale);
// sends the tone-mapping uniforms
shader->uniform( "uExposure", mExposure );
shader->uniform( "uGamma", mGamma );
// render a grid of sphere with different roughness/metallic values and colors
{
// shader->uniform( "uRoughness", mRoughness );
// shader->uniform( "uRoughness4", pow( mRoughness, 4.0f ) );
// shader->uniform( "uMetallic", mMetallic );
mBatchModel->draw();
}
// render skybox
shader = mBatchSkyBox->getGlslProg();
shader->uniform( "uExposure", mExposure );
shader->uniform( "uGamma", mGamma );
mBatchSkyBox->draw();
// DRAW SETTINGS
_params->draw();
}
示例2: drawParticles
void RandomSpawn::drawParticles()
{
mBatch_P->getGlslProg()->uniform("ViewDirection", mCamera.getViewDirection());
mBatch_P->getGlslProg()->uniform("LightPosition", vec3(0, 10, 0));
mBatch_P->getGlslProg()->uniform("SpecPow", 4.0f);
mBatch_P->getGlslProg()->uniform("SpecStr", 2.0f);
mBatch_P->drawInstanced(mPointsParticles.size());
}
示例3: loadAsset
void Day72App::setup()
{
mGlsl = gl::GlslProg::create(loadAsset("vertex.vert"), loadAsset("fragment.frag"));
mCamPos = vec3(0,0,4);
mCam.lookAt(mCamPos, vec3(0));
mCam.setPerspective(60.f, getWindowAspectRatio(), 1.f, 1000.f);
mCamUi = CameraUi(&mCam, getWindow());
mSkyBoxTex = gl::TextureCubeMap::create(loadImage(loadAsset("boxy.jpg")));
auto cube = geom::Cube();
mSkyBoxBatch = gl::Batch::create(cube >> geom::Scale(SKY_BOX_SIZE,SKY_BOX_SIZE,SKY_BOX_SIZE), mGlsl);
auto sphere = geom::Sphere().subdivisions(64);
auto c = geom::Cube();
auto torus = geom::Torus().subdivisionsAxis(64).subdivisionsHeight(32);
auto icos = geom::Icosahedron();
mSphere = gl::Batch::create(sphere, mGlsl);
mTorus = gl::Batch::create(torus >> geom::Scale(1.3,1.3,1.3), mGlsl);
mIcos = gl::Batch::create(icos >> geom::Scale(0.8,0.8,0.8), mGlsl);
mCube = gl::Batch::create(c, mGlsl);
//SET THE LOCATION OF THE TEXTURE
mSkyBoxBatch->getGlslProg()->uniform("uCubeMapTex", 0);
mSkyBoxTex->bind();
gl::enableDepth();
}
示例4: setup
void CubeMappingApp::setup()
{
mCubeMap = gl::TextureCubeMap::createHorizontalCross( loadImage( loadAsset( "env_map.jpg" ) ), gl::TextureCubeMap::Format().mipmap() );
#if defined( CINDER_GL_ES )
auto envMapGlsl = gl::GlslProg::create( loadAsset( "env_map_es2.vert" ), loadAsset( "env_map_es2.frag" ) );
auto skyBoxGlsl = gl::GlslProg::create( loadAsset( "sky_box_es2.vert" ), loadAsset( "sky_box_es2.frag" ) );
#else
auto envMapGlsl = gl::GlslProg::create( loadAsset( "env_map.vert" ), loadAsset( "env_map.frag" ) );
auto skyBoxGlsl = gl::GlslProg::create( loadAsset( "sky_box.vert" ), loadAsset( "sky_box.frag" ) );
#endif
mTeapotBatch = gl::Batch::create( geom::Teapot().subdivisions( 7 ), envMapGlsl );
mTeapotBatch->getGlslProg()->uniform( "uCubeMapTex", 0 );
mSkyBoxBatch = gl::Batch::create( geom::Cube(), skyBoxGlsl );
mSkyBoxBatch->getGlslProg()->uniform( "uCubeMapTex", 0 );
gl::enableDepthRead();
gl::enableDepthWrite();
}
示例5: setup
void BayBridgeApp::setup()
{
mGUI = params::InterfaceGl::create("Params", ivec2(300, 50));
mParamInvert = false;
mParamClear = true;
mGUI->addParam<bool>("paramInvert", &mParamInvert).optionsStr("label='Inverted'");
mGUI->addParam<bool>("paramClear", &mParamClear).optionsStr("label='Clear Frame'");
getWindow()->setSize(1280, 720);
getWindow()->setPos(ivec2(20));
setFrameRate(60);
mBridgeShader = gl::GlslProg::create(loadAsset("shaders/light_vert.glsl"), loadAsset("shaders/light_frag.glsl"));
mBridge.Init(mBridgeShader);
mCamera.setPerspective(45.0f, getWindowAspectRatio(), 10.0f, 10000.0f);
mCamera.lookAt(vec3(0, 50, -525), vec3(0,50,0), vec3(0, 1, 0));
mCamUi = CameraUi(&mCamera, getWindow());
mDS = CinderDSAPI::create();
mDS->init();
mDS->initDepth(FrameSize::DEPTHSD, 60);
mDS->start();
ImageSourceRef skybox[6]
{
loadImage(loadAsset("textures/px04.png")), loadImage(loadAsset("textures/nx04.png")),
loadImage(loadAsset("textures/py04.png")), loadImage(loadAsset("textures/ny04.png")),
loadImage(loadAsset("textures/pz04.png")), loadImage(loadAsset("textures/nz04.png"))
};
mTexSkybox = gl::TextureCubeMap::create(skybox);
mShaderSkybox = gl::GlslProg::create(loadAsset("shaders/skybox_vert.glsl"), loadAsset("shaders/skybox_frag.glsl"));
mBatchSkybox = gl::Batch::create(geom::Cube(), mShaderSkybox);
mBatchSkybox->getGlslProg()->uniform("uCubemapSampler", 0);
mShaderDiffuse = gl::GlslProg::create(loadAsset("shaders/diffuse_vert.glsl"), loadAsset("shaders/diffuse_frag.glsl"));
//Bloom
mFboRaw = gl::Fbo::create(1280, 720, gl::Fbo::Format().colorTexture(gl::Texture2d::Format().dataType(GL_FLOAT).internalFormat(GL_RGBA32F)));
mFboHiPass = gl::Fbo::create(1280, 720);
mFboBlurU = gl::Fbo::create(1280, 720);
mFboBlurV = gl::Fbo::create(1280, 720);
mShaderHiPass = gl::GlslProg::create(loadAsset("shaders/passthru_vert.glsl"), loadAsset("shaders/highpass_frag.glsl"));
mShaderHiPass->uniform("uTextureSampler", 0);
mShaderBlur = gl::GlslProg::create(loadAsset("shaders/blur_vert.glsl"), loadAsset("shaders/blur_frag.glsl"));
mShaderBlur->uniform("uTextureSampler", 0);
}
示例6: update
void ViewportArrayApp::update()
{
// bind the fbo and enable depth testing
gl::ScopedFramebuffer scopedFbo( mFbo );
gl::ScopedDepth scopedDepthTest( true );
// clear our fbo
gl::clear( Color( 0, 0, 0 ) );
// create an array with the different cameras matrices
vector<mat4> matrices;
for( auto cam : mCameras ) {
matrices.push_back( cam.getProjectionMatrix() * cam.getViewMatrix() );
}
// and send it to the shader
mTeapot->getGlslProg()->uniform( "uMatrices", &matrices[0], mCameras.size() );
// render the teapot once (the geometry shader takes care of the rest)
mTeapot->draw();
}