public static void Compile() { if (iscompiled) { return; } iscompiled = true; ShaderVariables.Log("Compiling Basic_Skinned"); string vertsrc; string fragsrc; vertsrc = ShCompHelper.FromArray(vertex_bytes); fragsrc = ShCompHelper.FromArray(fragment_bytes); variants = new ShaderVariables[16]; variants[0] = ShaderVariables.Compile(vertsrc, fragsrc, ""); variants[1] = ShaderVariables.Compile(vertsrc, fragsrc, "\n#define ALPHATEST_ENABLED\n#line 1\n"); variants[2] = ShaderVariables.Compile(vertsrc, fragsrc, "\n#define VERTEX_LIGHTING\n#line 1\n"); variants[3] = ShaderVariables.Compile(vertsrc, fragsrc, "\n#define ALPHATEST_ENABLED\n#define VERTEX_LIGHTING\n#line 1\n"); variants[4] = ShaderVariables.Compile(vertsrc, fragsrc, "\n#define ET_ENABLED\n#line 1\n"); variants[5] = ShaderVariables.Compile(vertsrc, fragsrc, "\n#define ALPHATEST_ENABLED\n#define ET_ENABLED\n#line 1\n"); variants[6] = ShaderVariables.Compile(vertsrc, fragsrc, "\n#define VERTEX_LIGHTING\n#define ET_ENABLED\n#line 1\n"); variants[7] = ShaderVariables.Compile(vertsrc, fragsrc, "\n#define ALPHATEST_ENABLED\n#define VERTEX_LIGHTING\n#define ET_ENABLED\n#line 1\n"); variants[8] = ShaderVariables.Compile(vertsrc, fragsrc, "\n#define FADE_ENABLED\n#line 1\n"); variants[9] = ShaderVariables.Compile(vertsrc, fragsrc, "\n#define ALPHATEST_ENABLED\n#define FADE_ENABLED\n#line 1\n"); variants[10] = ShaderVariables.Compile(vertsrc, fragsrc, "\n#define VERTEX_LIGHTING\n#define FADE_ENABLED\n#line 1\n"); variants[11] = ShaderVariables.Compile(vertsrc, fragsrc, "\n#define ALPHATEST_ENABLED\n#define VERTEX_LIGHTING\n#define FADE_ENABLED\n#line 1\n"); variants[12] = ShaderVariables.Compile(vertsrc, fragsrc, "\n#define ET_ENABLED\n#define FADE_ENABLED\n#line 1\n"); variants[13] = ShaderVariables.Compile(vertsrc, fragsrc, "\n#define ALPHATEST_ENABLED\n#define ET_ENABLED\n#define FADE_ENABLED\n#line 1\n"); variants[14] = ShaderVariables.Compile(vertsrc, fragsrc, "\n#define VERTEX_LIGHTING\n#define ET_ENABLED\n#define FADE_ENABLED\n#line 1\n"); variants[15] = ShaderVariables.Compile(vertsrc, fragsrc, "\n#define ALPHATEST_ENABLED\n#define VERTEX_LIGHTING\n#define ET_ENABLED\n#define FAD" + "E_ENABLED\n#line 1\n"); }
public static void Compile() { if (iscompiled) { return; } iscompiled = true; ShaderVariables.Log("Compiling all shaders"); AsteroidBand.Compile(); Atmosphere.Compile(); Basic_PositionColor.Compile(); Basic_PositionNormalColorTexture.Compile(); Basic_PositionNormalTexture.Compile(); Basic_PositionNormalTextureTwo.Compile(); Basic_PositionTexture.Compile(); Basic_Skinned.Compile(); Billboard.Compile(); DepthPass_AlphaTest.Compile(); DepthPass_Normal.Compile(); DetailMap2Dm1Msk2PassMaterial.Compile(); DetailMapMaterial.Compile(); IllumDetailMapMaterial.Compile(); Masked2DetailMapMaterial.Compile(); NebulaExtPuff.Compile(); NebulaInterior.Compile(); NebulaMaterial.Compile(); Nomad.Compile(); Normals.Compile(); Particle.Compile(); PhysicsDebug.Compile(); Polyline.Compile(); Projectile.Compile(); SunRadial.Compile(); SunSpine.Compile(); }
public Billboards() { shaderBasic = Shaders.Billboard.Get(); shaderBasic.Shader.SetInteger(shaderBasic.Shader.GetLocation("tex0"), 0); rendat = new RenderData[MAX_BILLBOARDS]; vboBasic = new VertexBuffer(typeof(BillboardVert), MAX_BILLBOARDS * 4, true); iboBasic = new ElementBuffer(MAX_BILLBOARDS * 6, true); vboBasic.SetElementBuffer(iboBasic); }
public PolylineRender(CommandBuffer buffer) { if (shader == null) { shader = Shaders.Polyline.Get(); shader.Shader.SetInteger(shader.Shader.GetLocation("tex0"), 0); } vbo = new VertexBuffer(typeof(VertexPositionColorTexture), MAX_VERTICES, true); this.buffer = buffer; }
Shader GetPuffShader() { if (_puffringsh == null) { _puffringsh = Shaders.NebulaExtPuff.Get(); _ptex0 = _puffringsh.Shader.GetLocation("tex0"); _pfogfactor = _puffringsh.Shader.GetLocation("FogFactor"); } return(_puffringsh.Shader); }
public static void Compile() { if (iscompiled) { return; } iscompiled = true; ShaderVariables.Log("Compiling NebulaExtPuff"); string vertsrc; string fragsrc; vertsrc = ShCompHelper.FromArray(vertex_bytes); fragsrc = ShCompHelper.FromArray(fragment_bytes); variants = new ShaderVariables[1]; variants[0] = ShaderVariables.Compile(vertsrc, fragsrc, ""); }
public static void Compile() { if (iscompiled) { return; } iscompiled = true; ShaderVariables.Log("Compiling DetailMap2Dm1Msk2PassMaterial"); string vertsrc; string fragsrc; vertsrc = ShCompHelper.FromArray(vertex_bytes); fragsrc = ShCompHelper.FromArray(fragment_bytes); variants = new ShaderVariables[1]; variants[0] = ShaderVariables.Compile(vertsrc, fragsrc, ""); }
public static void Compile() { if (iscompiled) { return; } iscompiled = true; ShaderVariables.Log("Compiling Masked2DetailMapMaterial"); string vertsrc; string fragsrc; vertsrc = ShCompHelper.FromArray(vertex_bytes); fragsrc = ShCompHelper.FromArray(fragment_bytes); variants = new ShaderVariables[2]; variants[0] = ShaderVariables.Compile(vertsrc, fragsrc, ""); variants[1] = ShaderVariables.Compile(vertsrc, fragsrc, "\n#define VERTEX_LIGHTING\n#line 1\n"); }
public BeamsBuffer() { var idx1 = ConstructIndices(spearIndices, 12, MAX_BEAMS); bufferSpear = new VertexBuffer(typeof(VertexPositionColorTexture), MAX_BEAMS * 12, true); var el1 = new ElementBuffer(idx1.Length); el1.SetData(idx1); bufferSpear.SetElementBuffer(el1); var idx2 = ConstructIndices(boltIndices, 17, MAX_BEAMS); bufferBolt = new VertexBuffer(typeof(VertexPositionColorTexture), MAX_BEAMS * 17, true); var el2 = new ElementBuffer(idx2.Length); el2.SetData(idx2); bufferBolt.SetElementBuffer(el2); shader = Shaders.Projectile.Get(); shader.Shader.SetInteger(shader.Shader.GetLocation("tex0"), 0); }
public override void Draw(ICamera camera, CommandBuffer commands, SystemLighting lights, NebulaRenderer nr) { if (sysr == null || vertices == null) { return; } float z = RenderHelpers.GetZ(Matrix4x4.Identity, camera.Position, pos); if (z > 900000) // Reduce artefacts from fast Z-sort calculation. This'll probably cause issues somewhere else { z = 900000; } var dist_scale = nr != null ? nr.Nebula.SunBurnthroughScale : 1; var alpha = nr != null ? nr.Nebula.SunBurnthroughIntensity : 1; if (radialShader == null) { radialShader = Shaders.SunRadial.Get(); radialTex0 = radialShader.Shader.GetLocation("tex0"); radialSize = radialShader.Shader.GetLocation("SizeMultiplier"); radialAlpha = radialShader.Shader.GetLocation("outerAlpha"); } if (spineShader == null) { spineShader = Shaders.SunSpine.Get(); spineTex0 = spineShader.Shader.GetLocation("tex0"); spineSize = spineShader.Shader.GetLocation("SizeMultiplier"); } radialShader.SetViewProjection(camera); radialShader.SetView(camera); spineShader.SetViewProjection(camera); spineShader.SetView(camera); int idx = sysr.StaticBillboards.DoVertices(ref ID, vertices); if (Sun.CenterSprite != null) { //draw center var cr = (Texture2D)sysr.ResourceManager.FindTexture(Sun.CenterSprite); commands.AddCommand(radialShader.Shader, RadialSetup, Cleanup, commands.WorldBuffer.Identity, new RenderUserData() { Float = 0, Color = new Color4(dist_scale, alpha, 0, 0), Texture = cr }, sysr.StaticBillboards.VertexBuffer, PrimitiveTypes.TriangleList, idx, 2, true, SortLayers.SUN, z); //next idx += 6; } //draw glow var gr = (Texture2D)sysr.ResourceManager.FindTexture(Sun.GlowSprite); commands.AddCommand(radialShader.Shader, RadialSetup, Cleanup, commands.WorldBuffer.Identity, new RenderUserData() { Float = 1, Color = new Color4(dist_scale, alpha, 0, 0), Texture = gr }, sysr.StaticBillboards.VertexBuffer, PrimitiveTypes.TriangleList, idx, 2, true, SortLayers.SUN, z + 108f); //next idx += 6; //draw spines if (Sun.SpinesSprite != null && nr == null) { var spinetex = (Texture2D)sysr.ResourceManager.FindTexture(Sun.SpinesSprite); commands.AddCommand(spineShader.Shader, SpineSetup, Cleanup, commands.WorldBuffer.Identity, new RenderUserData() { Texture = spinetex }, sysr.StaticBillboards.VertexBuffer, PrimitiveTypes.TriangleList, idx, 2 * Sun.Spines.Count, true, SortLayers.SUN, z + 1112f); } }
public PhysicsDebugRenderer() { shader = Shaders.PhysicsDebug.Get(); linebuffer = new VertexBuffer(typeof(VertexPositionColor), MAX_LINES * 2, true); }
public AsteroidFieldRenderer(AsteroidField field, SystemRenderer sys) { this.field = field; this.sys = sys; //Set up renderDistSq float rdist = 0f; if (field.Zone.Shape is ZoneSphere) { rdist = ((ZoneSphere)field.Zone.Shape).Radius; } else if (field.Zone.Shape is ZoneEllipsoid) { var s = ((ZoneEllipsoid)field.Zone.Shape).Size; rdist = Math.Max(Math.Max(s.X, s.Y), s.Z); } else if (field.Zone.Shape is ZoneBox) { var s = ((ZoneEllipsoid)field.Zone.Shape).Size; rdist = Math.Max(Math.Max(s.X, s.Y), s.Z); } if (field.BillboardCount != -1) { billboardCube = new AsteroidBillboard[field.BillboardCount]; for (int i = 0; i < field.BillboardCount; i++) { billboardCube[i].Spawn(this); } calculatedBillboards = new AsteroidBillboard[field.BillboardCount]; } rdist += field.FillDist; renderDistSq = rdist * rdist; cubes = new CalculatedCube[4000]; _asteroidsCalculation = CalculateAsteroidsTask; if (field.Cube.Count > 0) { CreateBufferObject(); } //Set up band if (field.Band == null) { return; } if (bandShader == null) { bandShader = Shaders.AsteroidBand.Get(); _bsTexture = bandShader.Shader.GetLocation("Texture"); _bsCameraPosition = bandShader.Shader.GetLocation("CameraPosition"); _bsColorShift = bandShader.Shader.GetLocation("ColorShift"); _bsTextureAspect = bandShader.Shader.GetLocation("TextureAspect"); } Vector3 sz; if (field.Zone.Shape is ZoneSphere) { sz = new Vector3(((ZoneSphere)field.Zone.Shape).Radius); } else if (field.Zone.Shape is ZoneEllipsoid) { sz = ((ZoneEllipsoid)field.Zone.Shape).Size; } else { return; } sz.X -= field.Band.OffsetDistance; sz.Z -= field.Band.OffsetDistance; lightingRadius = Math.Max(sz.X, sz.Z); renderBand = true; bandTransform = ( Matrix4x4.CreateScale(sz.X, field.Band.Height / 2, sz.Z) * field.Zone.RotationMatrix * Matrix4x4.CreateTranslation(field.Zone.Position) ); bandCylinder = sys.ResourceManager.GetOpenCylinder(SIDES); }