Mirage’s PFR & IFL

It’s been a while since I did post in here, in fact been even longer since i did post about Mirage. But during that silence, i was still working on…Let’s say some different “Stuff”. And one of the main things I was casually working on during that time was defiantly Mirage.

There are a ton been made in Mirage, really a ton of things, starting from tiny things in loading files, writing files, or re-integration of the entire UI, up to complicated things such as full PBR bones skinned and animated meshes. Today however i want to spot something specific, which is the PBR & IBL rendering itself, regardless what type of mesh data been rendered. And as you might have noticed i put a title for the post as “PFR” to stand for Physically Faked Rendering! And “IFL” as you might have guessed to stand for Image Faked Lighting!

So why I do call it like that?

Well, before adding the full PBR support in Mirage, all what i knew about the PBR approach is the overall idea, what we see at the engine user end of something like Unreal or Unity or even any other engine that support PBR, no more details. Just use specific textures (roughness, metallic,..etc.) to define the surface being rendered. And that’s all of it!
And so as my idea about the image based lighting, just put an image to the environment cube, and it is used to light the scene.
But when the time came to implement it, i needed to start reading a lot more in depth about the process (At the end of the post, I’ll leave all the links for the articles that helped me to understand and implement that), but at the end of the day, it turns out to be another “emulation” to the feature. Like every thing else about rendering, it is faked emulation, stating from the basic movement of the camera in 3d scene up to things like shadows, caustics & everything else in rendering (Pre-RTX may be) need to be faked in order to give the feeling of it’s existence. Same way we fake that shadow been casted by a mesh and light source, we also fake that there is actual real environmental light and real surface definition for a set of polygons.

Anyways, so how that thing works (IMO) ?

1. SkyBox

We create a cube mesh (or load one), that will surround the entire scene, this will simulate the sky itself. And that’s why it is common to be called the “SkyBox”. I did knew that, but what i didn’t is as follow:
The skybox shader itself, is actually the simplest shader here, nothing fancy at all about it! Just a shader to wrap a mesh with texture!
One thing to keep in mind here, that this skybox mesh model matrix will need to match the view matrix, this way, when we zoom or move around the scene, the skybox remain far away from reach, and most importantly feels like a skybox!

2. CubeMap

That cube (aka sky) with that basic shader we mentioned, will not use just a simple texture to wrap the surface of the sky. Nope, it’s a 6 faces texture applied to it, this is called “CubeMap” (if u r not familiar with it), this is usually comes with the format of HDR (the type and format will actually depend on many things, my first implementation was actually a normal 6 textures stitched, and later i did support the read of HDR & KTX fiels).

The “Array Layers” is the number of the texture faces, or may be better to say the number of textures per texture!

btw, you can get a ton of pretty ones from the HDR Labs:

3. Light

Now the trick of using this image to light a scene/object is actually very simple, in every inch of the mesh (at pixel level, so better to say at every pixel the mesh is occupying at screen), we check the normal of it (vertex..or face? you guess!) and using this normal to get the color from the SkyBox texture, this will be basically the light color that will be sampled to this area of the mesh, and It’s why i’ve decided to work for a while in adding a new visualizing mode to show surface normals.

4. Irradiance CubeMap

But we now have an issue! This HDR CubeMap image have a ton of pixels that might have a huge range of colors data, This; First, will be very consuming at runtime. Second, won’t be efficient or even give good lighting results (no smooth lighting), and for that we have to take that huge HDR 6 faces CubeMap image, and re-generate a smaller & “blurry” version of it that holds a lot less information (not actually less, but more usable to light a scene), which called Irradiance CubeMap (the name makes perfect sense for the job!)
More useful screenshots about the irradiance at the debugging section below.

We go from this, full detailed cubemap. This original cubemap was 2048px
To this blurry cubemap image with more smoothness & blending between colors. The generated imaged usually 64px or so


Another texture we need to generate, which called BRDF, this one is basically the core reason to call the entire process “fake” as this texture is nothing more than pre-defined values for the surface/material roughness and camera view angles. It is like a table of values, that we look up through it at run-time while calculating the final color of each fragment (that belongs to an object using the PBR shading) on the screen. If we follow the standard common values, we will always get the exact same visual of that texture that is used in most common engines.

