Phodex Games Posted July 6, 2018 Share Posted July 6, 2018 Hi, I wonder how I would achieve a dissolve effect, or simply make an material disappear over time. I want to for smoothly making objects disappear before they get removed. I found this, but don't know how to use it: https://www.google.de/search?q=leadwerks+dissolve+shader&rlz=1C1GCEA_enDE754DE754&oq=leadwerks+dissolve+shader&aqs=chrome..69i57j69i60.7455j1j4&sourceid=chrome&ie=UTF-8 I tried to apply the shader to an material and called material:SetColor(1, 1, 1, x-0.05) on update. But nothing seems to happen. Also if I try to decrease the alpha value of an material nothing happens, only if it reaches a value below 0.5 then the model with the material appears. So how to set up an material where I can seamlessly adjust the transparency? Thanks for your input! Quote Link to comment Share on other sites More sharing options...
Josh Posted July 10, 2018 Share Posted July 10, 2018 For a deferred renderer you want to discard one pixel at a time, rather than use transparency. This is what that shader does. Rick and TJHeldna also came up with something for their zombie survival game. (In the new forward renderer, transparency is fine). 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...
Phodex Games Posted July 10, 2018 Author Share Posted July 10, 2018 Well ok. Unforunately I am not very familiar with shaders yet. Thats a skill I need to learn any time soon ^^. Can't wait to see the new Turbo Engine! Keep it up, looking good. Quote Link to comment Share on other sites More sharing options...
Marcousik Posted July 24, 2018 Share Posted July 24, 2018 Hey I test it, it works..Using the animation shader of Shadmar on the crawler material And added same shader "diffuse+normal+specular+dissolve.shader" on the shadow shader of the material. just added this in the UpdatePhysics() of the MonsterAI.lua local matos=self.entity:GetSurface(0):GetMaterial() matos:SetColor(1,1,1,matos:GetColor().a-0.001) For fun I tried this: matos:SetColor(0,0,0,matos:GetColor().a-0.002) Here to see: Test_First 24.07.2018 12_08_53.mp4 1 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted September 22, 2018 Share Posted September 22, 2018 Does anyone have a copy of this? I actually need something like this right now. Can anyone post that and save me 15 minutes of work? 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 September 22, 2018 Share Posted September 22, 2018 Okay, here's how it is done. First you need a random function. This takes a vec2 input as a seed and returns a pseudorandom number: float rand(vec2 co) { return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); } Then you just add this at the beginning of the main function of any shader. The input vColor is used to get the alpha value to compare: //Dissolve effect float refalpha = rand(gl_FragCoord.xy * float(1+gl_SampleID)) * 0.99; if (vColor.a <= refalpha) discard; Including the sample ID makes it a bit less grainy when MSAA is used. 1 1 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...
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.