   Looking for alternative to stipple polygon
  I want to play around with stipple transparency in a deferred shader. Well, stippling seems to be deprecated with atleast OGL3.2 and I'm looking for an alternative way of appling a stipple pattern to my render pipeline.The best idea sofar would be the use of the stencil buffer. But how to initialize it ? Will using discard in glsl be interpretated as z-fail ? Are there other alternatives to stipple ?   
  You can use gl_FragCoord and discard in your shader to make your own stipple pattern.This was my quick solution for packing 4 layers of alpha in a 2x2 stipple pattern:alphaLayer = /* uniform with the value 0, 1, 2 or 3 */;vec2 oddOrEven = round( fract( gl_FragCoord.xy * 0.5 ) );vec2 patterns[4];patterns[0] = vec2(0,0);patterns[1] = vec2(0,1);patterns[2] = vec2(1,0);patterns[3] = vec2(1,1);oddOrEven = mix( oddOrEven, 1.0-oddOrEven, patterns[alphaLayer] );if( oddOrEven.x > 0.5 || oddOrEven.y > 0.5 ) discard;If you discard a pixel then it won't write to the Z-buffer, which means if your card supports early-Z (doing depth test/write before running the shader), it will disable this optimisation while these shaders are in use.   ;  Thanks you Hodgman, that was what I'm looking for. I saw in your thread about inferred lighting that you played around with stipple transparency too. Did you succeed in your efforts ? Are you satisfied with the result ?   ;  Yeah I think I'm going to stick with doing my transparent objects through the inferred pipeline this way, instead of rendering them in a seperate forward-lit pass. I just really like the fact that everything uses the one lighting pipe.The transparent lighting quality is degraded by 2x, but you generally don't have high-freqency light details on transparent objects anyway.I still haven't done too much experimentation on the problem I had in that thread you mention -- to select which layer/pattern each object uses I'm just using alphaLayer = mod( objectId, 4.0 );which means when 2 objects overlap, there's a 25% chance that only the front one will be lit (i.e. 25% chance that they select the same stipple pattern).I'm also just accepting the issue that opaque objects behind transparent objects also have their lighting quality reduced -- but if you're doing stippled transparency in a defferred pipe (not an inferred pipe with DSF) then you probably won't have that problem. Instead I'm guessing you'd use a seperate accumulation buffer for translucent objects and then composite this over the top of the solid layer, avoiding the problem altogether.   ;Quote:Original post by HodgmanI'm also just accepting the issue that opaque objects behind transparent objects also have their lighting quality reduced -- but if you're doing stippled transparency in a defferred pipe (not an inferred pipe with DSF) then you probably won't have that problem. Instead I'm guessing you'd use a seperate accumulation buffer for translucent objects and then composite this over the top of the solid layer, avoiding the problem altogether.No, I'm trying to use just one buffer. I've got a lot of lighting with different techniques involved(fullscreen-quad lights, volumne lights, particle lights) and therefor I want to avoid a second light pass. The basic pipeline idea is:- build g-buffer of opaque geometry- ssao- render transparent objects using stipple pattern- shadow- lighting passes- particle pass- tonemapping & blur for bloom- final composition(bloom+tonemapping+transparency composition)At first I'm happy with just one layer of transparency (water or fog). I will try to make the final composition recognise the presents of tranparent pixel, in this case the result will be a little bit blurred (half resolution), if no tranparent pixels are available,no blur will occur. In this case a transparent surface will most probably look a little bit blurred including some artifacts with high frequency hightlights. If this works, I will take a look at 3 layers and DSF.