public void Apply(int pass) { PlatformRenderer.SetBlending(Blending.Alpha); PrepareShaderProgram(); program.Use(); if (skinEnabled) { program.LoadMatrixArray(program.BonesUniformId, boneTransforms, boneCount); } program.LoadMatrix(program.LightWorldViewProjUniformId, Renderer.FixupWVP(Renderer.World * ViewProjection)); }
public void Apply(int pass) { PlatformRenderer.SetBlending(Blending); PrepareShaderProgram(); program.Use(); program.LoadMatrix(program.WorldViewProjUniformId, Renderer.FixupWVP(Renderer.WorldViewProjection)); program.LoadColor(program.DiffuseColorUniformId, DiffuseColor); program.LoadMatrix(program.WorldUniformId, Renderer.World); if (processLightning && lightSource != null) { program.LoadColor(program.LightColorUniformId, lightSource.Color); program.LoadVector3(program.LightDirectionUniformId, lightSource.Position.Normalized); program.LoadFloat(program.LightIntensityUniformId, lightSource.Intensity); program.LoadFloat(program.LightStrengthUniformId, lightSource.Strength); program.LoadFloat(program.AmbientLightUniformId, lightSource.Ambient); if (recieveShadows) { var lightWVP = Renderer.World * lightSource.ViewProjection * Matrix44.CreateScale(new Vector3(1, -1, 1)); program.LoadMatrix(program.LightWorldViewProjectionUniformId, lightWVP); program.LoadColor(program.ShadowColorUniformId, lightSource.ShadowColor); PlatformRenderer.SetTexture(lightSource.ShadowMap, CommonMaterialProgram.ShadowMapTextureStage); } } if (skinEnabled) { program.LoadMatrixArray(program.BonesUniformId, boneTransforms, boneCount); } if (fogMode != FogMode.None) { program.LoadMatrix(program.WorldViewUniformId, Renderer.WorldView); program.LoadColor(program.FogColorUniformId, FogColor); if (fogMode == FogMode.Linear) { program.LoadFloat(program.FogStartUniformId, FogStart); program.LoadFloat(program.FogEndUniformId, FogEnd); } else { program.LoadFloat(program.FogDensityUniformId, FogDensity); } } if (diffuseTexture != null) { PlatformRenderer.SetTexture(diffuseTexture, CommonMaterialProgram.DiffuseTextureStage); } }
public void Apply(int pass) { PlatformRenderer.SetTexture(Texture1, 0); PlatformRenderer.SetTexture(Texture2, 1); if (PassCount == 2 && pass == 0) { PlatformRenderer.SetBlending(Blending.Alpha, PremulAlpha); } else { PlatformRenderer.SetBlending(Blending, PremulAlpha); } PlatformRenderer.SetShaderProgram(ShaderProgram); }
public void Apply(int pass) { PlatformRenderer.SetTexture(Texture, 0); PlatformRenderer.SetTexture(null, 1); if (pass == 0) { PlatformRenderer.SetBlending(Blending.LcdTextFirstPass, false); PlatformRenderer.SetShaderProgram(shaderProgramPass1); } else { PlatformRenderer.SetBlending(Blending.LcdTextSecondPass, false); PlatformRenderer.SetShaderProgram(shaderProgramPass2); } }
public void Render(Widget parentWidget) { Renderer.Flush(); var animationTime = parentWidget.AnimationTime; // Find the morph targets to interpolate in between. MorphTarget target0, target1; if (MorphTargets.Count == 1) { target0 = target1 = MorphTargets[0]; } else { while (true) { target0 = MorphTargets[currentTarget]; target1 = MorphTargets[currentTarget + 1]; if (animationTime < target0.Timestamp) { if (currentTarget == 0) { break; } currentTarget--; } else if (animationTime <= target1.Timestamp) { break; } else if (currentTarget >= MorphTargets.Count - 2) { // We got across the rightmost target. target0 = target1; break; } else { currentTarget++; } } } // Create the mesh if there is no any. if (target0.Mesh == null) { target0.Mesh = new Mesh { VertexBuffers = new IVertexBuffer[] { UVBuffer, target0.PosColorBuffer, target1.PosColorBuffer }, Attributes = new[] { new[] { ShaderPrograms.Attributes.UV1 }, new[] { ShaderPrograms.Attributes.Pos1, ShaderPrograms.Attributes.Color1 }, new[] { ShaderPrograms.Attributes.Pos2, ShaderPrograms.Attributes.Color2 } }, IndexBuffer = IndexBuffer }; } // Calculate the interpolation koefficient. float t; if (animationTime <= target0.Timestamp) { t = 0; } else if (animationTime >= target1.Timestamp) { t = 1; } else { t = (float)((animationTime - target0.Timestamp) / (target1.Timestamp - target0.Timestamp)); } // Render all of it. if (shaderProgram == null) { var options = ShaderOptions.VertexAnimation; shaderProgram = ShaderPrograms.Instance.GetShaderProgram(ShaderId.Diffuse, 1, options); morphKoeffUid = shaderProgram.GetUniformId("morphKoeff"); globalColorUid = shaderProgram.GetUniformId("globalColor"); globalTransformUid = shaderProgram.GetUniformId("globalTransform"); } PlatformRenderer.SetBlending(Blending.Alpha); PlatformRenderer.SetShaderProgram(shaderProgram); var globalColor = parentWidget.GlobalColor; shaderProgram.LoadFloat(morphKoeffUid, t); if (loadedGlobalColor.ABGR != globalColor.ABGR) { loadedGlobalColor = globalColor; var globalColorVec4 = (globalColor.ABGR == 0xFFFFFFFF) ? Vector4.One : new Vector4( globalColor.R / 255f, globalColor.G / 255f, globalColor.B / 255f, globalColor.A / 255f); shaderProgram.LoadVector4(globalColorUid, globalColorVec4); } shaderProgram.LoadMatrix(globalTransformUid, (Matrix44)parentWidget.LocalToWorldTransform); foreach (var sm in Batches) { PlatformRenderer.SetTexture(sm.Texture, 0); PlatformRenderer.DrawTriangles(target0.Mesh, sm.StartIndex, sm.IndexCount); } }