public void End() { this.mesh.Clear(); Int32[] array = new Int32[this.ibOffset]; Buffer.BlockCopy(this.ibIndex, 0, array, 0, this.ibOffset << 2); this.mesh.vertices = this.vbPos; this.mesh.colors32 = this.vbCol; if (SFXKey.IsTexture(this.key)) { this.mesh.uv = this.vbTex; } else { this.mesh.uv = null; } if (SFX.isDebugLine) { this.mesh.SetIndices(array, MeshTopology.Lines, 0); } else if (SFXKey.isLinePolygon(this.key)) { this.mesh.SetIndices(array, MeshTopology.Lines, 0); } else { this.mesh.triangles = array; } }
public override void Render(Int32 index) { this.material.shader = SFXMesh.shaders[(Int32)((UIntPtr)this.shaderIndex)]; if (SFXKey.IsTexture(this.key)) { this.material.mainTexture = this.GetTexture(); if (this.material.mainTexture == (UnityEngine.Object)null) { return; } UInt32 fillter = SFXKey.GetFillter(this.key); if (fillter != 33554432u) { if (fillter != 67108864u) { this.material.mainTexture.filterMode = (FilterMode)((!SFX.isDebugFillter) ? FilterMode.Point : FilterMode.Bilinear); } else { this.material.mainTexture.filterMode = FilterMode.Bilinear; } } else { this.material.mainTexture.filterMode = FilterMode.Point; } this.material.mainTexture.wrapMode = TextureWrapMode.Clamp; this.material.SetVector("_TexParam", this.constTexParam); } this.material.SetColor("_Color", SFXMesh.colorData[SFX.colIntensity]); this.material.SetFloat("_Threshold", (SFX.colThreshold != 0) ? 0.05f : 0.0295f); this.material.SetPass(0); Graphics.DrawMeshNow(this.mesh, Matrix4x4.identity); }
private unsafe static void TILE(PSX_LIBGPU.TILE *tag, Int32 w, Int32 h) { UInt32 currentABR = SFXKey.GetCurrentABR(tag->code); SFXMesh mesh = SFXRender.GetMesh(currentABR, tag->code); mesh.TILE(tag, w, h); }
public static PSXTexture GetTexture(Int32 TP, Int32 TY, Int32 TX, Int32 clutY, Int32 clutX) { if (TP == 2) { clutY = (clutX = 0); } UInt32 num = SFXKey.GenerateKey(TP, TX, TY, clutX, clutY); for (Int32 i = 0; i < PSXTextureMgr.SST_MAX_TEXTURE; i++) { if (PSXTextureMgr.list[i].key == num && PSXTextureMgr.list[i].texture) { return(PSXTextureMgr.list[i]); } } for (Int32 j = 0; j < PSXTextureMgr.SST_MAX_TEXTURE; j++) { if (PSXTextureMgr.list[j].key == PSXTexture.EMPTY_KEY) { PSXTextureMgr.list[j].key = num; PSXTextureMgr.list[j].GenTexture(TP, TY, TX, clutY, clutX, 256, 256, FilterMode.Point, TextureWrapMode.Clamp); if (SFX.isDebugPng) { Byte[] bytes = PSXTextureMgr.list[j].texture.EncodeToPNG(); String path = "Temp/texture" + num.ToString("X8") + ".png"; File.WriteAllBytes(path, bytes); } return(PSXTextureMgr.list[j]); } } global::Debug.Assert(false); return((PSXTexture)null); }
private unsafe static void SPRT(PSX_LIBGPU.SPRT *tag, Int32 w, Int32 h) { UInt32 meshKey = SFXKey.GetCurrentABRTex(tag->code, tag->clut) | 67108864u; SFXMesh mesh = SFXRender.GetMesh(meshKey, tag->code); mesh.SPRT(tag, w, h); }
private unsafe static void PolyBGT4(PSX_LIBGPU.POLY_GT4 *tag) { UInt32 meshKey = SFXKey.GetABRTex(tag->code, tag->clut, tag->tpage) | 67108864u | 536870912u; SFXMesh mesh = SFXRender.GetMesh(meshKey, tag->code); mesh.PolyBGT4(tag); }
private unsafe static void PolyFT4(PSX_LIBGPU.POLY_FT4 *tag, UInt32 fillter = 0u) { UInt32 meshKey = SFXKey.GetABRTex(tag->code, tag->clut, tag->tpage) | fillter; SFXMesh mesh = SFXRender.GetMesh(meshKey, tag->code); mesh.PolyFT4(tag); }
private unsafe static void PolyGT4(PSX_LIBGPU.POLY_GT4 *tag) { UInt32 abrtex = SFXKey.GetABRTex(tag->code, tag->clut, tag->tpage); SFXMesh mesh = SFXRender.GetMesh(abrtex, tag->code); mesh.PolyGT4(tag); }
private Texture GetTexture() { UInt32 textureKey = SFXKey.GetTextureKey(this.key); if (SFXKey.GetTextureMode(this.key) != 2u) { if (SFX.currentEffectID == 435) { Single[] array = new Single[2]; Texture texture = PSXTextureMgr.GetTexture435(textureKey, array); if (texture != (UnityEngine.Object)null) { this.constTexParam.y = array[0]; this.constTexParam.w = array[1]; return(texture); } } return(PSXTextureMgr.GetTexture(this.key).texture); } if (SFXKey.IsBlurTexture(textureKey)) { if ((this.key & 536870912u) != 0u) { this.constTexParam.w = 240f; } else { this.constTexParam.y = -240f; this.constTexParam.w = -240f; } this.constTexParam.z = 320f; return(PSXTextureMgr.blurTexture); } if ((this.key & 2031616u) == PSXTextureMgr.bgKey) { return(PSXTextureMgr.bgTexture); } if (PSXTextureMgr.isCreateGenTexture) { this.constTexParam.x = (Single)((UInt64)SFXKey.GetPositionX(this.key) - (UInt64)((Int64)PSXTextureMgr.GEN_TEXTURE_X)) + 0.5f; this.constTexParam.z = (Single)PSXTextureMgr.GEN_TEXTURE_W; this.constTexParam.w = (Single)PSXTextureMgr.GEN_TEXTURE_H; return(PSXTextureMgr.genTexture); } if (SFX.currentEffectID == 274 && textureKey == 5767167u) { this.constTexParam.x = 176f; this.constTexParam.y = 0f; this.constTexParam.z = 480f; this.constTexParam.w = 360f; return(PSXTextureMgr.blurTexture); } return(PSXTextureMgr.GetTexture(this.key).texture); }
public static void SpEff435() { PSXTextureMgr.eff435Tex = new Texture[9]; PSXTextureMgr.eff435Key = new UInt32[9]; GameObject btlBGPtr = FF9StateSystem.Battle.FF9Battle.map.btlBGPtr; MeshRenderer[] componentsInChildren = btlBGPtr.GetComponentsInChildren <MeshRenderer>(); for (Int32 i = 0; i < (Int32)componentsInChildren.Length; i++) { Material[] materials = componentsInChildren[i].materials; for (Int32 j = 0; j < (Int32)materials.Length; j++) { if (materials[j].name == "135_tex9 (Instance)") { PSXTextureMgr.eff435Tex[0] = materials[j].mainTexture; PSXTextureMgr.eff435Key[0] = SFXKey.GenerateKey(1, 10, 0, 0, 224); } if (materials[j].name == "135_tex10 (Instance)") { PSXTextureMgr.eff435Tex[1] = materials[j].mainTexture; PSXTextureMgr.eff435Key[1] = SFXKey.GenerateKey(1, 12, 0, 0, 225); } if (materials[j].name == "135_tex0_2 (Instance)") { PSXTextureMgr.eff435Tex[2] = materials[j].mainTexture; PSXTextureMgr.eff435Key[2] = SFXKey.GenerateKey(1, 14, 0, 0, 228); } } } PSXTextureMgr.eff435Tex[3] = Resources.Load <Texture2D>("SpecialEffects/geo_mon_b3_199_02"); PSXTextureMgr.eff435Key[3] = SFXKey.GenerateKey(1, 0, 0, 0, 0); PSXTextureMgr.eff435Tex[4] = Resources.Load <Texture2D>("SpecialEffects/geo_mon_b3_199_00"); PSXTextureMgr.eff435Key[4] = SFXKey.GenerateKey(1, 1, 0, 0, 0); PSXTextureMgr.eff435Tex[5] = Resources.Load <Texture2D>("SpecialEffects/geo_mon_b3_199_01"); PSXTextureMgr.eff435Key[5] = SFXKey.GenerateKey(1, 2, 0, 0, 0); PSXTextureMgr.eff435Tex[6] = PSXTextureMgr.eff435Tex[5]; PSXTextureMgr.eff435Key[6] = SFXKey.GenerateKey(1, 3, 0, 0, 0); PSXTextureMgr.eff435Tex[7] = PSXTextureMgr.eff435Tex[4]; PSXTextureMgr.eff435Key[7] = SFXKey.GenerateKey(1, 4, 0, 0, 0); PSXTextureMgr.eff435Tex[8] = PSXTextureMgr.eff435Tex[4]; PSXTextureMgr.eff435Key[8] = SFXKey.GenerateKey(1, 5, 0, 0, 0); }
public void Setup(UInt32 meshKey, Byte code) { this.key = meshKey; Boolean flag = SFXKey.IsTexture(meshKey); this.shaderIndex = (UInt32)((!flag) ? 3u : 0u); if ((code & 2) != 0) { this.alpha = SFXMesh.abrAlphaData[(Int32)((UIntPtr)SFXKey.tmpABR)]; this.shaderIndex += SFXKey.GetBlendMode(meshKey); } else { this.alpha = 128; } if (flag) { if (SFX.pixelOffset == 0) { this.constTexParam.x = SFXMesh.HALF_PIXEL; this.constTexParam.y = SFXMesh.HALF_PIXEL; } else if (SFX.pixelOffset == 1) { this.constTexParam.x = SFXMesh.INV_HALF_PIXEL; this.constTexParam.y = SFXMesh.INV_HALF_PIXEL; } else { this.constTexParam.x = SFXMesh.HALF_PIXEL; this.constTexParam.y = SFXMesh.INV_HALF_PIXEL; } this.constTexParam.z = 256f; this.constTexParam.w = 256f; } }
public unsafe static void Add(PSX_LIBGPU.P_TAG *tag) { Int32 num = (Int32)(tag->code & 252); if (num == 32) { UInt32 meshKey = SFXKey.GetCurrentABR(tag->code); SFXMesh mesh = SFXRender.GetMesh(meshKey, tag->code); mesh.PolyF3((PSX_LIBGPU.POLY_F3 *)tag); return; } if (num == 36) { if (SFX.currentEffectID != 149) { SFXRender.PolyFT3((PSX_LIBGPU.POLY_FT3 *)tag); } return; } if (num == 40) { UInt32 meshKey = SFXKey.GetCurrentABR(tag->code); SFXMesh mesh = SFXRender.GetMesh(meshKey, tag->code); mesh.PolyF4((PSX_LIBGPU.POLY_F4 *)tag); return; } if (num == 44) { SFXRender.PolyFT4((PSX_LIBGPU.POLY_FT4 *)tag, 0u); return; } if (num == 48) { UInt32 meshKey = SFXKey.GetCurrentABR(tag->code); SFXMesh mesh = SFXRender.GetMesh(meshKey, tag->code); mesh.PolyG3((PSX_LIBGPU.POLY_G3 *)tag); return; } if (num == 52) { SFXRender.PolyGT3((PSX_LIBGPU.POLY_GT3 *)tag); return; } if (num == 56) { UInt32 meshKey = SFXKey.GetCurrentABR(tag->code); SFXMesh mesh = SFXRender.GetMesh(meshKey, tag->code); mesh.PolyG4((PSX_LIBGPU.POLY_G4 *)tag); return; } if (num == 60) { if (SFX.currentEffectID != 126 && SFX.currentEffectID != 149 && SFX.currentEffectID != 395) { SFXRender.PolyGT4((PSX_LIBGPU.POLY_GT4 *)tag); } return; } if (num == 64) { UInt32 meshKey = SFXKey.GetCurrentABR(tag->code) | 134217728u; SFXMesh mesh = SFXRender.GetMesh(meshKey, tag->code); mesh.LineF2((PSX_LIBGPU.LINE_F2 *)tag); return; } if (num == 68) { SFXRender.PolyBFT4((PSX_LIBGPU.POLY_FT4 *)tag); return; } if (num == 72) { SFXRender.PolyBGT4((PSX_LIBGPU.POLY_GT4 *)tag); return; } if (num == 76) { SFXRender.PolyFT4((PSX_LIBGPU.POLY_FT4 *)tag, 33554432u); return; } if (num == 80) { UInt32 meshKey = SFXKey.GetCurrentABR(tag->code) | 134217728u; SFXMesh mesh = SFXRender.GetMesh(meshKey, tag->code); mesh.LineG2((PSX_LIBGPU.LINE_G2 *)tag); return; } if (num == 96) { SFXRender.TILE((PSX_LIBGPU.TILE *)tag, (Int32)((PSX_LIBGPU.TILE *)tag)->w, (Int32)((PSX_LIBGPU.TILE *)tag)->h); return; } if (num == 100) { SFXRender.SPRT((PSX_LIBGPU.SPRT *)tag, (Int32)((PSX_LIBGPU.SPRT *)tag)->w, (Int32)((PSX_LIBGPU.SPRT *)tag)->h); return; } if (num == 104) { SFXRender.TILE((PSX_LIBGPU.TILE *)tag, 1, 1); return; } if (num == 112) { SFXRender.TILE((PSX_LIBGPU.TILE *)tag, 8, 8); return; } if (num == 116) { SFXRender.SPRT((PSX_LIBGPU.SPRT *)tag, 8, 8); return; } if (num == 120) { SFXRender.TILE((PSX_LIBGPU.TILE *)tag, 16, 16); return; } if (num != 124) { switch (tag->code) { case 225: if (tag->getLen() == 1u) { SFXRender.DR_TPAGE((PSX_LIBGPU.DR_TPAGE *)tag); } else { SFXRender.DR_TPAGE((PSX_LIBGPU.DR_TPAGE *)tag); } break; case 228: SFXRender.DR_AREA((PSX_LIBGPU.DR_AREA *)tag); break; case 229: SFXRender.DR_OFFSET((PSX_LIBGPU.DR_OFFSET *)tag); break; case 231: if (SFX.currentEffectID != 395 && SFX.currentEffectID != 126) { SFXRender.DR_MOVE((PSX_LIBGPU.DR_MOVE *)tag); } break; } return; } SFXRender.SPRT((PSX_LIBGPU.SPRT *)tag, 16, 16); }
private static SFXMesh GetMesh(UInt32 meshKey, Byte code) { UInt32 blendMode = SFXKey.GetBlendMode(meshKey); List <SFXMesh> list; if (!SFXKey.isLinePolygon(meshKey)) { if (SFXKey.IsTexture(meshKey)) { UInt32 num = blendMode; if (num != 0u) { if (num != 1u) { list = SFXRender.meshTexSub; } else { UInt32 fillter = SFXKey.GetFillter(meshKey); if (fillter != 33554432u) { if (fillter != 67108864u) { list = ((!SFX.isDebugFillter) ? SFXRender.meshTexAddPS : SFXRender.meshTexAddBL); } else { list = SFXRender.meshTexAddBL; } } else { list = SFXRender.meshTexAddPS; } } } else { list = SFXRender.meshTexOpa; } } else { UInt32 num = blendMode; if (num != 0u) { if (num != 1u) { list = SFXRender.meshSub; } else { list = SFXRender.meshAdd; } } else { list = SFXRender.meshOpa; } } } else { UInt32 num = blendMode; if (num != 0u) { if (num != 1u) { list = SFXRender.meshLineSub; } else { list = SFXRender.meshLineAdd; } } else { list = SFXRender.meshLineOpa; } } foreach (SFXMesh sfxmesh in list) { if (sfxmesh.GetKey() == meshKey) { return(sfxmesh); } } SFXMesh sfxmesh2 = SFXRender.meshEmpty[SFXRender.meshEmpty.Count - 1]; SFXRender.meshEmpty.RemoveAt(SFXRender.meshEmpty.Count - 1); list.Add(sfxmesh2); sfxmesh2.Setup(meshKey, code); return(sfxmesh2); }
private unsafe static void DR_TPAGE(PSX_LIBGPU.DR_TPAGE *obj) { SFXKey.SetCurrentTPage((UInt16)(obj->code[0] & 65535u)); }