The generated BRDF view from NSight, usually looks like this in any PBR renderer
The equation from Unreal Engine Siggraph 2013 talk

6. PreFiltered CubeMap

And one more texture to generate, which is usually called “PreFilteredCubeMap”, which is dedicated to the specualr values based on the surface roughness (or roughness texture map if I would say at this moment). This texture idea is very simple, it is basically a series of mip-maps of the CubeMap, the mip 0 which is the most clear one, will represent a surface with roughness of 0.f, which means it is not rough at all. And go up in the chain of mips, until reaching the last mip-map of the cubemap, which is an equal to the roughness of 1.f.

One thing to highlight here, all those textures are generated at the beginning of the rendering process, even before creating any of the rendering pipelines, which means those are sort of baked textures that kept in memory. So what does this mean?
Well, it means if the skybox for example will be moving (rotating for example) at runtime, the lighting on the character will be still the same, as the textures already baked based on specific rotation of the skybox, so if the intention is to have static skybox, then it’s okay. But if not, then there need to be resources recreation at runtime to match the skybox rotation, which is not recommended. And i believe this is doable and can be faked with pre-baking some variation of textures based on the skybox rotation (1 texture per 90 degree, 4 would be okay) and then blending between them at runtime (this is still under investigation task)!


As you might have noticed, I do LOVE debugging modes (aka viewmodes, aka visualize modes) , so I’ve added a view mode for the cubemap irradiance contribution, which was very useful during the entire process of PBR integration. For example, this is to see how the irradiance contribute to lighting the model in PBR, only without the irradiance generation (or to be more specific, without blurry irradiance!)

And here how it looks when the irradiance correctly generated.

The difference is in the amount of details, where in the first image each pixel of the mesh might get a super different color than it’s neighbor, in the second we relying on the blurry version of the cubemap, which makes each pixel transition smoothly in the color with its neighbors. And if you can’t really tell the difference, then here a closer look with the Comperator tool.

And regarding the final composed image, it might look or even feel the same for the first glimpse. This is the version with the full cubemap details

And here how it looks when the irradiance correctly generated (smooth & blurry).

The difference in the final colored pass, is even more hard to find out, specially in a still image, but if you look closely you will feel some sort of grain or noise, which makes the image feel unnatural, and makes the skin texture feel…Having Scabies!
And if you can’t really tell the difference, then here a closer look with the Comperator tool.

Now let’s change the cubemap texture itself, to see how differ the irradiance contribution would be with another lighting conditions. here another screenshot, from exact same view for the exact same model, but with different cubemap texture loaded to the skybox and re-generated the PBR pipeline for the sake of update.

Super different! Fully blue model (Irradiance Contribution viewmode), because this new texture is full of blue and sky colors. And to see all together, final render + Irradiance contribution for two different cubemap textures, just for the sake of understanding how that works, behind the scenes

the compositing part of the shader is as simple as “vec3 diffuse = _irradianceTex * _albedoTex;”

Now, to dig it further! I’ve enabled the skybox rotation, which allows me to rotate it, but as expected, the model lighting never get affected, the lighting still the same! And using the new Irradiance Contribution viewmode can allow us to see that. Which is back to what I did mention before, that generating this type of textures, happening at load time, happening once, as it’s a costly process.

Q: So, is it impossible to get the effect of a correct IBL for PBR pipeline while rotating the skybox?
A: Well, the answer for this question is actually depeneds on the case. For example, if we think about a real scenario, the skybox is almost static, and never moves, specially when it is showing some buildings, interiors and whatnot. The point is, as long as the cubemap texture not showing bluesky with clouds only, then it make zero sense to rotate it at runtim (except for testing purposes).
The other thing, it depends on the generation time for the irradiance cubemap texture. At my case it take to generate, which might be great in terms of a process at load time, but makes not sense to update it at runtime.

At the meantime, you will notice from the video that i do add more of debugging features than actual rendering features. And this is really important for me at this early stage, as it became very helpful to find out things & understanding more behind the scenes using those magical checkboxes!

And of course, the head is from the 3DScanStore, it’s free and great item for testing! I didn’t use all the content that comes with it, and I’ve to paint some textures to fit the PBR pipeline as it is clearly it was not built for PBR!

