コード例 #1
0
    public void OnGUI(ShaderInfo _info)
    {
        info = _info;


        if (info == null || info.variantInfo.keywords == null)
        {
            return;
        }
        GUILayout.Label("" + info.adbPath);

        GUILayout.Space(10);
        GUILayout.Label("变体数量:" + info.variantInfo.variantCount);

        GUILayout.Space(10);
        if (GUILayout.Button("Update", GUILayout.Width(220)))
        {
            var newSkips = info.variantInfo.NewSkips();
            ShaderTextProcess.AddKeywords(info.path, newSkips);
            AssetDatabase.ImportAsset(info.adbPath);
            info.variantInfo.Refresh();
        }

        scrollPos = GUILayout.BeginScrollView(scrollPos);
        for (int i = 0; i < info.variantInfo.keywords.Count; i++)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label(info.variantInfo.keywords [i], GUILayout.Width(200));
            info.variantInfo.keywordsIfSkip [i] = GUILayout.Toggle(info.variantInfo.keywordsIfSkip [i], "", GUILayout.Width(60));
            GUILayout.EndHorizontal();
        }
        GUILayout.EndScrollView();
    }
コード例 #2
0
        public static ShaderInfo LoadShader(LevelTags tags)
        {
            var shaderInfo = new ShaderInfo();

            var sizeList = tags.GetTag <int[]>("Size");

            shaderInfo.Size = new Vector3(sizeList[0], 1, sizeList[1]);
            if (sizeList.Length == 3)
            {
                shaderInfo.Size = new Vector3(sizeList[0], sizeList[1], sizeList[2]);
            }
            var shaderList = tags.GetTag <float[]>("Shader");

            shaderInfo.Shader        = new Vector3(shaderList[0], shaderList[1], shaderList[2]);
            shaderInfo.StopOnContact = tags.GetTag <bool>("StopOnContact");
            var posList = tags.GetTag <int[]>("Position");

            shaderInfo.Position = new Vector3(posList[0], posList[1], posList[2]);
            var objectSizeList = tags.GetTag <int[]>("Size");

            shaderInfo.ObjectSize = new Size(objectSizeList[0], objectSizeList[1]);
            if (tags.TagExists("DayTime"))
            {
                shaderInfo.DayTime = tags.GetTag <int[]>("DayTime");
            }

            return(shaderInfo);
        }
コード例 #3
0
ファイル: PartCamera.cs プロジェクト: wangjun1998a/DockingCam
        public PartCamera(Part thisPart, string resourceScanning, string bulletName, int hits,
                          string rotatorZ, string rotatorY, string zoommer, float stepper, string cameraName, int allowedScanDistance,
                          int windowSize, bool isOnboard, bool isLookAtMe, bool isLookAtMeAutoZoom, bool isFollowMe, bool isTargetCam,
                          float isFollowMeOffsetX, float isFollowMeOffsetY, float isFollowMeOffsetZ, float targetOffset, string restrictShaderTo,
                          string windowLabel = "Camera") : base(thisPart, windowSize, windowLabel)
        {
            var splresource = resourceScanning.Split('.').ToList();

            _resourceName        = splresource[0];
            _resourceUsage       = int.Parse(splresource[1]);
            _bulletName          = bulletName;
            _rotatorZ            = PartGameObject.gameObject.GetChild(rotatorZ);
            _rotatorY            = PartGameObject.gameObject.GetChild(rotatorY);
            _zoommer             = PartGameObject.gameObject.GetChild(zoommer);
            _camObject           = PartGameObject.gameObject.GetChild(cameraName);
            _stepper             = stepper;
            _allowedScanDistance = allowedScanDistance;
            _lastZoom            = CurrentZoom;

            availableShaders   = new ShaderInfo(restrictShaderTo);
            IsOnboard          = isOnboard;
            IsLookAtMe         = isLookAtMe;
            IsFollowMe         = isFollowMe;
            IsLookAtMeAutoZoom = isLookAtMeAutoZoom;
            IsTargetCam        = isTargetCam;
            IsFollowMeOffsetX  = isFollowMeOffsetX;
            IsFollowMeOffsetY  = isFollowMeOffsetY;
            IsFollowMeOffsetZ  = isFollowMeOffsetZ;
            TargetOffset       = targetOffset;

            GameEvents.onGameSceneLoadRequested.Add(LevelWasLoaded);

            GetCurrentBullets(bulletName, hits);
        }
