Shader glitches when camera is far

Edit: I solved this problem, but I have a new one, its in the next post :slight_smile:

Hi everyone! Ive been replicating one of the hallways in Amnesia in preparation for a scene in my game, when i came across a problem with the shaders i was using. I get this strange effect where the shader starts to glitch at a certain distance, like the image shows. If i move the camera closer, it is fixed. I thought this was odd as some of the lights don’t glitch, so I’m not sure whats going on :). Here’s the blend file if you want to take a closer look at how i set things up, and hopefully this can be solved :).

BlendFile: :smiley:

Thanks in advance! :smiley:

EDIT: Ive fixed the problem. Because the empties duplication of the group didnt carry over the logic bricks, the material never got the shaders effects. I just had to put one of the origional objects in the scene and it worked :D. It dosnt explain how some did, but at least it works :).

I also forgot to credit solar lune for the origional electricity shader. Ive tweaked it a little bit but overall its his, and its awesome! :smiley:

Ok, I’ve come up with another problem in the same scene. I’ve tried to create a system where bits of the level are chunks and so I can duplicate and move them to create the level. This is all fine, until I started to duplicate the lights I used for the fire. The lights were very glitchy, and only worked in the viewport, not when I hit p. it was fine when I replaced them with another light, so the problem was sort of solved. Problem is, pretty much every object I duplicate and move to the layer my new level system was using glitches up, or mainly it becomes invisible. Ill post a blend file tomorrow, as its two in the morning here and I need to sleep lol :smiley:

If anyone’s had this problem before, do you know how to fix it? Also if I’m unclear, the blend file will be up tomorrow :slight_smile:

It’s actually not my shader - I readapted it from ATI’s RenderMonkey software, if I recall. You should credit them, really.

As for your second problem, I don’t think you can duplicate lights in-game. You can, though, move lights around. So,

  1. Make a Python list of the lights in the current scene,

  2. Make a list of the ‘light positions’ in the current scene,

  3. Find the closest x number of light positions, and place the lights there.

I don’t think the problem is in the shader itself. I think that Blender or your video driver does not like what happens with the shaders related to the duplicated ‘torch’ group. I removed all the torches from the scene that were Empties duplicating the ‘torch’ Group and replaced them with some clones that I created by selecting the torch and doing “Shift-D” to make a duplicate Object. This did not suffer from the glitches.

thanks for all the replies, although i had already fixed it lol :D. Does anyone have any suggestions for the second question? Also, i think i was a little unclear :). I meant when i duplicate objects outside of the game in the editor, when i go into the game they usually act as if they don’t exist. Also, thanks solar lune for the extra crediting thing :D.