/// <inheritdoc/> public override unsafe void Prepare(RenderDrawContext context) { foreach (var renderNode in ((RootEffectRenderFeature)RootRenderFeature).RenderNodes) { var perDrawLayout = renderNode.RenderEffect.Reflection.PerDrawLayout; if (perDrawLayout == null) { continue; } var mappedCB = renderNode.Resources.ConstantBuffer.Data; var renderMesh = (RenderMesh)renderNode.RenderObject; var parameters = renderMesh.Mesh.Parameters; // Upload fog parameters var fogOffset = perDrawLayout.GetConstantBufferOffset(fog); if (fogOffset != -1) { var perDraw = (PerDrawFog *)((byte *)mappedCB + fogOffset); * perDraw = new PerDrawFog { FogColor = Color.FromAbgr(0xFF7D02FF), fogNearPlaneZ = 80.0f, fogFarPlaneZ = 250.0f, fogNearPlaneY = 0.0f, fogFarPlaneY = 120.0f }; } // Upload world bending parameters var bendOffset = perDrawLayout.GetConstantBufferOffset(bend); if (bendOffset != -1) { var perDraw = (float *)((byte *)mappedCB + bendOffset); * perDraw++ = parameters.Get(TransformationBendWorldKeys.DeformFactorX); * perDraw = parameters.Get(TransformationBendWorldKeys.DeformFactorX); } // Updload uv change parameters var uvChangeOffset = perDrawLayout.GetConstantBufferOffset(uvChange); if (uvChangeOffset != -1) { var perDraw = (Vector4 *)((byte *)mappedCB + uvChangeOffset); * perDraw = parameters.Get(TransformationTextureUVKeys.TextureRegion); } } }
/// <inheritdoc/> public unsafe override void Prepare(RenderDrawContext context) { foreach (var renderNode in ((RootEffectRenderFeature)RootRenderFeature).RenderNodes) { var perDrawLayout = renderNode.RenderEffect.Reflection.PerDrawLayout; if (perDrawLayout == null) continue; var mappedCB = renderNode.Resources.ConstantBuffer.Data; var renderMesh = (RenderMesh)renderNode.RenderObject; var parameters = renderMesh.Mesh.Parameters; // Upload fog parameters var fogOffset = perDrawLayout.GetConstantBufferOffset(fog); if (fogOffset != -1) { var perDraw = (PerDrawFog*)((byte*)mappedCB + fogOffset); *perDraw = new PerDrawFog { FogColor = Color.FromAbgr(0xFF7D02FF), fogNearPlaneZ = 80.0f, fogFarPlaneZ = 250.0f, fogNearPlaneY = 0.0f, fogFarPlaneY = 120.0f }; } // Upload world bending parameters var bendOffset = perDrawLayout.GetConstantBufferOffset(bend); if (bendOffset != -1) { var perDraw = (float*)((byte*)mappedCB + bendOffset); *perDraw++ = parameters.Get(TransformationBendWorldKeys.DeformFactorX); *perDraw = parameters.Get(TransformationBendWorldKeys.DeformFactorX); } // Updload uv change parameters var uvChangeOffset = perDrawLayout.GetConstantBufferOffset(uvChange); if (uvChangeOffset != -1) { var perDraw = (Vector4*)((byte*)mappedCB + uvChangeOffset); *perDraw = parameters.Get(TransformationTextureUVKeys.TextureRegion); } } }