Jump to content

Recommended Posts

Posted

Hi All,

 

I need a little direction on how to fade out a model over time, is this done via a shader? or is there some other method? (don't know a whole lot about shaders as of yet).

 

This would be great for fading out dead characters etc instead of just deleting them as I am doing currently.

 

Cheers!

trindieprod.png?dl=0spacer.png?dl=0steam-icon.png?dl=0twitter-icon.png?dl=0spacer.png?dl=0
Posted

This is one of the things I hate about the forward renderer. The model has to be in another world. If you are using the framework there is a transparency world created for you already. You have to switch to that world, load your object, then you can switch back.

 

The thing to remember is that this other world won't care the same lighting unless you make it the same as your main world. Also if you load multiple instances of the same model all in the same world, fading 1 will fade all. All in all it's a mess I think. If there were a way to do this with a shader it would be 100% better, but I'm not sure of the challenges in that alone.

Posted

..shader is best way to do it..not just with transparency, but make character disappear in to 'ash', or erode, and so on..other way is to control color value, and gradually cut it down to '0'. That however depending on your renderer setup so i cant say for sure..

 

Posted

Right, because deferred renderer handles transparency differently...

Windows 7 Professional 64 bit, 16 gigs ram, 3.30GHz Quad Core, GeForce GTX 460 one gig, Leadwerks 2.5, Blender 2.62, Photoshop CS3, UU3D

Posted

You still have to have the mesh in the transparency world when using shaders.

So assuming you are using fw, it should go someting like this (not tested)

 

SetWorld(fw.transparency.world)
model = LoadMesh("abstract::model.gmf")
SetWorld(fw.main.world);

myfade=0;
material=LoadMaterial("abstract::"))
shader=GetMaterialShader(material)


 

In your run loop :

 

myfade=myfade+0.001
SetShaderFloat(shader,"myfade",myfade)

 

In mat file have

 

blend=alpha

 

In your shader (frag file)

 

add before main():

uniform float myfade=0.0;

 

find : gl_FragData[0] = diffuse;

 

Add below

 

gl_FragData[0].a-=clamp(myfade,0,1);

 

 

It should now alpha fade by 0.001 per flip() (in theory)

HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB

  • 2 weeks later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...