lassev Posted June 2, 2003 Share Posted June 2, 2003 Hmm. I have been meddling with this shader for some time now, trying a couple'o'different blendmodes, but I don't seem to get rid of this strange error: What I'm talking about is that big, ugly red stripe across the orherwise nice shader. The stripe seems to appear only when you look at the shader from certain angles. The code is (right now) as follows: textures/lighthouse/glass_cautio { qer_editorimage textures/tests/glass2 qer_trans 0.5 surfaceparm nonopaque surfaceparm trans q3map_nolightmap { map textures/lighthouse/glass_cau blendFunc GL_ONE GL_ONE_MINUS_SRC_COLOR } { // tcMod scale 3 3 map textures/lighthouse/glass_cau blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_COLOR tcGen environment } } If it makes any difference, the actual glass_cau image (with the image on the left side, the alpha channel turned visible on the right side): Link to comment Share on other sites More sharing options...
Psynex Posted June 2, 2003 Share Posted June 2, 2003 textures/lighthouse/glass_cautio { qer_editorimage textures/tests/glass2 qer_trans 0.5 surfaceparm nonopaque surfaceparm trans q3map_nolightmap { // tcMod scale 3 3 map textures/lighthouse/glass_cau blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_COLOR tcGen environment } } I'm no shader master, but I can point out a few things you can try that might help. The reason you're only seeing it from certain angles has to do with the tcGen environment line right near the end along with applying two sets of blend functions to the same texture. Essentially what you've done is stacked the same image on top of itself using different blend modes causing that ugly streak. I would remove this line: { map textures/lighthouse/glass_cau blendFunc GL_ONE GL_ONE_MINUS_SRC_COLOR } and just work with the stage under it. But I think the blendFunc should be GL_ONE GL_ONE MINUS_SRC_ALPHA. So you should end up with: { // tcMod scale 3 3 map textures/lighthouse/glass_cau blendFunc GL_SRC_ONE GL_ONE_MINUS_SRC_ALPHA tcGen environment } One other thing I noticed, and don't know much of with shaders is the nonopaque surfaceparm and the trans surface parm. I don't know if telling the enging 3 times that the texture should be transparent is necessary. But because I don't know much about mapping, I don't know if you can use all of them together or if you NEED to use them all together. Link to comment Share on other sites More sharing options...
lassev Posted June 3, 2003 Author Share Posted June 3, 2003 Alas, I'm not an expert myself (no kidding), but rather I just mess with copy paste methods. Thus I cannot right away say, how the changes you proposed would work. But thanks for suggestions! Still, I must point one thing out. I should have mentioned it right away, but I forgot it. There are two stages of transparency, because the other is for the glass, which would be very transparent, and the other stage is for the red square, which should not be so transparent, but still somewhat transparent, in a different way (that's why I have the alpha channel). Yeah, I know it does not necessarily mean my shader code would be suitable (obviously it is not). I'll look more carefully at your answer and try to implement at least suitable parts of it. Thanks. Link to comment Share on other sites More sharing options...
Psynex Posted June 3, 2003 Share Posted June 3, 2003 ah...I see. Well, the same holds true with the red box image. You have it defined twice with different blend modes. I would get rid of the last stage: { // tcMod scale 3 3 map textures/lighthouse/glass_cau blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_COLOR tcGen environment } ...and change the blendFunc right above that to GL_ONE GL_ONE_MINUS_SRC_ALPHA. see if that helps. Link to comment Share on other sites More sharing options...
lassev Posted June 4, 2003 Author Share Posted June 4, 2003 Thanks. I haven't yet have time to test it, but I'll test it by tomorrov (hopefully). This is not a big issue, but certainly a nuisance. And I already feel myself a bit shader wiser. Link to comment Share on other sites More sharing options...
lassev Posted June 5, 2003 Author Share Posted June 5, 2003 Initially, it was nothing but my laziness to post this question. However, the benefits were greater. Thanks, Psynex, for forcing me to focus my attention at tcGen environment. It was indeed the culprit, in a sense. However, you cannot have a decent glass without it. It creates the glass effect. The solution to this problem was easy in the end. I just changed the second stage to use one of the original, plain glass images, not my custom glass with the red square. Of course there was no need for alpha channels, just GL_ONE GL_ONE (uh, if I remember correctly). Link to comment Share on other sites More sharing options...
Psynex Posted June 6, 2003 Share Posted June 6, 2003 yeah, GL_ONE GL_ONE is right; not using alphas is another way to go also. You could have left the alpah there and got it to work, but in eliminating it, you're lowering file size which is always an added bonus. Link to comment Share on other sites More sharing options...
lassev Posted June 6, 2003 Author Share Posted June 6, 2003 Eh, the alpha's still there for the first stage. But for the second stage there's little need for it, as the glass2 has no alpha channel. I wanted the alpha channel for the first image (glass_cau) to get more distinct red color in the square. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.