shader for "fading in" like landmines


(Zer0Cool) #1

I need a shader that fades my texture in after a certain distance like the landmines which can be seen from covert ops if they have enough xp.
i have seen the opposite of that done by a shader, it was in the map quakejumps. (it faded out if you were near enough to it)
the command for fadeing by distance seems to be

alphagen portal “value_for_distance”

but i dont know how the shader for fading in have to look like, or if it is even possible to do smth like that.

the best would be if i could use the shader from the game which is used for the mines, but i cant find it.It also could be that it isnt done by shader, but by the engine in a different way… :S


(carnage) #2

AFAIK the landmines are show/hidden by the game code they do not fade in out they just apear when you get withing a certain distance of them

The shader command you have posted I would guess generates alpha values for the surface based on how far away it is. I guess you need to then use a blend command to draw the texture to the apropriate transparency dependant on the alpha values

[Source * <srcBlend>] + [Destination * <dstBlend>]

source blend posible functions based on alpha values
GL_SRC_ALPHA
GL_ONE_MINUS_SRC_ALPHA

source blend posible functions based on alpha values
GL_SRC_ALPHA
GL_ONE_MINUS_SRC_ALPHA

so the final blend probably looks something like

blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA

inverting the blend functions will probably change so the thing fades in or out as you get closer

textures/distance_fade/shader_name
{
{

  map textures/distance_fade/image
  blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA

  }

}


(-SSF-Sage) #3

What about?


    // distanceCull <inner&rt; <outer&rt; <alpha threshold&rt;
    distanceCull 256 1024 0.4

This is used for grass in radar for example.


(Zer0Cool) #4

@carnage:

what texture do i have to use? with alphachannel? i tried different things but it was always the wrong direction, from visible->invisible

@{SSF}Sage

the command didnt work for me :frowning: does it need any preconditions to work?


(carnage) #5

blendFunc GL_ONE_MINUS_SRC_ALPHA GL_SRC_ALPHA

try replacing the blend func with this

AFAIK you shouldnt need a texture with a specific alpha channel as you are using shader lines to generate alpha values based on distance


(Zer0Cool) #6

It works. Thank you very much!


(Pande) #7

distanceCull = how far away until engine stops rendering. its used in that map because there is a lot of grass and Simon wanted to save on some fps.


(kamikazee) #8

So if I understand you right, it’s best to add distanceCull on top of alphagen to make sure no rendering happens at far distances.


(Pande) #9

ya its basically like what you use in world spawn to set max visibilty distance, only this time your setting it to one shader.


(Zer0Cool) #10

Me again,

is there a chance to get this working for moving shaders, for example scriptmovers that have this shader on them. (for me it doesnt work so far)
and distanceCul still doesnt work for me too. I tried it with exactly the same shader from the gras but with another texture and it didnt work.l