• Stencil tutorial
    54 replies, posted
[QUOTE=aualin;19769069]Love to see something redrawing the model a few hundred times for each pixel and color it differently. Could make an interesting effect :smile:[/QUOTE] Just create a texture and set each pixel to a different colour. Then use that with the stencils!
Looks really useful, but to be honest I'm not understanding this whole pixel values thing.. I'm going to mess around with this stuff later though, stencils look pretty helpful.
[QUOTE=Deco Da Man;19777688]Just create a texture and set each pixel to a different colour. Then use that with the stencils![/QUOTE] I dont like drawing :smith:
[QUOTE=Kopimi;19780440]Looks really useful, but to be honest I'm not understanding this whole pixel values thing.. I'm going to mess around with this stuff later though, stencils look pretty helpful.[/QUOTE] I guess you just need to be creative with what you draw. This will be incredibly useful with a future script I'm planning.
[QUOTE=grea$emonkey;19781937]This will be incredibly useful with a future script I'm planning.[/QUOTE] Care to share a hint what that might be?:3:
[QUOTE=ralle105;19782182]Care to share a hint what that might be?:3:[/QUOTE] Maybe. :3:
-I am dumb-
[QUOTE=aurum481;19799103]Clientside see-through-walls script that is not blocked by Script Enforcer because it is stencil rendering :3: Or something even better ? :v:[/QUOTE] How can it not be blocked by script enforcer?
Because i think, A. It's not being looked for and B. I don't think it scans things that run client side independently. ( I may be completely wrong, Educated guess )
[QUOTE=noforgivin;19800522]Because i think, A. It's not being looked for and B. I don't think it scans things that run client side independently. ( I may be completely wrong, Educated guess )[/QUOTE] Script Enforcer prevents all custom Lua code to be ran clientside, so you can't use the stencil buffer.
Oh hi overv, another time you correct me, Thanks. Rated myself dumb.
[QUOTE=Overv;19800582]Script Enforcer prevents all custom Lua code to be ran clientside, so you can't use the stencil buffer.[/QUOTE] There are ways >.>
[QUOTE=TehBigA;19817160]There are ways >.>[/QUOTE] You're so cool
Great tutorial, but still a little incomplete. Would be great to see some more examples of potential uses.
[QUOTE=grea$emonkey;19822247]Great tutorial, but still a little incomplete. Would be great to see some more examples of potential uses.[/QUOTE] I'll make some simple things and upload code + pics of what it looks like. [editline]07:00PM[/editline] Another example: [url=http://img5.imageshack.us/i/gmconstruct0000t.jpg/][img]http://img5.imageshack.us/img5/6673/gmconstruct0000t.th.jpg[/img][/url] [url=http://img294.imageshack.us/i/gmconstruct0001j.jpg/][img]http://img294.imageshack.us/img294/5117/gmconstruct0001j.th.jpg[/img][/url] [url=http://img682.imageshack.us/i/gmconstruct0002g.jpg/][img]http://img682.imageshack.us/img682/1643/gmconstruct0002g.th.jpg[/img][/url] Code: [lua] local mat = CreateMaterial("GARGAMEL!!!", "UnlitGeneric", {["$basetexture"] = "models/debug/debugwhite"}) hook.Add("PreDrawOpaqueRenderables", "lol", function() for _, v in pairs(ents.FindByClass("npc_*")) do v:SetNoDraw(true) --We want to draw npc with the stencil buffer, so we disable their default drawing end end) hook.Add("PostDrawOpaqueRenderables", "lol", function() render.ClearStencil() render.SetStencilEnable(true) render.SetStencilCompareFunction(STENCILCOMPARISONFUNCTION_ALWAYS) render.SetStencilPassOperation(STENCILOPERATION_KEEP) --If the pixel is visible, do nothing render.SetStencilFailOperation(STENCILOPERATION_KEEP) --If the pixel fails the comparison, do nothing render.SetStencilZFailOperation(STENCILOPERATION_REPLACE) --If the pixel is behind something we replace it's value with th reference value (1) render.SetStencilReferenceValue(1) render.SetBlend(.5) --Blend = alpha, we want the model to be trnaslucent or the pixels will fail on the model itself, and we'll get random white areas we dont want for _, v in pairs(ents.FindByClass("npc_*")) do v:DrawModel() --Draw to stencil end render.SetBlend(1) --Full alpha again render.SetStencilCompareFunction(STENCILCOMPARISONFUNCTION_EQUAL) --Only render the pixels who's value equals the reference value (1) render.SetMaterial(mat) render.DrawScreenQuad() --Draw a white rect covering the screen. This will only cover npcs that are behind something though, since we're using the stencilbuffer. render.SetStencilEnable(false) end) [/lua]
Nice.
And another: [url=http://img682.imageshack.us/i/gmconstruct0003w.jpg/][img]http://img682.imageshack.us/img682/2465/gmconstruct0003w.th.jpg[/img][/url] Code: [lua] hook.Add("PreDrawOpaqueRenderables", "lol", function() for _, v in pairs(ents.FindByClass("prop_physics")) do v:SetNoDraw(true) --We want to draw props with the stencil buffer, so we disable their default drawing end end) hook.Add("PostDrawOpaqueRenderables", "lol", function() render.ClearStencil() render.SetStencilEnable(true) render.SetStencilCompareFunction(STENCILCOMPARISONFUNCTION_ALWAYS) render.SetStencilPassOperation(STENCILOPERATION_REPLACE) --If the pixel is visible we replace it's value with th reference value (1) render.SetStencilFailOperation(STENCILOPERATION_KEEP) --If the pixel fails the comparison, do nothing render.SetStencilZFailOperation(STENCILOPERATION_KEEP) --If the pixel is behind something, do nothing render.SetStencilReferenceValue(1) render.SetBlend(0) --Not visible for _, v in pairs(ents.FindByClass("prop_physics")) do v:DrawModel() --Draw to stencil end render.SetStencilCompareFunction(STENCILCOMPARISONFUNCTION_EQUAL) render.SetStencilPassOperation(STENCILOPERATION_INCR) --If visible Do nothing render.SetStencilZFailOperation(STENCILOPERATION_DECR) --If behind something., decrease the pixels value for _, v in pairs(ents.FindByClass("npc_*")) do v:DrawModel() end render.SetBlend(1) --Visible for _, v in pairs(ents.FindByClass("prop_physics")) do v:DrawModel() end render.SetStencilEnable(false) end) [/lua]
[QUOTE=ralle105;19824814] Code: [lua] hook.Add("PreDrawOpaqueRenderables", "lol", function() for _, v in pairs(ents.FindByClass("prop_physics")) do v:SetNoDraw(true) --We want to draw npc with the stencil buffer, so we disable their default drawing end end)[/lua] [/QUOTE] How can a npc be a prop_physics?
[QUOTE=aualin;19825977]How can a npc be a prop_physics?[/QUOTE] Oh sorry, I just edited the other example. Don't mind that.
[QUOTE=aualin;19825977]How can a npc be a prop_physics?[/QUOTE] He just forgot to change the comment. [editline]07:41PM[/editline] Ninja'd.
A newer thread has been made that contains more stencils information, too. [url]http://facepunch.com/showthread.php?t=1337232[/url]
The year 2013 Excellent Back garden Pet bird Be counted destroys data files inside Colorado This The year 2013 Wonderful Property Fowl Calculate [url=http://www.xinlvxing.com.cn/topic/2011gd0908/cagoose.html]cheap canada goose[/url] set new records data this present year. He [url=http://www.qzhmzx.com/feishoushu/canadagoose.asp]canada goose outlet store[/url] did this the initial yr that was there for players throughout our world [url=http://www.molivagreyaway.com]cheap ugg outlet[/url] and not simply America. Check-lists were definitely sent in from all over the world, which include from the isolated region involving Antarctica. [url=http://zerowastenetwork.org/ca-goose.html]Cheap Canada Goose Citadel Parka[/url] Over a [url=http://www.tonyedu.com/yindiyu/cgm.asp]cheap canada goose[/url] thirdly off type of avian species [url=http://www.xinlvxing.com.cn/topic/2011gd0908/cagoose1.html]canada goose jackets outlet[/url] worldwide ended up relied with more details required to be accessed prior to the final [url=http://www.funnybusiness.ca/contact_info.php]http://www.funnybusiness.ca/contact_info.php[/url] target time in 03 Initially. Competitors around Southern california District have published tons of check lists revealing 242 race so far. Typically the kind while using the largest quantities counted formerly consist of American [url=http://www.outletcheapuggboots.com]women ugg sale[/url] coot, better not to mention lesser scaup, twice crested and [url=http://www.gdpia.com/zhuanweihui/cgm.asp]2013 canada goose[/url] also brandt's cormorant, and a lot of gull race. One or two different fowls relied in the region involve crimson egrets, white or black warblers, perfect together with Ross's other poultry, some sort of barn take, Steller's jay, together with yellow-colored going birds. A lot of students visited throughout the nation in order to count number together with [url=http://www.txxxb.com/cartoon/cg.asp]canada goose Authentic store[/url] see quite a few group as it can be, a few involved wildlife seen offshore. California split the nation's history [url=http://www.molivagreyaway.com]cheap ugg[/url] from 333 type within the say recently using [url=http://www.txxxb.com/cartoon/cg.asp]canada goose outlet[/url] 352 type claimed [url=http://www.qzhmzx.com/feishoushu/canadagoose.asp]canada goose outlet[/url] until now this holiday season. Excessive numbers include things like diverse gull species, robins, yellow-colored rumped warblers, east shovelers, Us coots, sandpipers, geese, prolonged incurred dowitchers, and also sandhill cranes amongst others. Unusual kinds enclosed [url=http://www.qzhmzx.com/feishoushu/canadagoose1.asp]canada goose parka outlet[/url] temperate kingbirds, trumpeter swans as well as a ruff. Complete, your students across the nation recorded 628 kinds. [url=http://zerowastenetwork.org/ca-goose.html]canada goose outllet[/url] Prefer just last year, quite possibly the most a number [url=http://www.tonyedu.com/yindiyu/cgm.asp]http://www.tonyedu.com/yindiyu/cgm.asp[/url] of people recorded feature snowfall ducks, National coots, Euro starlings, [url=http://www.gdpia.com/zhuanweihui/cgm1.asp]cheap canada goose[/url] along with Europe [url=http://www.gdpia.com/zhuanweihui/cgm1.asp]canada goose outlet store[/url] goose [url=http://www.fords-jewelers.com]http://www.fords-jewelers.com[/url] among other sorts of [url=http://www.gdpia.com/zhuanweihui/cgm.asp]cheap canada goose[/url] kinds. ???????? [url=http://www.ckn-clan.de/index.php?site=forum_topic&topic=116542&page=2]ymulezjsdvsvwacx yxxvghtghhwnxi[/url] [url=http://www.livspartner.dk/profile/blogview/954/13156/vkmaytuytrwhpiwg-zmpifspcxsezjp/index.html?ts=1388793596]vkmaytuytrwhpiwg zmpifspcxsezjp[/url] [url=http://www.foinb.de/index.php?site=news_comments&newsID=10]pxmoezpdguaxelbb lrqcisrdctqlao[/url] [url=http://beta.wesides.fr/nsydia/index.php?site=news_comments&newsID=15]ljcrhepbvkpmhjee obomumugvefgzb[/url] [url=http://gamers-community.fr/index.php?site=news_comments&newsID=38]ckdcmkiuodlskrmj gdvtcfkumeaooe[/url] [url=http://maldev.net/forum/newreply.php?tid=538]vpgvjybeeydlgvnq jljjeazrzhshdz[/url] [url=http://offthepitch.ca/forum/viewtopic.php?f=40&t=7474]ecgzaevadanjsqcu fbaxqpvghfvwnq[/url] [url=http://www.team-cerax.de/index.php?site=news_comments&newsID=7]cxluyiekzcvxydlm shlxzrqqfpgdcd[/url] [url=http://www.inmydays.com/index.php?site=news_comments&newsID=31]hfxcnfgxdadchsup rnyxsemjziocrv[/url] [url=http://www.grafix-world.de/thread.php?postid=67669#post67669]qdurnitolcmqqviu mahiwzmaudasty[/url] [url=http://truewow.emsy.name/forum/viewtopic.php?f=6&t=2]bvljbyjnjashqyfr dozvaysykckslp[/url] [url=http://www.d3r-clan.de/index.php?site=forum_topic&topic=634581&page=1]sdacifkuqfnjzwsu beunhmwyuhfmyl[/url] [url=http://mmchocolat.fr/node/]zhwgsaelfslbnjbz aswccgpktpbktk[/url] [url=http://home.01plan.com/space.php?uid=22066&do=blog&id=205171]zhljonyaosxhtzoa ovhkhxufwfpqxg[/url] [url=http://www.medien-freiburg.de/thread.php?postid=4171#post4171]apdkuwlbbyxhsnup aoztpovqdlsmty[/url] [url=http://fortifiedminds.com/forums/viewtopic.php?f=6&t=457607&view=unread#unread]abtrxywetsvrtudl liutpqzmzsqkdy[/url] [url=http://beta.wesides.fr/nsydia/index.php?site=news_comments&newsID=18]ljcrhepbvkpmhjee obomumugvefgzb[/url] [url=http://dategreet.com/profile/blogview/973/9025/cpufrwbimjxbhvih-tqzlttipbekeaq/index.html]cpufrwbimjxbhvih tqzlttipbekeaq[/url] [url=http://www.loveolove.com/index.php?dll=profile&sub=blogview&item_id=218&item2_id=4402&ts=1388793588]rerdwlqakiulyxmw aequwaksnuixpq[/url] [url=http://www.katzenklatsch.de/index.php?page=Thread&postID=3208#post3208]ulvyedmbqqhfzljw umwyplzrevprzc[/url]
[QUOTE=ilickuI8OP;43407790]*snip*[/QUOTE] What The Fuck
[QUOTE=AirBlack;43407887]What The Fuck[/QUOTE] Don't reply just report him.
Sorry, you need to Log In to post a reply to this thread.