Thareh Posted January 25, 2010 Share Posted January 25, 2010 Hi I just followed the Transparency and Refraction tutorial and got it working - except for the depth information which causes objects in front of the refraction to get refracted aswell. Is the tutorial a bit broken or have I messed up somewhere? Oh, and I am clearing the GBuffer after I've copied the LightBuffer and GBuffer to the Backbuffer. Thanks! Quote Core2Duo, 3.33GHz, Radeon HD 5850 Black Edition, 4GB RAM, 4 TB HDD, Windows 7. Core2Duo, 2.00GHz, Geforce 9500m, 4GB RAM, 320 GB HDD, Windows 7. Link to comment Share on other sites More sharing options...
Naughty Alien Posted January 26, 2010 Share Posted January 26, 2010 ..i will not trust much in to tutorials at this moment..i think Josh rewriting them, this time properly...I dont know are they updated, but if not (i guess), then, be ready for major nightmares... Quote Link to comment Share on other sites More sharing options...
Thareh Posted January 26, 2010 Author Share Posted January 26, 2010 That's what I thought I'll continue with my experiments and see if I can solve it myself ^^ Quote Core2Duo, 3.33GHz, Radeon HD 5850 Black Edition, 4GB RAM, 4 TB HDD, Windows 7. Core2Duo, 2.00GHz, Geforce 9500m, 4GB RAM, 320 GB HDD, Windows 7. Link to comment Share on other sites More sharing options...
Thareh Posted January 26, 2010 Author Share Posted January 26, 2010 I really don't have a clue on what could be wrong, I've tried 'everything'. Anyone have a clue? Quote Core2Duo, 3.33GHz, Radeon HD 5850 Black Edition, 4GB RAM, 4 TB HDD, Windows 7. Core2Duo, 2.00GHz, Geforce 9500m, 4GB RAM, 320 GB HDD, Windows 7. Link to comment Share on other sites More sharing options...
Josh Posted January 27, 2010 Share Posted January 27, 2010 Last time I checked, the lesson worked fine. It's not very compex, and I can't think of anything that would have affected it. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Thareh Posted January 27, 2010 Author Share Posted January 27, 2010 Can you please check again Josh? I really can't get refraction to work without objects in front of the refraction getting refracted aswell. I've experimented with it a bit, and I actually got the tutorial working now but only if I DON'T clear the depth information (?) and it'll only work with objects under VERY limited conditions. And by VERY limited I mean, if you move the cube or the camera back 1 unit you'll get the refraction artifact around the cube again. Thanks Quote Core2Duo, 3.33GHz, Radeon HD 5850 Black Edition, 4GB RAM, 4 TB HDD, Windows 7. Core2Duo, 2.00GHz, Geforce 9500m, 4GB RAM, 320 GB HDD, Windows 7. Link to comment Share on other sites More sharing options...
Josh Posted January 27, 2010 Share Posted January 27, 2010 I just tried the vc project included in the lesson with no problems. You can view the tutorial here now: http://leadwerks.com/werkspace/index.php?/page/index.html?record=10 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Thareh Posted January 27, 2010 Author Share Posted January 27, 2010 Okey, And what happens if you change the line: PositionEntity(cam,Vec3(0,0,-1.5)); with PositionEntity(cam,Vec3(0,0,-2.5)); Still working fine? Quote Core2Duo, 3.33GHz, Radeon HD 5850 Black Edition, 4GB RAM, 4 TB HDD, Windows 7. Core2Duo, 2.00GHz, Geforce 9500m, 4GB RAM, 320 GB HDD, Windows 7. Link to comment Share on other sites More sharing options...
Josh Posted January 28, 2010 Share Posted January 28, 2010 There are two cameras. Unlike the Highlander, there can be more than one. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Thareh Posted January 28, 2010 Author Share Posted January 28, 2010 Yes there is I've tried setting the 'MainCamera' and 'ForegroundCamera' to the same position etc, still doesn't work if that's where you're trying to point me ^^ SetEntityMatrix(fgcam,GetEntityMatrix(cam)); copies the 'MainCamera's position etc anyway, so just do as I said up there and replace the line: PositionEntity(cam,Vec3(0,0,-1.5)); with PositionEntity(cam,Vec3(0,0,-2.5)); In the last of the program examples in your 'Transparency and Refraction' tutorial. Quote Core2Duo, 3.33GHz, Radeon HD 5850 Black Edition, 4GB RAM, 4 TB HDD, Windows 7. Core2Duo, 2.00GHz, Geforce 9500m, 4GB RAM, 320 GB HDD, Windows 7. Link to comment Share on other sites More sharing options...
Thareh Posted January 28, 2010 Author Share Posted January 28, 2010 It's pretty important that I get this working, I've been stuck now for 3 days. Is there a way to get the refraction working properly? >.< Quote Core2Duo, 3.33GHz, Radeon HD 5850 Black Edition, 4GB RAM, 4 TB HDD, Windows 7. Core2Duo, 2.00GHz, Geforce 9500m, 4GB RAM, 320 GB HDD, Windows 7. Link to comment Share on other sites More sharing options...
Josh Posted January 29, 2010 Share Posted January 29, 2010 I can produce the problem. This is very strange. This code uses the up and down keys to move the camera forwards and backwards. There is a certain spot where the error appears and disappears almost instantly. Which GPU is this occuring on? I get an error with an ATI 3870, so it is unlikely to be a driver error if you are using NVidia cards: #include "engine.h" int main(int argc, char** argv) { Initialize(); //Create a graphics context Graphics(800,600); //Create a world TWorld world=CreateWorld(); if (!world) { MessageBoxA(0,"Error","Failed to create world.",0); goto exitapp; } //Create a render buffer TBuffer gbuffer=CreateBuffer(800,600,BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL); //Lighting buffer TBuffer lightbuffer=CreateBuffer(800,600,BUFFER_COLOR); //Create a camera TEntity campiv=CreatePivot(); PositionEntity(campiv,Vec3(0,2,0)); TCamera cam=CreateCamera(campiv); PositionEntity(cam,Vec3(0,0,-1.95)); //Load the scene LoadMesh("scene.gmf"); //Create a light TLight light=CreatePointLight(); PositionEntity(light,Vec3(0,1,0)); //Create the transparency world TWorld foreground=CreateWorld(); //Create a camera for the transparency world TCamera fgcam=CreateCamera(); CameraClearMode(fgcam,0); //Create the transparent object TMesh mesh=CreateSphere(); PositionEntity(mesh,Vec3(0,2,0)); //Load the transparent material TMaterial material=LoadMaterial("glass_refraction.mat"); SetMaterialTexture(material,GetColorBuffer(lightbuffer),2); SetMaterialTexture(material,GetDepthBuffer(gbuffer),3); PaintEntity(mesh,material); TShader refractionshader=GetMaterialShader(material); SetWorld(world); TMesh cube=CreateCube(); ScaleEntity(cube,Vec3(0.1)); PositionEntity(cube,Vec3(0,2,1)); TMaterial cubematerial=CreateMaterial(); SetMaterialColor(cubematerial,Vec4(1,0,0,1)); PaintEntity(cube,cubematerial); float refractionstrength=0.01; float mx=0.0,my=0.0; TVec3 camrotation; HideMouse(); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); //Main loop while(!KeyHit(KEY_ESCAPE)) { mx=Curve(MouseX()-GraphicsWidth()/2,mx,3); my=Curve(MouseY()-GraphicsHeight()/2,my,3); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); camrotation=EntityRotation(campiv); camrotation.X+=my; camrotation.Y-=mx; RotateEntity(campiv,camrotation); UpdateWorld(); //Render the main world SetBuffer(gbuffer); SetWorld(world); RenderWorld(); //Render lighting SetBuffer(lightbuffer); RenderLights(gbuffer); CopyBuffer(lightbuffer,BackBuffer(),BUFFER_DEPTH|BUFFER_COLOR); CopyBuffer(gbuffer,BackBuffer(),BUFFER_DEPTH); //Set the refraction strength if (KeyDown(KEY_UP)) {MoveEntity(cam,Vec3(0,0,0.01)); }//{ refractionstrength+=0.001 ; } if (KeyDown(KEY_DOWN)) {MoveEntity(cam,Vec3(0,0,-0.01)); }//{ refractionstrength-=0.001 ; } refractionstrength=max(refractionstrength,0.0); SetShaderFloat(refractionshader,"refractionstrength",refractionstrength); //SetBuffer(gbuffer); //ClearBuffer(); SetBuffer(BackBuffer()); //Render transparency SetWorld(foreground); SetEntityMatrix(fgcam,GetEntityMatrix(cam)); RenderWorld(); SetWorld(world); Flip(); } exitapp: return Terminate(); } Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted January 29, 2010 Share Posted January 29, 2010 Find this line in mesh.frag around line 181: if (DepthToZPosition(gl_FragCoord.z)<DepthToZPosition(texture2DProj(LE_DEPTHBUFFER,refractionvector2).x)) { Replace it with this: if (gl_FragCoord.z<texture2DProj(LE_DEPTHBUFFER,refractionvector2).x) { The variable gl_FragCoord.z is a nonlinear depth value between 0.0 and 1.0. It's stored the same way a depth value in a depth texture is stored. We could convert it to a z position with the DepthToZPosition() function, or we can just compare it directly to the depth texture read: http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=234519 I'm sure I knew this already, but I must have missed that when I wrote the shader. This will fix your problem. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Niosop Posted January 29, 2010 Share Posted January 29, 2010 Looks like this should be a fix that's applied for everyone, not just for this specific case, right? Quote Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX ZBrush - Blender Link to comment Share on other sites More sharing options...
Josh Posted January 29, 2010 Share Posted January 29, 2010 Yes, it will be fixed on the server. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Thareh Posted January 29, 2010 Author Share Posted January 29, 2010 Great Josh! It's working properly now! Thanks! ^^ Quote Core2Duo, 3.33GHz, Radeon HD 5850 Black Edition, 4GB RAM, 4 TB HDD, Windows 7. Core2Duo, 2.00GHz, Geforce 9500m, 4GB RAM, 320 GB HDD, Windows 7. Link to comment Share on other sites More sharing options...
Thareh Posted January 29, 2010 Author Share Posted January 29, 2010 I get another artifact now though ^^ When I increase the refractionstrength, and I'm using a water bumpmap found in the leadwerks SDK dir (water02_00.dds) the refraction gets 'cut off' at the edge of an object in the way. It's a bit hard to see without any motion, I can send you an example if you'd like. Quote Core2Duo, 3.33GHz, Radeon HD 5850 Black Edition, 4GB RAM, 4 TB HDD, Windows 7. Core2Duo, 2.00GHz, Geforce 9500m, 4GB RAM, 320 GB HDD, Windows 7. Link to comment Share on other sites More sharing options...
Thareh Posted January 30, 2010 Author Share Posted January 30, 2010 The refraction is supposed to go all the way there on the image, It's hard to see ^^ Quote Core2Duo, 3.33GHz, Radeon HD 5850 Black Edition, 4GB RAM, 4 TB HDD, Windows 7. Core2Duo, 2.00GHz, Geforce 9500m, 4GB RAM, 320 GB HDD, Windows 7. Link to comment Share on other sites More sharing options...
Josh Posted January 30, 2010 Share Posted January 30, 2010 I can't tell anything from that shot. It just looks like a lot of random colors. I updated the lesson to include information on how to use global objects to automate the material texture settings. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted January 30, 2010 Share Posted January 30, 2010 There's now a section at the end on how to do refraction effects in the editor. It's pretty simple: http://leadwerks.com/werkspace/index.php?/page/index.html?record=10 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Thareh Posted January 30, 2010 Author Share Posted January 30, 2010 Yeah, I though I'd be a bit fussy. Here's an example instead ^^ Quote Core2Duo, 3.33GHz, Radeon HD 5850 Black Edition, 4GB RAM, 4 TB HDD, Windows 7. Core2Duo, 2.00GHz, Geforce 9500m, 4GB RAM, 320 GB HDD, Windows 7. Link to comment Share on other sites More sharing options...
Thareh Posted January 30, 2010 Author Share Posted January 30, 2010 Just go closer to the bridge using WASD, and you'll see how the refraction is cut-off near the bridge when it's in the way Quote Core2Duo, 3.33GHz, Radeon HD 5850 Black Edition, 4GB RAM, 4 TB HDD, Windows 7. Core2Duo, 2.00GHz, Geforce 9500m, 4GB RAM, 320 GB HDD, Windows 7. Link to comment Share on other sites More sharing options...
Josh Posted January 30, 2010 Share Posted January 30, 2010 You should add more objects in the air to test with. What is different about that bridge? The sides of the pit don't cause any error like that, and I haven't seen that happen in any of my examples. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Thareh Posted January 30, 2010 Author Share Posted January 30, 2010 I'll add more objects, but do this first: Go to one of the pit walls, go straight up and look down in the pit. At the edge of the pit it'll be glitched I think Quote Core2Duo, 3.33GHz, Radeon HD 5850 Black Edition, 4GB RAM, 4 TB HDD, Windows 7. Core2Duo, 2.00GHz, Geforce 9500m, 4GB RAM, 320 GB HDD, Windows 7. Link to comment Share on other sites More sharing options...
Thareh Posted January 30, 2010 Author Share Posted January 30, 2010 I've tried with alot of other objects, with the same result ^^ Quote Core2Duo, 3.33GHz, Radeon HD 5850 Black Edition, 4GB RAM, 4 TB HDD, Windows 7. Core2Duo, 2.00GHz, Geforce 9500m, 4GB RAM, 320 GB HDD, Windows 7. 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.