Tải bản đầy đủ (.pdf) (435 trang)

Unity 5 x shaders and effects cookbook, second edition

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (7.4 MB, 435 trang )



Unity5.xShadersandEffectsCookbook


TableofContents
Unity5.xShadersandEffectsCookbook
Credits
AbouttheAuthors
www.PacktPub.com
eBooks,discountoffers,andmore
Whysubscribe?
Preface
Whatthisbookcovers
Whatyouneedforthisbook
Whothisbookisfor
Sections
Gettingready
Howtodoit…
Howitworks…
There’smore…
Seealso
Conventions
Readerfeedback
Customersupport
Downloadingtheexamplecode
Downloadingthecolorimagesofthisbook
Errata
Piracy
Questions
1.CreatingYourFirstShader


Introduction
CreatingabasicStandardShader
Gettingready
Howtodoit…


Howitworks…
Seealso
MigratingLegacyShadersfromUnity4toUnity5
Gettingready
Howtodoit…
Upgradingautomatically
UsingStandardShaders
Migratingcustomshaders
Howitworks…
Seealso
Addingpropertiestoashader
Gettingready
Howtodoit…
Howitworks…
Seealso
UsingpropertiesinaSurfaceShader
Howtodoit…
Howitworks…
There’smore…
Seealso
2.SurfaceShadersandTextureMapping
Introduction
Diffuseshading
Gettingready

Howtodoit…
Howitworks…
Usingpackedarrays
Howtodoit…
Packedmatrices
Seealso
Addingatexturetoashader


Gettingready
Howtodoit…
Howitworks…
There’smore…
Seealso
ScrollingtexturesbymodifyingUVvalues
Gettingready
Howtodoit…
Howitworks…
Normalmapping
Gettingready
Howtodoit…
Howitworks…
There’smore…
Creatingatransparentmaterial
Gettingready
Howtodoit…
Howitworks…
CreatingaHolographicShader
Gettingready
Howtodoit…

Howitworks…
There’smore…
Seealso
Packingandblendingtextures
Gettingready
Howtodoit…
Howitworks…
Creatingacirclearoundyourterrain
Gettingready
Howtodoit…


Movingthecircle
Howitworks…
3.UnderstandingLightingModels
Introduction
Creatingacustomdiffuselightingmodel
Gettingready
Howtodoit…
Howitworks…
CreatingaToonShader
Gettingready
Howtodoit…
Howitworks…
There’smore…
CreatingaPhongSpeculartype
Gettingready
Howtodoit…
Howitworks…
CreatingaBlinnPhongSpeculartype

Gettingready
Howtodoit…
Howitworks…
Seealso
CreatinganAnisotropicSpeculartype
Gettingready
Howtodoit…
Howitworks…
4.PhysicallyBasedRenderinginUnity5
Introduction
Understandingthemetallicsetup
Gettingready
Howtodoit…


Howitworks…
Seealso
AddingtransparencytoPBR
Gettingready
Howtodoit…
Semi-transparentmaterials
Fadingobjects
Solidgeometrieswithholes
Seealso
Creatingmirrorsandreflectivesurfaces
Gettingready
Howtodoit…
Howitworks…
Seealso
Bakinglightsinyourscene

Gettingready
Howtodoit…
Configuringthestaticgeometry
Configuringthelightprobes
Bakingthelights
Howitworks…
Seealso
5.VertexFunctions
Introduction
AccessingavertexcolorinaSurfaceShader
Gettingready
Howtodoit…
Howitworks…
There’smore…
AnimatingverticesinaSurfaceShader
Gettingready


Howtodoit…
Howitworks…
Extrudingyourmodels
Gettingready
Howtodoit…
Howitworks…
There’smore…
Addingextrusionmaps
Implementingasnowshader
Gettingready
Howtodoit…
Howitworks…

Coloringthesurface
Alteringthegeometry
Seealso
Implementingavolumetricexplosion
Gettingready
Howtodoit…
Howitworks…
There’smore…
Seealso
6.FragmentShadersandGrabPasses
Introduction
UnderstandingVertexandFragmentShaders
Gettingready
Howtodoit…
Howitworks…
There’smore…
Inputsemantics
Outputsemantics
Seealso


Usinggrabpass
Gettingready
Howtodoit…
Howitworks…
There’smore…
ImplementingaGlassShader
Gettingready
Howtodoit…
Howitworks…

There’smore…
ImplementingaWaterShaderfor2Dgames
Gettingready
Howtodoit…
Howitworks…
7.MobileShaderAdjustment
Introduction
Whatisacheapshader?
Gettingready
Howtodoit…
Howitworks…
Profilingyourshaders
Gettingready
Howtodoit…
Howitworks…
There’smore…
Modifyingourshadersformobile
Gettingready
Howtodoit…
Howitworks…
8.ScreenEffectswithUnityRenderTextures
Introduction


Settingupthescreeneffectsscriptsystem
Gettingready
Howtodoit…
Howitworks…
There’smore…
Usingbrightness,saturation,andcontrastwithscreeneffects