コード例 #4
0
ファイル: ShaderTool.cs プロジェクト: larnin/CustomCar
    void PrintMaterial(MaterialInfo m, ShaderInfo s)
    {
        GUILayout.Label("Shader: " + s.name);
        GUILayout.Label("Object: " + m.objectName + " - " + m.index);

        foreach (var u in s.uniforms)
        {
            switch (u.type)
            {
            case UniformType.Color:
                PrintColor(m.material, u.name);
                break;

            case UniformType.Float:
                PrintFloat(m.material, u.name);
                break;

            case UniformType.Int:
                PrintInt(m.material, u.name);
                break;

            case UniformType.Vector:
                PrintVector(m.material, u.name);
                break;

            case UniformType.Texture:
                PrintTexture(m.material, u.name);
                break;

            default:
                PrintInvalid(m.material, u.name);
                break;
            }
        }
    }
コード例 #5
0
ファイル: main.cs プロジェクト: jpbruyere/vke.net
        void init_final_pl()
        {
            descriptorPool = new DescriptorPool(dev, 3,
                                                new VkDescriptorPoolSize(VkDescriptorType.CombinedImageSampler, 2),
                                                new VkDescriptorPoolSize(VkDescriptorType.StorageImage, 4)
                                                );

            GraphicPipelineConfig cfg = GraphicPipelineConfig.CreateDefault(VkPrimitiveTopology.TriangleList, DeferredPbrRenderer.NUM_SAMPLES);

            if (DeferredPbrRenderer.NUM_SAMPLES != VkSampleCountFlags.SampleCount1)
            {
                cfg.multisampleState.sampleShadingEnable = true;
                cfg.multisampleState.minSampleShading    = 0.5f;
            }
            cfg.Layout = new PipelineLayout(dev,
                                            new VkPushConstantRange(VkShaderStageFlags.Fragment, 2 * sizeof(float)),
                                            new DescriptorSetLayout(dev, 0,
                                                                    new VkDescriptorSetLayoutBinding(0, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler)
                                                                    ));

            cfg.RenderPass = new RenderPass(dev, swapChain.ColorFormat, DeferredPbrRenderer.NUM_SAMPLES);

            using (ShaderInfo vs = new ShaderInfo(dev, VkShaderStageFlags.Vertex, "#vke.FullScreenQuad.vert.spv"))
                using (ShaderInfo fs = new ShaderInfo(dev, VkShaderStageFlags.Fragment, "#shaders.tone_mapping.frag.spv"))
                {
                    cfg.AddShaders(vs, fs);

                    plToneMap = new GraphicPipeline(cfg);
                }

            descriptorSet = descriptorPool.Allocate(cfg.Layout.DescriptorSetLayouts[0]);
        }
コード例 #6
0
        public SourceProgramRequest(ThreadedProgram program, ShaderSource[] shaders, ShaderInfo info)
        {
            Threaded = program;

            _shaders = shaders;
            _info    = info;
        }
コード例 #7
0
ファイル: SectionWriter.cs プロジェクト: impiaaa/Altar.NET
        private static void WriteShader(BBData data, ShaderInfo si, StringsChunkBuilder strings)
        {
            var se = new ShaderEntry
            {
                Name           = strings.GetOffset(si.Name),
                Type           = si.Type.Encode(),
                AttributeCount = (uint)si.Attributes.Length
            };

            unsafe
            {
                se.GLSL_ES.VertexSource   = strings.GetOffset(si.Code.GLSL_ES.VertexShader);
                se.GLSL_ES.FragmentSource = strings.GetOffset(si.Code.GLSL_ES.FragmentShader);
                se.GLSL.VertexSource      = strings.GetOffset(si.Code.GLSL.VertexShader);
                se.GLSL.FragmentSource    = strings.GetOffset(si.Code.GLSL.FragmentShader);
                se.HLSL9.VertexSource     = strings.GetOffset(si.Code.HLSL9.VertexShader);
                se.HLSL9.FragmentSource   = strings.GetOffset(si.Code.HLSL9.FragmentShader);
            }
            var tmp = new BinBuffer();

            tmp.Write(se);
            data.Buffer.Write(tmp, 0, tmp.Size - 4, 0); // TODO
            foreach (var attr in si.Attributes)
            {
                data.Buffer.Write(strings.GetOffset(attr));
            }
            data.Buffer.Write(2); // TODO: ShaderEntry2
            for (int i = 0; i < 12; i++)
            {
                data.Buffer.Write(0);
            }
        }
