Skip to content

Instantly share code, notes, and snippets.

@CoderJackLiu
Created August 21, 2023 02:57
Show Gist options
  • Save CoderJackLiu/21420f81499e50543afe254a4ea59fd6 to your computer and use it in GitHub Desktop.
Save CoderJackLiu/21420f81499e50543afe254a4ea59fd6 to your computer and use it in GitHub Desktop.
M_CameraPost
InUV.y = InUV.y - TopUVOffset;
float2 FGTexUV = InUV;
float2 BGTexUV = InUV;
float2 MGTexUV = InUV;
float2 BGGoodsTexUV = InUV;
float2 Goods1UV = InUV;
float2 Goods2UV = InUV;
float2 LabelTexUV = InUV;
float2 LogoTexUV = InUV;
float2 GoodsTex1Vec;
GoodsTex1.GetDimensions(GoodsTex1Vec.x, GoodsTex1Vec.y);
float2 GoodsTex2Vec;
GoodsTex2.GetDimensions(GoodsTex2Vec.x, GoodsTex2Vec.y);
float2 Goods1Size = float2(Goods1Param.x, Goods1Param.y);
float2 Goods2Size = float2(Goods2Param.x, Goods2Param.y);
float2 Goods1Pos = float2(Goods1Param.z, Goods1Param.w);
float2 Goods2Pos = float2(Goods2Param.z, Goods2Param.w);
float4 BGcol = Texture2DSample(BGTex, BGTexSampler, BGTexUV);
BGcol.a = 1;
float2 LogoTexVec;
LogoTex.GetDimensions(LogoTexVec.x, LogoTexVec.y);
float2 LabelTexVec;
LabelTex.GetDimensions(LabelTexVec.x, LabelTexVec.y);
float4 FGcol = float4(0, 0, 0, 0);
float4 BGGoodsCol = float4(0, 0, 0, 0);
float4 MGcol = float4(0, 0, 0, 0);
float4 Goods1Col = float4(0, 0, 0, 0);
float4 Goods2Col = float4(0, 0, 0, 0);
float4 LabelCol = float4(0, 0, 0, 0);
float4 LogoCol = float4(0, 0, 0, 0);
if (ScreenMode < 0.5f)
{
LabelTexUV = LabelTexUV * float2(1.8, 0.6);
float2 InMG_Pos = float2(PosX, PosY);
float2 StanderPosLeft = float2(229.f, 490.0f);
float2 StanderPosRight = float2(1691.f, 490.0f);
float2 FGPos = float2(960, 900.0f);
float2 BGVector = float2(1920, 1080);
float2 GoodsBGTexVec;
BGGoodsTex.GetDimensions(GoodsBGTexVec.x, GoodsBGTexVec.y);
float2 GoodsFGTexVec;
FGTex.GetDimensions(GoodsFGTexVec.x, GoodsFGTexVec.y);
// 人物的平移缩放
float testscale = 16.0 / 9.0 * 16.0 / 9.0;
float2 MGScale = float2(MGScaleX, MGScaleY);
MGTexUV = (MGTexUV - float2(0.5, 0.5)) / MGScale - InMG_Pos + float2(1, 1);
MGTexUV = MGTexUV - float2(0.5 - 0.5 / MGScaleX, 0);
MGTexUV = float2(MGTexUV.x * testscale, MGTexUV.y);
MGTexUV = MGTexUV - float2((testscale - 1) / 2 / MGScaleX, 0) + float2(0.5 - 0.5 / MGScaleX, 0);
MGcol = MGType < 0.5 ? Texture2DSample(MGTex, MGTexSampler, MGTexUV) : Texture2DSample(MGVideo, MGVideoSampler, MGTexUV);
MGcol = MGTexUV.x > 1.0 ? float4(0, 0, 0, 0) : MGcol;
MGcol = MGTexUV.x < 0.0 ? float4(0, 0, 0, 0) : MGcol;
MGcol = MGTexUV.y > 1.0 ? float4(0, 0, 0, 0) : MGcol;
MGcol = MGTexUV.y < 0.02 ? float4(0, 0, 0, 0) : MGcol;
MGcol = MGExist > 0.5 ? MGcol : float4(0, 0, 0, 0);
// 背景商品平移
BGGoodsTexUV = BGGoodsTexUV * BGVector / GoodsBGTexVec;
BGGoodsTexUV = BGGoodsTexUV - float2((BGVector.x - GoodsBGTexVec.x) / 2 / GoodsBGTexVec.x, 0);
BGGoodsCol = BGGoodsExist > 0.5 ? Texture2DSample(BGGoodsTex, BGGoodsTexSampler, BGGoodsTexUV) : float4(0, 0, 0, 0);
BGGoodsCol = BGGoodsTexUV.x > 1.0 ? float4(0, 0, 0, 0) : BGGoodsCol;
BGGoodsCol = BGGoodsTexUV.x < 0.0 ? float4(0, 0, 0, 0) : BGGoodsCol;
BGGoodsCol = BGGoodsTexUV.y > 1.0 ? float4(0, 0, 0, 0) : BGGoodsCol;
BGGoodsCol = BGGoodsTexUV.y < 0.0 ? float4(0, 0, 0, 0) : BGGoodsCol;
// 前景商品平移
FGTexUV = FGTexUV * BGVector / GoodsFGTexVec;
FGTexUV = FGTexUV - float2((BGVector.x - GoodsFGTexVec.x) / 2 / GoodsFGTexVec.x, (BGVector.y - GoodsFGTexVec.y) / GoodsFGTexVec.y);
FGcol = FGExist > 0.5 ? Texture2DSample(FGTex, FGTexSampler, FGTexUV) : float4(0, 0, 0, 0);
FGcol = FGTexUV.x > 1.0 ? float4(0, 0, 0, 0) : FGcol;
FGcol = FGTexUV.x < 0.0 ? float4(0, 0, 0, 0) : FGcol;
FGcol = FGTexUV.y > 1.0 ? float4(0, 0, 0, 0) : FGcol;
FGcol = FGTexUV.y < 0.02 ? float4(0, 0, 0, 0) : FGcol;
// 左边商品平移
float2 Goods1Scale = float2(BGVector.x / GoodsTex1Vec.x, BGVector.y / GoodsTex1Vec.y);
Goods1Pos.x = 0.5;
Goods1Pos.y = 0.5;
Goods1UV = Goods1UV * Goods1Scale + float2(0.5, 0.5) - float2(StanderPosLeft.x / GoodsTex1Vec.x, StanderPosLeft.y / GoodsTex1Vec.y);
Goods1Col = GoodsTex1Exist > 0.5 ? Texture2DSample(GoodsTex1, GoodsTex1Sampler, Goods1UV) : float4(0, 0, 0, 0);
Goods1Col = Goods1UV.x > 1.0 ? float4(0, 0, 0, 0) : Goods1Col;
Goods1Col = Goods1UV.x < 0.0 ? float4(0, 0, 0, 0) : Goods1Col;
Goods1Col = Goods1UV.y > 1.0 ? float4(0, 0, 0, 0) : Goods1Col;
Goods1Col = Goods1UV.y < 0.0 ? float4(0, 0, 0, 0) : Goods1Col;
// 右边商品平移
float2 Goods2Scale = float2(BGVector.x / GoodsTex2Vec.x, BGVector.y / GoodsTex2Vec.y);
Goods2UV = Goods2UV * Goods2Scale + float2(0.5, 0.5) - float2(StanderPosRight.x / GoodsTex2Vec.x, StanderPosRight.y / GoodsTex2Vec.y);;
Goods2Col = GoodsTex2Exist > 0.5 ? Texture2DSample(GoodsTex2, GoodsTex2Sampler, Goods2UV) : float4(0, 0, 0, 0);
Goods2Col = Goods2UV.x > 1.0 ? float4(0, 0, 0, 0) : Goods2Col;
Goods2Col = Goods2UV.x < 0.0 ? float4(0, 0, 0, 0) : Goods2Col;
Goods2Col = Goods2UV.y > 1.0 ? float4(0, 0, 0, 0) : Goods2Col;
Goods2Col = Goods2UV.y < 0.0 ? float4(0, 0, 0, 0) : Goods2Col;
LabelCol = LabelExist > 0.5f ? Texture2DSample(LabelTex, LabelTexSampler, LabelTexUV) : float4(0, 0, 0, 0);
// 裁剪超出uv的部分
LabelCol = LabelTexUV.x > 1.0 ? float4(0, 0, 0, 0) : LabelCol;
LabelCol = LabelTexUV.x < 0.0 ? float4(0, 0, 0, 0) : LabelCol;
LabelCol = LabelTexUV.y > 1.0 ? float4(0, 0, 0, 0) : LabelCol;
LabelCol = LabelTexUV.y < 0.0 ? float4(0, 0, 0, 0) : LabelCol;
// logo显示
LogoCol = LogoExist > 0.5f ? Texture2DSample(LogoTex, LogoTexSampler, LogoTexUV) : float4(0, 0, 0, 0);
// 裁剪超出uv的部分
LogoCol = LogoTexUV.x > 1.0 ? float4(0, 0, 0, 0) : LogoCol;
LogoCol = LogoTexUV.x < 0.0 ? float4(0, 0, 0, 0) : LogoCol;
LogoCol = LogoTexUV.y > 1.0 ? float4(0, 0, 0, 0) : LogoCol;
LogoCol = LogoTexUV.y < 0.0 ? float4(0, 0, 0, 0) : LogoCol;
}
else
{
float2 InMG_Pos = float2(PosX, PosY);
float2 StanderSize = float2(240.0f, 550.0f);
float2 StanderPosLeft = float2(229.f, 884.0f);
float2 StanderPosRight = float2(854.f, 884.0f);
float2 FGPos = float2(540.f, 1616.0f);
float2 FGVector ;
FGTex.GetDimensions(FGVector.x, FGVector.y);;
float2 BGVector = float2(1080, 1920);
LabelCol = LabelExist > 0.5f ? Texture2DSample(LabelTex, LabelTexSampler, LabelTexUV) : float4(0, 0, 0, 0);
// 裁剪超出uv的部分
LabelCol = LabelTexUV.x > 1.0 ? float4(0, 0, 0, 0) : LabelCol;
LabelCol = LabelTexUV.x < 0.0 ? float4(0, 0, 0, 0) : LabelCol;
LabelCol = LabelTexUV.y > 1.0 ? float4(0, 0, 0, 0) : LabelCol;
LabelCol = LabelTexUV.y < 0.0 ? float4(0, 0, 0, 0) : LabelCol;
// 人物的平移缩放
float2 MGScale = float2(MGScaleX, MGScaleY);
MGTexUV = (MGTexUV - float2(0.5, 0.5)) / MGScale - InMG_Pos + float2(1.0, 1.0);
MGcol = MGType < 0.5 ? Texture2DSample(MGTex, MGTexSampler, MGTexUV) : Texture2DSample(MGVideo, MGVideoSampler, MGTexUV);
MGcol = MGTexUV.x > 1.0 ? float4(0, 0, 0, 0) : MGcol;
MGcol = MGTexUV.x < 0.0 ? float4(0, 0, 0, 0) : MGcol;
MGcol = MGTexUV.y > 1.0 ? float4(0, 0, 0, 0) : MGcol;
MGcol = MGTexUV.y < 0.02 ? float4(0, 0, 0, 0) : MGcol;
MGcol = MGExist > 0.5 ? MGcol : float4(0, 0, 0, 0);
// 背景商品平移缩放
BGGoodsTexUV.y = FGVector.x / BGVector.x * (BGGoodsTexUV.y - 0.5) * BGVector.y / FGVector.y + 0.5 + 1.1;
BGGoodsCol = BGGoodsExist > 0.5 ? Texture2DSample(BGGoodsTex, BGGoodsTexSampler, BGGoodsTexUV) : float4(0, 0, 0, 0);
BGGoodsCol = BGGoodsTexUV.x > 1.0 ? float4(0, 0, 0, 0) : BGGoodsCol;
BGGoodsCol = BGGoodsTexUV.x < 0.0 ? float4(0, 0, 0, 0) : BGGoodsCol;
BGGoodsCol = BGGoodsTexUV.y > 1.0 ? float4(0, 0, 0, 0) : BGGoodsCol;
BGGoodsCol = BGGoodsTexUV.y < 0.0 ? float4(0, 0, 0, 0) : BGGoodsCol;
// 前景商品平移缩放
// FGTexUV.y = FGVector.x/BGVector.x * (FGTexUV.y - 0.5) * BGVector.y/FGVector.y + 0.5 - 1.22;
float2 FGTexScale = float2(FGVector.x / BGVector.x, FGVector.y / BGVector.y)*FGScale.x;
//return FGScale.x;
//float2 InFGScale= float2(FGScale.x, FGScale.x);
float2 InFG_Pos = float2(FG_Pos.x, FG_Pos.y);
//FGTexUV = ((FGTexUV - float2(0.5, 0.5)) / FGTexScale - InFG_Pos + float2(1.0, 1.0));
// FGTexUV = FGTexUV * FGTexScale + float2(0.5, 0.5) - float2(InFG_Pos.x / FGVector.x, InFG_Pos.y / FGVector.y);
//FGTexUV.y = FGTexUV.x *16.f/9.f;
//FGTexUV = FGTexUV * FGTexScale + float2(0.5, 0.5) - float2(FGPos.x / FGVector.x, FGPos.y / FGVector.y);;
FGTexUV = FGTexUV / FGTexScale + float2(0.5, 0.5) - float2(InFG_Pos.x / FGVector.x, InFG_Pos.y / FGVector.y);
//return float4(InFG_Pos.x ,InFG_Pos.y, 0, 0 );
FGcol = FGExist > 0.5 ? Texture2DSample(FGTex, FGTexSampler, FGTexUV) : float4(0, 0, 0, 0);
FGcol = FGTexUV.x > 1.0 ? float4(0, 0, 0, 0) : FGcol;
FGcol = FGTexUV.x < 0.0 ? float4(0, 0, 0, 0) : FGcol;
FGcol = FGTexUV.y > 1.0 ? float4(0, 0, 0, 0) : FGcol;
FGcol = FGTexUV.y < 0.0 ? float4(0, 0, 0, 0) : FGcol;
// 左边商品平移缩放
float2 Goods1Scale = float2(BGVector.x / GoodsTex1Vec.x, BGVector.y / GoodsTex1Vec.y);
Goods1Pos.x = 0.5;
Goods1Pos.y = 0.5;
Goods1UV = Goods1UV * Goods1Scale + float2(0.5, 0.5) - float2(StanderPosLeft.x / GoodsTex1Vec.x, StanderPosLeft.y / GoodsTex1Vec.y);
Goods1Col = GoodsTex1Exist > 0.5 ? Texture2DSample(GoodsTex1, GoodsTex1Sampler, Goods1UV) : float4(0, 0, 0, 0);
Goods1Col = Goods1UV.x > 1.0 ? float4(0, 0, 0, 0) : Goods1Col;
Goods1Col = Goods1UV.x < 0.0 ? float4(0, 0, 0, 0) : Goods1Col;
Goods1Col = Goods1UV.y > 1.0 ? float4(0, 0, 0, 0) : Goods1Col;
Goods1Col = Goods1UV.y < 0.0 ? float4(0, 0, 0, 0) : Goods1Col;
// 右边商品平移缩放
float2 Goods2Scale = float2(BGVector.x / GoodsTex2Vec.x, BGVector.y / GoodsTex2Vec.y);
Goods2UV = Goods2UV * Goods2Scale + float2(0.5, 0.5) - float2(StanderPosRight.x / GoodsTex2Vec.x, StanderPosRight.y / GoodsTex2Vec.y);;
Goods2Col = GoodsTex2Exist > 0.5 ? Texture2DSample(GoodsTex2, GoodsTex2Sampler, Goods2UV) : float4(0, 0, 0, 0);
Goods2Col = Goods2UV.x > 1.0 ? float4(0, 0, 0, 0) : Goods2Col;
Goods2Col = Goods2UV.x < 0.0 ? float4(0, 0, 0, 0) : Goods2Col;
Goods2Col = Goods2UV.y > 1.0 ? float4(0, 0, 0, 0) : Goods2Col;
Goods2Col = Goods2UV.y < 0.0 ? float4(0, 0, 0, 0) : Goods2Col;
// logo显示
LogoCol = LogoExist > 0.5f ? Texture2DSample(LogoTex, LogoTexSampler, LogoTexUV) : float4(0, 0, 0, 0);
// 裁剪超出uv的部分
LogoCol = LogoTexUV.x > 1.0 ? float4(0, 0, 0, 0) : LogoCol;
LogoCol = LogoTexUV.x < 0.0 ? float4(0, 0, 0, 0) : LogoCol;
LogoCol = LogoTexUV.y > 1.0 ? float4(0, 0, 0, 0) : LogoCol;
LogoCol = LogoTexUV.y < 0.0 ? float4(0, 0, 0, 0) : LogoCol;
}
float4 FinalColor;
BGcol = (1 - Goods1Col.a) * BGcol + Goods1Col * Goods1Col.a;
BGcol.a = 1.0;
BGcol = (1 - Goods2Col.a) * BGcol + Goods2Col * Goods2Col.a;
BGcol.a = 1.0;
BGcol = (1 - BGGoodsCol.a) * BGcol + BGGoodsCol * BGGoodsCol.a;
BGcol.a = 1.0;
BGcol = (1 - MGcol.a) * BGcol + MGcol * MGcol.a;
BGcol.a = 1.0;
//FirstColor = (1 - FGcol.a) * MGcol + FGcol * FGcol.a;
//SecondColor = (1 - FirstColor.a) * BGGoodsCol + FirstColor * FirstColor.a;
FinalColor = (1 - FGcol.a) * BGcol + FGcol * FGcol.a;
FinalColor.a = 1.0;
FinalColor = (1 - LabelCol.a) * FinalColor + LabelCol * LabelCol.a;
FinalColor = (1 - LogoCol.a) * FinalColor + LogoCol * LogoCol.a;
return FinalColor;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment