Пример #1
0
 private void AddBool(string name, GenericMaterial genericMaterial, long paramId, bool defaultValue)
 {
     if (boolByParamId.ContainsKey(paramId))
     {
         var value = boolByParamId[paramId];
         genericMaterial.AddBoolToInt(name, value);
     }
     else
     {
         genericMaterial.AddBoolToInt(name, defaultValue);
     }
 }
Пример #2
0
        private void AddBool(GenericMaterial genericMaterial, long paramId, bool defaultValue)
        {
            var name = $"param{paramId.ToString("X")}";

            if (boolByParamId.ContainsKey(paramId))
            {
                var value = boolByParamId[paramId];
                genericMaterial.AddBoolToInt(name, value);
            }
            else
            {
                genericMaterial.AddBoolToInt(name, defaultValue);
            }
        }
Пример #3
0
        public GenericMaterial CreateGenericMaterial(Material material)
        {
            // Don't use the default texture unit.
            var genericMaterial = new GenericMaterial(1);

            AddTextures(genericMaterial);

            genericMaterial.AddBoolToInt("useStippleBlend", UseStippleBlend);

            // HACK: There isn't an easy way to access the current frame.
            genericMaterial.AddFloat("currentFrame", CurrentFrame);

            genericMaterial.AddBoolToInt("hasCustomVector44", vec4ByParamId.ContainsKey(MatlEnums.ParamId.CustomVector44));
            genericMaterial.AddBoolToInt("hasCustomVector47", vec4ByParamId.ContainsKey(MatlEnums.ParamId.CustomVector47));

            // TODO: Convert from quaternion values in light.nuanimb.
            AddQuaternion("chrLightDir", genericMaterial, -0.453154f, -0.365998f, -0.211309f, 0.784886f);

            return(genericMaterial);
        }
Пример #4
0
        private GenericMaterial CreateGenericMaterial(bool hasRequiredAttributes)
        {
            // Don't use the default texture unit.
            var genericMaterial = new GenericMaterial(1);

            AddTextures(genericMaterial);

            genericMaterial.AddBoolToInt("hasRequiredAttributes", hasRequiredAttributes);
            genericMaterial.AddFloat("depthBias", DepthBias);
            genericMaterial.AddVector3("materialId", MaterialIdColorRgb255 / 255f);

            // TODO: Convert from quaternion values in light.nuanimb.
            AddQuaternion("chrLightDir", genericMaterial, -0.453154f, -0.365998f, -0.211309f, 0.784886f);

            return(genericMaterial);
        }
Пример #5
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);
        }
Пример #6
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);
        }
Пример #7
0
        private void AddMaterialParams(GenericMaterial genericMaterial)
        {
            // Set specific parameters and use a default value if not present.
            AddVec4(genericMaterial, RenderSettings.Instance.ParamId, new Vector4(0), true);

            // Assume no edge tint if not present.
            AddVec4(genericMaterial, 0xA6, new Vector4(1));

            // Some sort of skin subsurface color?
            if (RenderSettings.Instance.TransitionEffect == RenderSettings.TransitionMode.Ditto)
            {
                AddVec4(genericMaterial, 0x145, new Vector4(0.23f, 1.5f, 1f, 1f));
            }
            else
            {
                AddVec4(genericMaterial, 0xA3, new Vector4(0));
                AddVec4(genericMaterial, 0x145, new Vector4(1, 0, 0, 0));
            }

            // Mario Galaxy rim light?
            AddVec4(genericMaterial, 0xA0, new Vector4(1));

            // Diffuse color multiplier?
            AddVec4(genericMaterial, 0xA5, new Vector4(1));

            // Sprite sheet UV parameters.
            AddVec4(genericMaterial, 0xAA, new Vector4(1));

            AddVec4(genericMaterial, 0x156, new Vector4(0));
            genericMaterial.AddBoolToInt("hasParam156", vec4ByParamId.ContainsKey(0x156));

            // Enables/disables specular occlusion.
            AddBool(genericMaterial, 0xE9, true);

            AddBool(genericMaterial, 0xEA, true);

            // Controls anisotropic specular.
            AddFloat(genericMaterial, 0xCA, 0.0f);

            // Controls specular IOR.
            AddFloat(genericMaterial, 0xC8, 0.0f);

            // TODO: Refraction?
            AddFloat(genericMaterial, 0xD3, 0.0f);

            // TODO: du dv intensity?
            AddFloat(genericMaterial, 0xC4, 0.0f);

            // Some sort of sprite sheet scale toggle.
            AddBool(genericMaterial, 0xF1, true);

            // Enables/disables UV scrolling animations.
            AddBool(genericMaterial, 0xEE, false);
            AddBool(genericMaterial, 0xED, false);

            // Alpha offset.
            AddVec4(genericMaterial, 0x98, new Vector4(0, 0, 0, 0));

            // UV transforms.
            AddVec4(genericMaterial, 0x146, new Vector4(1, 1, 0, 0));
            AddVec4(genericMaterial, 0x147, new Vector4(1, 1, 0, 0));

            // UV transform for emissive map layer 1.
            AddVec4(genericMaterial, 0x9E, new Vector4(1, 1, 0, 0));

            // Wii Fit trainer stage color.
            genericMaterial.AddBoolToInt("hasParam153", vec4ByParamId.ContainsKey(0x153));
            AddVec4(genericMaterial, 0x153, new Vector4(0, 0, 0, 0));
            AddVec4(genericMaterial, 0x154, new Vector4(0, 0, 0, 0));

            // Some sort of emission color.
            AddVec4(genericMaterial, 0x9B, new Vector4(1));
        }