コード例 #8
0
        private static RuntimeShaderProfilesAsset Create()
        {
            RuntimeShaderProfilesAsset asset = ScriptableObject.CreateInstance <RuntimeShaderProfilesAsset>();

            asset.ShaderInfo = new List <RuntimeShaderInfo>();

            ShaderInfo[]     allShaderInfo = ShaderUtil.GetAllShaderInfo().OrderBy(si => si.name).ToArray();
            HashSet <string> shaderNames   = new HashSet <string>();

            for (int i = 0; i < allShaderInfo.Length; ++i)
            {
                ShaderInfo shaderInfo = allShaderInfo[i];
                Shader     shader     = Shader.Find(shaderInfo.name);

                RuntimeShaderInfo profile = Create(shader);
                asset.ShaderInfo.Add(profile);

                if (shaderNames.Contains(shaderInfo.name))
                {
                    Debug.LogWarning("Shader with same name already exists. Consider renaming " + shaderInfo.name + " shader. File: " + AssetDatabase.GetAssetPath(shader));
                }
                else
                {
                    shaderNames.Add(shaderInfo.name);
                }
            }
            return(asset);
        }
コード例 #9
0
        public BinaryProgramRequest(ThreadedProgram program, byte[] data, bool hasFragmentShader, ShaderInfo info)
        {
            Threaded = program;

            _data = data;
            _hasFragmentShader = hasFragmentShader;
            _info = info;
        }
コード例 #10
0
        internal int GetShaderiv(uint shader, ShaderInfo status)
        {
            int result;

            _getShaderiv(shader, status, out result);
            CheckForError();
            return(result);
        }
コード例 #11
0
    public void ExtrudedTruchetPattern(Device device, Type shaderType)
    {
        ShaderInfo info = ReflectionServices.GetShaderInfo <SwapChain.Shaders.Compute.ExtrudedTruchetPattern>();

        Assert.IsFalse(info.RequiresDoublePrecisionSupport);

        RunAndCompareShader(device, shaderType, 0.00011f);
    }
コード例 #12
0
        public static ShaderInfo GetShaderInfo(GMFileContent c, uint id)
        {
            if (id >= c.Shaders->Count)
            {
                throw new ArgumentOutOfRangeException(nameof(id));
            }

            var sh = (ShaderEntry *)GMFile.PtrFromOffset(c, (&c.Shaders->Offsets)[id]);

            var si = new ShaderInfo();

            si.Name = StringFromOffset(c, sh->Name);
            si.Type = sh->Type.Decode();

            si.Code.GLSL_ES = GetVxFxStrings(c, sh->GLSL_ES);
            si.Code.GLSL    = GetVxFxStrings(c, sh->GLSL);
            si.Code.HLSL9   = GetVxFxStrings(c, sh->HLSL9);

            ShaderEntry2 *sh2;

            // hack for a special case w. pre-DX11 stuff?
            if ((uint)c.General->BytecodeVersion == 0xE &&
                sh->HLSL11.VertexData == 0 &&
                sh->HLSL11.VertexLength == 0)
            {
                var sho = (ShaderEntryOld *)sh;

                var ats = new string[sho->AttributeCount];
                for (uint i = 0; i < ats.Length; ++i)
                {
                    ats[i] = StringFromOffset(c, (&sho->Attributes)[i]);
                }

                si.Attributes = ats;

                sh2 = (ShaderEntry2 *)&((&sho->Attributes)[sho->AttributeCount]);
            }
            else
            {
                //si.Code.HLSL11  = GetVxFxBlobs  (c, sh->HLSL11 , length=???); // TODO

                var ats = new string[sh->AttributeCount];
                for (uint i = 0; i < ats.Length; ++i)
                {
                    ats[i] = StringFromOffset(c, (&sh->Attributes)[i]);
                }

                si.Attributes = ats;

                sh2 = (ShaderEntry2 *)&((&sh->Attributes)[sh->AttributeCount]);
            }

            si.Code.PSSL   = GetVxFxBlobs(c, sh2->PSSL);
            si.Code.Cg     = GetVxFxBlobs(c, sh2->Cg);
            si.Code.Cg_PS3 = GetVxFxBlobs(c, sh2->Cg_PS3);

            return(si);
        }
