//========================================================================= public void Render(Transform icamtrans) { int index; bool flag; string[] finalKeywords; EchoPFXEffect epe; EchoPFXEffect epeNext; EchoPFXOption epo; EchoPFXRenderMaterial erm; EchoPFXRenderTexture.Active(_renTex, 0, passCount); GL.PushMatrix(); GL.LoadOrtho(); for (int pass = 0; pass < passCount; pass++) { erm = _echoRenderMaterial[pass]; erm.ResetAllFrameCounts(); Array.Copy(_finalKeyFlags[pass], _prevKeyFlags[pass], _finalKeyFlags[pass].Length); Array.Clear(_finalKeyFlags[pass], 0, _finalKeyFlags[pass].Length); for (epe = epeEchoList.GetFirstActive(); epe != null; epe = epeNext) { epeNext = epeEchoList.GetNext(epe); if (epe.passActive[pass]) { for (index = 0; index < epe.passOpt[pass].Count; index++) { epo = epe.passOpt[pass][index]; switch (epo.Process()) { case -1: epe.optionsOff++; if (epe.optionsOff >= epe.optionsTotal) { epeEchoList.Deactivate(epe); } break; case 0: break; default: // should index into order of passopts _finalKeyFlags[pass][epo.passOrder] = _finalKeyFlags[pass][epo.passOrder] | 1; switch (epo.optType) { case ECHOPFXOPTION.GREYSCALE: erm.SetFloat(ECHOPROP.GREYFADE, epo.fadeCur); break; case ECHOPFXOPTION.INVERSE: erm.SetFloat(ECHOPROP.INVERSEFADE, epo.fadeCur); break; case ECHOPFXOPTION.COLOR: erm.SetVector(ECHOPROP.COLOR, epo.rgba * epo.rgbaMultiply); erm.SetFloat(ECHOPROP.COLORFADE, epo.fadeCur); break; case ECHOPFXOPTION.ADD: erm.SetVector(ECHOPROP.ADD, epo.rgba * epo.rgbaMultiply); erm.SetFloat(ECHOPROP.ADDFADE, epo.fadeCur); break; case ECHOPFXOPTION.MULTIPLY: erm.SetVector(ECHOPROP.MULT, epo.rgba * epo.rgbaMultiply); erm.SetFloat(ECHOPROP.MULTFADE, epo.fadeCur); break; case ECHOPFXOPTION.NOISE: erm.SetFloat(ECHOPROP.NOISEFADE, epo.fadeCur); _echoRenderMaterial[pass].mat.SetTexture("_NoiseTex", epo.tex); break; case ECHOPFXOPTION.DISTORTION: erm.SetVector(ECHOPROP.DISTPARAMSH, new Vector4(epo.distSpeedH, epo.distAmountH, (1.0f / (float)meshCellWidth) * epo.distStrengthH, epo.fadeCur)); erm.SetVector(ECHOPROP.DISTPARAMSV, new Vector4(epo.distSpeedV, epo.distAmountV, (1.0f / (float)meshCellHeight) * epo.distStrengthV, epo.fadeCur)); break; case ECHOPFXOPTION.SHOCKWAVE: erm.SetVector(ECHOPROP.SHOCKPARAMS, new Vector4(epo.shockCenterX, epo.shockCenterY, epo.shockDistance, epo.shockSize)); erm.SetFloat(ECHOPROP.SHOCKFADE, epo.fadeCur); break; case ECHOPFXOPTION.SCANLINES: erm.SetFloat(ECHOPROP.SCANLINEFADE, epo.fadeCur); if (epo.linesAmountDivideH) { erm.SetFloat(ECHOPROP.SCANLINECOUNTH, (float)Screen.height / (float)epo.linesAmountH); } else { erm.SetFloat(ECHOPROP.SCANLINECOUNTH, epo.linesAmountH); } erm.SetFloat(ECHOPROP.SCANLINESCROLLH, epo.linesScrollH); if (epo.linesAmountDivideV) { erm.SetFloat(ECHOPROP.SCANLINECOUNTV, (float)Screen.width / (float)epo.linesAmountV); } else { erm.SetFloat(ECHOPROP.SCANLINECOUNTV, epo.linesAmountV); } erm.SetFloat(ECHOPROP.SCANLINESCROLLV, epo.linesScrollV); break; case ECHOPFXOPTION.LUMRAMP: erm.SetTexture(ECHOPROP.RAMP_TEX, epo.tex); erm.SetFloat(ECHOPROP.RAMPFADE, epo.fadeCur); break; case ECHOPFXOPTION.COLOR_CORRECT: erm.SetTexture(ECHOPROP.CORRECT_TEX, epo.tex); erm.SetFloat(ECHOPROP.CORRECTFADE, epo.fadeCur); break; case ECHOPFXOPTION.OVERLAY_NORMAL: erm.SetTexture(ECHOPROP.OVERLAY_TEX, epo.tex); erm.SetVector(ECHOPROP.OVERLAY_ST, epo.overlayST); erm.SetFloat(ECHOPROP.OVERLAY_FADE, epo.fadeCur); break; case ECHOPFXOPTION.OVERLAY_SCREEN: erm.SetTexture(ECHOPROP.OVERLAYSCR_TEX, epo.tex); erm.SetFloat(ECHOPROP.OVERLAYSCR_FADE, epo.fadeCur); erm.SetVector(ECHOPROP.OVERLAYSCR_ST, epo.overlayST); break; case ECHOPFXOPTION.OVERLAY_ADD: erm.SetTexture(ECHOPROP.OVERLAYADD_TEX, epo.tex); erm.SetFloat(ECHOPROP.OVERLAYADD_FADE, epo.fadeCur); erm.SetVector(ECHOPROP.OVERLAYADD_ST, epo.overlayST); break; case ECHOPFXOPTION.OVERLAY_SUBTRACT: erm.SetTexture(ECHOPROP.OVERLAYSUB_TEX, epo.tex); erm.SetFloat(ECHOPROP.OVERLAYSUB_FADE, epo.fadeCur); erm.SetVector(ECHOPROP.OVERLAYSUB_ST, epo.overlayST); break; case ECHOPFXOPTION.OVERLAY_MULTIPLY: erm.SetTexture(ECHOPROP.OVERLAYMUL_TEX, epo.tex); erm.SetFloat(ECHOPROP.OVERLAYMUL_FADE, epo.fadeCur); erm.SetVector(ECHOPROP.OVERLAYMUL_ST, epo.overlayST); break; case ECHOPFXOPTION.OVERLAY_OVERLAY: erm.SetTexture(ECHOPROP.OVERLAYOVR_TEX, epo.tex); erm.SetFloat(ECHOPROP.OVERLAYOVR_FADE, epo.fadeCur); erm.SetVector(ECHOPROP.OVERLAYOVR_ST, epo.overlayST); break; case ECHOPFXOPTION.CUSTOM_FRAG_1: if (epo.tex != null) { erm.SetTexture(ECHOPROP.CUSTOM_FRAG_1_TEX, epo.tex); erm.SetVector(ECHOPROP.CUSTOM_FRAG_1_ST, epo.overlayST); } erm.SetFloat(ECHOPROP.CUSTOM_FRAG_1_FADE, epo.fadeCur); erm.SetVector(ECHOPROP.CUSTOM_FRAG_1_ARGS, epo.customArgs); erm.SetVector(ECHOPROP.CUSTOM_FRAG_1_COLOR, epo.rgba * epo.rgbaMultiply); break; case ECHOPFXOPTION.CUSTOM_FRAG_2: if (epo.tex != null) { erm.SetTexture(ECHOPROP.CUSTOM_FRAG_2_TEX, epo.tex); erm.SetVector(ECHOPROP.CUSTOM_FRAG_2_ST, epo.overlayST); } erm.SetFloat(ECHOPROP.CUSTOM_FRAG_2_FADE, epo.fadeCur); erm.SetVector(ECHOPROP.CUSTOM_FRAG_2_ARGS, epo.customArgs); erm.SetVector(ECHOPROP.CUSTOM_FRAG_2_COLOR, epo.rgba * epo.rgbaMultiply); break; case ECHOPFXOPTION.CUSTOM_FRAG_3: if (epo.tex != null) { erm.SetTexture(ECHOPROP.CUSTOM_FRAG_3_TEX, epo.tex); erm.SetVector(ECHOPROP.CUSTOM_FRAG_3_ST, epo.overlayST); } erm.SetFloat(ECHOPROP.CUSTOM_FRAG_3_FADE, epo.fadeCur); erm.SetVector(ECHOPROP.CUSTOM_FRAG_3_ARGS, epo.customArgs); erm.SetVector(ECHOPROP.CUSTOM_FRAG_3_COLOR, epo.rgba * epo.rgbaMultiply); break; case ECHOPFXOPTION.CUSTOM_FRAG_4: if (epo.tex != null) { erm.SetTexture(ECHOPROP.CUSTOM_FRAG_4_TEX, epo.tex); erm.SetVector(ECHOPROP.CUSTOM_FRAG_4_ST, epo.overlayST); } erm.SetFloat(ECHOPROP.CUSTOM_FRAG_4_FADE, epo.fadeCur); erm.SetVector(ECHOPROP.CUSTOM_FRAG_4_ARGS, epo.customArgs); erm.SetVector(ECHOPROP.CUSTOM_FRAG_4_COLOR, epo.rgba * epo.rgbaMultiply); break; } break; } } } } erm.SubmitShaderProperties(); finalKeywords = _finalKeywords[pass]; flag = false; if (pass == 0) { for (index = 0; index < possibleOpts1.Count; index++) { finalKeywords[index] = _keywords[(int)possibleOpts1[index].type, _finalKeyFlags[pass][index]]; if (_finalKeyFlags[pass][index] != _prevKeyFlags[pass][index]) { flag = true; } } } else { for (index = 0; index < possibleOpts2.Count; index++) { finalKeywords[index] = _keywords[(int)possibleOpts2[index].type, _finalKeyFlags[pass][index]]; if (_finalKeyFlags[pass][index] != _prevKeyFlags[pass][index]) { flag = true; } } } if (flag) { _echoRenderMaterial[pass].mat.shaderKeywords = finalKeywords; } #if UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 _echoRenderMaterial[pass].mat.SetTexture("_echoScreen", _renTex[pass].texture); #else _echoRenderMaterial[pass].mat.SetTexture(_mainTexID, _renTex[pass].texture); #endif _echoRenderMaterial[pass].mat.SetPass(0); Graphics.DrawMeshNow(_mesh, icamtrans.position, icamtrans.rotation); if (passCount > 1) { EchoPFXRenderTexture.Active(_renTex, 1, passCount); } } GL.PopMatrix(); _renTex[0].DiscardContents(); if (passCount > 1) { _renTex[1].DiscardContents(); } }
//========================================================================= public static EchoPFXAreaEffect GetFirst() { return(objs.GetFirstActive()); }