@@ -154,49 +154,39 @@ namespace cage
154154 s.dofFar = Vec4 (fd + fr, fd + fr + br, 0 , 0 );
155155 q->universalUniformStruct (s, 2 );
156156
157- TextureHandle texNear = provTex (config.provisionals , " dofNear" , res, 1 , GL_RGB16F);
158- TextureHandle texFar = provTex (config.provisionals , " dofFar" , res, 1 , GL_RGB16F);
159-
160- q->bind (config.inColor , 0 );
161- q->bind (config.inDepth , 1 );
162- Holder<ShaderProgram> shader = config.assets ->get <AssetSchemeIndexShaderProgram, MultiShaderProgram>(HashString (" cage/shader/effects/dofCollect.glsl" ))->get (0 );
163- q->bind (shader);
157+ TextureHandle texDof = provTex (config.provisionals , " dofColor" , res, 1 , GL_RGB16F);
164158 Holder<Model> model = config.assets ->get <AssetSchemeIndexModel, Model>(HashString (" cage/model/square.obj" ));
165- { // collect near
166- q->colorTexture (fb, 0 , texNear);
159+
160+ { // collect
161+ q->bind (config.inColor , 0 );
162+ q->bind (config.inDepth , 1 );
163+ Holder<ShaderProgram> shader = config.assets ->get <AssetSchemeIndexShaderProgram, MultiShaderProgram>(HashString (" cage/shader/effects/dofCollect.glsl" ))->get (0 );
164+ q->bind (shader);
165+ q->colorTexture (fb, 0 , texDof);
167166 q->checkFrameBuffer (fb);
168- q->uniform (shader, 0 , 0 );
169167 q->draw (model);
170168 }
171- { // collect far
172- q->colorTexture (fb, 0 , texFar);
169+
170+ { // blur
171+ GfGaussianBlurConfig gb;
172+ (ScreenSpaceCommonConfig &)gb = config;
173+ gb.resolution = res;
174+ gb.internalFormat = GL_RGB16F;
175+ gb.texture = texDof;
176+ for (uint32 i = 0 ; i < config.blurPasses ; i++)
177+ gfGaussianBlur (gb);
178+ }
179+
180+ { // apply
181+ q->viewport (Vec2i (), config.resolution );
182+ q->colorTexture (fb, 0 , config.outColor );
173183 q->checkFrameBuffer (fb);
174- q->uniform (shader, 0 , 1 );
184+ q->bind (config.inColor , 0 );
185+ q->bind (config.inDepth , 1 );
186+ q->bind (texDof, 2 );
187+ q->bind (config.assets ->get <AssetSchemeIndexShaderProgram, MultiShaderProgram>(HashString (" cage/shader/effects/dofApply.glsl" ))->get (0 ));
175188 q->draw (model);
176189 }
177-
178- // blur
179- GfGaussianBlurConfig gb;
180- (ScreenSpaceCommonConfig &)gb = config;
181- gb.resolution = res;
182- gb.internalFormat = GL_RGB16F;
183- gb.texture = texNear;
184- for (uint32 i = 0 ; i < config.blurPasses ; i++)
185- gfGaussianBlur (gb);
186- gb.texture = texFar;
187- for (uint32 i = 0 ; i < config.blurPasses ; i++)
188- gfGaussianBlur (gb);
189-
190- // apply
191- q->viewport (Vec2i (), config.resolution );
192- q->colorTexture (fb, 0 , config.outColor );
193- q->checkFrameBuffer (fb);
194- q->bind (config.inColor , 0 );
195- q->bind (config.inDepth , 1 );
196- q->bind (texNear, 2 );
197- q->bind (texFar, 3 );
198- q->bind (config.assets ->get <AssetSchemeIndexShaderProgram, MultiShaderProgram>(HashString (" cage/shader/effects/dofApply.glsl" ))->get (0 ));
199- q->draw (model);
200190 }
201191
202192 namespace
0 commit comments