コード例 #13
0
                static void RunComputeShader <T>(ReadWriteTexture2D <Rgba32, float4> texture)
                    where T : struct, IComputeShader
                {
                    ShaderInfo info = ReflectionServices.GetShaderInfo <T>();

                    Assert.IsFalse(info.RequiresDoublePrecisionSupport);

                    texture.GraphicsDevice.For(texture.Width, texture.Height, (T)Activator.CreateInstance(typeof(T), texture, 0f) !);
                }
コード例 #14
0
        /// <summary>
        /// Processes the string representation of the specified effect into a platform-specific binary format using the specified context.
        /// </summary>
        /// <param name="input">The effect string to be processed.</param>
        /// <param name="context">Context for the specified processor.</param>
        /// <returns>A platform-specific compiled binary effect.</returns>
        /// <remarks>If you get an error during processing, compilation stops immediately. The effect processor displays an error message. Once you fix the current error, it is possible you may get more errors on subsequent compilation attempts.</remarks>
        public override CompiledEffectContent Process(EffectContent input, ContentProcessorContext context)
        {
#if WINDOWS
            var options = new Options();
            options.SourceFile  = input.Identity.SourceFilename;
            options.DX11Profile = context.TargetPlatform == TargetPlatform.Windows ||
                                  context.TargetPlatform == TargetPlatform.WindowsPhone8 ||
                                  context.TargetPlatform == TargetPlatform.WindowsStoreApp ||
                                  context.TargetPlatform == TargetPlatform.Xbox360;
            options.Debug      = DebugMode == EffectProcessorDebugMode.Debug;
            options.OutputFile = context.OutputFilename;

            // Parse the MGFX file expanding includes, macros, and returning the techniques.
            ShaderInfo shaderInfo;
            try
            {
                shaderInfo = ShaderInfo.FromFile(options.SourceFile, options);
            }
            catch (Exception ex)
            {
                // TODO: Extract good line numbers from mgfx parser!
                throw new InvalidContentException(ex.Message, input.Identity, ex);
            }

            // Create the effect object.
            DXEffectObject effect = null;
            try
            {
                effect = DXEffectObject.FromShaderInfo(shaderInfo);
            }
            catch (Exception ex)
            {
                throw ProcessErrorsAndWarnings(ex.Message, input, context);
            }

            // Write out the effect to a runtime format.
            CompiledEffectContent result;
            try
            {
                using (var stream = new MemoryStream())
                {
                    using (var writer = new BinaryWriter(stream))
                        effect.Write(writer, options);

                    result = new CompiledEffectContent(stream.GetBuffer());
                }
            }
            catch (Exception ex)
            {
                throw new InvalidContentException("Failed to serialize the effect!", input.Identity, ex);
            }

            return(result);
#else
            throw new NotImplementedException();
#endif
        }
コード例 #15
0
        public ChunkRenderBuffer()
        {
            shaderInfo = GenerateShader();

            GL.GenBuffers(1, out vbo_position);
            GL.GenBuffers(1, out vbo_color);
            GL.GenBuffers(1, out vbo_normal);
            GL.GenBuffers(1, out vbo_mview);
            GL.GenBuffers(1, out ibo_elements);
        }
コード例 #16
0
        public static bool IsShaderBlocked(string name)
        {
            if (m_shaderList.Any(s => s.Name == name))
            {
                ShaderInfo shader = m_shaderList.First(s => s.Name == name);
                return(shader.Blocked);
            }

            return(false);
        }
コード例 #17
0
        public static JsonData SerializeShader(ShaderInfo shdr)
        {
            var r = CreateObj();

            r["type"]       = shdr.Type.ToString();
            r["code"]       = SerializeShaderCode(shdr.Code);
            r["attributes"] = SerializeArray(shdr.Attributes, Utils.Identity);

            return(r);
        }
