Exemplo n.º 1
0
        public static void SetTextureUniformsNudMatSphere(Shader shader, Nud.Material mat, Dictionary <NudEnums.DummyTexture, Texture> dummyTextures)
        {
            SetHasTextureUniforms(shader, mat);
            SetRenderModeTextureUniforms(shader);

            // The material shader just uses predefined textures from the Resources folder.
            Nud.MatTexture diffuse     = new Nud.MatTexture((int)NudEnums.DummyTexture.DummyRamp);
            Nud.MatTexture cubeMapHigh = new Nud.MatTexture((int)NudEnums.DummyTexture.StageMapHigh);

            SetHasTextureUniforms(shader, mat);
            SetRenderModeTextureUniforms(shader);

            // The type of texture can be partially determined by texture order.
            GenericMaterial textures = new GenericMaterial(nutTextureUnitOffset);

            textures.AddTexture("dif", GetSphereTexture("dif", dummyTextures));
            textures.AddTexture("spheremap", GetSphereTexture("spheremap", dummyTextures));
            textures.AddTexture("dif2", GetSphereTexture("dif2", dummyTextures));
            textures.AddTexture("dif3", GetSphereTexture("dif3", dummyTextures));
            textures.AddTexture("stagecube", GetSphereTexture("stagecube", dummyTextures));
            textures.AddTexture("cube", GetSphereTexture("cube", dummyTextures));
            textures.AddTexture("ao", GetSphereTexture("ao", dummyTextures));
            textures.AddTexture("normalMap", GetSphereTexture("normalMap", dummyTextures));
            textures.AddTexture("ramp", GetSphereTexture("ramp", dummyTextures));
            textures.AddTexture("dummyRamp", GetSphereTexture("dummyRamp", dummyTextures));

            textures.SetShaderUniforms(shader);
        }
Exemplo n.º 2
0
 private void AddTextures(GenericMaterial genericMaterial)
 {
     AddMaterialTextures(genericMaterial);
     AddImageBasedLightingTextures(genericMaterial);
     AddRenderModeTextures(genericMaterial);
     genericMaterial.AddTexture("colorLut", DefaultTextures.Instance.Value.ColorGradingLut);
 }
Exemplo n.º 3
0
        private void AddTextures(GenericMaterial genericMaterial)
        {
            AddMaterialTextures(genericMaterial);

            AddImageBasedLightingTextures(genericMaterial);

            AddRenderModeTextures(genericMaterial);

            genericMaterial.AddTexture("stipplePattern", defaultTextures.stipplePattern);
        }
Exemplo n.º 4
0
        public static void SetTextureUniforms(Shader shader, Nud.Material mat, Dictionary <NudEnums.DummyTexture, Texture> dummyTextures)
        {
            SetHasTextureUniforms(shader, mat);
            SetRenderModeTextureUniforms(shader);

            int textureIndex = 0;

            // The type of texture can be partially determined by texture order.
            GenericMaterial textures = new GenericMaterial(nutTextureUnitOffset);

            textures.AddTexture("dif", GetTextureAndSetTexId(mat, mat.HasDiffuse, "dif", ref textureIndex, dummyTextures));
            textures.AddTexture("spheremap", GetTextureAndSetTexId(mat, mat.HasSphereMap, "spheremap", ref textureIndex, dummyTextures));
            textures.AddTexture("dif2", GetTextureAndSetTexId(mat, mat.HasDiffuse2, "dif2", ref textureIndex, dummyTextures));
            textures.AddTexture("dif3", GetTextureAndSetTexId(mat, mat.HasDiffuse3, "dif3", ref textureIndex, dummyTextures));
            textures.AddTexture("stagecube", GetTextureAndSetTexId(mat, mat.HasStageMap, "stagecube", ref textureIndex, dummyTextures));
            textures.AddTexture("cube", GetTextureAndSetTexId(mat, mat.HasCubeMap, "cube", ref textureIndex, dummyTextures));
            textures.AddTexture("ao", GetTextureAndSetTexId(mat, mat.HasAoMap, "ao", ref textureIndex, dummyTextures));
            textures.AddTexture("normalMap", GetTextureAndSetTexId(mat, mat.HasNormalMap, "normalMap", ref textureIndex, dummyTextures));
            textures.AddTexture("ramp", GetTextureAndSetTexId(mat, mat.HasRamp, "ramp", ref textureIndex, dummyTextures));
            textures.AddTexture("dummyRamp", GetTextureAndSetTexId(mat, mat.HasDummyRamp, "dummyRamp", ref textureIndex, dummyTextures));

            textures.SetShaderUniforms(shader);
        }
