internal void AddSurfaceSampler(string sid, SurfaceSampler sampler)
        {
            s_Log.Info("AddSurfaceSampler: " + sid);

            if (null != sampler.surfaceName)
            {
                m_SurfaceSamplers[sid] = sampler;
            }
        }
        private void GetMaterialScript_14(StringBuilder sb)
        {
            s_Log.Info(String.Format(
                           "Building namespace '{0}' from Effects list",
                           MaterialNamespace));

            char[] pathDelims = { '/', '\\' };
            foreach (string materialId in m_Effects.Keys)
            {
                s_Log.Info("    building: " + materialId);

                string effectId = m_Effects[materialId];
                if (!m_Techniques.ContainsKey(effectId))
                {
                    // TODO: This is a work-around for a case where an effect had
                    // an empty definition.  No technique is added for the effect,
                    // but the effectId is still in the effects dictionary. A better
                    // fix is don't put an effectId for an empty effect in the
                    // dictionary in the first place.
                    continue;
                }
                List <MaterialTechnique_14> materialTechniques = m_Techniques[effectId];
                sb.Append("material ");
                if (MaterialNamespace != null)
                {
                    sb.Append(MaterialNamespace);
                    sb.Append(".");
                }
                sb.Append(materialId);
                sb.Append("\n");
                sb.Append("{\n");
                foreach (MaterialTechnique_14 mt in materialTechniques)
                {
                    sb.Append("    technique\n");
                    sb.Append("    {\n");
                    sb.Append("        pass\n");
                    sb.Append("        {\n");
                    sb.Append("            shading phong\n");
                    sb.Append("\n");
                    sb.Append("            ambient  " + AsRGBAString(mt.Ambient) + "\n");
                    sb.Append("            diffuse  " + AsRGBAString(mt.Diffuse) + "\n");
                    sb.Append("            specular " + AsRGBAString(mt.Specular) + string.Format(" {0:f5}", mt.Shininess) + "\n");
                    sb.Append("            emissive " + AsRGBAString(mt.Emissive) + "\n");
                    sb.Append("\n");
                    if (mt.DiffuseTexture != null)
                    {
                        string diffuseTexture = string.Empty;
                        string imageId        = mt.DiffuseTexture.imageId;
                        // If we have a surface sampler, use that.
                        // If we don't, go ahead and just use the image
                        if (m_SurfaceSamplers.ContainsKey(imageId))
                        {
                            SurfaceSampler sampler = m_SurfaceSamplers[imageId];
                            if (m_Surfaces.ContainsKey(sampler.surfaceName))
                            {
                                Surface surface = m_Surfaces[sampler.surfaceName];
                                imageId = surface.image;
                            }
                        }
                        if (m_Images.ContainsKey(imageId))
                        {
                            diffuseTexture = m_Images[imageId];
                        }
                        int idx = diffuseTexture.LastIndexOfAny(pathDelims);
                        if (idx >= 0)
                        {
                            diffuseTexture = diffuseTexture.Substring(idx + 1);
                        }
                        sb.Append("            texture_unit\n");
                        sb.Append("            {\n");
                        sb.Append("                texture ");
                        sb.Append(diffuseTexture);
                        sb.Append("\n");
                        sb.Append("                tex_coord_set 0\n");
                        sb.Append("            }\n");
                    }
                    sb.Append("        }\n");
                    sb.Append("    }\n");
                }
                sb.Append("}\n");
            }
        }
        private void ReadSampler2D( string param_sid, XmlNode node, ColladaMeshInfo meshInfo )
        {
            SurfaceSampler sampler = new SurfaceSampler();
            sampler.samplerName = param_sid;
            sampler.texType = TextureType.TwoD;
            foreach( XmlNode childNode in node.ChildNodes )
            {
                switch( childNode.Name )
                {
                case "source":
                    sampler.surfaceName = childNode.InnerText;
                    break;
                default:
                    DebugMessage( childNode );
                    break;
                }
            }

            MaterialBuilder.AddSurfaceSampler( param_sid, sampler );
        }
        internal void AddSurfaceSampler( string sid, SurfaceSampler sampler )
        {
            s_Log.Info( "AddSurfaceSampler: " + sid );

            if( null != sampler.surfaceName )
            {
                m_SurfaceSamplers[ sid ] = sampler;
            }
        }
Ejemplo n.º 5
0
 public virtual void Initialize() {
     bool lowLatency = false;
     //this.IntersectionDevice = new CpuBvhIntersectionEngine(Scene);
     this.IntersectionDevice = new OpenClIntersectionDevice(Scene, lowLatency, 0);
     
     this.RenderThreads = new RenderThread[this.RenderThreadsCount];
     var sampler = new UniformSampler() { lowLatency = lowLatency };
     this.IntersectionManager = new SurfaceSampler(Scene);
     RenderThreads[0] = 
         //new NativeRenderThread(0, (CpuBvhIntersectionEngine)IntersectionDevice, Scene, true, (ImageFilm)Film, sampler, this.IntersectionManager);
         //new DeviceRenderThread(0, IntersectionDevice, Scene, lowLatency, (ImageFilm)Film, sampler, this.IntersectionManager);
         new PhotonMappingRenderThread(0, IntersectionDevice, Scene, lowLatency, (PMFilm)Film, sampler, this.IntersectionManager);
 }