/// <summary> /// Initializes a new instance of the <see cref="UITextureAtlas"/> class from resource names list. /// NOTE: For UI sprites loading use <see cref="U.AtlasBuilder"/> instead, do not call this. /// </summary> /// <param name="atlasName">Name for the new atlas.</param> /// <param name="resourcePrefix">Prefix to resource directory.</param> /// <param name="spriteDefs">Names of textures and sizes to load.</param> /// <param name="atlasSizeHint">Texture with this side size is created.</param> public static UITextureAtlas CreateAtlas(string atlasName, string resourcePrefix, U.AtlasSpriteDef[] spriteDefs, IntVector2 atlasSizeHint) { var loadedTextures = new List<Texture2D>(spriteDefs.Length); var loadedSpriteNames = new List<string>(); // Load separate sprites and then pack it in a texture together foreach (U.AtlasSpriteDef spriteDef in spriteDefs) { // Allow spritedef resouce prefix to override prefix given to this func string prefix = string.IsNullOrEmpty(spriteDef.ResourcePrefix) ? resourcePrefix : spriteDef.ResourcePrefix; //-------------------------- // Try loading the texture //-------------------------- string resourceName = $"{prefix}.{spriteDef.Name}.png"; Log._Debug($"TextureUtil: Loading {resourceName} for sprite={spriteDef.Name}"); Texture2D tex = TextureResources.LoadDllResource( resourceName: resourceName, size: spriteDef.Size); if (tex != null) { loadedTextures.Add(tex); loadedSpriteNames.Add(spriteDef.Name); // only take those which are loaded } // No error reporting, it is done in LoadDllResource } Log._Debug($"TextureUtil: Atlas textures loaded, in {spriteDefs.Length}, success {loadedTextures.Count}"); return PackTextures(atlasName, atlasSizeHint, loadedTextures, loadedSpriteNames); }
private void BuildEnemies() { string localClrStr = PlayerManager.Instance().local.MeepleColor.ToString(); texture = TextureResources.Get("NamePlateBackgroundLong" + localClrStr); foes.SetColor((localClrStr.Equals("Red") || localClrStr.Equals("Black")) ? ColorResources.White : ColorResources.Black); foesNames.Clear(); int totalHeight = foes.Position.Height; foreach (GhostPlayer enemy in PlayerManager.Instance().ghostPlayers) { if (enemy.Equals(PlayerManager.Instance().local)) { continue; } Rectangle nextRect = new Rectangle(contentRect.Location.X, contentRect.Location.Y + totalHeight, contentRect.Width, contentRect.Height / 4); string colorStr = enemy.MeepleColor.ToString(); Color textColor = ColorResources.ForName(colorStr); foesNames.Add(new TextBoardElement(nextRect, enemy.name, fontBig, "namePlateFoesNamesText" + enemy.name, textColor, zPosition + 2, TextBoardElement.Alignment.LeftMiddle)); totalHeight += nextRect.Height; } }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); TextureResources.contentManager = Content; TextureResources.LoadDefault(); SpriteFont oldenburg_8 = Content.Load <SpriteFont>("fonts/oldenburg_8"); SpriteFont oldenburg_20 = Content.Load <SpriteFont>("fonts/oldenburg_20"); SpriteFont oldenburg_30 = Content.Load <SpriteFont>("fonts/oldenburg_30"); SpriteFont oldenburg_60 = Content.Load <SpriteFont>("fonts/oldenburg_60"); SpriteFont josefin_20 = Content.Load <SpriteFont>("fonts/josefin_20"); QuestionManager.Instance().SetQuestionFont(oldenburg_60); QuestionManager.Instance().SetAnswerFont(oldenburg_30); FontResources.oldenburg_8 = oldenburg_8; FontResources.oldenburg_20 = oldenburg_20; FontResources.oldenburg_30 = oldenburg_30; FontResources.oldenburg_60 = oldenburg_60; FontResources.josefin_20 = josefin_20; setupper = new Setupper(windowWidth, windowHeight); setupper.Setup(); }
public void Init() { // Load default renderPipelineResources / Material / Shader string HDRenderPipelinePath = HDUtils.GetHDRenderPipelinePath() + "Runtime/"; // Shaders shaders = new ShaderResources { }; // Materials materials = new MaterialResources { // Defaults defaultDiffuseMat = Load <Material>(HDRenderPipelinePath + "RenderPipelineResources/Material/DefaultHDMaterial.mat"), defaultMirrorMat = Load <Material>(HDRenderPipelinePath + "RenderPipelineResources/Material/DefaultHDMirrorMaterial.mat"), defaultDecalMat = Load <Material>(HDRenderPipelinePath + "RenderPipelineResources/Material/DefaultHDDecalMaterial.mat"), defaultTerrainMat = Load <Material>(HDRenderPipelinePath + "RenderPipelineResources/Material/DefaultHDTerrainMaterial.mat"), }; // Textures textures = new TextureResources { }; // ShaderGraphs shaderGraphs = new ShaderGraphResources { //autodesk interactive autodeskInteractive = Load <Shader>(HDRenderPipelinePath + "RenderPipelineResources/ShaderGraph/AutodeskInteractive.ShaderGraph"), autodeskInteractiveMasked = Load <Shader>(HDRenderPipelinePath + "RenderPipelineResources/ShaderGraph/AutodeskInteractiveMasked.ShaderGraph"), autodeskInteractiveTransparent = Load <Shader>(HDRenderPipelinePath + "RenderPipelineResources/ShaderGraph/AutodeskInteractiveTransparent.ShaderGraph"), }; }
/// <summary>Helper to create speed limit sign + label below converted to the opposite unit</summary> /// <param name="showMph">Config value from GlobalConfig.I.M.ShowMPH</param> /// <param name="speedLimit">The float speed to show</param> private void _guiSpeedLimitsWindow_AddButton(bool showMph, float speedLimit) { // The button is wrapped in vertical sub-layout and a label for MPH/KMPH is added GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); var signSize = TrafficManagerTool.AdaptWidth(GuiSpeedSignSize); if (GUILayout.Button( TextureResources.GetSpeedLimitTexture(speedLimit), GUILayout.Width(signSize), GUILayout.Height(signSize * SpeedLimit.GetVerticalTextureScale()))) { currentPaletteSpeedLimit = speedLimit; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); // For MPH setting display KM/H below, for KM/H setting display MPH GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(showMph ? SpeedLimit.ToKmphPreciseString(speedLimit) : SpeedLimit.ToMphPreciseString(speedLimit)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); }
public Question(Rectangle position, string UID) : base(position, TextureResources.Get("QuestionBackground"), UID, defaultZPosition) { isConstructed = false; margin = UnitConvert.ToAbsoluteWidth(30); contentRect = new Rectangle(position.X + margin, position.Y + margin, position.Width - margin * 2, position.Height - margin * 2); }
public void UpdateColor() { string colorStr = PlayerManager.Instance().local.MeepleColor.ToString(); texture = TextureResources.Get("NamePlateBackground" + colorStr); Color textColor = (colorStr.Equals("Red") || colorStr.Equals("Black")) ? ColorResources.White : ColorResources.Black; hello.SetColor(textColor); playerName.SetColor(textColor); }
public static Texture2D GetTexture(string resourceIdentifier, string ModID) { string key = ModID + "::" + resourceIdentifier.ToLower(); if (TextureResources.ContainsKey(key)) { return(TextureResources[key]); } return(null); }
protected void SetupWelcomeTitle() { Texture2D titleTex = TextureResources.Get("LogoMixed"); float aspectR = titleTex.Width / (float)titleTex.Height; int titleWidth = windowWidth * 3 / 4; int titleHeight = (int)(titleWidth / aspectR); int titleX = (windowWidth - titleWidth) / 2; int titleY = (windowHeight - titleHeight) / 16; AlphaAnimatedVisibleBoardElement title = new AlphaAnimatedVisibleBoardElement(new Rectangle(titleX, titleY, titleWidth, titleHeight), titleTex, "welcometitle", 21); CommandQueue.Queue(new AddToBoardCommand(title)); }
protected void SetupPlayButton() { Texture2D btnTex = TextureResources.Get("Play"); float aspectR = btnTex.Width / (float)btnTex.Height; int btnWidth = UnitConvert.ToAbsoluteWidth(300); int btnHeight = (int)(btnWidth / aspectR); int btnX = (windowWidth - btnWidth) / 2; int btnY = (windowHeight - btnHeight) * 7 / 8; PlayButtonBoardElement playBtn = new PlayButtonBoardElement(new Rectangle(btnX, btnY, btnWidth, btnHeight), btnTex, "btn_play", 22, "welcomebackground", "welcometitle", "impressum"); CommandQueue.Queue(new AddToBoardCommand(playBtn)); }
protected AlphaAnimatedVisibleBoardElement SetupBackground(string uid, int zPosition, float alpha = 1f) { Texture2D background = TextureResources.Get("Background"); float backgroundAspectRatio = background.Width / (float)background.Height; int backgroundWidth = windowWidth; int backgroundHeight = (int)(backgroundWidth / backgroundAspectRatio); int backgroundX = (windowWidth - backgroundWidth) / 2; int backgroundY = (windowHeight - backgroundHeight) / 2; AlphaAnimatedVisibleBoardElement backgroundBoardEl = new AlphaAnimatedVisibleBoardElement(new Rectangle(backgroundX, backgroundY, backgroundWidth, backgroundHeight), background, uid, zPosition: zPosition, startAlpha: alpha); CommandQueue.Queue(new AddToBoardCommand(backgroundBoardEl)); return(backgroundBoardEl); }
public PyramidFloorBoardElementConnector(PyramidFloorBoardElement from, PyramidFloorBoardElement to, string UID, int zPosition = 0) : base( from.Position, TextureResources.Get("PyramidFieldConnectionShort"), UID, zPosition ) { this.fromBE = from; this.toBE = to; Setup(); }
/// /// <summary> /// Loads all game content. /// </summary> /// protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // Load all font resources. FontResources.loadContent(Content); // Load all texture resources. TextureResources.loadContent(Content); // Load all model resources. ModelResources.loadContent(Content); }
/// <summary> /// Initializes a new instance of the <see cref="SpriteAtlas"/> class from resource names list. /// </summary> /// <param name="atlasName">Name for the new atlas.</param> /// <param name="resourcePrefix">Prefix to resource directory.</param> /// <param name="spriteNames">Array of paths to load also they become atlas keys.</param> /// <param name="spriteWidth">Hint width for texture loader (todo: get rid of this).</param> /// <param name="spriteHeight">Hint height for texture loader (todo: get rid of this).</param> /// <param name="hintAtlasTextureSize">Square texture with this side size is created.</param> public static UITextureAtlas CreateAtlas(string atlasName, string resourcePrefix, string[] spriteNames, int spriteWidth, int spriteHeight, int hintAtlasTextureSize) { Texture2D texture2D = new Texture2D( hintAtlasTextureSize, hintAtlasTextureSize, TextureFormat.ARGB32, false); var textures = new List <Texture2D>(spriteNames.Length); // Load separate sprites and then pack it in a texture together foreach (string spriteName in spriteNames) { Texture2D loadedSprite = TextureResources.LoadDllResource( $"{resourcePrefix}.{spriteName}.png", spriteWidth, spriteHeight); textures.Add(loadedSprite); } var regions = texture2D.PackTextures(textures.ToArray(), 2, hintAtlasTextureSize); // Now using loaded and packed textures, create the atlas with sprites UITextureAtlas newAtlas = ScriptableObject.CreateInstance <UITextureAtlas>(); var uiView = UIView.GetAView(); Material material = UnityEngine.Object.Instantiate(uiView.defaultAtlas.material); material.mainTexture = texture2D; newAtlas.material = material; newAtlas.name = atlasName; for (int i = 0; i < spriteNames.Length; i++) { var item = new UITextureAtlas.SpriteInfo { name = spriteNames[i], texture = textures[i], region = regions[i], }; newAtlas.AddSprite(item); } return(newAtlas); }
public override void Construct() { base.Construct(); answers = new List <QuestionKnowledgeAnswer>(); backgrounds = new List <StaticVisibleBoardElement>(); Rectangle qRect = new Rectangle(contentRect.X, contentRect.Y, contentRect.Width, contentRect.Height / 2); question = new TextBoardElement(qRect, content.question, QuestionManager.Instance().questionFont, "questknow_cur_title", ColorResources.Black, ZPosition + 2); backgrounds.Add(new StaticVisibleBoardElement(qRect, TextureResources.Get("WhiteBackground"), "questknow_cur_title_background", ZPosition + 1)); int gridSize = (int)Math.Sqrt(answerCount); Point answerSize = new Point(contentRect.Width / gridSize, contentRect.Height / (2 * gridSize)); Point answerMargin = new Point(margin / answerCount, margin / gridSize); int charInt = 65; for (int y = 0; y < gridSize; y++) { for (int x = 0; x < gridSize; x++) { Rectangle ansRect = new Rectangle( new Point( contentRect.Left + (x % gridSize) * (answerSize.X + margin / answerCount), contentRect.Center.Y + (y % gridSize) * answerSize.Y + margin / gridSize ), answerSize - answerMargin ); char answerChar = (char)charInt; string answerText = answerChar + ". " + content.answers[x + y * gridSize]; string answerUID = UID + "answer" + x.ToString() + y.ToString(); answers.Add(new QuestionKnowledgeAnswer(OnAnswerClicked, ansRect, answerText, QuestionManager.Instance().answerFont, answerUID, margin * 3 / 5, zPosition + 2)); backgrounds.Add(new StaticVisibleBoardElement(ansRect, TextureResources.Get("BorderBackground"), answerUID + "background", ZPosition + 1)); charInt++; } } }
private void _createSurfaceList( D3D9.Device d3d9Device, TextureResources textureResources ) { Debug.Assert( textureResources != null ); Debug.Assert( textureResources.BaseTexture != null ); // Make sure number of mips is right mipmapCount = textureResources.BaseTexture.LevelCount - 1; // Need to know static / dynamic BufferUsage bufusage; if ( ( ( Usage & TextureUsage.Dynamic ) != 0 ) && this._dynamicTextures ) { bufusage = BufferUsage.Dynamic; } else { bufusage = BufferUsage.Static; } if ( ( Usage & TextureUsage.RenderTarget ) != 0 ) { bufusage = (BufferUsage)( (int)bufusage | (int)TextureUsage.RenderTarget ); } var surfaceCount = FaceCount*( mipmapCount + 1 ); var updateOldList = this._surfaceList.Count == surfaceCount; if ( !updateOldList ) { // Create new list of surfaces _clearSurfaceList(); for ( var face = 0; face < FaceCount; ++face ) { for ( var mip = 0; mip <= MipmapCount; ++mip ) { var buffer = new D3D9HardwarePixelBuffer( bufusage, this ); this._surfaceList.Add( buffer ); } } } switch ( TextureType ) { case TextureType.OneD: case TextureType.TwoD: Debug.Assert( textureResources.NormalTexture != null ); // For all mipmaps, store surfaces as HardwarePixelBuffer for ( var mip = 0; mip <= MipmapCount; ++mip ) { var surface = textureResources.NormalTexture.GetSurfaceLevel( 0 ); var currPixelBuffer = _getSurfaceAtLevel( 0, mip ); if ( mip == 0 && requestedMipmapCount != 0 && ( usage & TextureUsage.AutoMipMap ) != 0 ) { currPixelBuffer.SetMipmapping( true, mipmapsHardwareGenerated ); } currPixelBuffer.Bind( d3d9Device, surface, textureResources.FSAASurface, this._hwGammaWriteSupported, fsaa, _name, textureResources.BaseTexture ); // decrement reference count, the GetSurfaceLevel call increments this // this is safe because the pixel buffer keeps a reference as well //TODO //surface.Release(); } break; case TextureType.CubeMap: Debug.Assert( textureResources.CubeTexture != null ); // For all faces and mipmaps, store surfaces as HardwarePixelBuffer for ( var face = 0; face < 6; ++face ) { for ( var mip = 0; mip <= MipmapCount; ++mip ) { var surface = textureResources.CubeTexture.GetCubeMapSurface( (D3D9.CubeMapFace)face, mip ); var currPixelBuffer = _getSurfaceAtLevel( face, mip ); if ( mip == 0 && requestedMipmapCount != 0 && ( usage & TextureUsage.AutoMipMap ) != 0 ) { currPixelBuffer.SetMipmapping( true, mipmapsHardwareGenerated ); } currPixelBuffer.Bind( d3d9Device, surface, textureResources.FSAASurface, this._hwGammaWriteSupported, fsaa, _name, textureResources.BaseTexture ); // decrement reference count, the GetSurfaceLevel call increments this // this is safe because the pixel buffer keeps a reference as well //TODO //surface.Release(); } } break; case TextureType.ThreeD: Debug.Assert( textureResources.VolumeTexture != null ); // For all mipmaps, store surfaces as HardwarePixelBuffer for ( var mip = 0; mip <= MipmapCount; ++mip ) { var volume = textureResources.VolumeTexture.GetVolumeLevel( mip ); var currPixelBuffer = _getSurfaceAtLevel( 0, mip ); currPixelBuffer.Bind( d3d9Device, volume, textureResources.BaseTexture ); if ( mip == 0 && requestedMipmapCount != 0 && ( usage & TextureUsage.AutoMipMap ) != 0 ) { currPixelBuffer.SetMipmapping( true, mipmapsHardwareGenerated ); } // decrement reference count, the GetSurfaceLevel call increments this // this is safe because the pixel buffer keeps a reference as well //TODO //volume.Release(); } break; } ; }
private TextureResources _allocateTextureResources( D3D9.Device d3d9Device ) { Debug.Assert( !this._mapDeviceToTextureResources.ContainsKey( d3d9Device ) ); var textureResources = new TextureResources(); this._mapDeviceToTextureResources.Add( d3d9Device, textureResources ); return textureResources; }
private static MeepleColor Color4Texture(Texture2D texture) { Enum.TryParse(TextureResources.Get(texture).Replace("Player", ""), out MeepleColor color); return(color); }
private void _setFinalAttributes( D3D9.Device d3d9Device, TextureResources textureResources, int width, int height, int depth, PixelFormat format ) { // set target texture attributes Height = height; Width = width; Depth = depth; this.format = format; // Update size (the final size, not including temp space) // this is needed in Resource class Size = calculateSize(); // say to the world what we are doing if ( Width != SrcWidth || Height != SrcHeight ) { LogManager.Instance.Write( "D3D9 : ***** Dimensions altered by the render system" ); LogManager.Instance.Write( "D3D9 : ***** Source image dimensions : {0}x{1}", SrcWidth, SrcHeight ); LogManager.Instance.Write( "D3D9 : ***** Texture dimensions : {0}x{1}", Width, Height ); } // Create list of subsurfaces for getBuffer() _createSurfaceList( d3d9Device, textureResources ); }
public void Hover() { texture = TextureResources.Get("PyramidFieldHover"); isHoverTarget = true; }
private static Texture2D Texture4Color(MeepleColor color) { return(TextureResources.Get("Player" + color.ToString())); }
public void BuildPyramidInSpace() { boardUnit = space.Width / boardUnitCount; floorRects[0] = new Rectangle(1, 1, 13, 13); floorRects[1] = new Rectangle(3, 3, 9, 9); floorRects[2] = new Rectangle(5, 5, 5, 5); floorRects[3] = new Rectangle(7, 7, 1, 1); backgroundRects[0] = new Rectangle(0, 0, 15, 15); backgroundRects[1] = new Rectangle(2, 2, 11, 11); backgroundRects[2] = new Rectangle(4, 4, 7, 7); backgroundRects[3] = new Rectangle(6, 6, 3, 3); floors[0] = new PyramidFloorDoubleCorner(7, floorRects[0], 4); floors[1] = new PyramidFloor(5, floorRects[1], 5); floors[2] = new PyramidFloor(4, floorRects[2], 6); foreach (PyramidFloor floor in floors) { CommandQueue.Queue(new AddToBoardCommand(floor.elements.ToArray())); } winningField = new PyramidFloorBoardElement(ToAbsolute(floorRects[3]), "winningfield", 1); CommandQueue.Queue(new AddToBoardCommand(winningField)); // setting background images for (int i = 1; i <= 4; i++) { string backgroundName = "PyramidBackgroundFloor" + i; StaticVisibleBoardElement background = new StaticVisibleBoardElement(ToAbsolute(backgroundRects[i - 1]), TextureResources.Get(backgroundName), backgroundName, i != 4 ? i : 8); CommandQueue.Queue(new AddToBoardCommand(background)); } AddElevationConnections(); AddRegularConnections(); MakeConnectionsVisible(); PlaceQuestionmarks(); }
/// <summary> /// Initializes a new instance of the <see cref="SpriteAtlas"/> class from resource names list. /// </summary> /// <param name="atlasName">Name for the new atlas.</param> /// <param name="resourcePrefix">Prefix to resource directory.</param> /// <param name="spriteNames">Array of paths to load also they become atlas keys.</param> /// <param name="spriteWidth">Hint width for texture loader (todo: get rid of this).</param> /// <param name="spriteHeight">Hint height for texture loader (todo: get rid of this).</param> /// <param name="hintAtlasTextureSize">Square texture with this side size is created.</param> public static UITextureAtlas CreateAtlas(string atlasName, string resourcePrefix, string[] spriteNames, int spriteWidth, int spriteHeight, int hintAtlasTextureSize) { Texture2D texture2D = new Texture2D( width: hintAtlasTextureSize, height: hintAtlasTextureSize, format: TextureFormat.ARGB32, mipmap: false); var loadedTextures = new List <Texture2D>(spriteNames.Length); var loadedSpriteNames = new List <string>(); // Load separate sprites and then pack it in a texture together foreach (string spriteName in spriteNames) { string resourceName = $"{resourcePrefix}.{spriteName}.png"; Log._Debug($"TextureUtil: Loading {resourceName} for sprite={spriteName}"); Texture2D loadedSprite = TextureResources.LoadDllResource( resourceName: resourceName, width: spriteWidth, height: spriteHeight); if (loadedSprite != null) { loadedTextures.Add(loadedSprite); loadedSpriteNames.Add(spriteName); // only take those which are loaded } else { Log.Error($"TextureUtil: Sprite load failed: {resourceName} for sprite={spriteName}"); } } var regions = texture2D.PackTextures( textures: loadedTextures.ToArray(), padding: 2, maximumAtlasSize: hintAtlasTextureSize); // Now using loaded and packed textures, create the atlas with sprites UITextureAtlas newAtlas = ScriptableObject.CreateInstance <UITextureAtlas>(); var uiView = UIView.GetAView(); Material material = UnityEngine.Object.Instantiate(uiView.defaultAtlas.material); material.mainTexture = texture2D; newAtlas.material = material; newAtlas.name = atlasName; for (int i = 0; i < spriteNames.Length; i++) { var item = new UITextureAtlas.SpriteInfo { name = loadedSpriteNames[i], texture = loadedTextures[i], region = regions[i], }; newAtlas.AddSprite(item); } return(newAtlas); }
public void Init() { // Load default renderPipelineResources / Material / Shader string HDRenderPipelinePath = HDUtils.GetHDRenderPipelinePath() + "Runtime/"; string CorePath = HDUtils.GetHDRenderPipelinePath() + "Runtime/Core/"; // HDUtils.GetCorePath(); // All CoreRP have been move to HDRP currently for out of preview of SRP and LW // Shaders shaders = new ShaderResources { // Defaults defaultPS = Load <Shader>(HDRenderPipelinePath + "Material/Lit/Lit.shader"), // Debug debugDisplayLatlongPS = Load <Shader>(HDRenderPipelinePath + "Debug/DebugDisplayLatlong.Shader"), debugViewMaterialGBufferPS = Load <Shader>(HDRenderPipelinePath + "Debug/DebugViewMaterialGBuffer.Shader"), debugViewTilesPS = Load <Shader>(HDRenderPipelinePath + "Debug/DebugViewTiles.Shader"), debugFullScreenPS = Load <Shader>(HDRenderPipelinePath + "Debug/DebugFullScreen.Shader"), debugColorPickerPS = Load <Shader>(HDRenderPipelinePath + "Debug/DebugColorPicker.Shader"), debugLightVolumePS = Load <Shader>(HDRenderPipelinePath + "Debug/DebugLightVolumes.Shader"), debugLightVolumeCS = Load <ComputeShader>(HDRenderPipelinePath + "Debug/DebugLightVolumes.compute"), // Lighting deferredPS = Load <Shader>(HDRenderPipelinePath + "Lighting/Deferred.Shader"), colorPyramidCS = Load <ComputeShader>(HDRenderPipelinePath + "RenderPipeline/RenderPass/ColorPyramid.compute"), colorPyramidPS = Load <Shader>(HDRenderPipelinePath + "RenderPipeline/RenderPass/ColorPyramidPS.Shader"), depthPyramidCS = Load <ComputeShader>(HDRenderPipelinePath + "RenderPipeline/RenderPass/DepthPyramid.compute"), copyChannelCS = Load <ComputeShader>(CorePath + "CoreResources/GPUCopy.compute"), applyDistortionCS = Load <ComputeShader>(HDRenderPipelinePath + "RenderPipeline/RenderPass/Distortion/ApplyDistorsion.compute"), screenSpaceReflectionsCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/ScreenSpaceLighting/ScreenSpaceReflections.compute"), // Lighting tile pass clearDispatchIndirectCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/cleardispatchindirect.compute"), buildDispatchIndirectCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/builddispatchindirect.compute"), buildScreenAABBCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/scrbound.compute"), buildPerTileLightListCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/lightlistbuild.compute"), buildPerBigTileLightListCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/lightlistbuild-bigtile.compute"), buildPerVoxelLightListCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/lightlistbuild-clustered.compute"), buildMaterialFlagsCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/materialflags.compute"), deferredCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/Deferred.compute"), screenSpaceShadowCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/Shadow/ScreenSpaceShadow.compute"), volumeVoxelizationCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/VolumetricLighting/VolumeVoxelization.compute"), volumetricLightingCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/VolumetricLighting/VolumetricLighting.compute"), deferredTilePS = Load <Shader>(HDRenderPipelinePath + "Lighting/LightLoop/DeferredTile.shader"), subsurfaceScatteringCS = Load <ComputeShader>(HDRenderPipelinePath + "Material/SubsurfaceScattering/SubsurfaceScattering.compute"), combineLightingPS = Load <Shader>(HDRenderPipelinePath + "Material/SubsurfaceScattering/CombineLighting.shader"), // General cameraMotionVectorsPS = Load <Shader>(HDRenderPipelinePath + "RenderPipeline/RenderPass/MotionVectors/CameraMotionVectors.shader"), copyStencilBufferPS = Load <Shader>(HDRenderPipelinePath + "ShaderLibrary/CopyStencilBuffer.shader"), copyDepthBufferPS = Load <Shader>(HDRenderPipelinePath + "ShaderLibrary/CopyDepthBuffer.shader"), blitPS = Load <Shader>(HDRenderPipelinePath + "ShaderLibrary/Blit.shader"), // Sky blitCubemapPS = Load <Shader>(HDRenderPipelinePath + "Sky/BlitCubemap.shader"), buildProbabilityTablesCS = Load <ComputeShader>(HDRenderPipelinePath + "Material/GGXConvolution/BuildProbabilityTables.compute"), computeGgxIblSampleDataCS = Load <ComputeShader>(HDRenderPipelinePath + "Material/GGXConvolution/ComputeGgxIblSampleData.compute"), GGXConvolvePS = Load <Shader>(HDRenderPipelinePath + "Material/GGXConvolution/GGXConvolve.shader"), charlieConvolvePS = Load <Shader>(HDRenderPipelinePath + "Material/Fabric/CharlieConvolve.shader"), opaqueAtmosphericScatteringPS = Load <Shader>(HDRenderPipelinePath + "Lighting/AtmosphericScattering/OpaqueAtmosphericScattering.shader"), hdriSkyPS = Load <Shader>(HDRenderPipelinePath + "Sky/HDRISky/HDRISky.shader"), integrateHdriSkyPS = Load <Shader>(HDRenderPipelinePath + "Sky/HDRISky/IntegrateHDRISky.shader"), proceduralSkyPS = Load <Shader>(HDRenderPipelinePath + "Sky/ProceduralSky/ProceduralSky.shader"), gradientSkyPS = Load <Shader>(HDRenderPipelinePath + "Sky/GradientSky/GradientSky.shader"), ambientProbeConvolutionCS = Load <ComputeShader>(HDRenderPipelinePath + "Sky/AmbientProbeConvolution.compute"), // Skybox/Cubemap is a builtin shader, must use Shader.Find to access it. It is fine because we are in the editor skyboxCubemapPS = Shader.Find("Skybox/Cubemap"), // Material preIntegratedFGD_GGXDisneyDiffusePS = Load <Shader>(HDRenderPipelinePath + "Material/PreIntegratedFGD/PreIntegratedFGD_GGXDisneyDiffuse.shader"), preIntegratedFGD_CharlieFabricLambertPS = Load <Shader>(HDRenderPipelinePath + "Material/PreIntegratedFGD/PreIntegratedFGD_CharlieFabricLambert.shader"), preIntegratedFGD_CookTorrancePS = Load <Shader>(HDRenderPipelinePath + "Material/AxF/PreIntegratedFGD_CookTorrance.shader"), preIntegratedFGD_WardPS = Load <Shader>(HDRenderPipelinePath + "Material/AxF/PreIntegratedFGD_Ward.shader"), // Utilities / Core encodeBC6HCS = Load <ComputeShader>(CorePath + "CoreResources/EncodeBC6H.compute"), cubeToPanoPS = Load <Shader>(CorePath + "CoreResources/CubeToPano.shader"), blitCubeTextureFacePS = Load <Shader>(CorePath + "CoreResources/BlitCubeTextureFace.shader"), filterAreaLightCookiesPS = Load <Shader>(CorePath + "CoreResources/FilterAreaLightCookies.shader"), // Shadow shadowClearPS = Load <Shader>(HDRenderPipelinePath + "Lighting/Shadow/ShadowClear.shader"), shadowBlurMomentsCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/Shadow/ShadowBlurMoments.compute"), debugHDShadowMapPS = Load <Shader>(HDRenderPipelinePath + "Lighting/Shadow/DebugDisplayHDShadowMap.shader"), momentShadowsCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/Shadow/MomentShadows.compute"), // Decal decalNormalBufferPS = Load <Shader>(HDRenderPipelinePath + "Material/Decal/DecalNormalBuffer.shader"), // Ambient occlusion aoDownsample1CS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/ScreenSpaceLighting/AmbientOcclusionDownsample1.compute"), aoDownsample2CS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/ScreenSpaceLighting/AmbientOcclusionDownsample2.compute"), aoRenderCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/ScreenSpaceLighting/AmbientOcclusionRender.compute"), aoUpsampleCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/ScreenSpaceLighting/AmbientOcclusionUpsample.compute"), // MSAA depthValuesPS = Load <Shader>(HDRenderPipelinePath + "RenderPipeline/RenderPass/MSAA/DepthValues.shader"), colorResolvePS = Load <Shader>(HDRenderPipelinePath + "RenderPipeline/RenderPass/MSAA/ColorResolve.shader"), aoResolvePS = Load <Shader>(HDRenderPipelinePath + "RenderPipeline/RenderPass/MSAA/AmbientOcclusionResolve.shader"), // Post-processing exposureCS = Load <ComputeShader>(HDRenderPipelinePath + "PostProcessing/Shaders/Exposure.compute"), uberPostCS = Load <ComputeShader>(HDRenderPipelinePath + "PostProcessing/Shaders/UberPost.compute"), lutBuilder3DCS = Load <ComputeShader>(HDRenderPipelinePath + "PostProcessing/Shaders/LutBuilder3D.compute"), temporalAntialiasingCS = Load <ComputeShader>(HDRenderPipelinePath + "PostProcessing/Shaders/TemporalAntialiasing.compute"), depthOfFieldKernelCS = Load <ComputeShader>(HDRenderPipelinePath + "PostProcessing/Shaders/DepthOfFieldKernel.compute"), depthOfFieldCoCCS = Load <ComputeShader>(HDRenderPipelinePath + "PostProcessing/Shaders/DepthOfFieldCoC.compute"), depthOfFieldCoCReprojectCS = Load <ComputeShader>(HDRenderPipelinePath + "PostProcessing/Shaders/DepthOfFieldCoCReproject.compute"), depthOfFieldDilateCS = Load <ComputeShader>(HDRenderPipelinePath + "PostProcessing/Shaders/DepthOfFieldCoCDilate.compute"), depthOfFieldMipCS = Load <ComputeShader>(HDRenderPipelinePath + "PostProcessing/Shaders/DepthOfFieldMip.compute"), depthOfFieldMipSafeCS = Load <ComputeShader>(HDRenderPipelinePath + "PostProcessing/Shaders/DepthOfFieldMipSafe.compute"), depthOfFieldPrefilterCS = Load <ComputeShader>(HDRenderPipelinePath + "PostProcessing/Shaders/DepthOfFieldPrefilter.compute"), depthOfFieldTileMaxCS = Load <ComputeShader>(HDRenderPipelinePath + "PostProcessing/Shaders/DepthOfFieldTileMax.compute"), depthOfFieldGatherCS = Load <ComputeShader>(HDRenderPipelinePath + "PostProcessing/Shaders/DepthOfFieldGather.compute"), depthOfFieldCombineCS = Load <ComputeShader>(HDRenderPipelinePath + "PostProcessing/Shaders/DepthOfFieldCombine.compute"), motionBlurTileGenCS = Load <ComputeShader>(HDRenderPipelinePath + "PostProcessing/Shaders/MotionBlurTilePass.compute"), motionBlurCS = Load <ComputeShader>(HDRenderPipelinePath + "PostProcessing/Shaders/MotionBlur.compute"), motionBlurVelocityPrepCS = Load <ComputeShader>(HDRenderPipelinePath + "PostProcessing/Shaders/MotionBlurVelocityPrep.compute"), paniniProjectionCS = Load <ComputeShader>(HDRenderPipelinePath + "PostProcessing/Shaders/PaniniProjection.compute"), bloomPrefilterCS = Load <ComputeShader>(HDRenderPipelinePath + "PostProcessing/Shaders/BloomPrefilter.compute"), bloomBlurCS = Load <ComputeShader>(HDRenderPipelinePath + "PostProcessing/Shaders/BloomBlur.compute"), bloomUpsampleCS = Load <ComputeShader>(HDRenderPipelinePath + "PostProcessing/Shaders/BloomUpsample.compute"), FXAACS = Load <ComputeShader>(HDRenderPipelinePath + "PostProcessing/Shaders/FXAA.compute"), finalPassPS = Load <Shader>(HDRenderPipelinePath + "PostProcessing/Shaders/FinalPass.shader"), #if ENABLE_RAYTRACING aoRaytracing = Load <RaytracingShader>(HDRenderPipelinePath + "RenderPipeline/Raytracing/Shaders/RaytracingAmbientOcclusion.raytrace"), reflectionRaytracing = Load <RaytracingShader>(HDRenderPipelinePath + "RenderPipeline/Raytracing/Shaders/RaytracingReflections.raytrace"), shadowsRaytracing = Load <RaytracingShader>(HDRenderPipelinePath + "RenderPipeline/Raytracing/Shaders/RaytracingAreaShadows.raytrace"), areaBillateralFilterCS = Load <ComputeShader>(HDRenderPipelinePath + "RenderPipeline/Raytracing/Shaders/AreaBilateralShadow.compute"), jointBilateralFilterCS = Load <ComputeShader>(HDRenderPipelinePath + "RenderPipeline/Raytracing/Shaders/JointBilateralFilter.compute"), reflectionBilateralFilterCS = Load <ComputeShader>(HDRenderPipelinePath + "RenderPipeline/Raytracing/Shaders/RaytracingReflectionFilter.compute"), lightClusterBuildCS = Load <ComputeShader>(HDRenderPipelinePath + "RenderPipeline/Raytracing/Shaders/RaytracingLightCluster.compute"), lightClusterDebugCS = Load <ComputeShader>(HDRenderPipelinePath + "RenderPipeline/Raytracing/Shaders/DebugLightCluster.compute"), countTracedRays = Load <ComputeShader>(HDRenderPipelinePath + "RenderPipeline/Raytracing/Shaders/CountTracedRays.compute"), debugViewRayCountPS = Load <Shader>(HDRenderPipelinePath + "RenderPipeline/Raytracing/Shaders/DebugViewRayCount.shader") #endif }; // Materials materials = new MaterialResources { }; // Textures textures = new TextureResources { // Debug debugFontTex = Load <Texture2D>(HDRenderPipelinePath + "RenderPipelineResources/Texture/DebugFont.tga"), colorGradient = Load <Texture2D>(HDRenderPipelinePath + "Debug/ColorGradient.png"), filmGrainTex = new[] { // These need to stay in this specific order! Load <Texture2D>(HDRenderPipelinePath + "RenderPipelineResources/Texture/FilmGrain/Thin01.png"), Load <Texture2D>(HDRenderPipelinePath + "RenderPipelineResources/Texture/FilmGrain/Thin02.png"), Load <Texture2D>(HDRenderPipelinePath + "RenderPipelineResources/Texture/FilmGrain/Medium01.png"), Load <Texture2D>(HDRenderPipelinePath + "RenderPipelineResources/Texture/FilmGrain/Medium02.png"), Load <Texture2D>(HDRenderPipelinePath + "RenderPipelineResources/Texture/FilmGrain/Medium03.png"), Load <Texture2D>(HDRenderPipelinePath + "RenderPipelineResources/Texture/FilmGrain/Medium04.png"), Load <Texture2D>(HDRenderPipelinePath + "RenderPipelineResources/Texture/FilmGrain/Medium05.png"), Load <Texture2D>(HDRenderPipelinePath + "RenderPipelineResources/Texture/FilmGrain/Medium06.png"), Load <Texture2D>(HDRenderPipelinePath + "RenderPipelineResources/Texture/FilmGrain/Large01.png"), Load <Texture2D>(HDRenderPipelinePath + "RenderPipelineResources/Texture/FilmGrain/Large02.png") }, blueNoise16LTex = new Texture2D[32], blueNoise16RGBTex = new Texture2D[32], }; // ShaderGraphs shaderGraphs = new ShaderGraphResources { }; // Fill-in blue noise textures for (int i = 0; i < 32; i++) { textures.blueNoise16LTex[i] = Load <Texture2D>(HDRenderPipelinePath + "RenderPipelineResources/Texture/BlueNoise16/L/LDR_LLL1_" + i + ".png"); textures.blueNoise16RGBTex[i] = Load <Texture2D>(HDRenderPipelinePath + "RenderPipelineResources/Texture/BlueNoise16/RGB/LDR_RGB1_" + i + ".png"); } // Coherent noise textures textures.owenScrambledTex = Load <Texture2D>(HDRenderPipelinePath + "RenderPipelineResources/Texture/CoherentNoise/OwenScrambledNoise.png"); textures.scramblingTex = Load <Texture2D>(HDRenderPipelinePath + "RenderPipelineResources/Texture/CoherentNoise/ScrambleNoise.png"); }
public ArrowAnimatable(Rectangle position, string UID, int zPosition) : base(position, TextureResources.Get("arrow"), UID, zPosition) { distance = defaultDistance; Setup(); }
public NamePlateFoes(Rectangle position, SpriteFont fontSmall, SpriteFont fontBig, string UID, int zPosition = 0) : base(position, TextureResources.Get("NamePlateBackgroundLongRed"), UID, zPosition) { current = this; foesNames = new List <TextBoardElement>(); this.fontBig = fontBig; contentRect = new Rectangle(position.Location + margin, position.Size - margin - margin); Rectangle foesRect = new Rectangle(contentRect.Location.X, contentRect.Location.Y, contentRect.Width, contentRect.Height / 6); foes = new TextBoardElement(foesRect, "Your foes are:", fontSmall, "namePlateFoes", ColorResources.White, zPosition + 1, TextBoardElement.Alignment.LeftBottom); CommandQueue.Queue(new AddToBoardCommand(foes)); UpdateColor(); }
/// <summary> /// Initializes a new instance of the <see cref="UITextureAtlas"/> class from resource names list. /// NOTE: For UI sprites loading use <see cref="U.AtlasBuilder"/> instead, do not call this. /// </summary> /// <param name="atlasName">Name for the new atlas.</param> /// <param name="resourcePrefix">Prefix to resource directory.</param> /// <param name="spriteDefs">Names of textures and sizes to load.</param> /// <param name="atlasSizeHint">Texture with this side size is created.</param> public static UITextureAtlas CreateAtlas(string atlasName, string resourcePrefix, U.AtlasSpriteDef[] spriteDefs, IntVector2 atlasSizeHint) { var loadedTextures = new List <Texture2D>(spriteDefs.Length); var loadedSpriteNames = new List <string>(); #if DEBUG bool debugResourceLoading = DebugSwitch.ResourceLoading.Get(); #else const bool debugResourceLoading = false; #endif // Load separate sprites and then pack it in a texture together foreach (U.AtlasSpriteDef spriteDef in spriteDefs) { // Allow spritedef resouce prefix to override prefix given to this func string prefix = resourcePrefix; string resourceName; if (spriteDef.Name.StartsWith("/")) { // If sprite name starts with /, use it as full resource path without .PNG resourceName = $"{spriteDef.Name.Substring(1)}.png"; } else { // Otherwise use prefix + sprite name + .PNG resourceName = $"{prefix}.{spriteDef.Name}.png"; } //-------------------------- // Try loading the texture //-------------------------- if (debugResourceLoading) { Log._Debug($"TextureUtil: Loading {resourceName} for sprite={spriteDef.Name}"); } Texture2D tex = TextureResources.LoadDllResource( resourceName: resourceName, size: spriteDef.Size); if (tex != null) { loadedTextures.Add(tex); loadedSpriteNames.Add(spriteDef.Name); // only take those which are loaded } // No error reporting, it is done in LoadDllResource } if (debugResourceLoading) { Log._Debug( $"TextureUtil: Atlas textures loaded, in {spriteDefs.Length}, " + $"success {loadedTextures.Count}"); } return(PackTextures(atlasName, atlasSizeHint, loadedTextures, loadedSpriteNames)); }
public PyramidFloorBoardElement(Rectangle position, string UID, int zPosition = 0) : base(position, TextureResources.Get("PyramidField"), UID, zPosition) { connectedFields = new List <PyramidFloorBoardElement>(); }
private void _freeTextureResources( D3D9.Device d3d9Device, TextureResources textureResources ) { //Entering critical section this.LockDeviceAccess(); // Release surfaces from each mip level. foreach ( var it in this._surfaceList ) { it.ReleaseSurfaces( d3d9Device ); } // Release the rest of the resources. textureResources.NormalTexture.SafeDispose(); textureResources.NormalTexture = null; textureResources.CubeTexture.SafeDispose(); textureResources.CubeTexture = null; textureResources.VolumeTexture.SafeDispose(); textureResources.VolumeTexture = null; textureResources.BaseTexture.SafeDispose(); textureResources.BaseTexture = null; textureResources.FSAASurface.SafeDispose(); textureResources.FSAASurface = null; //Leaving critical section this.UnlockDeviceAccess(); }
private void TextureToDefault() { texture = TextureResources.Get(isStartingField ? "PyramidFieldStart" : "PyramidField"); }
private bool drawSpeedLimitHandles(ushort segmentId, ref NetSegment segment, bool viewOnly, ref Vector3 camPos) { if (viewOnly && !Options.speedLimitsOverlay) { return(false); } var center = segment.m_bounds.center; var netManager = Singleton <NetManager> .instance; var hovered = false; var speedLimitToSet = viewOnly ? -1f : currentPaletteSpeedLimit; bool showPerLane = showLimitsPerLane; if (!viewOnly) { showPerLane = showLimitsPerLane ^ (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)); } // US signs are rectangular, all other are round var speedLimitSignVerticalScale = SpeedLimit.GetVerticalTextureScale(); if (showPerLane) { // show individual speed limit handle per lane int numDirections; var numLanes = TrafficManagerTool.GetSegmentNumVehicleLanes(segmentId, null, out numDirections, SpeedLimitManager.VEHICLE_TYPES); var segmentInfo = segment.Info; var yu = (segment.m_endDirection - segment.m_startDirection).normalized; var xu = Vector3.Cross(yu, new Vector3(0, 1f, 0)).normalized; /*if ((segment.m_flags & NetSegment.Flags.Invert) == NetSegment.Flags.None) { * xu = -xu; * }*/ var f = viewOnly ? 4f : 7f; // reserved sign size in game coordinates var zero = center - 0.5f * (float)(numLanes - 1 + numDirections - 1) * f * xu; uint x = 0; var guiColor = GUI.color; var sortedLanes = Constants.ServiceFactory.NetService.GetSortedLanes( segmentId, ref segment, null, SpeedLimitManager.LANE_TYPES, SpeedLimitManager.VEHICLE_TYPES); var onlyMonorailLanes = sortedLanes.Count > 0; if (!viewOnly) { foreach (LanePos laneData in sortedLanes) { var laneIndex = laneData.laneIndex; var laneInfo = segmentInfo.m_lanes[laneIndex]; if ((laneInfo.m_vehicleType & VehicleInfo.VehicleType.Monorail) == VehicleInfo.VehicleType.None) { onlyMonorailLanes = false; break; } } } var directions = new HashSet <NetInfo.Direction>(); var sortedLaneIndex = -1; foreach (LanePos laneData in sortedLanes) { ++sortedLaneIndex; uint laneId = laneData.laneId; byte laneIndex = laneData.laneIndex; NetInfo.Lane laneInfo = segmentInfo.m_lanes[laneIndex]; if (!directions.Contains(laneInfo.m_finalDirection)) { if (directions.Count > 0) { ++x; // space between different directions } directions.Add(laneInfo.m_finalDirection); } var laneSpeedLimit = SpeedLimitManager.Instance.GetCustomSpeedLimit(laneId); var hoveredHandle = MainTool.DrawGenericOverlayGridTexture( TextureResources.GetSpeedLimitTexture(laneSpeedLimit), camPos, zero, f, f, xu, yu, x, 0, speedLimitSignSize, speedLimitSignSize * speedLimitSignVerticalScale, !viewOnly); if (!viewOnly && !onlyMonorailLanes && (laneInfo.m_vehicleType & VehicleInfo.VehicleType.Monorail) != VehicleInfo.VehicleType.None) { MainTool.DrawStaticSquareOverlayGridTexture( TextureResources.VehicleInfoSignTextures[ LegacyExtVehicleType.ToNew(ExtVehicleType.PassengerTrain) ], camPos, zero, f, xu, yu, x, 1, speedLimitSignSize); } if (hoveredHandle) { hovered = true; } if (hoveredHandle && Input.GetMouseButton(0) && !IsCursorInPanel()) { SpeedLimitManager.Instance.SetSpeedLimit(segmentId, laneIndex, laneInfo, laneId, speedLimitToSet); if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { SegmentLaneTraverser.Traverse(segmentId, SegmentTraverser.TraverseDirection.AnyDirection, SegmentTraverser.TraverseSide.AnySide, SegmentLaneTraverser.LaneStopCriterion.LaneCount, SegmentTraverser.SegmentStopCriterion.Junction, SpeedLimitManager.LANE_TYPES, SpeedLimitManager.VEHICLE_TYPES, delegate(SegmentLaneVisitData data) { if (data.segVisitData.initial) { return(true); } if (sortedLaneIndex != data.sortedLaneIndex) { return(true); } Constants.ServiceFactory.NetService.ProcessSegment(data.segVisitData.curSeg.segmentId, delegate(ushort curSegmentId, ref NetSegment curSegment) { NetInfo.Lane curLaneInfo = curSegment.Info.m_lanes[data.curLanePos.laneIndex]; SpeedLimitManager.Instance.SetSpeedLimit(curSegmentId, data.curLanePos.laneIndex, curLaneInfo, data.curLanePos.laneId, speedLimitToSet); return(true); }); return(true); }); } } ++x; } } else { // draw speedlimits over mean middle points of lane beziers Dictionary <NetInfo.Direction, Vector3> segCenter; if (!segmentCenterByDir.TryGetValue(segmentId, out segCenter)) { segCenter = new Dictionary <NetInfo.Direction, Vector3>(); segmentCenterByDir.Add(segmentId, segCenter); TrafficManagerTool.CalculateSegmentCenterByDir(segmentId, segCenter); } foreach (KeyValuePair <NetInfo.Direction, Vector3> e in segCenter) { Vector3 screenPos; var visible = MainTool.WorldToScreenPoint(e.Value, out screenPos); if (!visible) { continue; } var zoom = 1.0f / (e.Value - camPos).magnitude * 100f * MainTool.GetBaseZoom(); var size = (viewOnly ? 0.8f : 1f) * speedLimitSignSize * zoom; var guiColor = GUI.color; var boundingBox = new Rect(screenPos.x - (size / 2), screenPos.y - (size / 2), size, size * speedLimitSignVerticalScale); var hoveredHandle = !viewOnly && TrafficManagerTool.IsMouseOver(boundingBox); guiColor.a = MainTool.GetHandleAlpha(hoveredHandle); if (hoveredHandle) { // mouse hovering over sign hovered = true; } // Draw something right here, the road sign texture GUI.color = guiColor; var displayLimit = SpeedLimitManager.Instance.GetCustomSpeedLimit(segmentId, e.Key); var tex = TextureResources.GetSpeedLimitTexture(displayLimit); GUI.DrawTexture(boundingBox, tex); if (hoveredHandle && Input.GetMouseButton(0) && !IsCursorInPanel()) { // change the speed limit to the selected one //Log._Debug($"Setting speed limit of segment {segmentId}, dir {e.Key.ToString()} to {speedLimitToSet}"); SpeedLimitManager.Instance.SetSpeedLimit(segmentId, e.Key, currentPaletteSpeedLimit); if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { NetInfo.Direction normDir = e.Key; if ((netManager.m_segments.m_buffer[segmentId].m_flags & NetSegment.Flags.Invert) != NetSegment.Flags.None) { normDir = NetInfo.InvertDirection(normDir); } SegmentLaneTraverser.Traverse(segmentId, SegmentTraverser.TraverseDirection.AnyDirection, SegmentTraverser.TraverseSide.AnySide, SegmentLaneTraverser.LaneStopCriterion.LaneCount, SegmentTraverser.SegmentStopCriterion.Junction, SpeedLimitManager.LANE_TYPES, SpeedLimitManager.VEHICLE_TYPES, delegate(SegmentLaneVisitData data) { if (data.segVisitData.initial) { return(true); } bool reverse = data.segVisitData.viaStartNode == data.segVisitData.viaInitialStartNode; ushort otherSegmentId = data.segVisitData.curSeg.segmentId; NetInfo otherSegmentInfo = netManager.m_segments.m_buffer[otherSegmentId].Info; uint laneId = data.curLanePos.laneId; byte laneIndex = data.curLanePos.laneIndex; NetInfo.Lane laneInfo = otherSegmentInfo.m_lanes[laneIndex]; NetInfo.Direction otherNormDir = laneInfo.m_finalDirection; if ((netManager.m_segments.m_buffer[otherSegmentId].m_flags & NetSegment.Flags.Invert) != NetSegment.Flags.None ^ reverse) { otherNormDir = NetInfo.InvertDirection(otherNormDir); } if (otherNormDir == normDir) { SpeedLimitManager.Instance.SetSpeedLimit(otherSegmentId, laneInfo.m_finalDirection, speedLimitToSet); } return(true); }); } } guiColor.a = 1f; GUI.color = guiColor; } } return(hovered); }
/// <summary> /// The window for setting the defaullt speeds per road type /// </summary> /// <param name="num"></param> private void _guiDefaultsWindow(int num) { var mainNetInfos = SpeedLimitManager.Instance.GetCustomizableNetInfos(); if (mainNetInfos == null || mainNetInfos.Count <= 0) { Log._Debug($"mainNetInfos={mainNetInfos?.Count}"); DragWindow(ref defaultsWindowRect); return; } bool updateRoadTex = false; if (currentInfoIndex < 0 || currentInfoIndex >= mainNetInfos.Count) { currentInfoIndex = 0; updateRoadTex = true; Log._Debug($"set currentInfoIndex to 0"); } NetInfo info = mainNetInfos[currentInfoIndex]; if (updateRoadTex) { UpdateRoadTex(info); } if (currentSpeedLimit < 0f) { currentSpeedLimit = SpeedLimitManager.Instance.GetCustomNetInfoSpeedLimit(info); Log._Debug($"set currentSpeedLimit to {currentSpeedLimit}"); } //Log._Debug($"currentInfoIndex={currentInfoIndex} currentSpeedLimitIndex={currentSpeedLimitIndex}"); // Road type label GUILayout.BeginVertical(); GUILayout.Space(10); GUILayout.Label(Translation.GetString("Road_type") + ":"); GUILayout.EndVertical(); // switch between NetInfos GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); if (GUILayout.Button("←", GUILayout.Width(50))) { currentInfoIndex = (currentInfoIndex + mainNetInfos.Count - 1) % mainNetInfos.Count; info = mainNetInfos[currentInfoIndex]; currentSpeedLimit = SpeedLimitManager.Instance.GetCustomNetInfoSpeedLimit(info); UpdateRoadTex(info); } GUILayout.FlexibleSpace(); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); // NetInfo thumbnail GUILayout.Box(RoadTexture, GUILayout.Height(GuiSpeedSignSize)); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); if (GUILayout.Button("→", GUILayout.Width(50))) { currentInfoIndex = (currentInfoIndex + 1) % mainNetInfos.Count; info = mainNetInfos[currentInfoIndex]; currentSpeedLimit = SpeedLimitManager.Instance.GetCustomNetInfoSpeedLimit(info); UpdateRoadTex(info); } GUILayout.FlexibleSpace(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); var centeredTextStyle = new GUIStyle("label") { alignment = TextAnchor.MiddleCenter }; // NetInfo name GUILayout.Label(info.name, centeredTextStyle); // Default speed limit label GUILayout.BeginVertical(); GUILayout.Space(10); GUILayout.Label(Translation.GetString("Default_speed_limit") + ":"); GUILayout.EndVertical(); // switch between speed limits GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); if (GUILayout.Button("←", GUILayout.Width(50))) { // currentSpeedLimit = (currentSpeedLimitIndex + SpeedLimitManager.Instance.AvailableSpeedLimits.Count - 1) % SpeedLimitManager.Instance.AvailableSpeedLimits.Count; currentSpeedLimit = SpeedLimit.GetPrevious(currentSpeedLimit); } GUILayout.FlexibleSpace(); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); // speed limit sign GUILayout.Box(TextureResources.GetSpeedLimitTexture(currentSpeedLimit), GUILayout.Width(GuiSpeedSignSize), GUILayout.Height(GuiSpeedSignSize)); GUILayout.Label(GlobalConfig.Instance.Main.DisplaySpeedLimitsMph ? Translation.GetString("Miles_per_hour") : Translation.GetString("Kilometers_per_hour")); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); if (GUILayout.Button("→", GUILayout.Width(50))) { // currentSpeedLimitIndex = (currentSpeedLimitIndex + 1) % SpeedLimitManager.Instance.AvailableSpeedLimits.Count; currentSpeedLimit = SpeedLimit.GetNext(currentSpeedLimit); } GUILayout.FlexibleSpace(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); // Save & Apply GUILayout.BeginVertical(); GUILayout.Space(10); GUILayout.BeginHorizontal(); // Close button. TODO: Make more visible or obey 'Esc' pressed or something GUILayout.FlexibleSpace(); if (GUILayout.Button("X", GUILayout.Width(80))) { defaultsWindowVisible = false; } GUILayout.FlexibleSpace(); if (GUILayout.Button(Translation.GetString("Save"), GUILayout.Width(70))) { SpeedLimitManager.Instance.FixCurrentSpeedLimits(info); SpeedLimitManager.Instance.SetCustomNetInfoSpeedLimit(info, currentSpeedLimit); } GUILayout.FlexibleSpace(); if (GUILayout.Button( Translation.GetString("Save") + " & " + Translation.GetString("Apply"), GUILayout.Width(160))) { SpeedLimitManager.Instance.SetCustomNetInfoSpeedLimit(info, currentSpeedLimit); SpeedLimitManager.Instance.ClearCurrentSpeedLimits(info); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); DragWindow(ref defaultsWindowRect); }
public void Init() { // Load default renderPipelineResources / Material / Shader string HDRenderPipelinePath = HDUtils.GetHDRenderPipelinePath() + "Runtime/"; string CorePath = HDUtils.GetHDRenderPipelinePath() + "Runtime/Core/"; // HDUtils.GetCorePath(); // All CoreRP have been move to HDRP currently for out of preview of SRP and LW // Shaders shaders = new ShaderResources { // Defaults defaultPS = Load <Shader>(HDRenderPipelinePath + "Material/Lit/Lit.shader"), // Debug debugDisplayLatlongPS = Load <Shader>(HDRenderPipelinePath + "Debug/DebugDisplayLatlong.Shader"), debugViewMaterialGBufferPS = Load <Shader>(HDRenderPipelinePath + "Debug/DebugViewMaterialGBuffer.Shader"), debugViewTilesPS = Load <Shader>(HDRenderPipelinePath + "Debug/DebugViewTiles.Shader"), debugFullScreenPS = Load <Shader>(HDRenderPipelinePath + "Debug/DebugFullScreen.Shader"), debugColorPickerPS = Load <Shader>(HDRenderPipelinePath + "Debug/DebugColorPicker.Shader"), debugLightVolumePS = Load <Shader>(HDRenderPipelinePath + "Debug/DebugLightVolumes.Shader"), debugLightVolumeCS = Load <ComputeShader>(HDRenderPipelinePath + "Debug/DebugLightVolumes.compute"), // Lighting deferredPS = Load <Shader>(HDRenderPipelinePath + "Lighting/Deferred.Shader"), colorPyramidCS = Load <ComputeShader>(HDRenderPipelinePath + "RenderPipeline/RenderPass/ColorPyramid.compute"), depthPyramidCS = Load <ComputeShader>(HDRenderPipelinePath + "RenderPipeline/RenderPass/DepthPyramid.compute"), copyChannelCS = Load <ComputeShader>(CorePath + "CoreResources/GPUCopy.compute"), applyDistortionCS = Load <ComputeShader>(HDRenderPipelinePath + "RenderPipeline/RenderPass/Distortion/ApplyDistorsion.compute"), screenSpaceReflectionsCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/ScreenSpaceLighting/ScreenSpaceReflections.compute"), // Lighting tile pass clearDispatchIndirectCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/cleardispatchindirect.compute"), buildDispatchIndirectCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/builddispatchindirect.compute"), buildScreenAABBCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/scrbound.compute"), buildPerTileLightListCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/lightlistbuild.compute"), buildPerBigTileLightListCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/lightlistbuild-bigtile.compute"), buildPerVoxelLightListCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/lightlistbuild-clustered.compute"), buildMaterialFlagsCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/materialflags.compute"), deferredCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/Deferred.compute"), screenSpaceShadowCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/Shadow/ScreenSpaceShadow.compute"), volumeVoxelizationCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/VolumetricLighting/VolumeVoxelization.compute"), volumetricLightingCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/VolumetricLighting/VolumetricLighting.compute"), subsurfaceScatteringCS = Load <ComputeShader>(HDRenderPipelinePath + "Material/SubsurfaceScattering/SubsurfaceScattering.compute"), combineLightingPS = Load <Shader>(HDRenderPipelinePath + "Material/SubsurfaceScattering/CombineLighting.shader"), // General cameraMotionVectorsPS = Load <Shader>(HDRenderPipelinePath + "RenderPipeline/RenderPass/MotionVectors/CameraMotionVectors.shader"), copyStencilBufferPS = Load <Shader>(HDRenderPipelinePath + "ShaderLibrary/CopyStencilBuffer.shader"), copyDepthBufferPS = Load <Shader>(HDRenderPipelinePath + "ShaderLibrary/CopyDepthBuffer.shader"), blitPS = Load <Shader>(HDRenderPipelinePath + "ShaderLibrary/Blit.shader"), // Sky blitCubemapPS = Load <Shader>(HDRenderPipelinePath + "Sky/BlitCubemap.shader"), buildProbabilityTablesCS = Load <ComputeShader>(HDRenderPipelinePath + "Material/GGXConvolution/BuildProbabilityTables.compute"), computeGgxIblSampleDataCS = Load <ComputeShader>(HDRenderPipelinePath + "Material/GGXConvolution/ComputeGgxIblSampleData.compute"), GGXConvolvePS = Load <Shader>(HDRenderPipelinePath + "Material/GGXConvolution/GGXConvolve.shader"), charlieConvolvePS = Load <Shader>(HDRenderPipelinePath + "Material/Fabric/CharlieConvolve.shader"), opaqueAtmosphericScatteringPS = Load <Shader>(HDRenderPipelinePath + "Lighting/AtmosphericScattering/OpaqueAtmosphericScattering.shader"), hdriSkyPS = Load <Shader>(HDRenderPipelinePath + "Sky/HDRISky/HDRISky.shader"), integrateHdriSkyPS = Load <Shader>(HDRenderPipelinePath + "Sky/HDRISky/IntegrateHDRISky.shader"), proceduralSkyPS = Load <Shader>(HDRenderPipelinePath + "Sky/ProceduralSky/ProceduralSky.shader"), gradientSkyPS = Load <Shader>(HDRenderPipelinePath + "Sky/GradientSky/GradientSky.shader"), // Skybox/Cubemap is a builtin shader, must use Shader.Find to access it. It is fine because we are in the editor skyboxCubemapPS = Shader.Find("Skybox/Cubemap"), // Material preIntegratedFGD_GGXDisneyDiffusePS = Load <Shader>(HDRenderPipelinePath + "Material/PreIntegratedFGD/PreIntegratedFGD_GGXDisneyDiffuse.shader"), preIntegratedFGD_CharlieFabricLambertPS = Load <Shader>(HDRenderPipelinePath + "Material/PreIntegratedFGD/PreIntegratedFGD_CharlieFabricLambert.shader"), preIntegratedFGD_CookTorrancePS = Load <Shader>(HDRenderPipelinePath + "Material/AxF/PreIntegratedFGD_CookTorrance.shader"), preIntegratedFGD_WardPS = Load <Shader>(HDRenderPipelinePath + "Material/AxF/PreIntegratedFGD_Ward.shader"), // Utilities / Core encodeBC6HCS = Load <ComputeShader>(CorePath + "CoreResources/EncodeBC6H.compute"), cubeToPanoPS = Load <Shader>(CorePath + "CoreResources/CubeToPano.shader"), blitCubeTextureFacePS = Load <Shader>(CorePath + "CoreResources/BlitCubeTextureFace.shader"), // Shadow shadowClearPS = Load <Shader>(HDRenderPipelinePath + "Lighting/Shadow/ShadowClear.shader"), shadowBlurMomentsCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/Shadow/ShadowBlurMoments.compute"), debugHDShadowMapPS = Load <Shader>(HDRenderPipelinePath + "Lighting/Shadow/DebugDisplayHDShadowMap.shader"), // Decal decalNormalBufferPS = Load <Shader>(HDRenderPipelinePath + "Material/Decal/DecalNormalBuffer.shader"), // MSAA depthValuesPS = Load <Shader>(HDRenderPipelinePath + "RenderPipeline/RenderPass/MSAA/DepthValues.shader"), aoResolvePS = Load <Shader>(HDRenderPipelinePath + "RenderPipeline/RenderPass/MSAA/AOResolve.shader"), colorResolvePS = Load <Shader>(HDRenderPipelinePath + "RenderPipeline/RenderPass/MSAA/ColorResolve.shader"), }; // Materials materials = new MaterialResources { // Defaults defaultDiffuseMat = Load <Material>(HDRenderPipelinePath + "RenderPipelineResources/Material/DefaultHDMaterial.mat"), defaultMirrorMat = Load <Material>(HDRenderPipelinePath + "RenderPipelineResources/Material/DefaultHDMirrorMaterial.mat"), defaultDecalMat = Load <Material>(HDRenderPipelinePath + "RenderPipelineResources/Material/DefaultHDDecalMaterial.mat"), defaultTerrainMat = Load <Material>(HDRenderPipelinePath + "RenderPipelineResources/Material/DefaultHDTerrainMaterial.mat"), }; // Textures textures = new TextureResources { // Debug debugFontTex = Load <Texture2D>(HDRenderPipelinePath + "RenderPipelineResources/Texture/DebugFont.tga"), colorGradient = Load <Texture2D>(HDRenderPipelinePath + "Debug/ColorGradient.png"), }; // ShaderGraphs shaderGraphs = new ShaderGraphResources { }; }
public NamePlateLocal(Rectangle position, SpriteFont fontSmall, SpriteFont fontBig, string UID, int zPosition = 0) : base(position, TextureResources.Get("NamePlateBackgroundRed"), UID, zPosition) { current = this; contentRect = new Rectangle(position.Location + margin, position.Size - margin - margin); Rectangle helloRect = new Rectangle(contentRect.Location.X, contentRect.Location.Y, contentRect.Width, contentRect.Height / 4); hello = new TextBoardElement(helloRect, "Hello", fontSmall, "namePlateHello", ColorResources.White, zPosition + 1, TextBoardElement.Alignment.LeftBottom); Rectangle nameRect = new Rectangle(contentRect.Location.X, contentRect.Location.Y + helloRect.Height, contentRect.Width, contentRect.Height * 3 / 4); playerName = new TextBoardElement(nameRect, GetLocalPlayerName() + "!", fontBig, "namePlatePlayer", ColorResources.White, zPosition + 1, TextBoardElement.Alignment.LeftTop); CommandQueue.Queue(new AddToBoardCommand(hello, playerName)); UpdateColor(); }