コード例 #18
0
    public void DealShader()
    {
        infos.Clear();
        string content = File.ReadAllText(filePath);
        //Debug.Log(File.ReadAllText(filePath));
        Regex regex =
            new Regex("((Keywords)|(No keywords))(.|\n)*?-- Fragment shader");
        MatchCollection ma = regex.Matches(content);

        for (int i = 0; i < ma.Count; i++)
        {
            string     text       = ma[i].ToString();
            ShaderInfo si         = new ShaderInfo();
            int        startIndex = text.IndexOf(": ", StringComparison.Ordinal);
            int        endNum     = text.IndexOf("\n", StringComparison.Ordinal);
            if (startIndex != -1 && startIndex < endNum)
            {
                startIndex += 2;
                string   result  = text.Substring(startIndex, endNum - startIndex);
                string[] allKeys = result.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                si.keyWords = allKeys[0];
                for (int j = 1; j < allKeys.Length; j++)
                {
                    si.keyWords += "\n" + allKeys[j];
                }
                //si.keyWords = si.keyWords.Replace(" ", "\n");
            }
            else
            {
                si.keyWords = "NoKeyWords";
            }
            startIndex = text.IndexOf("#ifdef VERTEX", StringComparison.Ordinal) + 13;
            endNum     = text.IndexOf("#endif", StringComparison.Ordinal);
            si.vert    = text.Substring(startIndex, endNum - startIndex);

            startIndex = text.IndexOf("#ifdef FRAGMENT", StringComparison.Ordinal) + 16;
            endNum     = text.LastIndexOf("#endif", StringComparison.Ordinal);
            si.frag    = text.Substring(startIndex, endNum - startIndex);
            if (!si.frag.Contains("float;\n"))
            {
                string first = si.frag.Substring(0, si.frag.IndexOf('\n') + 1);
                startIndex = si.frag.IndexOf("precision", StringComparison.Ordinal);
                string third = si.frag.Substring(startIndex);
                si.frag = first + "precision highp float;\n" + third;
            }
            //Debug.Log(si.keyWords);
            //Debug.Log(si.vert);
            //Debug.Log(si.frag);
            infos.Add(si);
        }
        ProfileShader();
        showShaderInfo = 1;
    }
コード例 #19
0
        protected override void OnLoad(EventArgs e)
        {
            GL.ClearColor(Color.Black);

            InitVbo();

            ShaderInfo shader = Config.ShaderName != null?ShaderRegistry.Get(Config.ShaderName) : ShaderRegistry.First();

            SetShaders(shader?.VertexCode, shader?.FragmentCode);

            base.OnLoad(e);
        }
コード例 #20
0
        private void ShaderComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (ShaderComboBox.SelectedValue == null)
            {
                return;
            }

            var shader  = (MtrlShader)ShaderComboBox.SelectedValue;
            var presets = ShaderInfo.GetAvailablePresets(shader);

            PresetSource.Clear();
            foreach (var p in presets)
            {
                PresetSource.Add(new KeyValuePair <MtrlShaderPreset, string>(p, p.ToString()));
            }

            // Disable the box if the user has no choice anyways.
            if (PresetSource.Count > 1)
            {
                PresetComboBox.IsEnabled = true;
            }
            else
            {
                PresetComboBox.IsEnabled = false;
            }


            PresetComboBox.SelectedValue = MtrlShaderPreset.Default;
            // Ensure the UI is updated for the new selection.
            PresetComboBox_SelectionChanged(null, null);

            if (shader == MtrlShader.Furniture || shader == MtrlShader.DyeableFurniture || shader == MtrlShader.Other)
            {
                // Disable all the editable options except transparency for these items.
                NormalTextBox.IsEnabled    = false;
                DiffuseTextBox.IsEnabled   = false;
                SpecularTextBox.IsEnabled  = false;
                ColorsetComboBox.IsEnabled = false;
                PresetComboBox.IsEnabled   = false;
            }

            if (shader == MtrlShader.Other)
            {
                // Disable everything.
                TransparencyComboBox.IsEnabled = false;
                ShaderComboBox.IsEnabled       = false;
                SaveButton.IsEnabled           = false;
                SaveButton.Visibility          = Visibility.Hidden;
            }
        }
コード例 #21
0
ファイル: ShaderUtility.cs プロジェクト: georgex1/rednit
        public ShaderInfo GetShaderInfo(string _shaderName)
        {
            for (int _iter = 0; _iter < m_shaderInfoList.Count; _iter++)
            {
                ShaderInfo _curShaderInfo = m_shaderInfoList[_iter];

                if (_shaderName.Equals(_curShaderInfo.Name))
                {
                    return(_curShaderInfo);
                }
            }

            return(null);
        }
