Jump to content

Palette colour filter


wh1sp3r
 Share

Recommended Posts

Hi, i'd like to ask, how to pass a texture to the shader ?

 

 

C++ code:

	world = CreateWorld() ;	
gbuffer=CreateBuffer(GraphicsWidth(),GraphicsHeight(),BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL);
TBuffer postbuffer=CreateBuffer(GraphicsWidth(),GraphicsHeight(),BUFFER_COLOR);

camera=CreateCamera();PositionEntity(camera,Vec3(0,0,-2));

material=LoadMaterial("abstract::cobblestones.mat");
mesh=CreateCube();
PaintEntity(mesh,material);

light=CreateDirectionalLight();
RotateEntity(light,Vec3(45,45,45));
   TShader postfilter;

postfilter=LoadShader("abstract::postfilter.vert","abstract::palette.frag");
TTexture palette = LoadTexture("abstract::palette.dds");

while( !KeyHit() && !AppTerminate() )
{
		TurnEntity( mesh, Vec3( 0.5f*AppSpeed() ) ) ;
		UpdateAppTime();
		UpdateWorld(AppSpeed()) ;	

		SetBuffer(gbuffer);
		RenderWorld();			
		SetBuffer(postbuffer);
		RenderLights(gbuffer);

		SetBuffer(BackBuffer());           

		BindTexture( palette , 1 );
		SetShader(postfilter);			
		DrawImage(GetColorBuffer(postbuffer),0,0,GraphicsWidth(),GraphicsHeight()); 
		SetShader(0);


		DrawText(0,0, "%f", FPS());
		Flip(0) ;
}
return Terminate() ;
}

 

Shader code:

uniform sampler2D Texture0;
uniform sampler2D Texture1;

void main()
{
  vec4 ncolor = vec4(1,0,0,1);
  float colour_distance_nearest = 200000.0;
  float pixelx = 1.0 / 32.0;
  float pixely = 1.0 / 32.0;

  vec4 color = texture2D( Texture0, gl_FragCoord.xy);

  ...


  my super top secret code 

  ...

  gl_FragColor = ncolor;
}

 

i tested shader in rendermonkey and It's working fine :)

i just want to know, how to pass a second texture, this shows me a black screen :(

 

thank you

-= Phenom II X4 965 3.4Ghz - ATI HD5870 - 6 GB DDR3 RAM - Windows 8 Pro 64x=-

Website: http://www.flamewarestudios.com

Link to comment
Share on other sites

1) Look like you have assigned palette texture to TMU 1 and in you shader you have used only TMU 0.

2) shader is case sensitive, default names for TMU are texture0 - texture32, when you use BindTexture command. (Wiki: BindTexture)

[HW] C2D Q6600, 4GB RAM, NV8800GTX, Vista Ultimate x64

[sW] Blide Plus, BlitzMax, Delphi, C++, 3DWS 5.53, Leadwerks 2.xx

 

76561197970156808.pngAndyGFX.png

Link to comment
Share on other sites

? what shader e.g.

 

SetShader(postfilter);

BindTexture( palette , 1 );

 

... in ASM Programs a black output usually means the texture target is empty iirc.

 

shouldnt

vec4 ncolor = vec4(1,0,0,1);

be more like

vec4 ncolor = vec4(0);

just guessing though.

AMD 64 X2 Dual 5k - 4GB - XFX GForce9800GT - nv196.21 - WinXP Sp3

zBrush4R2 - Silo2Pro - Unwrap3DPro - Gile - MaPZone2.5

 

adv_banner-april2012_720x150_tex01.png

 

Xxploration FPS in progress ...

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...