Andy Gilbert Posted September 18, 2013 Share Posted September 18, 2013 I still dont get how we dont have any fog, especially now we have terrain? Im sure OpenGL has fog features out-of-the-box? Cant we just have them? Andy Quote The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do. Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d Link to comment Share on other sites More sharing options...
YouGroove Posted September 18, 2013 Share Posted September 18, 2013 Humm .... Fog and shaders are not compatible from what i read long time ago. Some special work is needed if you need fog. A cheap solution : Make several aligned transparent background big planes always facing camera. By using several transparent layers you'll heav fog impression. But indeed not as good as real fog. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
YouGroove Posted September 18, 2013 Share Posted September 18, 2013 What i found : HLSL fog shader : http://ploobs.com.br/?p=1868 shader fog for dummies : https://www.dropbox.com/s/z05aql3qp3dsly5/Codea%20shaders.pdf OpenGL fog : http://www.ozone3d.net/tutorials/glsl_fog/ All it needs is you to put at hard work now on this shader Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Andy Gilbert Posted September 18, 2013 Author Share Posted September 18, 2013 YouGroove, i dont want to use transparent backgrounds, otherwise i would do? Ide like to have the ability to turn on fog. This isnt a "find an alternative" forum, its a sugesstions forum? Please stop posting, unnecessary replies. Andy 1 Quote The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do. Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d Link to comment Share on other sites More sharing options...
shadmar Posted September 18, 2013 Share Posted September 18, 2013 (edited) If you want to hack in your own fog, add this to the bottom of all fragment shaders you use just before } to add fog. vec4 fog=vec4(1,1,1,0.05); // R,G,B,strength #define LOG2 1.442695 float z = gl_FragCoord.z / gl_FragCoord.w; float fogFactor = clamp(exp2(-fog.w*fog.w*z*z*LOG2),0.0,1.0); gl_FragColor = mix(vec4(fog.xyz,1.0), gl_FragColor, fogFactor); For terrain : terrain.shader, just before gl_FragData[0] = outcolor; add : vec4 fog=vec4(1,1,1,0.05); // R,G,B,strength #define LOG2 1.442695 float z = gl_FragCoord.z / gl_FragCoord.w; float fogFactor = clamp(exp2(-fog.w*fog.w*z*z*LOG2),0.0,1.0); outcolor = mix(vec4(fog.xyz,1.0), outcolor, fogFactor); A more elegant way would be to add vec4 fog as a uniform and send color and density from your app using SetVec4 EDIT: sorry Andy if I'm also derailing your post. Edited September 18, 2013 by shadmar 2 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Andy Gilbert Posted September 18, 2013 Author Share Posted September 18, 2013 Hi shad, thanks and no derailing going on. I very much welcome useful replies. Ill give that ago, it seems like it will do the trick for now. You really are a shader wiz! Thanks shad Andy Quote The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do. Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d Link to comment Share on other sites More sharing options...
YouGroove Posted September 18, 2013 Share Posted September 18, 2013 Ok , i will let shadmar and other programmers reply to programming or features missing on suggestion forum so. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Josh Posted September 19, 2013 Share Posted September 19, 2013 The plan is to create a post-processing list in the editor and then you can just add effects like fog, SSDO, and whatever other crazy effects Shadmar makes. 5 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...
gamecreator Posted September 19, 2013 Share Posted September 19, 2013 Love that. And I mentioned this before but if possible, please make it so that we can set the strength of any effect, especially in our code. Something like SetEffect(fog, 0.5); which would enable fog at half strength. Of course you'd know the better way to implement that function but that's the idea. Quote Link to comment Share on other sites More sharing options...
Nexerade Posted February 7, 2016 Share Posted February 7, 2016 If you want to hack in your own fog, add this to the bottom of all fragment shaders you use just before } to add fog. vec4 fog=vec4(1,1,1,0.05); // R,G,B,strength #define LOG2 1.442695 float z = gl_FragCoord.z / gl_FragCoord.w; float fogFactor = clamp(exp2(-fog.w*fog.w*z*z*LOG2),0.0,1.0); gl_FragColor = mix(vec4(fog.xyz,1.0), gl_FragColor, fogFactor); For terrain : terrain.shader, just before gl_FragData[0] = outcolor; add : vec4 fog=vec4(1,1,1,0.05); // R,G,B,strength #define LOG2 1.442695 float z = gl_FragCoord.z / gl_FragCoord.w; float fogFactor = clamp(exp2(-fog.w*fog.w*z*z*LOG2),0.0,1.0); outcolor = mix(vec4(fog.xyz,1.0), outcolor, fogFactor); A more elegant way would be to add vec4 fog as a uniform and send color and density from your app using SetVec4 EDIT: sorry Andy if I'm also derailing your post. I have a black screen when I put this to ambientlight.shares. I guess it's no more working? :c Quote I am not silly. My english is just not really great. T_T But I'm learning! Link to comment Share on other sites More sharing options...
macklebee Posted February 7, 2016 Share Posted February 7, 2016 I have a black screen when I put this to ambientlight.shares. I guess it's no more working? :c ambientlight.shares? the ambientlight.shader? yeah dont do that. This topic was from over two years ago - there have been many updates since then. Also, have you checked the shadmar's Post Effect shaders in the workshop? I believe klepto's fog is available in there. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel 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.