{"id":156,"date":"2010-04-14T21:24:40","date_gmt":"2010-04-14T19:24:40","guid":{"rendered":"http:\/\/EinleitungIndiesemTutorialm\u00f6chteichdirzeigen,wiedueinenbereitsvorhandenenoderauchselbsterstelltenLinsenreflektions-EffektindeineMapeinbauenkannst.Bevorduaberloslegenkannst,solltestdusicherstellen,dassdudenQ3"},"modified":"2020-06-04T10:06:39","modified_gmt":"2020-06-04T08:06:39","slug":"adding-a-lens-reflection-effect-to-the-environment-box","status":"publish","type":"post","link":"https:\/\/worldofpadman.net\/en\/tutorials\/adding-a-lens-reflection-effect-to-the-environment-box\/","title":{"rendered":"Adding a lens reflection effect to the environment box"},"content":{"rendered":"<p>In this tutorial I would like to show you how to add an existing lens reflection effect to the environment box of your map. But before you start, you should make sure that you have installed and configured the Q3Map2 compiler at least in version 2.5.16 and the GtkRadiant 1.4 or newer for World of Padman. With older versions, you may encounter errors when using this tutorial.<\/p>\n<h2>Lens reflections in World of Padman<\/h2>\n<p>Lens flare is the visible reflection and scattering of light from a point light source in a lens system. While the occurrence of lens flare is often perceived as disturbing in photography, this effect is deliberately used in computer games. It is supposed to contribute to optical embellishment, although for the player there is actually no lens system at all, hence the effect cannot occur at all. In reality, the shape of the lens reflection can be star-shaped, ring-shaped or circular and the colouring can vary greatly. Basically, the occurrence at the affected areas leads to a reduction of the chromatic contrast.<\/p>\n<div id=\"attachment_2574\" style=\"width: 686px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/worldofpadman.net\/wp-content\/uploads\/map_padgarden3.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2574\" class=\"wp-image-2574 size-large\" src=\"https:\/\/worldofpadman.net\/wp-content\/uploads\/map_padgarden3-676x507.jpg\" alt=\"Lens reflection effect of the environment box in ENTE's PadGarden\" width=\"676\" height=\"507\" srcset=\"https:\/\/worldofpadman.net\/wp-content\/uploads\/map_padgarden3-676x507.jpg 676w, https:\/\/worldofpadman.net\/wp-content\/uploads\/map_padgarden3-326x245.jpg 326w, https:\/\/worldofpadman.net\/wp-content\/uploads\/map_padgarden3.jpg 1280w\" sizes=\"auto, (max-width: 676px) 100vw, 676px\" \/><\/a><p id=\"caption-attachment-2574\" class=\"wp-caption-text\">Lens reflection effect of the environment box in ENTE&#8217;s PadGarden<\/p><\/div>\n<p>World of Padman has its own system for displaying lens reflections, which was implemented by our coder #@ (raute). The possibilities of this system can be very complex, so in the following I will limit myself to the integration of a lens reflection effect already existing in WoP. For more detailed information I refer to the <a href=\"http:\/\/www.base0x23.de\/Lensflare\/\" target=\"_blank\" rel=\"noopener noreferrer\">documentation of #@<\/a>.<\/p>\n<p>All lens reflections are implemented in WoP by script. So far all mappers of the WoP team use the same lens reflection effect <em>Photoshop\/50-300mmZoom<\/em> for all environment boxes that have a bright day sky and allow a direct view of a point light source, like the sun. The corresponding script file is called <em>photoshop.lensflare<\/em> and is located in the subdirectory scripts. This naming came about because the textures for the effect were created with Photoshop at that time.<\/p>\n<h2>Embedding the lens flare script<\/h2>\n<p>First you have to enter two keys in the worldspawn of your map. You can do this in GtkRadiant 1.4 by simply pressing the N key without selecting anything first, which opens the Entities Inspector. In GtkRadiant 1.5 or NetRadiant 1.5, you must first select a brush of the worldspawn before you open the Entities Inspector. Add the named values for the following keys:<\/p>\n<pre>skylensflare       Photoshop\/50-300mmZoom\r\nskylensflare_dir   -0.463591927 -0.324418826 0.927183854<\/pre>\n<p>The key <em>skylensflare<\/em> requires here, as already known from shaders, the path in the script file, here <em>Photoshop\/50-300mmZoom<\/em>, not the path or file name of the script (here: <em>photoshop.lensflare<\/em>)! The key <em>skylensflare_dir<\/em> requires the specification of coordinates that define the position of the point light source, such as the sun, on the environment box. The values above are taken from the TrashMapBB and match the values defined for <em>q3map_sun<\/em> (or <em>q3map_sunExt<\/em>) in the corresponding shader of the environment box.<\/p>\n<div id=\"attachment_11263\" style=\"width: 1290px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-11263\" class=\"wp-image-11263 size-full\" src=\"https:\/\/worldofpadman.net\/wp-content\/uploads\/woptut_skylensflarekeys.jpg\" alt=\"Worldspawn keys skylensflare and skylensflare_dir with values in the Entities Inspector of NetRadiants 1.5\" width=\"1280\" height=\"720\" srcset=\"https:\/\/worldofpadman.net\/wp-content\/uploads\/woptut_skylensflarekeys.jpg 1280w, https:\/\/worldofpadman.net\/wp-content\/uploads\/woptut_skylensflarekeys-326x183.jpg 326w, https:\/\/worldofpadman.net\/wp-content\/uploads\/woptut_skylensflarekeys-676x380.jpg 676w, https:\/\/worldofpadman.net\/wp-content\/uploads\/woptut_skylensflarekeys-728x409.jpg 728w, https:\/\/worldofpadman.net\/wp-content\/uploads\/woptut_skylensflarekeys-139x78.jpg 139w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><p id=\"caption-attachment-11263\" class=\"wp-caption-text\">Worldspawn keys skylensflare and skylensflare_dir with values in the Entities Inspector of NetRadiants 1.5<\/p><\/div>\n<p>For your map you only have to find out the correct values. The coordinates can be determined quite easily by the command <em>cg_printDir 1<\/em> during in-game testing, provided you started your map with <em>sv_pure 0<\/em> and devmap mymap. In the game, you only have to stand in the middle of the map, aim at the existing point light source (sun, etc.) and then transfer the vector coordinates as values for <em>skylensflare_dir<\/em> into the worldspawn.<\/p>\n<div id=\"attachment_11266\" style=\"width: 410px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-11266\" class=\"wp-image-11266 size-full\" src=\"https:\/\/worldofpadman.net\/wp-content\/uploads\/woptut_skylensflarecgprintdir1.jpg\" alt=\"Display of the vector coordinates of the player's viewing direction by cg_printdir 1\" width=\"400\" height=\"248\" srcset=\"https:\/\/worldofpadman.net\/wp-content\/uploads\/woptut_skylensflarecgprintdir1.jpg 400w, https:\/\/worldofpadman.net\/wp-content\/uploads\/woptut_skylensflarecgprintdir1-326x202.jpg 326w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><p id=\"caption-attachment-11266\" class=\"wp-caption-text\">Display of the vector coordinates of the player&#8217;s viewing direction by cg_printdir 1<\/p><\/div>\n<p>If your environment box has no visible point light source (sun etc.) on the texture, you should proceed the other way around. Since the lens reflection effect <em>Photoshop\/50-300mmZoom<\/em> automatically creates a bright point on the environment box that can be used as a sun, you should first define the polar coordinates of the point from which direct light will be emitted into the map. This means the specifications for <em>q3map_sun<\/em> (or <em>q3map_sunExt<\/em>) in the shader of the environment box. If you want to do without further math games now, you have to simply estimate by means of the shadow cast in your map and approach the actual position of the sun by testing to get <em>q3map_sun<\/em> (or <em>q3map_sunExt<\/em>) and <em>skylensflare_dir<\/em> on top of each other. But if you are familiar with trigonometric functions like sine and cosine, take a look at the next section.<\/p>\n<h2>Conversion from polar to vector coordinates<\/h2>\n<p>If by chance the polar coordinates of the <em>q3map_sun<\/em> (or <em>q3map_sunExt<\/em>) function are known from the shader of the environment box, the required vector coordinates for <em>skylensflare_dir<\/em> can be converted from the values of horizontal angle and elevation angle using the following equations:<\/p>\n<pre>X = SIN(elevation angle) x SIN(horizontal angle)\r\nY = COS(elevation angle) x COS(horizontal angle)\r\nZ = SIN(elevation angle)<\/pre>\n<p>For a horizontal angle of 210\u00b0 and an elevation angle of 68\u00b0, as in the BB version of the TrashMap, the following vector coordinates result:<\/p>\n<pre>X = SIN(68&deg;) x SIN(210&deg;) = -0,463591927\r\nY = COS(68&deg;) x COS(210&deg;) = -0,324418826\r\nZ = SIN(68&deg;)             =  0,927183854<\/pre>\n<p>These coordinates can then be transferred to the worldspawn. Please note the American spelling with decimal point instead of the comma!<\/p>\n<pre>skylensflare_dir   -0.463591927 -0.324418826 0.927183854<\/pre>\n<p><div id=\"attachment_5973\" style=\"width: 445px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5973\" class=\"wp-image-5973 size-full\" src=\"https:\/\/worldofpadman.net\/wp-content\/uploads\/woptut_q3map2sunelevationazimut.jpg\" alt=\"Horizontal angle and elevation angle of the sun in the TrashMapBB\" width=\"435\" height=\"342\" srcset=\"https:\/\/worldofpadman.net\/wp-content\/uploads\/woptut_q3map2sunelevationazimut.jpg 435w, https:\/\/worldofpadman.net\/wp-content\/uploads\/woptut_q3map2sunelevationazimut-326x256.jpg 326w\" sizes=\"auto, (max-width: 435px) 100vw, 435px\" \/><p id=\"caption-attachment-5973\" class=\"wp-caption-text\">Horizontal angle and elevation angle of the sun in the TrashMapBB<\/p><\/div><\/p>","protected":false},"excerpt":{"rendered":"<p>In this tutorial I would like to show you how to add an existing lens reflection effect to the environment box of your map. But before you start, you should make sure that you have installed and configured the Q3Map2 compiler at least in version 2.5.16 and the GtkRadiant 1.4 or newer for World of [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":11263,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[119,19],"tags":[155,34,40,42,18,36,38],"class_list":["post-156","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mapping","category-tutorials","tag-flare-effect","tag-sky","tag-lens-flare","tag-lens-flare-effect","tag-radiant","tag-skybox","tag-environment-box"],"_links":{"self":[{"href":"https:\/\/worldofpadman.net\/en\/wp-json\/wp\/v2\/posts\/156","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/worldofpadman.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/worldofpadman.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/worldofpadman.net\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/worldofpadman.net\/en\/wp-json\/wp\/v2\/comments?post=156"}],"version-history":[{"count":10,"href":"https:\/\/worldofpadman.net\/en\/wp-json\/wp\/v2\/posts\/156\/revisions"}],"predecessor-version":[{"id":11279,"href":"https:\/\/worldofpadman.net\/en\/wp-json\/wp\/v2\/posts\/156\/revisions\/11279"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/worldofpadman.net\/en\/wp-json\/wp\/v2\/media\/11263"}],"wp:attachment":[{"href":"https:\/\/worldofpadman.net\/en\/wp-json\/wp\/v2\/media?parent=156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/worldofpadman.net\/en\/wp-json\/wp\/v2\/categories?post=156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/worldofpadman.net\/en\/wp-json\/wp\/v2\/tags?post=156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}