Jump to content

Pass the color screen to shader


Gilmer
 Share

Recommended Posts

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:

 

post-313-0-81737900-1306773344_thumb.jpg

 

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:

 

post-313-0-75335800-1306773346_thumb.jpg

 

Why I cant get the texture0? Whats I need to do?

Link to comment
Share on other sites

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();
}

post-2-0-52517800-1306775981_thumb.png

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...