00001 //------------------------------------------------------------------------------ 00002 // This file is part of the OpenStructure project <www.openstructure.org> 00003 // 00004 // Copyright (C) 2008-2011 by the OpenStructure authors 00005 // 00006 // This library is free software; you can redistribute it and/or modify it under 00007 // the terms of the GNU Lesser General Public License as published by the Free 00008 // Software Foundation; either version 3.0 of the License, or (at your option) 00009 // any later version. 00010 // This library is distributed in the hope that it will be useful, but WITHOUT 00011 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00012 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00013 // details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with this library; if not, write to the Free Software Foundation, Inc., 00017 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 //------------------------------------------------------------------------------ 00019 #ifndef OST_SCENE_FX_HH 00020 #define OST_SCENE_FX_HH 00021 00022 #include <ost/gfx/gl_helper.hh> 00023 #include <ost/geom/geom.hh> 00024 00025 /* 00026 low level code for scene shading effects 00027 00028 Author: Ansgar Philippsen 00029 */ 00030 00031 namespace ost { namespace gfx { 00032 00033 class Scene; 00034 00035 namespace impl { 00036 00037 struct Beacon { 00038 float wx, wy; 00039 geom::Vec3 p0,p1; 00040 geom::Mat4 mat; 00041 }; 00042 00043 class SceneFX { 00044 friend class ::ost::gfx::Scene; 00045 public: 00046 ~SceneFX(); 00047 static SceneFX& Instance(); 00048 00049 void Setup(); 00050 00051 void Resize(unsigned int w, unsigned int h); 00052 00053 void Preprocess(); 00054 // assumes scene has been drawn in the active framebuffer 00055 void Postprocess(); 00056 00057 // returns true if the post-processing will run 00058 bool WillPostprocess() const; 00059 00060 void DrawTex(unsigned int w, unsigned int h, GLuint texid); 00061 00062 bool shadow_flag; 00063 int shadow_quality; 00064 float shadow_weight; 00065 bool depth_dark_flag; 00066 float depth_dark_factor; 00067 bool amb_occl_flag; 00068 float amb_occl_factor; 00069 uint amb_occl_mode; 00070 uint amb_occl_quality; 00071 float amb_occl_size; 00072 bool use_beacon; 00073 Beacon beacon; 00074 00075 private: 00076 SceneFX(); 00077 SceneFX(const SceneFX&) {} 00078 SceneFX& operator=(const SceneFX&) {return *this;} 00079 00080 void screenblur4(); 00081 void prep_shadow_map(); 00082 void prep_depth_darkening(); 00083 void prep_amb_occlusion(); 00084 void draw_screen_quad(uint w, uint h); 00085 void prep_beacon(); 00086 void draw_beacon(); 00087 00088 GLuint scene_tex_id_; 00089 GLuint depth_tex_id_; 00090 GLuint shadow_tex_id_; 00091 geom::Mat4 shadow_tex_mat_; 00092 GLuint occl_tex_id_; 00093 GLuint dark_tex_id_; 00094 GLuint norm_tex_id_; 00095 GLuint kernel_tex_id_; 00096 uint kernel_size_; 00097 GLuint kernel2_tex_id_; 00098 uint kernel2_size_; 00099 00100 GLuint scene_tex2_id_; 00101 GLuint norm_tex2_id_; 00102 GLuint scene_fb_; 00103 GLuint scene_rb_; 00104 GLuint depth_rb_; 00105 00106 bool use_fb_; 00107 }; 00108 00109 }}} // ns 00110 00111 #endif