GLSL post process

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Xeus32
Posts: 20
Joined: Tue Mar 22, 2005 9:11 am
Location: Italy , Padua

Post by Xeus32 »

Emil_halim wrote:Xeus32

i have the same problem , so that i have changed SL to CG.

here is your shader program but with CG works fin with me.

Code: Select all

void Vmain( float4 position          : POSITION,             
            out float4 oPosition     : POSITION,            
            out float2 oTexCoord     : TEXCOORD)            
     {                                                     
           float2 P = sign( position.xy );                 
           oPosition = float4( P.x,-P.y ,0.0, 1.0 );       
           oTexCoord = P * 0.5 + 0.5;                      
     }                                                     

    

void Fmain(  float2 TexCoord  : TEXCOORD,              
             out float4 color     : COLOR,             
             uniform sampler2D txtr : texunit0)        
     {                                                    
            float4 col  = tex2D(txtr, TexCoord);          
            float intensity = col.r * 0.299 + col.g * 0.587 +col.b * 0.184 ; 
            color  = float4(intensity, intensity, intensity,col.a) ;                         
     }            
hi sorry for the late !
the code don't compile il the program name is not mane!
so change Fmain in main and Vmain in main!
if not work use this code! It work perfectualy

Vertex

Code: Select all

uniform sampler2D Texture0;

uniform float viewport_inv_width;
uniform float viewport_inv_height;
varying vec2 texCoord;


void main(void)
{
   vec2 P = sign( gl_Vertex.xy );
   gl_Position = vec4( P, 0.0, 1.0 );
   texCoord.x =  0.5+ 0.5*(P.x  ) ; 
   texCoord.y =  0.5+ 0.5*(P.y ) ;
}
Fragment

Code: Select all

uniform sampler2D Texture0;
varying vec2 texCoord;

void main(void)
{
   vec4 color  = texture2D(Texture0,texCoord);
   float intensity = color.r * 0.299 + color.g * 0.587 +color.b * 0.184 ;
   gl_FragColor = vec4(intensity, intensity, intensity,color.a) ;

}
Note the if you use render to texture in opengl mode you can render only 512x512 texture! If you use more big texture you swap in z-buffer and you have display error!
I signalled the bug and the necessity to change glCopyTexSubImage2D in setRenderTarget ( COpengldriver.cpp:2443) with direct render to texture as explain in http://developer.nvidia.com/attach/6725( Page 18 )! This change can permit to use high quality filtering over opengl.
If you need other help i can send my source and FX file for RenderMonkey!

Good Works at all!


(Sorry for my very bad English)
TNX

Xeus32
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

Xeus32 very thanks to you for your great link of fast render to a texture

also i have found that you shader program is so good so that i will use it with my program. :D

i think working with CG is more easlly than work with GLSL.

againe thank you very much.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

You don't listen very well. Here is my first post on this topic...
I had no problem getting them to compile and link from within Irrlicht if I put them into seperate files.
Post Reply