SpiderPig Posted August 6, 2010 Share Posted August 6, 2010 I've made this simple program based on the Post-Processing tutorial which works fine until I set a shader which causes the end result to be a solid grey image. I'm positive it's a problem somewhere when setting the shader because it all rendered fine before I added that code. I've tried 'abstract' file system as well as loading each file directly. Can anyone help? Here's the code : #include "engine.h" int main(int argc,char** argv) { Initialize(); Graphics(640,480); TWorld world=CreateWorld(); TEntity MainCam=CreateCamera(); MoveEntity(MainCam,Vec3(0,5,-20)); CameraClearMode(MainCam,BUFFER_DEPTH); //creat a render buffer for lighting TBuffer gbuffer=CreateBuffer(640,480,BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL); //create a buffer for post processing effects TBuffer postbuffer=CreateBuffer(640,480,BUFFER_COLOR); //creat a directional light, e.g. the sun TLight light=CreateDirectionalLight(); RotateEntity(light,Vec3(45,45,0)); //create the skybox TWorld background=CreateWorld(); TMesh skybox=CreateCube(); TCamera skycam=CreateCamera(); FlipMesh(skybox); PaintEntity(skybox,LoadMaterial("FullskiesBlueClear0016_2_L.mat")); SetWorld(world); TTerrain terrain=CreateTerrain(64); ScaleEntity(terrain,Vec3(5,5,5)); TEntity Oak=LoadModel("Oak/Oak.gmf"); PositionEntity(Oak,Vec3(-40,0,-30)); TShader postfilter=LoadShader("abstract::postfilter.vert","abstract::postfilter_desaturate.frag"); TTexture grass1=LoadTexture("terrain_forest_grass.dds"); SetTerrainTexture(terrain,grass1,0,0); SetTerrainTextureScale(terrain,6,0); TVec3 camrotation=Vec3(0); float mx=0; float my=0; HideMouse(); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); while(!KeyHit(KEY_ESCAPE)) { mx=Curve(MouseX()-GraphicsWidth()/2,mx,6); my=Curve(MouseY()-GraphicsHeight()/2,my,6); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); camrotation.X=camrotation.X+my/10.0; camrotation.Y=camrotation.Y-mx/10.0; RotateEntity(MainCam,camrotation); if(KeyDown(KEY_W)) { MoveEntity(MainCam,Vec3(0.0,0.0,0.2)); }; if(KeyDown(KEY_S)) { MoveEntity(MainCam,Vec3(0.0,0.0,-0.2)); }; UpdateAppTime(); UpdateWorld(); SetBuffer(gbuffer); //render the background RotateEntity(skycam,EntityRotation(MainCam)); SetWorld(background); RenderWorld(); SetWorld(world); RenderWorld(); SetBuffer(postbuffer); RenderLights(gbuffer); SetBuffer(BackBuffer()); SetShader(postfilter); DrawImage(GetColorBuffer(postbuffer),0,GraphicsHeight(),GraphicsWidth(),-GraphicsHeight()); Flip(); } Terminate(); return 0; } Quote Link to comment Share on other sites More sharing options...
ZioRed Posted August 6, 2010 Share Posted August 6, 2010 I still don't know shaders coding, but I noticed that postfilter_desaturate.frag defines LW_DESATURATE while inside postfilter.frag there are no checks for it but only for LW_SATURATION on line 234: #ifdef LW_SATURATION Include "saturation.frag" #endif May be it is a bug or I am completely wrong (I checked on all frags/verts and didn't find any define for LW_SATURATION). Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com Link to comment Share on other sites More sharing options...
SpiderPig Posted August 6, 2010 Author Share Posted August 6, 2010 Your right there doesn't seem to be anything for desaturate in "postfilter.frag", I also tried the "postfilter_distancefog.frag" but it still gave me the same grey screen. I have a feeling something else is going here...as well as the failure to recognise "LW_DESATURATE". Would Framework be the better option? 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.