wh1sp3r Posted April 5, 2010 Posted April 5, 2010 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 Quote -= Phenom II X4 965 3.4Ghz - ATI HD5870 - 6 GB DDR3 RAM - Windows 8 Pro 64x=- Website: http://www.flamewarestudios.com
AndyGFX Posted April 5, 2010 Posted April 5, 2010 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) Quote [HW] C2D Q6600, 4GB RAM, NV8800GTX, Vista Ultimate x64 [sW] Blide Plus, BlitzMax, Delphi, C++, 3DWS 5.53, Leadwerks 2.xx
wh1sp3r Posted April 5, 2010 Author Posted April 5, 2010 Hi Andy .. i renamed it .. but same result .. i will send it a link to you hehe Quote -= Phenom II X4 965 3.4Ghz - ATI HD5870 - 6 GB DDR3 RAM - Windows 8 Pro 64x=- Website: http://www.flamewarestudios.com
AndyGFX Posted April 5, 2010 Posted April 5, 2010 Change BindTexture( palette , 1 ); to BindTexture( palette , 0 ); Quote [HW] C2D Q6600, 4GB RAM, NV8800GTX, Vista Ultimate x64 [sW] Blide Plus, BlitzMax, Delphi, C++, 3DWS 5.53, Leadwerks 2.xx
wh1sp3r Posted April 5, 2010 Author Posted April 5, 2010 Change BindTexture( palette , 1 ); to BindTexture( palette , 0 ); i tried it, but i see only white screen, by the way, why ? texture0 is for screenimage and my texture1 is for palette. Quote -= Phenom II X4 965 3.4Ghz - ATI HD5870 - 6 GB DDR3 RAM - Windows 8 Pro 64x=- Website: http://www.flamewarestudios.com
flachdrache Posted April 7, 2010 Posted April 7, 2010 ? 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. Quote AMD 64 X2 Dual 5k - 4GB - XFX GForce9800GT - nv196.21 - WinXP Sp3 zBrush4R2 - Silo2Pro - Unwrap3DPro - Gile - MaPZone2.5 Xxploration FPS in progress ...
wh1sp3r Posted April 7, 2010 Author Posted April 7, 2010 everything solved, so, no problem here Quote -= Phenom II X4 965 3.4Ghz - ATI HD5870 - 6 GB DDR3 RAM - Windows 8 Pro 64x=- Website: http://www.flamewarestudios.com
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.