Exemplo n.º 5
0
 private void AddImageBasedLightingTextures(GenericMaterial genericMaterial)
 {
     genericMaterial.AddTexture("diffusePbrCube", defaultTextures.diffusePbr);
     genericMaterial.AddTexture("specularPbrCube", specularIbl);
     genericMaterial.AddTexture("iblLut", defaultTextures.iblLut);
 }
Exemplo n.º 6
0
 private void AddRenderModeTextures(GenericMaterial genericMaterial)
 {
     genericMaterial.AddTexture("uvPattern", defaultTextures.uvPattern);
 }
Exemplo n.º 7
0
        private void AddMaterialTextures(GenericMaterial genericMaterial)
        {
            genericMaterial.AddTexture("colMap", col);
            genericMaterial.AddBoolToInt("hasColMap", HasCol);

            genericMaterial.AddTexture("col2Map", col2);
            genericMaterial.AddBoolToInt("hasCol2Map", HasCol2);

            genericMaterial.AddTexture("prmMap", prm);
            genericMaterial.AddTexture("norMap", nor);

            genericMaterial.AddTexture("inkNorMap", inkNor);
            genericMaterial.AddBoolToInt("hasInkNorMap", HasInkNorMap);

            genericMaterial.AddTexture("emiMap", emi);
            genericMaterial.AddTexture("emi2Map", emi2);

            genericMaterial.AddTexture("bakeLitMap", bakeLit);
            genericMaterial.AddTexture("gaoMap", gao);
            genericMaterial.AddTexture("projMap", proj);

            genericMaterial.AddTexture("difCubemap", difCube);
            genericMaterial.AddBoolToInt("hasDifCubemap", HasDifCube);

            genericMaterial.AddTexture("difMap", dif);
            genericMaterial.AddBoolToInt("hasDiffuse", HasDiffuse);

            genericMaterial.AddTexture("dif2Map", dif2);
            genericMaterial.AddBoolToInt("hasDiffuse2", HasDiffuse2);

            genericMaterial.AddTexture("dif3Map", dif3);
            genericMaterial.AddBoolToInt("hasDiffuse3", HasDiffuse3);

            // HACK: There's probably a better way to handle blending emission and base color maps.
            var hasDiffuseMaps = HasCol || HasCol2 || HasDiffuse || HasDiffuse2 || HasDiffuse3;
            var hasEmiMaps     = HasEmi || HasEmi2;

            genericMaterial.AddBoolToInt("emissionOverride", hasEmiMaps && !hasDiffuseMaps);
        }
Exemplo n.º 8
0
 private void AddImageBasedLightingTextures(GenericMaterial genericMaterial)
 {
     genericMaterial.AddTexture("diffusePbrCube", DefaultTextures.Instance.DiffusePbr);
     genericMaterial.AddTexture("specularPbrCube", GetTexture(MatlEnums.ParamId.Texture7));
 }
Exemplo n.º 9
0
 private void AddRenderModeTextures(GenericMaterial genericMaterial)
 {
     genericMaterial.AddTexture("uvPattern", DefaultTextures.Instance.UvPattern);
 }