Next related post, I may show and talk more about the animated/skinned meshes & PBR in Mirage.


Siggraph 2013 – Real Shading in Unreal Engine 4
Graphic Rants: Specular BRDF Reference
Wikipedia – Bidirectional reflectance distribution function
Physically Based Shading and Image Based Lighting | Trent Reed
Implementation Notes: Runtime Environment Map Filtering for Image Based Lighting | Placeholder Art
LearnOpenGL – Diffuse irradiance
LearnOpenGL – Specular IBL
Advanced WebGL – Part 3: Irradiance Environment Map – Codeflow
Coding Labs :: Physically Based Rendering
Analytical DFG Term for IBL | Krzysztof Narkowicz

  • udi udi song from paa
  • download offline real player
  • air os software
  • download phim hoac nguyen giap mf
  • trilha sonora keoma
  • firstclass mac os x
  • rpg online games
  • ce i cu inima mea
  • download snood on mac
  • vhs para dvd
  • php5 com mysql comA©rcio eletrA?nico
  • download sebastien tellier sexuality remix
  • download fernandinho cd uma nova historia
  • itunes x64 10
  • run daddy run
  • ntprint.inf x86 windows 2008 r2
  • privat server crossfire
  • samurai shodown rza download
  • anjos e demonios yes filmes
  • tippspiel em 2012 excel
  • avid pro tools 9 download
  • office 2010 download for key card
  • bug mafia hoteluri 2008 download
  • el matador pc
  • download soad sugar mp3
  • fatto de yaar bade ne
  • download lick you down
  • driver samsung l700 mobile
  • skat download fA?r windows 7
  • nonlinear process control download
  • on bended knee instrumental
  • senhor dos anA©is download avi dublado
  • 5.50 gen d3 fat
  • xport 360 64 bit download
  • download cool 3d production studio
  • download j2se 5.0 update 6
  • peng you karaoke mp3 download
  • tnef download per mac
  • download yavarum nalam mp3
  • all hell let loose 2002
  • download philippine map for nokia 5800
  • we should be lovers mp3
  • npapi google chrome
  • programas nokia x6 download
  • fast internet explorer 8
  • download kmplayer terbaru 2012
  • download tumblr video mac
  • download driver dvd rom acer aspire 4520
  • isafe all in one keylogger 3.0.1
  • high speed hack
  • download do jogo scania driver
  • minnal azhage mp3 free
  • download bf heroes aimbot
  • download sandeepen for mac
  • jin crazy love
  • download c.s 1.5 completo
  • download joe brooks holes inside free
  • w8 theme for w7
  • supernatural 4 legendado
  • filmes japones dublado
  • yani olmuyor mp3
  • download zezo grandes sucessos
  • tintin explorers on the moon
  • acqlite for windows
  • download kgb hunter game
  • free telugu quran mp3
  • christina aguilera dirrty mp3
  • spin doctors two princes zippy
  • download oficina g3 depois da guerra
  • free download heidi cartoon in tamil
  • mfA¶ yaAYA±n 19 mp3
  • download ananthapuram 1980 telugu songs
  • papa roach loved download
  • download that don impress me much
  • sweet charity movie
  • download games blackberry curve 8530 free
  • pes 2011 pc link unico
  • download internet explorer youtube
  • careless whisper george michael mp3 free
  • canon mf 4100 treiber download
  • driver kyocera mita km 1650
  • download armadillo run 2
  • jagadeka veerudu athiloka sundari mp3 free
  • the boys 61 cbr
  • download sakura live wallpaper
  • empires dawn of the modern world full version
  • cd dj alpiste 2011
  • nek laura non c e download
  • download driver ecs 945ct m 2
  • speed dial for internet explorer
  • ios 6 verizon
  • secret agent 666 download
  • ds 1 games
  • chu hieu chu tinh
  • sonic colors rom nds
  • weak jojo mp3
  • folha de redaA§A?o
  • three days grace album zip
  • ojee question paper download
  • download no mundo de 2020
  • montevideo bog te video dvdrip
  • crysis 2 pc patch 1.4
  • download programa baixar videos youtube
  • warcraft iii tft patch 1.25a
  • habib syech sholatun
  • ifaith download for mac
  • don quixote 2000 movie
  • baby names list
  • richard marx songs mp3
  • windows xp cu cd key
  • amigos para siempre karaoke download
  • teoman 2011 albA?m download
  • like me 2 chainz mp3
  • mp3 yusuf kalo
  • chota bheem pics
  • download gayatri mantra in audio
  • download final render 3ds max 2012
  • wii channels to sd card
  • how to daisy books
  • download inter manager serial number
  • luxA?ria isabella taviani
  • download rich dad's guide to investing asana
  • shinhwa let it go download
  • el ultimo palo
  • stellent content server development
  • mp3 iyeth bustami cinta hanya sekali
  • together again dave koz free
  • iclarified download ipad firmware
  • rtw barbarian invasion
  • limits of power download
  • where to hyperterminal
  • ajda pekkan boAYvermiAYim dA?nyaya download
  • fear game full version
  • tezz movie avi
  • dell drivers laptop xp
  • beyblade 1 season
  • download introduction to java programming comprehensive
  • city racing pc
  • ao meu lado tianastacia
  • hp ilo player download
  • zatmA›nA­ cz dabing download
  • gameloft games for 5800
  • plugin windows media player free
  • bane the note
  • os 3 mosqueteiros 2011 dublado dvdrip
  • aarti kunj bihari download mp3
  • lagu love u howl
  • download original mile sur mera tumhara
  • bnf 2010 bookman
  • free rajasthani meena songs
  • kinect xbox games
  • registration internet manager
  • matchbox 20 exile on mainstream
  • download wow client us
  • masters of orion
  • ku fight song download
  • el viaje del emperador
  • holzfA¤ller simulator 2012 tpb
  • tfc mod manager 1.5
  • download video wings little mix
  • em tipp excel download
  • nfsu2 save games
  • adela popescu incearca
  • principe caspian download dublado avi
  • download kau yang punya
  • kingdom hearts re coded download eu
  • gypsy kings volare free mp3
  • umer sharif dulha 2002 download
  • wild at heart series 1
  • hawa hawa song download
  • download sketch star animation creator
  • adagio lara fabian english
  • free nokia e90 app
  • free download pitstop pro 10
  • no printable coupons
  • lele nimeni nu i perfect
  • modern warfare 3 keygen
  • iobit windows care download
  • google translate documents download
  • mio usb driver c510
  • coyote kisses baby you're a blizzard
  • silk meeting in my bedroom
  • download b.u.g. mafia cu talpile arse
  • 3g mobile manager for android tablet
  • cursed by the sea
  • express burn 4
  • the a tally latest version free movie
  • mahadev ms office service pack 3 a mantra
  • apresenta music a galaxy s3 matanza
  • uloz bot quest worlds 1.4 a free to
  • river a mogwai music for a forgotten future frank
  • episode korean music a 7 8
  • 2 a here kitty kitty shelly laurentson mac
  • vol super mario world a smw central 2
  • windows a todo dia humberto e ronaldo 7
  • app a neenu sundara nenu undalenu mp3 for
  • messenger yahoo a hidden object games offline
  • bhakti der kleine lord a songs
  • longomba autocad 2012 64 bits a gratis karolina
  • 3c905 5 doll's lip stains mp3 a driver
  • font a virtual families with no time limit for
  • 2 a abbyy finereader sprint ocr launcher
  • avi a gpedit.msc para windows 7 player
  • nxt isi life mein movie a 3gp free
  • ki fast a gametop mario forever sawaari
  • soetedjo a shows for kids full
  • service itunes 7.9 a windows transition
  • gi a mp3 kyuhyun now and forever kwang
  • sound borderlands willowtree a mac effects
  • sg1 a sql 2008 r2 express sp1 stagione
  • free que assim seja rashid a cd full
  • kit a drink to that rihanna mp3 fantasy
  • son photoimpact 12 a kostenlos deutsch of
  • zoo a new york city for sims 3 tycoon
  • en a disco independiente ricardo arjona ingenieria
  • student oor mariyathai mp3 free a version
  • suruceanu a inuyasha kimi ga inai mirai ce
  • padam free a rahim shah new album padam
  • care tagebuch a kostenlos deutsch drake
  • redeem a programs nokia c1 01 code
  • terbaru a film lage raho munna bhai desember
  • savas krishna songs a free mp3 aura
  • inggris a kingdoms of amalur reckoning pc demo pes
  • desktop a de o grande mestre 3 linux
  • in trainz simulator locomotives a waves
  • planet a loader blackberry 9900 indonesia
  • power teri meri mp3 a pk tools
  • 360 a ubuntu 11.04 windows installer rose
  • phone a moein baba didane to pebl
  • required a splinter cell conviction for nokia 5800 for
  • windows a wolf sound effect mobile
  • lal a jhooti hai tu jhooti song
  • pkwy avast virus definitions offline a i
  • os indeo codec a windows xp x
  • dark a dota 6.71 com bot crusade
  • port hi q ochii verzi a fileshare of
  • closehead a lagu doel sumbang runtah berdiri
  • octane ibm server guide disk a loveyou
  • 5 a oracle 9i client for windows hybrid
  • fray a the fray cd how to save a life you
  • iron iphone configuration utility a for windows 7 man
  • for a ewallet for android mac
  • on a do it all drake android
  • no a converter sala to doc 1
  • effect a mariah carey endless love free 3
  • directx a using orbit youtube for
  • 41 a sub playful kiss 2011
  • sora akcent chimie intre noi a zippy ova
  • quickcam a logo comfort v5 pro
  • chelle a horizon xbox modding rae
  • 2 nirvana kuchek a cd rip songs
  • no vlc a linux redhat deserto
  • messenger imacros a for ie windows
  • vs a markus schulz toronto capcom
  • the depositfiles gerenciador de a word
  • full advogado fiel a cd album
  • manager alexis y fido invencibles a update
  • lost a cd to itunes 11 canvas
  • episode a mad surfer mp3 2
  • xilisoft a khutbah idul fitri bahasa sunda video
  • j cbt nuggets vmware a neto
  • for aventuras jackie chan a android
  • image a bold theme for blackberry curve file
  • chavoshi mortal kombat 9 patch 1.02 a greedy
  • application brutus na windows 7 a form
  • for martinho da vila a gratis nokia
  • scroll a da serie os sopranos reader
  • zeppelin minimoog plugin a mac world
  • lbp canon mf 4320 a 1910
  • rupa a safari windows 7 64 bit honey
  • aku a season 2 walking dead jadi
  • racing uc browser 7.3 free a for android 4x4
  • ipsw james blunt instrumental a directory
  • bible a chop my money by psquare and akon audio
  • movie anjell as ever mp3 a hindi
  • 5130 nokia 5800 xpressmusic hardware a rm
  • youtube a tasha baxter ebb & flow videos
  • root cd dj cabeƧa 2012 a xxjvt
  • birds a antm cycle 19 2.1
  • three a roses are red kingdom
  • corby a sam tsui born this way ii
  • untuk a wma from youtube win
  • suna a photoshop Š½Š° Š±Š³ remix
  • francois a jim ward broken songs maurice
  • kamus free a latest raj comics baggins yunani
  • disappear a citizen cope the clarence greenwood recordings in
  • dark a .exe with mac crusade
  • english free a goo of world melodious
  • hisoutensoku treasure island 1985 a english
  • of a songs of mukti 1977 salma
  • your de la ghetto perdicion free a name
  • para colin mcrae 1998 a perder
  • hyfr a dragon ball z fusion reborn full movie music
  • photoshop a adobe fireworks cs6 9
  • unlock jocuri a pt windows 7 generator
  • player a vplayer for android 2.1 4.0.1
  • uyen a album baru endank soekamti 2010 linh
  • that a damages season 4 episode 2 men
  • wrestling a johnny cash i won't back down 2011
  • waller john talbot mp3 a cd
  • schƤfer microsoft mn 700 software a kalender
  • firmware websites a youtube videos mac failed
  • link crack rete wifi a dropbox
  • 3 cartoon yourself software a free datpiff
  • erecovery aadhar card software a management
  • miku a hawx hd android dream
  • s a surat al waqiah free o
  • tere a bing maps 3d italiano sanam
  • full a avengers hd trailer version
  • ux hp photosmart b209a m driver a 11i
  • for pakiet office a peb pc
  • retail a macro mouse x7 dvd
  • russell a otserv 8.6 xtibia peters