public Scene(RGBColor iamb, NameableCollection <Light> lights, Camera defaultCamera, float refractIndice) { this.IAmb = iamb; this.RefractIndex = refractIndice; if (lights != null) { this.Lights = new NameableCollection <Light>(lights); } else { this.Lights = new NameableCollection <Light>(); } this.primitives = new NameableCollection <Primitive>(); this.AccelerationStructure = new KDTreePrimitiveManager(this.primitives as IList <Primitive>); this.materials = new NameableCollection <Material>(); this.DefaultCamera = defaultCamera; this.Cameras = new NameableCollection <Camera>(); if (defaultCamera != null) { this.Cameras.Add(defaultCamera); } this.sampler = new JitteredSampler(); this.shader = new PhongShader(this); this.renderStrategy = new ScanlineRenderStrategy(); this.isShadowActive = false; this.softShadowSamples = 8; this.glossySamples = 8; //this.cameras.CollectionChanged += new NotifyCollectionChangedEventHandler<Camera>(cameras_CollectionChanged); }
public void CanRenderSimpleTemplate() { var renderer = new RenderStrategy(new Liquid(), new Markdown(), new HtmlContentFilter()); var result = renderer.Render(@"hello {{variable}}", new { variable = "world" }); Assert.Equal("hello world", result); }
public void CanRenderTemplateWithNumberFormatting() { var renderer = new RenderStrategy(new Liquid(), new Markdown(), new HtmlContentFilter()); var result = renderer.Render(@"hello {{variable | string.to_double | math.format ""N"" ""nl-NL""}}", new { variable = "1345" }); Assert.Equal("hello 1.345,00", result); result = renderer.Render(@"hello {{variable | string.to_double | math.format ""N"" ""nl-NL""}}", new { variable = "1345.1" }); Assert.Equal("hello 1.345,10", result); }
public PhotonTracer(Scene scene, RenderStrategy renderStrategy, int maxPhotons) : base(scene, renderStrategy) { this.scene = scene; this.maxPhotons = maxPhotons; this.indirectEnlightenment = new PhotonMap(maxPhotons); this.causticsEnlightenment = new PhotonMap(maxPhotons); this.buildPhotonMaps = true; this.scene.Primitives.CollectionChanged += Primitives_CollectionChanged; this.scene.Lights.CollectionChanged += Lights_CollectionChanged; this.scene.Materials.CollectionChanged += Materials_CollectionChanged; }
// Update is called once per frame void Update() { if (_cachedDebug != _debug) { _renderStrategy.SetDebug(_debug); _cachedDebug = _debug; } // If the user changes what kind of rendering they want, update if (_cachedInstanceRendering != _instancedRendering) { ToggleInstancedRendering(); } // If the user changes how many meshes or unique objects they want, create new renderings if (_cachedNumMeshes != _totalNumMeshes || !ArrayEquals(_objs, _cachedObjs)) { InitializeInfo(); _renderStrategy.Destroy(); if (_instancedRendering == true) { _renderStrategy = new Instanced(this.gameObject, _objs, _objMat, _computeShader, _objInfo, _totalNumMeshes); } else { _renderStrategy = new Instantiated(this.gameObject, _objs, _objMat, _computeShader, _objInfo, _totalNumMeshes); } _renderStrategy.SetDebug(_debug); _renderStrategy.SetNormalMapsEnabled(_normalMapsEnabled); _cachedNumMeshes = _totalNumMeshes; _cachedObjs = new GameObject[_objs.Length]; _cachedObjs = (GameObject[])_objs.Clone(); } // IF the user changes whether or not they want to be using normal maps or not if (_cachedNormalMapsEnabled != _normalMapsEnabled) { _renderStrategy.SetNormalMapsEnabled(_normalMapsEnabled); _cachedNormalMapsEnabled = _normalMapsEnabled; } // Update our objects based on our render strategy _renderStrategy.UpdateMeshes(); }
/* * CLASS DOCUMENTATION: ObjRenderer * This class acts as a layer and user interface. It has a series of objects in its slice that move * with it, as well as giving the option to have the objects rendered in different forms: * Instantiated GameObjects * GPU Instanced */ // Use this for initialization void Start() { InitializeInfo(); // Initialize our new RenderStrategy _renderStrategy = new Instantiated(this.gameObject, _objs, _objMat, _computeShader, _objInfo, _totalNumMeshes); _renderStrategy.SetDebug(_debug); _cachedInstanceRendering = _instancedRendering; _cachedNumMeshes = _totalNumMeshes; _cachedObjs = new GameObject[_objs.Length]; _cachedObjs = (GameObject[])_objs.Clone(); _cachedDebug = _debug; _cachedNormalMapsEnabled = _normalMapsEnabled; }
public void CanRenderTemplateUsingDictionary() { var fields = new Dictionary <string, object>(); fields.Add("boolean", true); fields.Add("double", 4.25); fields.Add("hello", "hello"); var renderer = new RenderStrategy(new Liquid(), new Markdown(), new HtmlContentFilter()); var result = renderer.Render(@"**{{hello}}** € {{double}} {% if boolean %} world! {% endif %} ", fields); Assert.Equal("<strong>hello</strong> € 4.25 world!", result); }
/* * Based on user input, decide whether to render objects using GPU Instancing * or Gameobject Instantiation */ void ToggleInstancedRendering() { List <ObjInfo>[] newObjInfo = _renderStrategy.GetObjInfo(); _renderStrategy.Destroy(); if (_instancedRendering == true) { _renderStrategy = new Instanced(this.gameObject, _objs, _objMat, _computeShader, newObjInfo, _totalNumMeshes); } else { _renderStrategy = new Instantiated(this.gameObject, _objs, _objMat, _computeShader, newObjInfo, _totalNumMeshes); } _renderStrategy.SetDebug(_debug); _renderStrategy.SetNormalMapsEnabled(_normalMapsEnabled); _cachedInstanceRendering = _instancedRendering; }
public AbstractSpriteSet(Device device, Array points) { if (RenderContext11.Downlevel) { if (RenderContext11.SupportsInstancing) { renderStrategy = RenderStrategy.Instanced; } else { renderStrategy = RenderStrategy.Fallback; } } else { renderStrategy = RenderStrategy.GeometryShader; } count = points.Length; createAuxilliaryBuffers(device); }
public AbstractSpriteSet(SharpDX.Direct3D11.Device device, System.Array points) { if (RenderContext11.Downlevel) { if (RenderContext11.SupportsInstancing) { renderStrategy = RenderStrategy.Instanced; } else { renderStrategy = RenderStrategy.Fallback; } } else { renderStrategy = RenderStrategy.GeometryShader; } count = points.Length; createAuxilliaryBuffers(device); }
public static void SetFrameRate(double frameRate) { RenderStrategy.SetTargetFrameRate(frameRate); }
protected RayCasting(Scene scene, RenderStrategy renderStrategy) { this.scene = scene; this.maxDepth = 5; this.RenderStrategy = renderStrategy; }
public RayTracer(Scene scene, RenderStrategy renderStrategy) : base(scene, renderStrategy) { }
public DistributedRayTracer(Scene scene, RenderStrategy renderStrategy) : base(scene, renderStrategy) { }