I'm trying to make a minmap with RenderView, and I want it to be entirely top-down 2 dimensional instead of appearing 3D from the origin of the RenderView.
Can I accomplish this using RenderViews? And if not, how else?
Take a look at this [url]https://github.com/wiox/gmod-gta-radar[/url] I think this might help you.
[QUOTE=smithy285;46964723]Take a look at this [url]https://github.com/wiox/gmod-gta-radar[/url] I think this might help you.[/QUOTE]
Thanks, this helped a lot. One more question though:
Can I improve the quality of the image? When I just used typical render.RenderView, it was equal quality to the rest of the game, no matter how much I blew up the image. With the following method, it's very pixelated. Something about the fact that it's making a material and then drawing that.
[LUA]
local height = ScrH()-100
local width = ScrW()-100
local rendering_map = false
local map_rt = GetRenderTarget( "GTARadar!!!", width, height, true )
local map_rt_mat = CreateMaterial( "GTA_Radar!!!", "UnlitGeneric", { ["$basetexture"] = "GTARadar!!!" } )
local old_rt = render.GetRenderTarget()
local old_w, old_h = ScrW(), ScrH()
render.SetRenderTarget( map_rt )
render.SetViewPort(ScrW()/2-width/2, ScrH()/2-height/2, width, height)
render.Clear( 0, 0, 0, 0 )
cam.Start2D()
rendering_map = true
render.RenderView {
origin = Vector(0,0,8000),
angles = Angle(90,0,0),
x = 0,
y = 0,
w = width-1,
h = height-1,
ortho = true,
ortholeft = -15500,
orthoright = 12800,
orthotop = -15000,
orthobottom = 13400,
znear = 6000,
zfar = 10000
}
rendering_map = false
cam.End2D()
render.SetViewPort( 0, 0, old_w, old_h )
render.SetRenderTarget( old_rt )
surface.SetMaterial( map_rt_mat )
surface.DrawTexturedRect( ScrW()/2-width/2, ScrH()/2-height/2, width, height)
[/LUA]
[editline]19th January 2015[/editline]
Well, I fixed it by simply rendering to the screen instead of to a different target using a material.
[editline]19th January 2015[/editline]
Final problem now:
Water doesn't render on the map, it just shows up as solid black.
[QUOTE=RealDope;46966450]Water doesn't render on the map, it just shows up as solid black.[/QUOTE]
An annoying issue to do with the origin parameter being outside of the map. You could change it to a trace, but then you'll find other issues when walking through doorways.
[QUOTE=Willox;46967010]An annoying issue to do with the origin parameter being outside of the map. You could change it to a trace, but then you'll find other issues when walking through doorways.[/QUOTE]
I plan to cache the image of the rendered map at client join, and then display that from then on. I won't have any problems with moving through doorways. Can you explain what you mean by change it to a trace?
RenderView works fine except for it's ability to stencil out things.
I found a way to fix it in my version though.
[t]https://dl.dropboxusercontent.com/u/17839069/C_243.png[/t]
Using RenderView's render znear and zfar causes 3d menus, and other things to break.
[QUOTE=EthanTheGreat;46967420]RenderView works fine except for it's ability to stencil out things.
I found a way to fix it in my version though.
Using RenderView's render znear and zfar causes 3d menus, and other things to break.[/QUOTE]
Sorry I'm not very familiar with stenciling and the like.. Can this help me display water in the RenderView?
Like I said earlier, I don't need it to be constantly rendering. I may actually just capture it on my own client and have clients download the image for display. I still need to render the water just once though, to capture.
[editline]19th January 2015[/editline]
Is there a better way to capture than render.Capture()? It works fine except that I can only write it to a txt file, and it appears GLua cannot rename files, so I can't make it a jpeg to use as a material.
Bumping, I've gotten everything except the water problem. I don't know how to make it render when I place the view 8000 units up.
[QUOTE=RealDope;46976128]Bumping, I've gotten everything except the water problem. I don't know how to make it render when I place the view 8000 units up.[/QUOTE]
The issue is your "camera" is above the map's limit, probably.
Instead of placing the view 8000 units up, do an isometric view at 500 units which has really high field of view.
Thanks, I'll try that if I can't get it working any other way.
[QUOTE=Willox;46967010]An annoying issue to do with the origin parameter being outside of the map. You could change it to a trace, but then you'll find other issues when walking through doorways.[/QUOTE]
Can you elaborate on this? Like I said above, I only need to render it once, and stationary, so walking through doorways isn't a problem.
Bumping, as it turns out, I can't even place the camera at (0,0,_) and do it because the places in the map with water are covered by a taller skybox than (0,0) is. If I lower the camera enough to be out of the skybox at (0,0), then other places in the map with skyboxes higher than that don't render at all.
The skybox can be a real bitch.
You can do a trace from the player's head which hits only the skybox and set the camera just below that, then calculate the field of view accordingly, but that sounds incredibly complex.
There are working examples of minimaps all over the place. Look at them.
Thanks, I looked at that GTA map and that's where I found most of what I'm working with.
I'm having a difficult time figuring out the orthogonal settings, and the wiki is far from helpful. Can someone better explain what ortholeft, right, top, and bottom represent? Are they world coordinates, or relative to the origin of my renderview, and which way is up...
[QUOTE=RealDope;46967523]Sorry I'm not very familiar with stenciling and the like.. Can this help me display water in the RenderView?
Like I said earlier, I don't need it to be constantly rendering. I may actually just capture it on my own client and have clients download the image for display. I still need to render the water just once though, to capture.
[editline]19th January 2015[/editline]
Is there a better way to capture than render.Capture()? It works fine except that I can only write it to a txt file, and it appears GLua cannot rename files, so I can't make it a jpeg to use as a material.[/QUOTE]
That's exactly what I want to do on my game but impossible to get a renderable texture from render.Capture, and in plus the function generates a strange image.
[QUOTE=Yuri6037;47005789]That's exactly what I want to do on my game but impossible to get a renderable texture from render.Capture, and in plus the function generates a strange image.[/QUOTE]
I've settled for capturing the image on my own client, renaming it to a .jpg, and then just distributing it along with the rest of the content required for my server. I was hoping I could capture the water on my map with a low camera, then crop that picture into the main map, scaling it to size, so that it would appear one clean image that included water. I can't manage to do this though, because I can't figure out the ortho settings.
[editline]25th January 2015[/editline]
I've managed to get the ortho settings working as I want them, but now even when the camera is not blocked by the skybox, the water is nearly invisible?
Instead of a black box, it's just empty, with a barely visible disturbance right at the edge of the water in some places.
[editline]25th January 2015[/editline]
I think it's likely because I'm rendering it in Cam2D3D, which makes me think it's probably not possible...
Sorry, you need to Log In to post a reply to this thread.