Exemplo n.º 10
0
 private void AddMaterialTextures(GenericMaterial genericMaterial)
 {
     genericMaterial.AddTexture("colMap", GetTexture(MatlEnums.ParamId.Texture0), GetSampler(MatlEnums.ParamId.Sampler0));
     genericMaterial.AddTexture("col2Map", GetTexture(MatlEnums.ParamId.Texture1), GetSampler(MatlEnums.ParamId.Sampler1));
     genericMaterial.AddTexture("prmMap", GetTexture(MatlEnums.ParamId.Texture6), GetSampler(MatlEnums.ParamId.Sampler6));
     genericMaterial.AddTexture("norMap", GetTexture(MatlEnums.ParamId.Texture4), GetSampler(MatlEnums.ParamId.Sampler4));
     genericMaterial.AddTexture("inkNorMap", GetTexture(MatlEnums.ParamId.Texture16), GetSampler(MatlEnums.ParamId.Sampler16));
     genericMaterial.AddTexture("emiMap", GetTexture(MatlEnums.ParamId.Texture5), GetSampler(MatlEnums.ParamId.Sampler5));
     genericMaterial.AddTexture("emi2Map", GetTexture(MatlEnums.ParamId.Texture14), GetSampler(MatlEnums.ParamId.Sampler14));
     genericMaterial.AddTexture("bakeLitMap", GetTexture(MatlEnums.ParamId.Texture9), GetSampler(MatlEnums.ParamId.Sampler9));
     genericMaterial.AddTexture("gaoMap", GetTexture(MatlEnums.ParamId.Texture3), GetSampler(MatlEnums.ParamId.Sampler3));
     genericMaterial.AddTexture("projMap", GetTexture(MatlEnums.ParamId.Texture13), GetSampler(MatlEnums.ParamId.Sampler13));
     genericMaterial.AddTexture("difCubeMap", GetTexture(MatlEnums.ParamId.Texture8), GetSampler(MatlEnums.ParamId.Sampler8));
     genericMaterial.AddTexture("difMap", GetTexture(MatlEnums.ParamId.Texture10), GetSampler(MatlEnums.ParamId.Sampler10));
     genericMaterial.AddTexture("dif2Map", GetTexture(MatlEnums.ParamId.Texture11), GetSampler(MatlEnums.ParamId.Sampler11));
     genericMaterial.AddTexture("dif3Map", GetTexture(MatlEnums.ParamId.Texture12), GetSampler(MatlEnums.ParamId.Sampler12));
 }
Exemplo n.º 11
0
        private void AddMaterialTextures(GenericMaterial genericMaterial)
        {
            // Use black for the default value.
            // Some materials seem to use emission as the main diffuse.
            genericMaterial.AddTexture("colMap", col);

            // Use the first texture for both layers if the second layer isn't present.
            if (HasCol2)
            {
                genericMaterial.AddTexture("col2Map", col2);
            }
            else
            {
                genericMaterial.AddTexture("col2Map", col);
            }

            genericMaterial.AddTexture("prmMap", prm);
            genericMaterial.AddTexture("norMap", nor);
            genericMaterial.AddTexture("inkNorMap", inkNor);

            genericMaterial.AddTexture("emiMap", emi);
            if (HasEmi2)
            {
                genericMaterial.AddTexture("emi2Map", emi2);
            }
            else
            {
                genericMaterial.AddTexture("emi2Map", emi);
            }

            genericMaterial.AddTexture("bakeLitMap", bakeLit);
            genericMaterial.AddTexture("gaoMap", gao);
            genericMaterial.AddTexture("projMap", proj);
            genericMaterial.AddTexture("difCubemap", difCube);

            genericMaterial.AddTexture("difMap", dif);
            genericMaterial.AddBoolToInt("hasDiffuse", HasDiffuse);
        }
