Gilmer Posted May 30, 2011 Share Posted May 30, 2011 Hi, Im trying use my own post process shader. But the strange is that when I use: "texture2D( texture3....." to get the blurred bloom, it get, but if I use "texture2D( texture0...." to get the color, appears only a black screen, like if dont have color. I think that is something with the way that I'm using the buffers in code. I never did some like this. And the only topic that I found, is this: http://www.leadwerks.com/werkspace/topic/2969-cartoon-shaders/ But the link dont's working :/ Here the code: main.cpp gaussianRally = LoadShader("abstract::postfilter.vert","abstract::postfilter_blurRally.frag"); SetBloom(1); ....... //Main Loop UpdateFramework(); RenderFramework(); SetShader(gaussianRally); SetBlend(0); DrawImage(GetColorBuffer(shaderBuffer,0),0,0,1024,768); Flip(); // end Loop postfilter_blurRally.frag #define LW_BLURRALLY Include "abstract::postfilter.frag" blurrally.frag (getting the "texture3") #define gaussiansamplerange 1.0 for(int i=0;i<8;i++){ outputcolor += texture2D( texture3, texcoord + vec2(0.0,pixelsize.y*gaussiansamplerange ) ); outputcolor += texture2D( texture3, texcoord + vec2(0.0,pixelsize.y*gaussiansamplerange*0.2*i) ); outputcolor += texture2D( texture3, texcoord - vec2(0.0,pixelsize.y*gaussiansamplerange ) ); outputcolor += texture2D( texture3, texcoord - vec2(0.0,pixelsize.y*gaussiansamplerange*0.2*i ) ); outputcolor += texture2D( texture3, texcoord + vec2(pixelsize.x*gaussiansamplerange,0.0 ) ); outputcolor += texture2D( texture3, texcoord + vec2(pixelsize.x*gaussiansamplerange*0.2*i,0.0 ) ); outputcolor += texture2D( texture3, texcoord - vec2(pixelsize.x*gaussiansamplerange,0.0 ) ); outputcolor += texture2D( texture3, texcoord - vec2(pixelsize.x*gaussiansamplerange*0.2*i,0.0 ) ); outputcolor /= 9.0; } result: blurrally.frag (getting the "texture0") #define gaussiansamplerange 1.0 for(int i=0;i<8;i++){ outputcolor += texture2D( texture0, texcoord + vec2(0.0,pixelsize.y*gaussiansamplerange ) ); outputcolor += texture2D( texture0, texcoord + vec2(0.0,pixelsize.y*gaussiansamplerange*0.2*i) ); outputcolor += texture2D( texture0, texcoord - vec2(0.0,pixelsize.y*gaussiansamplerange ) ); outputcolor += texture2D( texture0, texcoord - vec2(0.0,pixelsize.y*gaussiansamplerange*0.2*i ) ); outputcolor += texture2D( texture0, texcoord + vec2(pixelsize.x*gaussiansamplerange,0.0 ) ); outputcolor += texture2D( texture0, texcoord + vec2(pixelsize.x*gaussiansamplerange*0.2*i,0.0 ) ); outputcolor += texture2D( texture0, texcoord - vec2(pixelsize.x*gaussiansamplerange,0.0 ) ); outputcolor += texture2D( texture0, texcoord - vec2(pixelsize.x*gaussiansamplerange*0.2*i,0.0 ) ); outputcolor /= 9.0; } result: Why I cant get the texture0? Whats I need to do? Quote Link to comment Share on other sites More sharing options...
Canardia Posted May 30, 2011 Share Posted May 30, 2011 Works fine for me: #include "engine.h" int main() { Initialize(); Graphics(); CreateFramework(); TCamera cam=GetLayerCamera(GetFrameworkLayer(0)); TMesh cube=CreateCube(); MoveEntity(cam,Vec3(0,0,-5)); AmbientLight(Vec3(0)); CreateDirectionalLight(); EntityColor(cube,Vec4(1,0,0,1)); TShader gaussianrally = LoadShader("abstract::postfilter.vert","abstract::postfilter_blurrally.frag"); TBuffer shaderbuffer = CreateBuffer(640,480,BUFFER_COLOR); SetBloom(1); while(!KeyHit()) { UpdateFramework(); TurnEntity(cube,Vec3(AppSpeed())); SetBuffer(shaderbuffer); RenderFramework(); SetBuffer(BackBuffer()); SetShader(gaussianrally); DrawImage(GetColorBuffer(shaderbuffer,0),0,0,640,480); SetShader(NULL); Flip(0); } return Terminate(); } Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Gilmer Posted May 30, 2011 Author Share Posted May 30, 2011 hehe...now it's working for me. I dont know work very good with buffers.. thx Lumooja Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.