tx for u response Art ,

if i understand u correctly  my code will be something like this  ,i am using 
glew .
(suppose my input texture where i want  to find my maximum value is 
(width,height) and i have a FrameBuffer class and a GL_Texture class, and a 
shader.)

inputtexture=new GL_Texture(...width,height...)
n=2;
fbo=new FrameBuffer(...)

loop
{
outputexture=new GL_Texture(..width/n,height/n)

//activate fbo to render to texture 
fbo->Bind();

//attach a outputexturetexture to render to it
fbo->AttachTexture(outputexture);

//setup viewport to size of outputetexture
glViewport(0, 0,width/n,height/n);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho (0, (GLdouble) ,width/n, 0,height/n, -30, 30);
glClearColor(0,0,0,0);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();

//activate inputtexture and run shader 
inputtexture->Activate(GL_TEXTURE0);
shader->begin();

//pass inputtexture to shader 
shader->setUniform1i("texture0",0);

//Here i render a Rectangle at width/n and height/n

//disable shader and fbo
shader->end();
fbo->Disable();

 //go to next step of reducing inputtexture
n*=2;

//copy outputetexture to inputtexture for next iteration : 
inputtexture=outputexture
inputtexture=GetCopy(outputexture);


delete outputexture;

}//end loop

and in the fragment shader all i have to do is : each pixel shader will 
calulate a maximum for 4 neighberhood texels  of the input texture ?
is it correct ?

thx in advance
 


> Message: 5
> Date: Tue, 5 Aug 2008 17:09:45 +0000 (GMT)
> From: Art Tevs <[EMAIL PROTECTED]>
> Subject: Re: [osg-users] using shaders to find fthe maximum value in a
>       texture
> To: OpenSceneGraph Users <[email protected]>
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=utf-8
> 
> Do you need the maximum value over all texture elements?
> If yes, then you just have to compute a mipmap with max as combining 
> operation. In the last level, where only one pixel left, you will get the 
> maximum value.
> It is pretty straight forward to implement such an algorithm. 
> 
> Either any GPGPU approach can help you, or if you use osg, then take a look 
> into osgPPU's hdr example.
> 
> Best regards,
> Art
> 
> 
> --- Abdallah Deeb <[EMAIL PROTECTED]> schrieb am Di, 5.8.2008:
> 
> > Von: Abdallah Deeb <[EMAIL PROTECTED]>
> > Betreff: [osg-users] using shaders to find fthe maximum value in a texture
> > An: [email protected]
> > Datum: Dienstag, 5. August 2008, 16:56
> > Hello, 
> > i am new to glsl ,  i have a probleme ( it seems that it is
> >  fondamental problem in shaders) 
> > in order to calculate the maximum/minumum value in a
> > texture passed to fragment shader ,
> > it seems that there is as special architecture to implement
> > to resolve this probleme .
> > i passed a days searching on the net to solve this problem
> > but no one discuss this probleme and how to calculate a
> > maximum or minimum in a texture or vector norm ... i heard
> > something called vector reduce in shaders.. but i have no
> > clear idea about it . 
> > 
> > so in resume  my question is how can i create a fragment
> > shader that can calculate (a maximum value for ex) in a
> > texture passed to it ,
> > 
> > if anyone can help me plz  , i really need an
> > implementation or a reference docs.. 
> > thx in advance . 
> > 
> > 


_________________________________________________________________
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to