public TargetSpecific(SSScene main3dScene, SSScene hud2dScene) { _targetObj3dScene = main3dScene; main3dScene.preRenderHooks += preRenderUpdate; _outline = new SSObjectMesh(); _outline.renderState.lighted = false; _outline.renderState.alphaBlendingOn = true; _outline.renderState.frustumCulling = false; _outline.renderState.noShader = true; _outline.lineStipplePattern = 0xFFC0; _outline.Name = "hud target outline"; _outline.preRenderHook += (obj, rc) => { GL.LineWidth(_targetViewDepth < 0f ? outlineWidthWhenInFront : outlinelineWidthWhenBehind); GL.Disable(EnableCap.LineSmooth); }; hud2dScene.AddObject(_outline); _labelBelow = new SSObjectGDISurface_Text(); _labelBelow.renderState.alphaBlendingOn = true; _labelBelow.Name = "hud target label below"; hud2dScene.AddObject(_labelBelow); _labelAbove = new SSObjectGDISurface_Text(); _labelAbove.renderState.alphaBlendingOn = true; _labelAbove.Name = "hud target label above"; hud2dScene.AddObject(_labelAbove); }
public SSpaceMissilesRenderManager(SSScene objScene, SSScene particleScene, SSScene screenScene, int particleCapacity = 10000) { _simulation = new SSpaceMissilesVisualSimulation(); _objScene = objScene; objScene.preRenderHooks += this._preRenderUpdate; objScene.preUpdateHooks += _simulation.updateSimulation; objScene.preRenderHooks += simulation.updateSimulation; _screenScene = screenScene; // particle system _particlesData = new SSParticleSystemData(particleCapacity); _particleRenderer = new SSInstancedMeshRenderer( _particlesData, SSTexturedQuad.SingleFaceInstance); _particleRenderer.renderState.alphaBlendingOn = true; _particleRenderer.renderState.castsShadow = false; _particleRenderer.renderState.receivesShadows = false; _particleRenderer.renderState.depthTest = true; _particleRenderer.renderState.depthWrite = false; //_particleRenderer.renderMode = SSInstancedMeshRenderer.RenderMode.CpuFallback; //_particleRenderer.renderMode = SSInstancedMeshRenderer.RenderMode.GpuInstancing; //_particleRenderer.renderState.visible = false; _particleRenderer.AmbientMatColor = new Color4(1f, 1f, 1f, 1f); _particleRenderer.DiffuseMatColor = new Color4(0f, 0f, 0f, 0f); _particleRenderer.EmissionMatColor = new Color4(0f, 0f, 0f, 0f); _particleRenderer.SpecularMatColor = new Color4(0f, 0f, 0f, 0f); _particleRenderer.ShininessMatColor = 0f; _particleRenderer.Name = "missile smoke renderer"; particleScene.AddObject(_particleRenderer); }
public SSpaceMissilesRenderManager (SSScene objScene, SSScene particleScene, SSScene screenScene, int particleCapacity = 10000) { _simulation = new SSpaceMissilesSimulation (); _objScene = objScene; objScene.preRenderHooks += this._preRenderUpdate; objScene.preUpdateHooks += _simulation.updateSimulation; objScene.preRenderHooks += simulation.updateSimulation; _screenScene = screenScene; // particle system _particlesData = new SSParticleSystemData (particleCapacity); _particleRenderer = new SSInstancedMeshRenderer ( _particlesData, SSTexturedQuad.SingleFaceInstance); _particleRenderer.renderState.alphaBlendingOn = true; _particleRenderer.renderState.castsShadow = false; _particleRenderer.renderState.receivesShadows = false; _particleRenderer.renderState.depthTest = true; _particleRenderer.renderState.depthWrite = false; //_particleRenderer.renderMode = SSInstancedMeshRenderer.RenderMode.CpuFallback; //_particleRenderer.renderMode = SSInstancedMeshRenderer.RenderMode.GpuInstancing; //_particleRenderer.renderState.visible = false; _particleRenderer.AmbientMatColor = new Color4 (1f, 1f, 1f, 1f); _particleRenderer.DiffuseMatColor = new Color4 (0f, 0f, 0f, 0f); _particleRenderer.EmissionMatColor = new Color4(0f, 0f, 0f, 0f); _particleRenderer.SpecularMatColor = new Color4 (0f, 0f, 0f, 0f); _particleRenderer.ShininessMatColor = 0f; _particleRenderer.Name = "missile smoke renderer"; particleScene.AddObject(_particleRenderer); }
public SLaserManager(SSScene beamScene3d, SSScene occDiskScene, SSScene flareScene2d, int sprite2dCapacity = 1000, int laserBurnParticlesCapacity = 2000) { _beamScene3d = beamScene3d; _occDiskScene = occDiskScene; _flareScene2d = flareScene2d; _2dEffectInstanceData = new SInstancedSpriteData (sprite2dCapacity); _2dEffectRenderer = new SSInstancedSpriteRenderer (_beamScene3d, _2dEffectInstanceData); _2dEffectRenderer.Name = "laser manager's 2d screen effect renderer"; _2dEffectRenderer.renderState.alphaBlendingOn = true; _2dEffectRenderer.renderState.blendFactorSrc = BlendingFactorSrc.SrcAlpha; _2dEffectRenderer.renderState.blendFactorDest = BlendingFactorDest.One; //_2dEffectRenderer.renderMode = SSInstancedMeshRenderer.RenderMode.GpuInstancing; _flareScene2d.AddObject(_2dEffectRenderer); _laserBurnParticles = new SLaserBurnParticlesObject ( laserBurnParticlesCapacity, SLaserParameters.laserBurnParticlesDefaultTexture()); _laserBurnParticles.Name = "laser manager's laser burn particle system renderer"; //_laserBurnParticles.renderMode = SSInstancedMeshRenderer.RenderMode.GpuInstancing; _beamScene3d.AddObject(_laserBurnParticles); _beamScene3d.preRenderHooks += this._update; }
protected virtual void setupScene() { hud2dScene = new SSScene(mainShader, pssmShader, instancingShader, instancingPssmShader); environmentScene = new SSScene(mainShader, pssmShader, instancingShader, instancingPssmShader); sunFlareScene = new SSScene(mainShader, pssmShader, instancingShader, instancingPssmShader); sunDiskScene = new SSScene(mainShader, pssmShader, instancingShader, instancingPssmShader); main3dScene = new SSScene(mainShader, pssmShader, instancingShader, instancingPssmShader); main3dScene.renderConfig.frustumCulling = true; main3dScene.renderConfig.usePoissonSampling = true; main3dScene.BeforeRenderObject += this.beforeRenderObjectHandler; alpha3dScene = new SSScene(mainShader, pssmShader, instancingShader, instancingPssmShader); alpha3dScene.renderConfig.frustumCulling = true; alpha3dScene.renderConfig.usePoissonSampling = false; alpha3dScene.BeforeRenderObject += this.beforeRenderObjectHandler; // 0. Add Lights var light = new SSDirectionalLight(LightName.Light0); light.Direction = new Vector3(0f, 0f, -1f); #if true if (OpenTKHelper.areFramebuffersSupported()) { if (main3dScene.renderConfig.pssmShader != null && main3dScene.renderConfig.instancePssmShader != null) { //if (false) { light.ShadowMap = new SSParallelSplitShadowMap(TextureUnit.Texture7); } else { light.ShadowMap = new SSSimpleShadowMap(TextureUnit.Texture7); } } if (!light.ShadowMap.IsValid) { light.ShadowMap = null; } #endif main3dScene.AddLight(light); #if true if (light.ShadowMap != null) { shadowmapDebugQuad = new SSObjectHUDQuad(light.ShadowMap.TextureID); shadowmapDebugQuad.Scale = new Vector3(0.3f); shadowmapDebugQuad.Pos = new Vector3(50f, 200, 0f); hud2dScene.AddObject(shadowmapDebugQuad); } #endif }
protected void _createRenderObjects() { var laserParams = this._laser.parameters; if (laserParams.doEmissionFlare && _occDiskFlatObj == null) { _occDiskFlatObj = new SSObjectOcclusionQueuery(new SSMeshDisk()); _occDiskFlatObj.renderState.alphaBlendingOn = true; _occDiskFlatObj.renderState.lighted = false; _occDiskFlatObj.renderState.depthTest = true; _occDiskFlatObj.renderState.depthWrite = false; _occDiskFlatObj.renderState.doBillboarding = false; _occDiskFlatObj.renderState.matchScaleToScreenPixels = true; _occDiskFlatObj.Scale = new Vector3(_laser.parameters.emissionOccDiskRadiusPx); var color = _laser.parameters.backgroundColor; // debugging color.A = _laser.parameters.emissionOccDisksAlpha; _occDiskFlatObj.MainColor = color; _occDiskFlatObj.Name = "occlusion disk object for laser beam's emission flare"; _occDiskScene.AddObject(_occDiskFlatObj); } if (_beamObj == null) { _beamObj = new SLaserBeamMiddleObject( _laser, _beamId, _beamScene, laserParams.middleBackgroundTexture(), laserParams.middleOverlayTexture(), laserParams.middleInterferenceTexture()); _beamObj.Name = "laser beam middle section object"; _beamScene.AddObject(_beamObj); } if (laserParams.doEmissionFlare && _emissionFlareUpdater == null) { _emissionFlareUpdater = new SLaserEmissionFlareUpdater( _laser, _beamId, _occDiskFlatObj, laserParams.emissionBackgroundRect, laserParams.emissionOverlayRect); _sprite2dRenderer.addUpdater(_emissionFlareUpdater); } if (laserParams.doScreenHitFlare && _hitFlareUpdater == null) { float[] masterScales = { laserParams.hitFlareCoronaOverlayScale, laserParams.hitFlareCoronaOverlayScale, laserParams.hitFlareRing1Scale, laserParams.hitFlareRing2Scale }; _hitFlareUpdater = new SLaserScreenHitFlareUpdater(_laser, _beamId, _beamScene, null, masterScales); _sprite2dRenderer.addUpdater(_hitFlareUpdater); } }
//public SLaserBurnParticlesObject laserBurnParticlesObject { // get { return _laserBurnParticles; } //} public SLaserManager(SSScene beamScene3d, SSScene occDiskScene, SSScene flareScene2d, int sprite2dCapacity = 1000, int laserBurnParticlesCapacity = 500) { _beamScene3d = beamScene3d; _occDiskScene = occDiskScene; _flareScene2d = flareScene2d; _2dEffectInstanceData = new SInstancedSpriteData(sprite2dCapacity); _2dEffectRenderer = new SSInstancedSpriteRenderer(_beamScene3d, _2dEffectInstanceData); _2dEffectRenderer.Name = "laser manager's 2d screen effect renderer"; _2dEffectRenderer.renderState.alphaBlendingOn = true; _2dEffectRenderer.renderState.blendFactorSrc = BlendingFactorSrc.SrcAlpha; _2dEffectRenderer.renderState.blendFactorDest = BlendingFactorDest.One; //_2dEffectRenderer.renderMode = SSInstancedMeshRenderer.RenderMode.GpuInstancing; _flareScene2d.AddObject(_2dEffectRenderer); _beamScene3d.preRenderHooks += this._update; _maxBurnParticlesPerObject = laserBurnParticlesCapacity; }
//public SLaserBurnParticlesObject laserBurnParticlesObject { // get { return _laserBurnParticles; } //} public SLaserManager(SSScene beamScene3d, SSScene occDiskScene, SSScene flareScene2d, int sprite2dCapacity = 1000, int laserBurnParticlesCapacity = 500) { _beamScene3d = beamScene3d; _occDiskScene = occDiskScene; _flareScene2d = flareScene2d; _2dEffectInstanceData = new SInstancedSpriteData (sprite2dCapacity); _2dEffectRenderer = new SSInstancedSpriteRenderer (_beamScene3d, _2dEffectInstanceData); _2dEffectRenderer.Name = "laser manager's 2d screen effect renderer"; _2dEffectRenderer.renderState.alphaBlendingOn = true; _2dEffectRenderer.renderState.blendFactorSrcRGB = _2dEffectRenderer.renderState.blendFactorSrcAlpha = BlendingFactorSrc.SrcAlpha; _2dEffectRenderer.renderState.blendFactorDestRGB = _2dEffectRenderer.renderState.blendFactorDestAlpha = BlendingFactorDest.One; //_2dEffectRenderer.renderMode = SSInstancedMeshRenderer.RenderMode.GpuInstancing; _flareScene2d.AddObject(_2dEffectRenderer); _beamScene3d.preRenderHooks += this._update; _maxBurnParticlesPerObject = laserBurnParticlesCapacity; }
public TargetSpecific(SSScene main3dScene, SSScene hud2dScene) { _targetObj3dScene = main3dScene; main3dScene.preRenderHooks += preRenderUpdate; _outline = new SSObjectMesh(); _outline.renderState.lighted = false; _outline.renderState.alphaBlendingOn = true; _outline.renderState.frustumCulling = false; _outline.renderState.noShader = true; _outline.Name = "hud target outline"; _outline.preRenderHook += (obj, rc) => { GL.LineWidth(_targetIsInFront ? lineWidthWhenInFront : lineWidthWhenBehind); GL.Disable(EnableCap.LineSmooth); }; hud2dScene.AddObject(_outline); _labelBelow = new SSObjectGDISurface_Text(); _labelBelow.renderState.alphaBlendingOn = true; _labelBelow.Name = "hud target label below"; hud2dScene.AddObject(_labelBelow); _labelAbove = new SSObjectGDISurface_Text(); _labelAbove.renderState.alphaBlendingOn = true; _labelAbove.Name = "hud target label above"; hud2dScene.AddObject(_labelAbove); }
protected virtual void setupScene() { scene = new SSScene(mainShader, pssmShader, instancingShader, instancingPssmShader); sunDiskScene = new SSScene(); sunFlareScene = new SSScene(); hudScene = new SSScene(); environmentScene = new SSScene(); scene.renderConfig.frustumCulling = true; // TODO: fix the frustum math, since it seems to be broken. scene.BeforeRenderObject += beforeRenderObjectHandler; // 0. Add Lights var light = new SSDirectionalLight(LightName.Light0); light.Direction = new Vector3(0f, 0f, -1f); #if true if (OpenTKHelper.areFramebuffersSupported()) { if (scene.renderConfig.pssmShader != null && scene.renderConfig.instancePssmShader != null) { light.ShadowMap = new SSParallelSplitShadowMap(TextureUnit.Texture7); } else { light.ShadowMap = new SSSimpleShadowMap(TextureUnit.Texture7); } } if (!light.ShadowMap.IsValid) { light.ShadowMap = null; } #endif scene.AddLight(light); #if true var smapDebug = new SSObjectHUDQuad(light.ShadowMap.TextureID); smapDebug.Scale = new Vector3(0.3f); smapDebug.Pos = new Vector3(50f, 200, 0f); hudScene.AddObject(smapDebug); #endif // setup a sun billboard object and a sun flare spriter renderer { var sunDisk = new SSMeshDisk(); var sunBillboard = new SSObjectBillboard(sunDisk, true); sunBillboard.MainColor = new Color4(1f, 1f, 0.8f, 1f); sunBillboard.Pos = new Vector3(0f, 0f, 18000f); sunBillboard.Scale = new Vector3(600f); sunBillboard.renderState.frustumCulling = false; sunBillboard.renderState.lighted = false; sunBillboard.renderState.castsShadow = false; sunDiskScene.AddObject(sunBillboard); SSTexture flareTex = SSAssetManager.GetInstance <SSTextureWithAlpha>(".", "sun_flare.png"); const float bigOffset = 0.8889f; const float smallOffset = 0.125f; RectangleF[] flareSpriteRects = { new RectangleF(0f, 0f, 1f, bigOffset), new RectangleF(0f, bigOffset, smallOffset, smallOffset), new RectangleF(smallOffset, bigOffset, smallOffset, smallOffset), new RectangleF(smallOffset * 2f, bigOffset, smallOffset, smallOffset), new RectangleF(smallOffset * 3f, bigOffset, smallOffset, smallOffset), }; float[] spriteScales = { 20f, 1f, 2f, 1f, 1f }; var sunFlare = new SimpleSunFlareMesh(sunDiskScene, sunBillboard, flareTex, flareSpriteRects, spriteScales); sunFlare.Scale = new Vector3(2f); sunFlare.renderState.lighted = false; sunFlareScene.AddObject(sunFlare); } }