コード例 #22
0
 private void updateButton1_Click(object sender, EventArgs e)
 {
     //set the shader for this material
     if (mMaterial != null)
     {
         Object     obj    = shaderComboBox1.SelectedItem;
         ShaderInfo sinfo  = (ShaderInfo)obj;
         bool       wasSet = mMaterial.setShader(sinfo.id);
         if (!wasSet)
         {
             MessageBox.Show("Shader was not set on the Material...");
         }
     }
 }
コード例 #23
0
 void Init()
 {
     shaderInfos.Clear();
     //Debug.Log ("1:"+Time.realtimeSinceStartup);
     string[] paths = Directory.GetFiles(Application.dataPath, "*.shader", SearchOption.AllDirectories);
     //Debug.Log (paths.Length);
     //Debug.Log ("2:"+Time.realtimeSinceStartup);
     foreach (var path in paths)
     {
         ShaderInfo info = new ShaderInfo(path);
         shaderInfos.Add(info);
     }
     //Debug.Log ("3:"+Time.realtimeSinceStartup);
     Search();
 }
コード例 #24
0
        public static void UnblockShader(string name)
        {
            ShaderInfo shader = new ShaderInfo()
            {
                Name    = name,
                Blocked = false
            };

            if (m_shaderList.Any(s => s.Name == name))
            {
                shader         = m_shaderList.First(s => s.Name == name);
                shader.Blocked = false;
            }

            SaveShaderList();
        }
コード例 #25
0
        public static List <Shader> GetAllShaders(bool supportedOnly)
        {
            List <Shader> shaders = new List <Shader>();

            ShaderInfo[] shaderInfos = ShaderUtil.GetAllShaderInfo();
            for (int i = 0; i < shaderInfos.Length; i++)
            {
                ShaderInfo info = shaderInfos[i];
                if (supportedOnly && !info.supported)
                {
                    continue;
                }
                shaders.Add(Shader.Find(info.name));
            }
            return(shaders);
        }
コード例 #26
0
    private static bool tryGetShaderInfo(Shader shader, out ShaderInfo info)
    {
        string path = AssetDatabase.GetAssetPath(shader);

        if (string.IsNullOrEmpty(path))
        {
            info = default(ShaderInfo);
            return(false);
        }

        DateTime modifiedTime = File.GetLastWriteTime(path);

        if (_infoCache.TryGetValue(path, out info))
        {
            //If the check time is newer than the modified time, return cached results
            if (modifiedTime < info.checkTime)
            {
                return(true);
            }
        }

        info.isSurfaceShader = false;
        info.doesHaveShaderVariantsDisabled = false;
        info.checkTime = modifiedTime;

        string[] lines = File.ReadAllLines(path);
        foreach (var line in lines)
        {
            if (!line.Contains(EARLY_OUT_KEYWORD))
            {
                continue;
            }

            if (disabledVariantRegex.IsMatch(line))
            {
                info.doesHaveShaderVariantsDisabled = true;
            }

            if (isSurfaceShaderRegex.IsMatch(line))
            {
                info.isSurfaceShader = true;
            }
        }

        _infoCache[path] = info;
        return(true);
    }
コード例 #27
0
ファイル: DispatchTests.cs プロジェクト: nasa03/ComputeSharp
    public void Verify_DispatchSize(Device device)
    {
        using ReadWriteBuffer <int> buffer = device.Get().AllocateReadWriteBuffer <int>(6);

        device.Get().For(11, 22, 3, new DispatchSizeShader(buffer));

        ShaderInfo info = ReflectionServices.GetShaderInfo <DispatchSizeShader>();

        int[] data = buffer.ToArray();

        Assert.AreEqual(data[0], 11 * 22 * 3);
        Assert.AreEqual(data[1], 11);
        Assert.AreEqual(data[2], 22);
        Assert.AreEqual(data[3], 3);
        Assert.AreEqual(data[4], 11 + 22);
        Assert.AreEqual(data[5], 11 + 22 + 3);
    }
