• Render Targets are drawing off (when attached to a skybox)
    0 replies, posted
Here I am, at it again, trying to make a fading skybox... Basically, I've made 6 render targets each like this: [lua] "RPOnIceSkybox_up" { "Name" "RPOnIceSkybox_up" "Width" "1024" "Height" "1024" } [/lua] I then replace the skybox textures with the rendertargets, and try to draw on it. Except this happens, but it's only affecting the top and bottom faces: [img]http://dl.dropbox.com/u/3787621/gm_construct0002.jpg[/img] [img]http://dl.dropbox.com/u/3787621/gm_construct0003.jpg[/img] [img]http://dl.dropbox.com/u/3787621/gm_construct0004.jpg[/img] [img]http://dl.dropbox.com/u/3787621/gm_construct0005.jpg[/img] [img]http://dl.dropbox.com/u/3787621/gm_construct0006.jpg[/img] Code: [lua] // This example is based off the GMDMPickup code (Pickups in the GMDeathmatch mode by garry) local skyboxRT_up = GetRenderTarget("RPOnIceSkybox_up",1024,1024) local skyboxRT_dn = GetRenderTarget("RPOnIceSkybox_dn",1024,1024) local skyboxRT_lf = GetRenderTarget("RPOnIceSkybox_lf",1024,1024) local skyboxRT_rt = GetRenderTarget("RPOnIceSkybox_rt",1024,1024) local skyboxRT_bk = GetRenderTarget("RPOnIceSkybox_bk",1024,1024) local skyboxRT_ft = GetRenderTarget("RPOnIceSkybox_ft",1024,1024) local skyname = "none" local function GetSkyname() skyname = GetConVarString("sv_skyname") Material("skybox/".. skyname .. "up"):SetMaterialTexture("$basetexture", skyboxRT_up) Material("skybox/".. skyname .. "dn"):SetMaterialTexture("$basetexture", skyboxRT_dn) Material("skybox/".. skyname .. "lf"):SetMaterialTexture("$basetexture", skyboxRT_lf) Material("skybox/".. skyname .. "rt"):SetMaterialTexture("$basetexture", skyboxRT_rt) Material("skybox/".. skyname .. "ft"):SetMaterialTexture("$basetexture", skyboxRT_ft) Material("skybox/".. skyname .. "bk"):SetMaterialTexture("$basetexture", skyboxRT_bk) end hook.Add( "InitPostEntity", "GetSkyname", GetSkyname ) local rtscreen = Material("skybox/"..skyname.."up") local rttarget = skyboxRT_up function RenderNewSkyboxes() local oldRT = render.GetRenderTarget() local newskyboxname = "sky_day01_01" render.SetRenderTarget(skyboxRT_up) render.Clear(0,0,0,255) render.SetViewPort(0,0,1024,1024) cam.Start2D() local QuadTable = {} QuadTable.texture = surface.GetTextureID( "skybox/"..newskyboxname.."up" ) QuadTable.color = Color( 255, 255, 255, 255 ) QuadTable.x = 0 QuadTable.y = 0 QuadTable.w = 1024 QuadTable.h = 1024 draw.TexturedQuad( QuadTable ) cam.End2D() render.SetRenderTarget(skyboxRT_dn) render.Clear(0,0,0,255) render.SetViewPort(0,0,1024,1024) cam.Start2D() local QuadTable = {} QuadTable.texture = surface.GetTextureID( "skybox/"..newskyboxname.."dn" ) QuadTable.color = Color( 255, 255, 255, 255 ) QuadTable.x = 0 QuadTable.y = 0 QuadTable.w = 1024 QuadTable.h = 1024 draw.TexturedQuad( QuadTable ) cam.End2D() render.SetRenderTarget(skyboxRT_lf) render.Clear(0,0,0,255) render.SetViewPort(0,0,1024,1024) cam.Start2D() local QuadTable = {} QuadTable.texture = surface.GetTextureID( "skybox/"..newskyboxname.."lf" ) QuadTable.color = Color( 255, 255, 255, 255 ) QuadTable.x = 0 QuadTable.y = 0 QuadTable.w = 1024 QuadTable.h = 1024 draw.TexturedQuad( QuadTable ) cam.End2D() render.SetRenderTarget(skyboxRT_rt) render.Clear(0,0,0,255) render.SetViewPort(0,0,1024,1024) cam.Start2D() local QuadTable = {} QuadTable.texture = surface.GetTextureID( "skybox/"..newskyboxname.."rt" ) QuadTable.color = Color( 255, 255, 255, 255 ) QuadTable.x = 0 QuadTable.y = 0 QuadTable.w = 1024 QuadTable.h = 1024 draw.TexturedQuad( QuadTable ) cam.End2D() render.SetRenderTarget(skyboxRT_ft) render.Clear(0,0,0,255) render.SetViewPort(0,0,1024,1024) cam.Start2D() local QuadTable = {} QuadTable.texture = surface.GetTextureID( "skybox/"..newskyboxname.."ft" ) QuadTable.color = Color( 255, 255, 255, 255 ) QuadTable.x = 0 QuadTable.y = 0 QuadTable.w = 1024 QuadTable.h = 1024 draw.TexturedQuad( QuadTable ) cam.End2D() render.SetRenderTarget(skyboxRT_bk) render.Clear(0,0,0,255) render.SetViewPort(0,0,1024,1024) cam.Start2D() local QuadTable = {} QuadTable.texture = surface.GetTextureID( "skybox/"..newskyboxname.."bk" ) QuadTable.color = Color( 255, 255, 255, 255 ) QuadTable.x = 0 QuadTable.y = 0 QuadTable.w = 1024 QuadTable.h = 1024 draw.TexturedQuad( QuadTable ) cam.End2D() render.SetRenderTarget(oldRT) render.SetViewPort(0,0,ScrW(),ScrH()) end hook.Add( "RenderScreenspaceEffects", "RenderNewSkyboxes", RenderNewSkyboxes ) [/lua] Could someone please help! Thanks! Also, the PreDrawSkyBox and PostDrawSkyBox hooks don't seem to work for me.. I tried making an entity at the sky_camera position that draws quads around the sky_camera. This works perfectly until the player stops looking in the direction of the entity. ENT.UpdateTransmitState doesn't work. AddOriginToPVS doesn't work.
Sorry, you need to Log In to post a reply to this thread.