Gettingready
Howtodoit…
Howitworks…
UsingbasicPhotoshop-likeBlendmodeswithscreeneffects
Gettingready
Howtodoit…
Howitworks…
There’smore…
UsingtheOverlayBlendmodewithscreeneffects
Gettingready
Howtodoit…
Howitworks…
9.GameplayandScreenEffects
Introduction
Creatinganoldmoviescreeneffect
Gettingready
Howtodoit…
Howitworks…
Seealso
Creatinganightvisionscreeneffect
Gettingready
Howtodoit…
Howitworks…
There’smore…
10.AdvancedShadingTechniques


Introduction
UsingCgIncludefilesthatarebuiltintoUnity
Gettingready

Howtodoit…
Howitworks…
MakingyourshaderworldmodularwithCgInclude
Gettingready
Howtodoit…
Howitworks…
ImplementingaFurShader
Gettingready
Howtodoit…
Howitworks…
There’smore…
Implementingheatmapswitharrays
Gettingready
Howtodoit…
Howitworks…
Index



Unity5.xShadersandEffectsCookbook



Unity5.xShadersandEffectsCookbook
Copyright©2016PacktPublishing
Allrightsreserved.Nopartofthisbookmaybereproduced,storedinaretrievalsystem,
ortransmittedinanyformorbyanymeans,withoutthepriorwrittenpermissionofthe
publisher,exceptinthecaseofbriefquotationsembeddedincriticalarticlesorreviews.
Everyefforthasbeenmadeinthepreparationofthisbooktoensuretheaccuracyofthe
informationpresented.However,theinformationcontainedinthisbookissoldwithout

warranty,eitherexpressorimplied.Neithertheauthors,norPacktPublishing,andits
dealersanddistributorswillbeheldliableforanydamagescausedorallegedtobecaused
directlyorindirectlybythisbook.
PacktPublishinghasendeavoredtoprovidetrademarkinformationaboutallofthe
companiesandproductsmentionedinthisbookbytheappropriateuseofcapitals.
However,PacktPublishingcannotguaranteetheaccuracyofthisinformation.
FirstPublished:February2016
Productionreference:1220216
PublishedbyPacktPublishingLtd.
LiveryPlace
35LiveryStreet
BirminghamB32PB,UK.
ISBN978-1-78528-524-0
www.packtpub.com



Credits
Authors
AlanZucconi
KennethLammers
Reviewer
KennethLammers
CommissioningEditor
PriyaSingh
AcquisitionEditors
RahulNair
ErolStaveley
ContentDevelopmentEditor
MehvashFatima

TechnicalEditors
PranilPathare
DanishShaikh
CopyEditor
TasneemFatehi
ProjectCoordinator
KinjalBari
Proofreader
SafisEditing
Indexer
MonicaAjmeraMehta
Graphics
KirkD’Penha
DishaHaria
ProductionCoordinator
NileshMohite
CoverWork
NileshMohite




AbouttheAuthors
AlanZucconiisapassionatedeveloper,author,andmotivationalspeaker,recognizedas
oneofDevelop’s“30under30.”Hisexpertisehasbeenbuiltoverthepast10years,while
hededicatedhistimetoacademiaandthegamingindustry.Hestartedhisindependent
careertofullyexplorehiscreativity,tearingdownthewallbetweenartandgaming.Prior
tothat,heworkedatImperialCollegeLondon,wherehediscoveredhispassionfor
teachingandwriting.Histitlesincludethegravitypuzzle,0RBITALIS,andtheupcoming
timetravelplatformer,StillTime.

KennethLammershasover15yearsofexperienceinthegamingindustry,workingasa
characterartist,technicalartist,technicalartdirector,andprogrammer.Throughouthis
career,hehasworkedontitlessuchasCallofDuty3,Crackdown2,AlanWake,and
KinectStarWars.HecurrentlyownsandoperatesOzoneInteractivealongwithhis
businesspartner,NoahKaarbo.Together,theyhaveworkedwithclientssuchasAmazon,
ElineMedia,IGT,andMicrosoft.
KennyhasworkedforMicrosoftGamesStudios,Activision,andSurreal,andhasrecently
goneoutonhisown,operatingCreativeTDandOzoneInteractive.
KennyauthoredthefirstversionofUnityShadersandEffectsCookbookbyPackt
Publishing,andwasveryhappytobeapartofthewriting,updatingandreviewingofthis
book.



www.PacktPub.com


eBooks,discountoffers,andmore
DidyouknowthatPacktofferseBookversionsofeverybookpublished,withPDFand
ePubfilesavailable?YoucanupgradetotheeBookversionatwww.PacktPub.comandas
aprintbookcustomer,youareentitledtoadiscountontheeBookcopy.Getintouchwith
usat<>formoredetails.
Atwww.PacktPub.com,youcanalsoreadacollectionoffreetechnicalarticles,signup
forarangeoffreenewslettersandreceiveexclusivediscountsandoffersonPacktbooks
andeBooks.

/>DoyouneedinstantsolutionstoyourITquestions?PacktLibisPackt’sonlinedigital
booklibrary.Here,youcansearch,access,andreadPackt’sentirelibraryofbooks.



Whysubscribe?
FullysearchableacrosseverybookpublishedbyPackt
Copyandpaste,print,andbookmarkcontent
Ondemandandaccessibleviaawebbrowser


×