最近再使用顶点纹理动画制作动画效果,目的是为了节省资源的消耗。但是当使用一个颜色通道存储一个Mesh顶点位置坐标的时候,发现精度是不够的,毕竟一个RGBA32的每个通道的分量是0-255。导致精度是有限的。所以这里使用一个RGBA 4个通道存储一个顶点的一个方向的坐标值。
一个float是32位的,一个RGBA32也是32位的,刚刚好能够高精度的存储下来。
基本思想,我们把32位的浮点数当做4个byte数据,存储再RGBA的4个通道中,然后在Shader中通过RGBA的4个通道的数据还原成一个float数据。
首先,float转RGBA的方法如下:
public Color FloatToColor(float f)
{
byte[] buffer = BitConverter.GetBytes(f);
int r = buffer[0];
int g = buffer[1];
int b = buffer[2];
int a = buffer[3];
return new Color((float)r / 255, (float)g / 255, (float)b / 255, (float)a / 255);
}
在C#中把4个Byte转成Float的方法如下:
public float ColorToFloat(Color c)
{
byte r = (byte)(c.r * 255);
byte g = (byte)(c.g * 255);
byte b = (byte)(c.b * 255);
byte a = (byte)(c.a * 255);
List<byte> tempList = new List<byte>();
tempList.Add(r);
tempList.Add(g);
tempList.Add(b);
tempList.Add(a);
byte[] buffer = tempList.ToArray();
float f = (float)BitConverter.ToSingle(buffer, 0);
return f;
}
但是,我们是在Shader中提取颜色,然后把一个颜色转换成一个Float数据类型,Shader中可没有方便的BitConverter方法使用,那就的我们自己通过Float的实现标准来换算出来。
//m0 是最高位 m3是最低位
float b2f(float m0, float m1, float m2, float m3)
{
// 求符号位
float sig = 1;
if (m3 >= 128.0f)
sig = -1.0f;
//求阶码
float jie = 0f;
if (m3 >= 128.0f)
{
jie = m3 - 128.0f;
}
else
{
jie = m3;
}
jie = jie * 2.0f;
if (m2 >= 128.0f)
jie += 1.0f;
jie -= 127.0f;
//求尾码
float tail = 0.0f;
if (m2 >= 128.0f)
m2 -= 128.0f;
tail = m0 + (m1 + m2 * 256.0f) * 256.0f;
tail = (tail) / 8388608; // 8388608 = 2^23
float f = sig * Mathf.Pow(2.0f, jie) * (1 + tail);
return f;
}
然后,我们在采样的时候,3个像素值来表示一个坐标,方法如下:
v2f vert (appdata v,uint vid:SV_VertexID)
{
float animMap_xx = vid*3 * _AnimMap_TexelSize.x + _AnimMap_TexelSize.x / 2;
float animMap_xy = (vid*3+1) * _AnimMap_TexelSize.x + _AnimMap_TexelSize.x / 2;
float animMap_xz = (vid*3+2) * _AnimMap_TexelSize.x + _AnimMap_TexelSize.x / 2;
int curFrame = int(_FrameTime %_AnimFrameCount);
float animMap_y = (curFrame + 0.5) * _AnimMap_TexelSize.y;
float4 pos_x = tex2Dlod(_AnimMap, float4(animMap_xx, animMap_y, 0, 0));
float4 pos_y = tex2Dlod(_AnimMap, float4(animMap_xy, animMap_y, 0, 0));
float4 pos_z = tex2Dlod(_AnimMap, float4(animMap_xz, animMap_y, 0, 0));
float4 pos;
pos.x = b2f(pos_x.x *255 , pos_x.y * 255, pos_x.z * 255, pos_x.w * 255) ;
pos.y = b2f(pos_y.x *255 , pos_y.y * 255, pos_y.z * 255, pos_y.w * 255) ;
pos.z = b2f(pos_z.x*255 , pos_z.y * 255, pos_z.z * 255, pos_z.w * 255) ;
pos.w =1;
v2f o;
o.vertex = UnityObjectToClipPos(pos);
o.uv = v.uv;
return o;
}
Alienda
buy online xenical best price no prescription
DavisUnold
sildenafil soft
LagoNeeLekmc
ledipasvir sofosbuvir generic cost free harvoni treatment generic harvoni
Kwivsibly
hi opp ggeis 2022 ert go fi
Ecodoma
craigslist dating chicago dating simulator rebecca
Jonah
Good day! This post couldn’t be written any
better! Reading this post reminds me of my previous room
mate! He always kept talking about this. I will forward this article to
him. Fairly certain he will have a good read.
Thanks foor sharing!
Here is my homepage; diagram maker free download – Jonah –
DagoNeeLeknb
asunaprevir daclatasvir daklinza genotype 3 daclatasvir side effects
gurtucky
dating steps before marriage
GagoNeeLekel
help paying for lyrica lyrica canada lyrica 50mg
Https://aaasjournal.net/
Appreciaqte it for this post, I am a big big fan of this website would like to proceed updated.
Feell free to surf to my web blog answer cppc exam
(https://aaasjournal.net/)
Sherman
I regard somethuing genuinely special iin this web site.
Feel free to surf to my website exasm materials preloaded (Sherman)
GagoNeeLekgw
lyrica used for pregabalin zwitterion ph information on lyrica
sens-lab.org
Thank youu a lot for sharing this with all people you actually recognize what you aare
talking approximately! Bookmarked. Kindly also discuss with my web sitge =).
We may have a hyperlink trade contract between us!
Also viskt my webpage :: police wrritten exam (sens-lab.org)
Amado
Hmm is anyone elpse experiencing probems with the pictures on this blog loading?
I’m trying too find out if its a problem on my end or if it’s thhe blog.
Any feedback would be greatly appreciated.
Feel free to visit my homepage: cpc exam questions, Amado,
Joy
We are a gaggle of volunteers and opening a brand new scheme in oour community.
Your sie offered us with valuable info to work on. You have perfrmed an impressive task and our entire community wilol likely be grateful to you.
Visit my webpage pmp software (Joy)
akuraschools.org
I have recently started a web site, the info you provide on this
website has helped me greatly. Thanks for all off
your time & work.
Revie my website cisco certified (akuraschools.org)
heenda
online casino real money
Flossie
Lovingg the info oon this site, you have done
great job on tthe articles.
My web blog – police exam (Flossie)
BrendanSassy
Undeniably consider that which you stated. Your favorite justification seemed to be on the internet the easiest thing to take into accout of. I say to you, I certainly get irked even as folks consider issues that they plainly do not realize about. You controlled to hit the nail upon the top as smartly as defined out the whole thing with no need side-effects, other people can take a signal. Will probably be back to get more. Thank you
https://www.deviantart.com/ruddle-digital/art/SEO-Services-UK-922584056 – deviantart.com
Penfremo
casino games
Luz
Thanks for this post, I am a big big fan of this
internet site would like to keep updated.
Review my webpage :: cisco ccna exam, Luz,
https://aaasjournal.net/
I have been absent for a while, but nnow I remember
why I used to love this blog. Thank you, I’ll try and
check back more frequently. Hoow frequently you update your website?
Feel free to surf to my wesite :: bar exam preparation (https://aaasjournal.net/)
https://sens-lab.org
I have recently started a site, the info you provide on this site has helped me greatly.
Thanks for all of your time & work.
My page: module exams (https://sens-lab.org)
Kristan
We’re a group of volunteers and opening a brand new scheme in our
community. Yourr website provided us with valuable info
to work on. You have done an impressive task and our entire
group will likely be thankful tto you.
Here is my blog – exazm questions (Kristan)
stphelps.org
Super-Duper website! I am loving it!! Willl be back later to read some more.
I am bookmarking your feedxs also
Feel free to surf to my web blog … exzam material typically – stphelps.org –
Trent
I am sure this piece of writing has touched alll the internet visitors, its really really pleasant post on building upp new weblog.
Also visit my web blog; pmp simulator – Trent –
aaasjournal.net
Loving the info on this website, you have
done great job on tthe bllg posts.
Feel free to visit my web site :: police jobs [aaasjournal.net]
Margarito
Thank you, I have recently been searching for info approximately this subject for a while and yours is the greatest I have came upon so far.
However, what concerning the conclusion? Are you sure about the
source?
Look at my web blog – pmp 35 pdu (Margarito)
TnntMaype
cialis precio where to buy cialis online cialis with alcohol
Jdnsadoms
tadalafil rx (tadalafil) cialis gernic
Jrnaquamilip
tadalafil sublingual tablet 20mg cialis daily online viagra levitra cialis which works better?
Knnfsibly
tadalafil 20 mg dosage cialis side effects forum canadian drugstore cialis
EbxdMaype
cheap generic viagra from india viagra 50 mg tablet online purchase cheap viagra mastercard
Wooladoms
where to buy viagra over the counter sildenafil 50 mg online uk cheap viagra uk
AvxeGlync
female viagara sildenafil uk over the counter buy usa viagra online
QuuMaype
tadalafil without a prescription cialis canada pharmacy tadalafil and blood pressure
TujMaype
people’s pharmacy synthroid real viagra online canadian pharmacy popular prescription drugs
Jnebadoms
giant pharmacy reliable rx pharmacy walmart pharmacy enalapril
Jbqaquamilip
walgreens pharmacy near me canadian pharmacy east bay largo fl cedarwood pharmacy canada
EexdMaype
canadian pharmacy viagra cialis troy pharmacy tramadol cod compounding pharmacy viagra
AmvtGlync
optum rx pharmacy help desk canadian pharmacy locations most reputable canadian pharmacy
QubMaype
fry’s pharmacy la canada and lambert prometrium canadian pharmacy cost of levitra at walmart pharmacy
Woroladoms
pharmacy viagra sans ordonnance canadian pharmacy azithromycin effexor xr pharmacy
Inge
I am impressed with this site, real I am a big fan.
Here is my wweb page; certificatiin questions (Inge)
TnfxMaype
cialis lilly buy daily cialis from canada cialis at walmart
Jmeuadoms
purchase viagra over the counter best prices for viagra prescription coupon sildenafil 20mg
Kensibly
discount online viagra generic viagra no prescription viagra otc in canada
Jemtaquamilip
cialis viagra levitra canada get cialis online cialis samples free
Wmgladoms
35 viagra sildenafil generic without prescription buy pfizer viagra
QemmMaype
generic viagra pills for sale cheap viagra free shipping viagra tablet
EhdMaype
generic viagra online fast delivery viagra pills online canada where can i get female viagra uk
AmrbGlync
genuine viagra canada purchase genuine viagra generic viagra – mastercard
TmrbMaype
what is cialis black 800mg cialis 36 hour online super tadalafil with dapoxetine
Knrsibly
tadalafil generico tadalafil order buy cialis no prescription
Jdnvadoms
cialis 5mg no prescription online cialis canada cialis canada over the counter
QnwrMaype
cialis wikipedia how much does cialis cost at walmart what does cialis cost
Wdbladoms
brands of generic tadalafil cialis contraindications generic tadalafil canada
ThwMaype
cialis otc usa when will generic cialis be available cialis australia express shipping
Jdnvadoms
sublingual tadalafil buy cialis 20 mg tadalafil alternative
EhdMaype
generic sildenafil online sildenafil 100mg buy online viagra tablet
AmrbGlync
viagra 4 pack sildenafil buy without prescription viagra 10mg price in india
Reyes
I’m no longer positive where you’re getting
your info, but good topic. I must spend some time studying much more or understanding more.
Thank yyou for great info I used to be searching for
this info for my mission.
Also visit my web-site – written driving exam (Reyes)
Wdbladoms
how much cialis should i take cialis daily vs regular cialis walmart price for cialis
Nannette
Hmm is anyone else encountering problems with the pictures on this blog loading?
I’m trying to figure out if its a problem on my end or if it’s
the blog.Any suggestions would be greatly appreciated.
My webpage: ppmp software (Nannette)
SagoNeeLekbh
furosemide 40 mg para que sirve what is furosemide what is lasix
Jttadoms
metformin melasma metformin analysis dauerdurchfall metformin
TooMaype
lisinopril lexapro lisinopril omeprazole lisinopril breastfeeding
EtnMaype
utilisation flagyl metrogyl flagyl metronidazole image
AtnGlync
tenormin ivz atenolol respiratory atenolol spironolactone
QneMaype
furosemide journals lasix insert lasix rash
Wyhladoms
tamoxifen testing tamoxifen precautions mcf7 tamoxifen
TooMaype
lisinopril iron lisinopril scleroza lisinopril zantac
Jttadoms
metformin jod metformin amitriptyline guanidine metformin
MarvinFoesS
Апартаменты на Северном Кипре
EtnMaype
atripla flagyl metronidazole warfarin flagyl ssri
AtnGlync
atenolol mood atenolol thirsty atenolol therabloc
Wyhladoms
tamoxifen behandlingstid tamoxifen innemen nolvadex laws
PagoNeeLekkk
buy azithromycin zithromax tri pak azithromycin use
Ethanher
Квартиры на Северном Кипре
QneMaype
lasix medicines lasix cad adjusting lasix
Jnnadoms
synthroid pronunciation synthroid medicinenet administering synthroid
AefGlync
pregabalin withdrawal reviews what does lyrica do to you lyrica dose
Wrnadoms
valtrex itchy valtrex 200mg valtrex site
Ethanher
Виллы, Таунхаусы, Дуплексы на Северном Кипре
QubMaype
trazodone haldol trazodone white trazodone venezuela
TzqMaype
furosemide werkingsduur lasix shape lasix msds
Jnnadoms
synthroid sudafed warfarin synthroid aspirin synthroid
AefGlync
pregabalin good rx how much lyrica to get high pregabalin for seizures
Wrnadoms
bactrim valtrex malarone valtrex valtrex hepatitis
Tzqclems
metformin liraglutide metformin nierenversagen metformin gynaecology
JnnOpilt
bnf lisinopril lisinopril laryngitis lisinopril vs avalide
MagoNeeLekzv
provigil drug provigil pill provigil pill
EnrHycle
tenormin and aspirin tenormin safe dose atenolol adderall
Henrykat
Комнаты на Северном Кипре
Aefpoolf
trazodone pharmacodynamics trazodone barr trazodone agoraphobia
QubWaity
tamoxifen dabur jual nolvadex nolvadex guys
WrnBoype
nejm atorvastatin lipitor obat atorvastatin potenz
BrianAmums
Коммерческая недвижимость на Северном Кипре
EnrHycle
atenolol pheochromocytoma atenolol concentration atenolol exhaustion
Aefpoolf
trazodone als bupropion trazodone trazodone tolerance
JnnOpilt
lisinopril mental health lisinopril swallowing sinopren lisinopril
Tzqclems
metformin hwz metformin cream metformin koloskopie
Tzqfclems
lipitor sortis lipitor erectile ap0-atorvastatin
EdfHycle
synthroid mania organic synthroid synthroid overdoses
WarrenSAh
Земельные участки на Северном Кипре
WrfvBoype
pregabalin 50mg pregabalin 25 mg price pregabalin 150 mg cost
QvaWaity
neurontin and citalopram neurontin and hypertension gabapentin powder
Tzqfclems
atorvastatin antibiotics teva-atorvastatin mГ©dicament lipitor haitat
Ferne
I’ll right away snatch your rsss ass I can’t
find your email subscription hyperlink or newsletter service.
Do you’ve any? Please permit me understand in order
that I may just subscribe. Thanks.
Also visit my web site exam material (Ferne)
Aespoolf
metronidazole pgd flagyl lepistes flagyl apresentacoes
JwnOpilt
valtrex confusion valacyclovir dialysis valtrex zinc
SagoNeeLekqo
ivermectin dog dosage pyrantel ivermectin stromectol 3 mg tablet
EdfHycle
synthroid doping synthroid hipotiroidismo synthroid medscape
WrfvBoype
pregabalin 100mg capsules best dose of pregabalin for anxiety side effects of lyrica
QvaWaity
occipital neuralgia neurontin gabapentin greyhound neurontin causes neuropathy
Jamesfoems
Земельные участки на Северном Кипре
StephenCOn
Гаражи и машиноместа на Северном Кипре
then stake it in Syrup Pools to earn more tokens!
I think the admin of this site is truly working hard in favor of his website, for the reason that here every data is quality based stuff.
then stake it in Syrup Pools to earn more tokens! Win millions in prizes
WilliamTaine
Продажа апартаментов на Северном Кипре
XagoNeeLekbr
clomid prescription canada where can i get clomid uk clomid 100g
Howardbok
Аренда квартиры на Северном Кипре
Tnuuclems
academic essay writer college essay sample essay word
JnwOpilt
comparative essay example write my essay for cheap the best way to ensure parallel construction in your essay is to use similar
EdfsHycle
essay proposal example college admission essay help character analysis essay example
Ahrspoolf
thesis statement in an essay sat essay tips respond essay
WnsBoype
essay writer software citations in an essay essay title page
QnwWaity
essay writing website essay help online essay writers
takipçi satın al ucuz
En iyi takipç isitesinden takipçi satın al ucuza ;https://rebrand.ly/2d8aee
Tcctclems
best college essay service editing essay services college essay help nyc
JamesAmilm
Продажа дома на Северном Кипре
YagoNeeLekpg
clomid no prescription where can i purchase clomid over the counter how can i get clomid
EddHycle
auto essay writer cyber bullying essay buy cheap essays
WwnBoype
where to buy college research papers writing a research paper in apa format professional paper writing services
Aujnpoolf
write essay essay writing service canada bullying essay
QjfWaity
academic essay help what is a claim in an essay custom essay writing canada
Williamjorie
Продажа и Аренда Недвижимости на Северном Кипре
Thwcclems
decorative writing paper printable horizontal writing paper custom written paper
JzzqOpilt
which of the following are best practices when writing the first draft of a research paper? writing a college paper help with writing a paper for college
EoopHycle
printing writing paper writing paper for kindergarten imagine you are writing a research paper on social networking sites which of the following thesis
WxedBoype
chinese writing paper lined paper for second grade writing write my paper for money
QhrWaity
primary writing paper with picture box free writing paper to print writing paper 1st grade
Aybvpoolf
online paper writing service paper writing sites printable writing paper with border
Tnssclems
thesis paper writing service designed paper for writing printable free writing paper with picture box pdf
JntjOpilt
literature review for dissertation dissertation proposal digital dissertations
SagoNeeLekab
ivermectin tractor supply pyrantel ivermectin ivermectin side effects in dogs
WikkBoype
best dissertation services cornell dissertation how many pages should a dissertation be
Adnvpoolf
rackham dissertation deadlines dissertation proposal writing service dissertation examples in education
Tnssclems
do my papers bee writing paper professional paper writer
JntjOpilt
higher education dissertation topics how long is a dissertation for phd dissertation literature review
Tnssclems
college paper writers lined writing paper templates buying papers online
JntjOpilt
citing a dissertation mla doctoral dissertation writing help acls dissertation completion fellowship
EncxHycle
dissertation help reviews dissertation topic how to ask someone to be on your dissertation committee
Adnvpoolf
dissertation reviewer how long to write dissertation e thesis and dissertation
WikkBoype
help writing dissertation proposal dissertation topics writing your dissertation in 15 minutes a day
EagoNeeLekyj
stromectol ivermectin for dogs ivermectin toxicity in dogs
Tujclems
admission essay writing services cheap essay service custom essays no plagiarism
JrjbOpilt
assignment essay help custom essay writing reviews write my essay today
EybvHycle
help me write an essay buy essays for college college admission essay help
Aybapoolf
online essay writing help help essay 123 help for essay writing
WuqBoype
best essay writers online recommended essay writing service will someone write my essay for me
Tujclems
top 10 essay writers essay writing service toronto essay helper app
JrjbOpilt
top rated essay writing services websites for essay writing essay introduction help
EybvHycle
essay helper law essay writing service custom essays online
Aybapoolf
can someone write my essay online essay writing help essay help websites
WuqBoype
essay revision help online what are good essay writing services help write my essay
EagoNeeLekba
stromectol over the counter ivermectin pour on oral ivermectin for rosacea
QnehWaity
personal essay help best essay for you cheap essay writing service usa
JamesAmilm
Продажа коммерческой недвижимости на Северном Кипре
Mauriceevoli
Аренда коммерческой недвижимости на Северном Кипре
MauriceowelD
Продажа земельных участков на Северном Кипре
JamesVot
Апартаменты на Северном Кипре
JesusIsomy
Продажа Гаражей и машиноместа на Северном Кипре
RichardSof
Аренда Гаражей и машиноместа на Северном Кипре
CharlesNex
Апартаменты в Искеле (Трикомо)