Exemplo n.º 12
0
 private void AddMaterialTextures(GenericMaterial genericMaterial)
 {
     genericMaterial.AddTexture("colMap", col, colSampler);
     genericMaterial.AddTexture("col2Map", col2, col2Sampler);
     genericMaterial.AddTexture("prmMap", prm, prmSampler);
     genericMaterial.AddTexture("norMap", nor, norSampler);
     genericMaterial.AddTexture("inkNorMap", inkNor, inkNorSampler);
     genericMaterial.AddTexture("emiMap", emi, emiSampler);
     genericMaterial.AddTexture("emi2Map", emi2, emi2Sampler);
     genericMaterial.AddTexture("bakeLitMap", bakeLit, bakeLitSampler);
     genericMaterial.AddTexture("gaoMap", gao, gaoSampler);
     genericMaterial.AddTexture("projMap", proj, projSampler);
     genericMaterial.AddTexture("difCubeMap", difCube, difCubeSampler);
     genericMaterial.AddTexture("difMap", dif, difSampler);
     genericMaterial.AddTexture("dif2Map", dif2, dif2Sampler);
     genericMaterial.AddTexture("dif3Map", dif3, dif3Sampler);
 }
Exemplo n.º 13
0
        private void AddMaterialTextures(GenericMaterial genericMaterial)
        {
            // Make sure the sampler info is updated.
            // Creating the samplers on another thread likely won't work due to the context not being current.
            while (samplerUpdates.TryDequeue(out Tuple <MatlEnums.ParamId, SamplerData>?update))
            {
                samplerByParamId[update.Item1] = update.Item2.ToSampler();
            }

            genericMaterial.AddTexture("colMap", TextureAssignment.GetTexture(this, MatlEnums.ParamId.Texture0), GetSampler(MatlEnums.ParamId.Sampler0));
            genericMaterial.AddTexture("col2Map", TextureAssignment.GetTexture(this, MatlEnums.ParamId.Texture1), GetSampler(MatlEnums.ParamId.Sampler1));
            genericMaterial.AddTexture("prmMap", TextureAssignment.GetTexture(this, MatlEnums.ParamId.Texture6), GetSampler(MatlEnums.ParamId.Sampler6));
            genericMaterial.AddTexture("norMap", TextureAssignment.GetTexture(this, MatlEnums.ParamId.Texture4), GetSampler(MatlEnums.ParamId.Sampler4));
            genericMaterial.AddTexture("inkNorMap", TextureAssignment.GetTexture(this, MatlEnums.ParamId.Texture16), GetSampler(MatlEnums.ParamId.Sampler16));
            genericMaterial.AddTexture("emiMap", TextureAssignment.GetTexture(this, MatlEnums.ParamId.Texture5), GetSampler(MatlEnums.ParamId.Sampler5));
            genericMaterial.AddTexture("emi2Map", TextureAssignment.GetTexture(this, MatlEnums.ParamId.Texture14), GetSampler(MatlEnums.ParamId.Sampler14));
            genericMaterial.AddTexture("bakeLitMap", TextureAssignment.GetTexture(this, MatlEnums.ParamId.Texture9), GetSampler(MatlEnums.ParamId.Sampler9));
            genericMaterial.AddTexture("gaoMap", TextureAssignment.GetTexture(this, MatlEnums.ParamId.Texture3), GetSampler(MatlEnums.ParamId.Sampler3));
            genericMaterial.AddTexture("projMap", TextureAssignment.GetTexture(this, MatlEnums.ParamId.Texture13), GetSampler(MatlEnums.ParamId.Sampler13));
            genericMaterial.AddTexture("difCubeMap", TextureAssignment.GetTexture(this, MatlEnums.ParamId.Texture8), GetSampler(MatlEnums.ParamId.Sampler8));
            genericMaterial.AddTexture("difMap", TextureAssignment.GetTexture(this, MatlEnums.ParamId.Texture10), GetSampler(MatlEnums.ParamId.Sampler10));
            genericMaterial.AddTexture("dif2Map", TextureAssignment.GetTexture(this, MatlEnums.ParamId.Texture11), GetSampler(MatlEnums.ParamId.Sampler11));
            genericMaterial.AddTexture("dif3Map", TextureAssignment.GetTexture(this, MatlEnums.ParamId.Texture12), GetSampler(MatlEnums.ParamId.Sampler12));
        }