Exemple #1
0
  void 
  RLight::pickingRender(const magnet::GL::Camera& cam, 
			const uint32_t offset)
  {
    if (!_visible) return;
    
    using namespace magnet::GL;

    magnet::math::Vector loc = getEyeLocationObjSpace();
    GLfloat pos[3] = {loc[0], loc[1], loc[2]};
    std::vector<GLfloat> position(pos, pos + 3);
    _glposition.init(position);
    
    _context->cleanupAttributeArrays();
    //Set the normals to zero so it is fully illuminated
    _context->setAttribute(Context::instanceScaleAttrIndex, 0.05, 0.05, 0.05, 1);
    
    _context->setAttribute(Context::vertexColorAttrIndex, 
			   (offset % 256) / 255.0, 
			   ((offset / 256) % 256) / 255.0, 
			   (((offset / 256) / 256) % 256) / 255.0, 
			   ((((offset / 256) / 256) / 256) % 256) / 255.0);
    
    _sphereShader.attach();
    _sphereShader["ProjectionMatrix"] = cam.getProjectionMatrix();
    _sphereShader["ViewMatrix"] = cam.getViewMatrix();
    _sphereShader["global_scale"] = GLfloat(1.0);
    _glposition.drawArray(magnet::GL::element_type::POINTS, 3);
    _sphereShader.detach();
  }
Exemple #2
0
  void 
  RLight::glRender(const magnet::GL::Camera& cam, 
		   RenderMode mode)
  {
    if (!_visible) return;
    
    using namespace magnet::GL;

    if (mode & RenderObj::COLOR)
      {
	magnet::math::Vector loc = getEyeLocationObjSpace();
	GLfloat pos[3] = {loc[0], loc[1], loc[2]};
	std::vector<GLfloat> position(pos, pos + 3);
	_glposition.init(position);

	_context->cleanupAttributeArrays();
	//Set the normals to zero so it is fully illuminated
	_context->setAttribute(Context::instanceScaleAttrIndex, 0.05, 0.05, 0.05, 1);
	_context->setAttribute(Context::vertexColorAttrIndex, 1, 1, 1, 1);
	
	if (_context->testExtension("GL_ARB_sample_shading"))
	  {
#ifndef GL_SAMPLE_SHADING
# define GL_SAMPLE_SHADING GL_SAMPLE_SHADING_ARB
#endif
	    glEnable(GL_SAMPLE_SHADING);
	    glMinSampleShadingARB(1.0);
	  }

	_sphereShader.attach();
	_sphereShader["ProjectionMatrix"] = cam.getProjectionMatrix();
	_sphereShader["ViewMatrix"] = cam.getViewMatrix();
	_sphereShader["global_scale"] = GLfloat(1.0);
	_glposition.drawArray(magnet::GL::element_type::POINTS, 3);
	_sphereShader.detach();

	if (_context->testExtension("GL_ARB_sample_shading"))
	  glDisable(GL_SAMPLE_SHADING);
      }
  }
Exemple #3
0
  void SSAOWrapper::invoke(GLint colorTextureUnit, 
			   size_t width, size_t height,
			   const magnet::GL::Camera& vp)
  {
    glActiveTextureARB(GL_TEXTURE7);
    glBindTexture(GL_TEXTURE_2D, _randomTexture);

    _filter.attach();

    _filter["radius"] = _radius;
    _filter["totStrength"] = _totStrength;
    _filter["depthDropoff"] = _dropoff;
    _filter["offset"] = GLfloat(std::max(width, height)) / _randomTextureSize;
    _filter["NormalsTex"] = 1;
    _filter["EyePosTex"] = 2;
    _filter["rnm"] = 7;
    _filter["ProjectionMatrix"] = vp.getProjectionMatrix();
    _filter["ViewMatrix"] = vp.getViewMatrix();

    _filter.invoke();
    _filter.detach();
  }