コード例 #28
0
        ShaderInfo GenerateShader()
        {
            shaderInfo = new ShaderInfo();

            shaderInfo.ShaderProgramID = GL.CreateProgram();

            ShaderHelper.LoadShader("Shaders/vertex.glsl", ShaderType.VertexShader, shaderInfo.ShaderProgramID, out shaderInfo.VertexShaderID);
            ShaderHelper.LoadShader("Shaders/fragment.glsl", ShaderType.FragmentShader, shaderInfo.ShaderProgramID, out shaderInfo.FragmentShaderID);

            GL.LinkProgram(shaderInfo.ShaderProgramID);
            Console.WriteLine(GL.GetProgramInfoLog(shaderInfo.ShaderProgramID));

            shaderInfo.Attribute_vertexPosition = GL.GetAttribLocation(shaderInfo.ShaderProgramID, "vPosition");
            shaderInfo.Attribute_vertexColor    = GL.GetAttribLocation(shaderInfo.ShaderProgramID, "vColor");
            shaderInfo.Attribute_vertexNormal   = GL.GetAttribLocation(shaderInfo.ShaderProgramID, "vNormal");
            shaderInfo.Uniform_modelview        = GL.GetUniformLocation(shaderInfo.ShaderProgramID, "modelview");

            return(shaderInfo);
        }
コード例 #29
0
        public DockingCamera(OLDD_camera.Modules.DockingCameraModule dcm, Part thisPart,
                             bool noise, double electricchargeCost, bool crossStock, bool crossDPAI, bool crossOLDD, bool transformModification,
                             int windowSize, string restrictShaderTo,
                             string windowLabel       = "DockCam", string cameraName = "dockingNode",
                             bool slidingOptionWindow = false, bool allowZoom        = false, bool noTransformMod = false)
            : base(thisPart, windowSize, windowLabel)
        {
            GameEvents.onGameSceneLoadRequested.Add(LevelWasLoaded);
            Noise            = noise;
            TargetCrossDPAI  = crossDPAI;
            TargetCrossOLDD  = crossOLDD;
            TargetCrossStock = crossStock;
            AuxWindowAllowed = slidingOptionWindow;
            IsZoomAllowed    = allowZoom;

            availableShaders             = new ShaderInfo(restrictShaderTo);
            _target                      = new TargetHelper(thisPart);
            _moduleDockingNodeGameObject = PartGameObject.GetChild(cameraName) ?? PartGameObject;  //GET orientation from dockingnode

            if (cameraName != "dockingNode" && transformModification)
            {
                Vector3 v3 = dcm.cameraPosition;

                _moduleDockingNodeGameObject.transform.position += _moduleDockingNodeGameObject.transform.rotation * v3;
                _moduleDockingNodeGameObject.transform.rotation  = dcm.part.transform.rotation;
                _moduleDockingNodeGameObject.transform.rotation *= Quaternion.LookRotation(dcm.cameraForward, dcm.cameraUp);
            }

            if (_textureWhiteNoise == null)
            {
                _textureWhiteNoise = new List <Texture2D> [4];
                for (int j = 0; j < 3; j++)
                {
                    _textureWhiteNoise[j] = new List <Texture2D>();
                    for (int i = 0; i < 4; i++)
                    {
                        _textureWhiteNoise[j].Add(Util.WhiteNoiseTexture((int)TexturePosition.width, (int)TexturePosition.height));
                    }
                }
            }
        }
コード例 #30
0
    void OnGUI()
    {
        GUILayout.BeginHorizontal();
        searchText = GUILayout.TextField(searchText, GUILayout.Width(200));
        if (GUILayout.Button("Search", GUILayout.Width(70)))
        {
            Search();
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.BeginVertical(GUILayout.Width(600));
        scrollPos = GUILayout.BeginScrollView(scrollPos);
        for (int i = 0; i < shaderInfosResult.Count; i++)
        {
            GUILayout.Label(shaderInfosResult [i].adbPath);
            Rect rect = GUILayoutUtility.GetLastRect();

            if (GUI.Button(rect, "", GUIStyle.none))
            {
                selected = shaderInfosResult [i];
                selected.OnSelect();
                Selection.activeObject = selected.shader;
            }
            if (selected == shaderInfosResult [i])
            {
                GUI.backgroundColor = new Color(0, 1, 1);
                GUI.Box(rect, "");
                GUI.backgroundColor = Color.white;
            }
        }
        GUILayout.EndScrollView();
        GUILayout.EndVertical();

        GUILayout.BeginVertical();
        shaderManager.OnGUI(selected);
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
    }