Re: Question about dealing with content creation for large worlds
Sylvain Vignaud <[email protected]> Mon, 26 Nov 2012 20:55:29 -0500
| Newsgroups | gmane.games.devel.sweng |
|---|---|
| Message-ID | <[email protected]> |
--===============2026543486== Content-Type: multipart/alternative; boundary="_133b21ce-4898-4683-b03b-b2ea90916916_" --_133b21ce-4898-4683-b03b-b2ea90916916_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable On Sat=2C Nov 24=2C 2012 at 12:50 PM=2C Juan Linietsky <[email protected]> = wrote: =0A= I looked into Carmack's megatexturing approach=2C but it seems too unnecesa= rily complex IMO=2C plus there are no tools available that artists can use = commercially?=0A= It's actually not that hard really=2C if you generate the virtual texture(s= ) from common artists' data - not using particular artist tool. It took me = a bit more than one week to implement a virtual 3D texture system to displa= y CT scans of a human body which would otherwise not fit in video memory. Here's a short description of the way I implemented it: Pixel shader part: instead of giving a shader one albedo texture=2C you give it two: the first= one is a map=2C which you read using normal UVs. This will tell you where = to read in the second=2C content texture. This map is much smaller than the= original texture=2C it should have only one texel per geometry (a larger m= ap can be used for several objects to share texture space across several ob= jects). But depending on how you share texture space between several object= s (see texture atlas)=2C some objects may require several texels. then compute: UV in the content texture =3D (base UV mod slot size * scalin= g) + offset. You get "scaling" and "offset" in the first map texture. to get correct bi-linear filtering: after you mod your UV inside the slot s= ize=2C clamp them between +epsilon and 1-epsilon before adding the offset= =2C to never get bi-linear filtering blur across slot boundaries. In theory= this should create obvious too sharp line in the texture on screen=2C but = in practice I couldn't see any in my 3d virtual texture using 3d bi-linear = filtering. Might needs more effort (manual bi-linear filtering or adding sl= ot boundaries) in a more generic case. CPU part: stream texture slots from disk to system memory that would be used in a dis= tance around the camera. I prefer not to take into account the direction of= the camera at this point.send required slots for current rendering and for= a bit more around from system memory to video memory.create map textures i= n VRAM for each object/mipmap to be displayed.when displaying an object=2C = send its shader its map texture and the corresponding content texture. Offline (or during object loading if you have enough memory and availalble = cpu): For each texture/mipmap=2C cut it in slots of the size your system use.Stor= e list of virtual texture slots per object. = --_133b21ce-4898-4683-b03b-b2ea90916916_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <html> <head> <style><!-- .hmmessage P { margin:0px=3B padding:0px } body.hmmessage { font-size: 12pt=3B font-family:Calibri } --></style></head> <body class=3D'hmmessage'><div dir=3D'ltr'>On Sat=2C Nov 24=2C 2012 at 12:5= 0 PM=2C Juan Linietsky <span dir=3D"ltr"><=3B<a href=3D"mailto:reduzio@gm= ail.com">[email protected]</a>>=3B</span> wrote:<br>=0A= <div><div dir=3D"ltr"><div><br><blockquote class=3D"ecxgmail_quote" style= =3D"border-left-width:1px=3Bborder-left-color:rgb(204=2C204=2C204)=3Bborder= -left-style:solid=3Bpadding-left:1ex">I looked into Carmack's megatexturing= approach=2C but it seems too unnecesarily complex IMO=2C plus there are no= tools available that artists can use commercially?</blockquote>=0A= <br><br>It's actually not that hard really=2C if you generate the virtual t= exture(s) from common artists' data - not using particular artist tool. It = took me a bit more than one week to implement a virtual 3D texture system t= o display CT scans of a human body which would otherwise not fit in video m= emory.<br><br><br><br>Here's a short description of the way I implemented i= t:<br><br>Pixel shader part:<br><ul><li>instead of giving a shader one albe= do texture=2C you give it two: the first one is a map=2C which you read usi= ng normal UVs. This will tell you where to read in the second=2C content te= xture. This map is much smaller than the original texture=2C it should have= only one texel per geometry (a larger map can be used for several objects = to share texture space across several objects). But depending on how you sh= are texture space between several objects (see texture atlas)=2C some objec= ts may require several texels.<br></li><li>then compute: UV in the content = texture =3D (base UV mod slot size * scaling) + offset. You get "scaling" a= nd "offset" in the first map texture.<br></li><li>to get correct bi-linear = filtering: after you mod your UV inside the slot size=2C clamp them between= +epsilon and 1-epsilon before adding the offset=2C to never get bi-linear = filtering blur across slot boundaries. In theory this should create obvious= too sharp line in the texture on screen=2C but in practice I couldn't see = any in my 3d virtual texture using 3d bi-linear filtering. Might needs more= effort (manual bi-linear filtering or adding slot boundaries) in a more ge= neric case.<br></li></ul><br>CPU part:<br><ul><li>stream texture slots from= disk to system memory that would be used in a distance around the camera. = I prefer not to take into account the direction of the camera at this point= .</li><li>send required slots for current rendering and for a bit more arou= nd from system memory to video memory.</li><li>create map textures in VRAM = for each object/mipmap to be displayed.</li><li>when displaying an object= =2C send its shader its map texture and the corresponding content texture.<= /li></ul><br>Offline (or during object loading if you have enough memory an= d availalble cpu):<br><ul><li>For each texture/mipmap=2C cut it in slots of= the size your system use.</li><li>Store list of virtual texture slots per = object.</li></ul><br></div> </div></div> </div></body= > </html>= --_133b21ce-4898-4683-b03b-b2ea90916916_-- --===============2026543486== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Sweng-Gamedev mailing list [email protected] http://lists.midnightryder.com/listinfo.cgi/sweng-gamedev-midnightryder.com --===============2026543486==--