public void activate(Shader shader, Drawable drawble) { GL.Uniform3(shader.sunDirection, ref pointingDirection); GL.Uniform3(shader.sunColor, ref colorRgb); GL.Uniform3(shader.lightAmbientLocation, ref lightAmbient); GL.UniformMatrix4(shader.sunMatrix, false, ref shadowMatrix); GL.UniformMatrix4(shader.sunInnerMatrix, false, ref innerShadowMatrix); }
public override void activate(Shader shader, Drawable drawble) { GL.Uniform3(shader.sunDirection, ref pointingDirection); GL.Uniform3(shader.sunColor, ref colorRgb); shader.insertUniform(Shader.Uniform.in_lightambient, ref lightAmbient); GL.UniformMatrix4(shader.sunMatrix, false, ref shadowMatrix); GL.UniformMatrix4(shader.sunInnerMatrix, false, ref innerShadowMatrix); }
public override bool frustrumCheck(Drawable drawable) { Vector4 vSpacePos = GenericMethods.Mult(new Vector4(drawable.Position, 1), modelviewProjectionMatrix); float range = drawable.boundingSphere * 2f / widith; if (float.IsNaN(range) || float.IsInfinity(range)) return false; vSpacePos /= vSpacePos.W; return ( vSpacePos.X < (1f + range) && vSpacePos.X > -(1f + range) && vSpacePos.Y < (1f + range) && vSpacePos.Y > -(1f + range) && vSpacePos.Z < (1f) && vSpacePos.Z > -(1f) ); }
public virtual bool frustrumCheck(Drawable drawable) { Vector4 vSpacePos = GenericMethods.Mult(new Vector4(drawable.Position, 1), modelviewProjectionMatrix); float range = drawable.boundingSphere; float distToDrawAble = (position - drawable.Position).Length; if (distToDrawAble < range * 1.5f) return true; if (distToDrawAble - range > zFar) return false; if(vSpacePos.W <= 0) return false; range /= vSpacePos.W * 0.6f; if (float.IsNaN(range) || float.IsInfinity(range)) return false; vSpacePos /= vSpacePos.W; return ( vSpacePos.X < (1f + range) && vSpacePos.X > -(1f + range) && vSpacePos.Y < (1f + range * aspect) && vSpacePos.Y > -(1f + range * aspect) ); }
internal void activate(Shader shader, int i, Drawable drawble) { int active = 0; if (viewInfo.frustrumCheck(drawble)) { GL.Uniform3(shader.lightLocationsLocation[i], ref position); GL.Uniform3(shader.lightDirectionsLocation[i], ref pointingDirection); GL.Uniform3(shader.lightColorsLocation[i], ref colorRgb); GL.UniformMatrix4(shader.lightViewMatrixLocation[i], false, ref shadowMatrix); GL.Uniform1(shader.lightTextureLocation[i], 1, ref ProjectionTexture); active = 1; } GL.Uniform1(shader.lightActiveLocation[i], 1, ref active); }
public virtual void activate(Shader shader, Drawable drawable) { }
public static int CompareByDistance(Drawable drawableA, Drawable drawableB) { return drawableA.distToCamera.CompareTo(drawableB.distToCamera); }