GMod - What are you working on? January 2015 (#41)
781 replies, posted
I am actually very curious how that was done and how soon it will be released to the public.
I've been wanting to make a Sword Art Online menu for a long time now.
Grab the current render target to a variable. It's the screen. Set the render target to a new render target. Draw some plain 2d text. It won't be visible on the screen, because the render target is not the screen. Copy the render target to a texture. Set the render target back to the screen. Use that texture in a material, on a rotating curved surface.
[QUOTE=zzaacckk;47010855]sexy bank + [B]curved 3d2d[/B] scrolling text + npcs[/QUOTE]
Good stuff man. Is this the map you said you almost hit the brush limit in? Looks sick.
[B]EDIT:[/B]
Phongs are amazing guys, check out the difference:
Phong'd
[t]https://dl.dropboxusercontent.com/u/17839069/C_252.png[/t]
unphong'd
[t]https://dl.dropboxusercontent.com/u/17839069/C_253.png[/t]
For everyone who doesn't know what it is, it's an amazing way to enhance your model's textures:
[url]https://developer.valvesoftware.com/wiki/Phong[/url]
Here's the code I use, please feel free to change the entity.
[code]
local entPolish = LocalPlayer( ).Vehicle
local materials = entPolish:GetMaterials( )
for index, matPath in pairs( materials ) do
print( "PHONG MAT CREATED!", matPath )
local iMat = Material( matPath )
iMat:SetInt( "$phong", 1 )
iMat:SetInt( "$phongexponent", 5 )
iMat:SetString( "$phongexponenttexture", matPath )
iMat:SetFloat( "$phongboost", 0.2 )
iMat:SetString( "$PhongFresnelRanges", "[1 1 1]" )
end
[/code]
[QUOTE=EthanTheGreat;47011504]Good stuff man. Is this the map you said you almost hit the brush limit in? Looks sick.
[B]EDIT:[/B]
Phongs are amazing guys, check out the difference:
UNPHONG'D
[t]https://dl.dropboxusercontent.com/u/17839069/C_252.png[/t]
PHONG'D
[t]https://dl.dropboxusercontent.com/u/17839069/C_253.png[/t]
For everyone who doesn't know what it is, it's an amazing way to enhance your model's textures:
[url]https://developer.valvesoftware.com/wiki/Phong[/url]
Here's the code I use, please feel free to change the entity.
[code]
local entPolish = LocalPlayer( ).Vehicle
local materials = entPolish:GetMaterials( )
for index, matPath in pairs( materials ) do
print( "PHONG MAT CREATED!", matPath )
local iMat = Material( matPath )
iMat:SetInt( "$phong", 1 )
iMat:SetInt( "$phongexponent", 5 )
iMat:SetString( "$phongexponenttexture", matPath )
iMat:SetFloat( "$phongboost", 0.2 )
iMat:SetString( "$PhongFresnelRanges", "[1 1 1]" )
end
[/code][/QUOTE]
I like the top image better than the bottom image. Did you label them right? because I think the top image is the one with phong.
[QUOTE=WalkingZombie;47011666]I like the top image better than the bottom image. Did you label them right? because I think the top image is the one with phong.[/QUOTE]
Yeah it looks like the bottom image has no specular lighting.
[QUOTE=WalkingZombie;47007344]The amount of not realistic the flying is has always bothered me. It's pretty cool though! I like making helicopters, programming [del]realistic[/del] fairly realistic tilt response and all, but I don't have any good models to do it with except maybe the combine helicopter.[/QUOTE]
Actually these planes use something that looks like a flight model but the stuka is a bad example :v: I've always gone for an easier to control approach. Real planes and helicopters are hard to control and with maps the size of a shoebox it's just not fun having to spend 3/4th of the map taking off then spend the rest of the time flying in circles due to skybox limits.
I hate posting unless it's something cool I'm showing, check this out:
[t]https://dl.dropboxusercontent.com/u/17839069/C_256.png[/t]
[t]https://dl.dropboxusercontent.com/u/17839069/C_257.png[/t]
[t]https://dl.dropboxusercontent.com/u/17839069/C_258.png[/t]
That polish tho.
[QUOTE=EthanTheGreat;47012277]That polish tho.[/QUOTE]
[t]https://dl.dropboxusercontent.com/u/17839069/C_147.png[/t]
That bikini tho.
Sorry, I kind of got sidetracked and ended up looking at all of your screenshots. This project of yours is really cool and every post you make just makes me wish I spent less time on doing back-end stuff, sigh.
Back on topic, that looks pretty sweet but I suggest you turn down the exponent slightly to give it a less 'glossy' / 'web 2.0' look
[QUOTE=xaviergmail;47012618]
Sorry, I kind of got sidetracked and ended up [u][B][I]looking at all of your screenshots[/I][/B][/u]. This project of yours is really cool and every post you make just makes me wish I spent less time on doing back-end stuff, sigh.
[/QUOTE]
Why are you such a creep?
[QUOTE=bobbleheadbob;47014233]Why are you such a creep?[/QUOTE]
How does that make him a creep?
Some content. Some changes to the Team Select Menu as well as Unit menu that pops up when you select the team:
[t]http://i.imgur.com/BBb5TxQ.png[/t]
[t]http://i.imgur.com/tMz10Ry.png[/t]
[t]http://i.imgur.com/FCyLxUb.png[/t]
The help menu, which I think explains the premise pretty clearly:
[t]http://i.imgur.com/2qNXws0.png[/t]
And I finished coding the "Arena" that the rounds will be taking place:
[t]http://i.imgur.com/9KmcZn9.jpg[/t]
The arena will randomly be in different parts of the map each round, however I'm not sure how to approach the punishment for leaving the arena.
It's either I make it so that if the player leaves the arena they are disintegrated, which would open up the ability for out-of-bounds KO's; or I make it so the player simply gets pushed back into the arena.
On a side note: Does anyone have any idea how to get around c_pistol.mdl not having a ValveBiped.base bone like the normal pistol? Usually I'd set the scale of the bones to 0 but it's missing that key part
[QUOTE=AJ10017;47010394]So i finally figured out how to use sound.PlayURL to use the Penis Corp TTS API
[video=youtube;Mm69l_wt_UE]http://www.youtube.com/watch?v=Mm69l_wt_UE[/video]
If its in TTT, you can only use it when alive, and on DarkRP it sends it to everyone when using OOC, or to people within 800 units
[code]
AddCSLuaFile()
hook.Add("OnPlayerChat","data",function(ply,txt,team,dead)
local TP = function()
sound.PlayURL("http://tts.peniscorp.com/speak.lua?"..txt,"mono",function(tts)
if ( IsValid(tts) ) then
tts:Play()
end
end)
end
local CheckDead = false
local OOC = false
if engine.ActiveGamemode()=="terrortown" then CheckDead = true end
if engine.ActiveGamemode()=="darkrp" then OOC = true end
if OOC and CheckDead==false then
if txt.Explode(" ")[1]==string.lower("/ooc") or txt.Explode(" ")[1]==string.lower("//") then
TP()
else
if ply:GetPos():Distance(LocalPlayer():GetPos())<800 then TP() end
end
end
if CheckDead and OOC==false then
if dead==false and ply:IsSpec()==false then
TP()
end
end
if CheckDead==false and OOC==false then
TP()
end
end)
[/code]
yes i know the variable names are terrible
On a side note, how do i play a sound on a player using this?[/QUOTE]
Here's another version of the TTS. Mainly designed for sandbox. Plays across the server.
(chat commands so it doesnt play EVERYTHING)
I probably could've done this better but I threw it together in about 5-10 mins.
[lua]local enabled = false
hook.Add("OnPlayerChat","omgiamsocool",function(ply,text)
if enabled then
if ( string.sub( text, 1, 5 ) == "!dtts" ) then
local textToSpeech = function()
sound.PlayURL("http://tts.peniscorp.com/speak.lua?".. string.sub( text, 7 ),"mono",function(tts)
if ( IsValid(tts) ) then
tts:Play()
end
end)
end
textToSpeech()
end
end
end)
hook.Add("OnPlayerChat", "toggleTTS", function(ply, text)
if ply == LocalPlayer() then
if ( string.sub( text, 1, 12 ) == "!dtts_toggle" ) then
if not enabled then
enabled = true
LocalPlayer():ConCommand("say >DTTS enabled for "..ply:Name()..".")
else
enabled = false
LocalPlayer():ConCommand("say >DTTS disabled for "..ply:Name()..".")
end
end
end
end)[/lua]
[QUOTE=Exho;47015625]How does that make him a creep?[/QUOTE]
don't take it too seriously
[editline]26th January 2015[/editline]
Here's a better TTS script that tries to not abuse Gran PC's servers by relying on google as much as possible:
[url]http://facepunch.com/showthread.php?t=1448287[/url]
Gives each player a unique voice, which properly follows that player.
[lua]
local accents = {
"http://translate.google.co.uk/translate_tts?tl=en&q=",
"http://translate.google.com/translate_tts?tl=en&q=",
"http://translate.google.com/translate_tts?tl=fr&q=",
"http://translate.google.com/translate_tts?tl=ru&q=",
"http://tts.peniscorp.com/speak.lua?"
}
local wait = false
local channels = {}
local function playvoice(ply,text,accent,speed)
if wait then
accent = "http://tts.peniscorp.com/speak.lua?"
end
sound.PlayURL(accent..text,"3d noplay",function(channel,errorid,errorname)
if channel == nil || errorid != nil || errorname != nil then --peniscorp backup; google is upset
if wait == false then
wait = true
timer.Simple(125,function() wait = false end)
playvoice(ply,text,accent,speed)
end
return
end
channel:SetPos(ply:GetPos(),Vector(0,0,0))
channel:Set3DFadeDistance(300,9999999999)
channel:SetPlaybackRate(math.Clamp(.5+speed,.5,2))
channel:Play()
table.insert(channels,{channel,ply})
end)
end
hook.Add("Think","TTSThink",function()
for k, v in pairs(channels) do
if !v[1]:IsValid() then table.remove(channels,k) return end
if v[2] == nil ||
v[1]:GetState() != GMOD_CHANNEL_PLAYING ||
v[1]:GetTime() >= v[1]:GetLength() then
v[1]:Stop()
table.remove(channels,k)
return
end
v[1]:SetPos(v[2]:GetPos(),Vector(0,0,0))
end
end)
hook.Add("OnPlayerChat","TTSPlayerChat",function(ply,text,team,dead)
--firstly, checking for popular gamemode limitations
local dotts = true
if engine.ActiveGamemode() == "terrortown" then
if dead then dotts = false end
if ply.IsSpec != nil && ply:IsSpec() then dotts = false end
end
if engine.ActiveGamemode() == "darkrp" then
if text[1] == "/" then dotts = false end
if ply:GetPos():Distance(LocalPlayer():GetPos()) > 500 then dotts = false end --250 = default chat range
end
if dotts then
local speed,accent,nick = 1, accents[1], ply:Nick()
local nlen = #nick
local vowels, vow, notvow, vrat = {"a","e","i","o","u","y"}, 0, 0, 1
for i = 1, nlen do
if table.HasValue(vowels,nick[i]) then vow = vow+1 else notvow = notvow+1 end
end
if vow == 0 then notvow = nlen end
vrat = vow/notvow
accent = accents[math.Clamp(vow,1,#accents)]
speed = vrat
playvoice(ply,text,accent,speed)
end
end)
[/lua]
[editline]26th January 2015[/editline]
use it clientside
[QUOTE=xaviergmail;47012618]Sorry, I kind of got sidetracked and ended up looking at all of your screenshots. This project of yours is really cool and every post you make just makes me wish I spent less time on doing back-end stuff, sigh.
Back on topic, that looks pretty sweet but I suggest you turn down the exponent slightly to give it a less 'glossy' / 'web 2.0' look[/QUOTE]
MIX
[t]https://dl.dropboxusercontent.com/u/17839069/C_260.png[/t]
Before PHONG
[t]https://dl.dropboxusercontent.com/u/17839069/C_259.png[/t]
After PHONG
[t]https://dl.dropboxusercontent.com/u/17839069/C_261.png[/t]
The polish looks a lot better now.
[QUOTE=EthanTheGreat;47016784]MIX
[t]https://dl.dropboxusercontent.com/u/17839069/C_260.png[/t]
Before PHONG
[t]https://dl.dropboxusercontent.com/u/17839069/C_259.png[/t]
After PHONG
[t]https://dl.dropboxusercontent.com/u/17839069/C_261.png[/t]
The polish looks a lot better now.[/QUOTE]
First: Excellent work! What you're doing here (forget graphics) is incredible any way you look at it!
Now just a little thought I had based on the first person view. I don't recall his name, but someone managed to achieve real time reflections on... everything, iirc. Just for the hell of it, for the sake of graphics, considering that you DO have a first person mode it would be useful to have real time reflective mirrors. Maybe you could work with him in a project to create such a feature?
[editline]27th January 2015[/editline]
-snip- Bottom image looks alright, but I feel like the steering wheel needs more shine. You could use an exponent map instead of a static value.
..then again, that map doesn't like like it has the brightest lighting. Maybe those settings work well across different situations.
Making a mirror is infinitely easier to do than that reflective surfacing from earlier in the thread. Simply a rendertarget as a material, using renderview.
[QUOTE=bitches;47018848]Making a mirror is infinitely easier to do than that reflective surfacing from earlier in the thread. Simply a rendertarget as a material, using renderview.[/QUOTE]
Are there any good reference pages about this stuff? I've always wondered how to do them properly.
[lua]
local screenrt = render.GetRenderTarget() --the screen, normally, for setting the rt back to this later
local newrt = GetRenderTarget("MyLovelyRenderTarget",512,512) --returns itexture (RT)
local materialtoapply = Material("some blank or white material path here") --the toolgun uses "models/weapons/v_toolgun/screen"
--and now later, in some rendering code:
render.SetRenderTarget(newrt)
local viewdat = {}
viewdat.origin = ply:GetEyePos()+(ply:EyeAngles()*50)
viewdat.angles = ply:EyeAngles()
viewdat.x, viewdat.y = 0, 0
viewdat.w, viewdat.h = 512, 512
render.RenderView(viewdat)
render.SetRenderTarget(screenrt)
--also, on some object:
materialtoapply:SetTexture("$basetexture",newrt)
and then apply the materialtoapply onto an object
[/lua]
Something like this. Problem is, I don't know how to apply the material at the end of the code onto an object, such as a box. You can very easily set it for a 2d screen draw or panel material and draw that in 3D2D, though.
[editline]27th January 2015[/editline]
if someone could refine this into a working example that would be great
[editline]27th January 2015[/editline]
you know what, if simply doing ent:SetMaterial(materialtoapply) doesn't work, you can create the material with a name instead using CreateMaterial(name,shader,data)
still, it's a hassle, but doable
[t]http://i.imgur.com/cmLxRWw.jpg[/t]
i still get this thing though, the same as when i tried earlier
[QUOTE=Giraffen93;47019112][t]http://i.imgur.com/cmLxRWw.jpg[/t]
i still get this thing though, the same as when i tried earlier[/QUOTE]
I did something like that for this:
[media]http://www.youtube.com/watch?v=hFTaR3IyxO8[/media]
I can dig out the code for it a little later.
Color highlighting for Atom.
[IMG]https://i.github-camo.com/23197a747bd89aea774e0688ca932c6c0f9642cb/687474703a2f2f692e696d6775722e636f6d2f58497951684b482e706e67[/IMG]
Here's the package: [url]https://atom.io/packages/atom-color-highlight-gmod[/url]
[QUOTE=bitches;47018987][lua]
local screenrt = render.GetRenderTarget() --the screen, normally, for setting the rt back to this later
local newrt = GetRenderTarget("MyLovelyRenderTarget",512,512) --returns itexture (RT)
local materialtoapply = Material("some blank or white material path here") --the toolgun uses "models/weapons/v_toolgun/screen"
--and now later, in some rendering code:
render.SetRenderTarget(newrt)
local viewdat = {}
viewdat.origin = ply:GetEyePos()+(ply:EyeAngles()*50)
viewdat.angles = ply:EyeAngles()
viewdat.x, viewdat.y = 0, 0
viewdat.w, viewdat.h = 512, 512
render.RenderView(viewdat)
render.SetRenderTarget(screenrt)
--also, on some object:
materialtoapply:SetTexture("$basetexture",newrt)
and then apply the materialtoapply onto an object
[/lua]
Something like this. Problem is, I don't know how to apply the material at the end of the code onto an object, such as a box. You can very easily set it for a 2d screen draw or panel material and draw that in 3D2D, though.
[editline]27th January 2015[/editline]
if someone could refine this into a working example that would be great
[editline]27th January 2015[/editline]
you know what, if simply doing ent:SetMaterial(materialtoapply) doesn't work, you can create the material with a name instead using CreateMaterial(name,shader,data)
still, it's a hassle, but doable[/QUOTE]
Since a rendertarget is just a texture (ITexture), you simply create a material (CreateMaterial) and set the $basetexture to the name of the rendertarget.
The Portal Gun is a great example of render targets with simulated DEPTH.
On startup:
[lua]
local OurRT = render.GetSuperFPTex()
local PortalMaterial = CreateMaterial(
"PortalMaterial",
"UnlitGeneric",
{
[ '$basetexture' ] = OurRT,
[ '$model' ] = "1",
[ '$alphatest' ] = "0",
[ '$additive' ] = "0",
[ '$translucent' ] = "0",
[ '$ignorez' ] = "0"
}
)
[/lua]
On ENT:Draw():
[lua]
PortalMaterial:SetTexture( "$basetexture", OurRT)
render.SetMaterial( PortalMaterial )
render.DrawScreenQuad() --Stencils are used to limit the quad to just the portal.
[/lua]
On GM:RenderScene():
[lua]
local oldrt = render.GetRenderTarget()
render.SetRenderTarget( OurRT )
local b = render.EnableClipping(true)
render.Clear( 0, 0, 0, 255 )
render.ClearDepth()
render.ClearStencil()
portal:SetNoDraw( true )
RENDERING_PORTAL = ent --the portal
render.RenderView( view )
render.UpdateScreenEffectTexture()
RENDERING_PORTAL = false
portal:SetNoDraw( false )
render.EnableClipping(b)
render.SetRenderTarget( oldrt )
[/lua]
Of course, instead of stencils and screen quads, you could just SetMaterial, but it will have [URL="https://www.youtube.com/watch?v=v-N3Hb6sceE#t=14"]poor quality and it will seem very two-dimensional[/URL] and fake, like a video monitor instead of a mirror.
[editline]s[/editline]
I can get to the nitty gritty over PM if you want to go with this route. It's not simple but it looks [URL="https://www.youtube.com/watch?v=akIkLeaSGpg"]so nice[/URL].
[QUOTE=bitches;47016341]Here's a better TTS script that tries to not abuse Gran PC's servers by relying on google as much as possible:[/QUOTE]
hey, thanks. for the record im ok with any sort of 'normal' usage -- the tts cache is already big enough to the point where a large percentage of the requests are no longer even being processed by dectalk! thank you for your consideration though!!
Well, these are my last works so far:
- Indoor firing gallery map
[url]https://www.youtube.com/watch?v=XCvgeCZ66m4[/url]
- Firing range with pop-up targets map
[url]https://www.youtube.com/watch?v=05rE1OZC7AQ[/url]
- Direct Action Resource Center map (for Close Quarters training)
[url]http://gmod.gamebanana.com/maps/182656[/url]
*Notice another beautiful gallery inside this map, shown briefly on following link
[url]https://www.youtube.com/watch?v=rqAe4cP6ywE[/url]
- Spanish GEO player model
[url]https://www.youtube.com/watch?v=vF1nB8qxJsg[/url]
- Garry's Mod to CQB training simulator conversion (example)
[url]https://www.youtube.com/watch?v=pBRf9YxWh9A[/url]
- Tactical operator player model
[url]https://www.youtube.com/watch?v=b-oD5p8-WKE[/url]
- Added LAM to FireArms: Source II Glock-20, then set alternative reload animations found inside decompiled model
[url]https://www.youtube.com/watch?v=ol7yhznOsow[/url]
- Ported new weapons (Beretta M-92 FS/ H&K USP Tactical pistols) to FA:S II with Sig Sauer P-226 animations being applied
[url]https://www.youtube.com/watch?v=XzLdMlI0lZ8[/url]
[url]https://www.youtube.com/watch?v=vwc5LoK8Igk[/url]
- Changed FA:S II MP5SD-6 empty magazine reload animation, by adding bolt slap completely edited by myself
[url]https://www.youtube.com/watch?v=TCvj8QZtGms[/url]
So I guess I'm quite active lately.
Edit: I should say SD-5 since I also hacked that model and replaced retractable by solid stock.
[QUOTE=bobbleheadbob;47019992]The Portal Gun is a great example of render targets with simulated DEPTH.
On startup:
-- code
On ENT:Draw():
-- code
On GM:RenderScene():
-- code
Of course, instead of stencils and screen quads, you could just SetMaterial, but it will have [URL="https://www.youtube.com/watch?v=v-N3Hb6sceE#t=14"]poor quality and it will seem very two-dimensional[/URL] and fake, like a video monitor instead of a mirror.
[editline]s[/editline]
I can get to the nitty gritty over PM if you want to go with this route. It's not simple but it looks [URL="https://www.youtube.com/watch?v=akIkLeaSGpg"]so nice[/URL].[/QUOTE]
I'm not entirely sure, but you might have just helped me solve a very longstanding issue I've been having.
[QUOTE=bitches;47018848]Making a mirror is infinitely easier to do than that reflective surfacing from earlier in the thread. Simply a rendertarget as a material, using renderview.[/QUOTE]
3 render targets... each mirror needs to work properly for proper driving. Trust me, I should know, me mother is an automotive safety manager.
[QUOTE=WalkingZombie;47020468][QUOTE=bitches;47018848]Making [b]A MIRROR[/b] is infinitely easier to do than that reflective surfacing from earlier in the thread. Simply a rendertarget as a material, using renderview.[/QUOTE]3 render targets... each mirror needs to work properly for proper driving. Trust me, I should know, me mother is an automotive safety manager.[/QUOTE]
A mirror, not 3.
He was referring to the side mirrors, totalling three.
Would a material-based 2D looking rendertarget look properly 3D if the angle also took into account the player's eye position?
[IMG]https://dl.dropboxusercontent.com/u/40443211/Share/2015-01/2015-01-27_19-55-46.png[/IMG]
Working on a tracker for garrysmod.
I'm still working on the basic .xm file format importing right now. Hopefully I'll see some chiptunes in garrysmod after I get the sampledata working.
As for what I'm going to do with the sampledata, i haven't decided.
Should I use sound.Generate to make a sound?
Or would writing the .wav's embedded in the file to the disk (.txt) and using sound.PlayFile on it sound like a faster method.
Sorry, you need to Log In to post a reply to this thread.