示例#1
0
        public void DrawProjectionCube(Vector3 center, Vector3 radius)
        {
            if (projMaterial == null)
            {
                projMaterial = Resources.Load <Material>("projectionMat");
                if (!projMaterial)
                {
                    Debug.LogError("Failed to find projectionMat material in Resources folder!");
                }
            }

            Vector4 exposureIBL = Vector4.one;

            exposureIBL.z = this.CamExposure;
            exposureIBL  *= this.masterIntensity;

            ShaderIDs bids = this.blendIDs[0];

            projMaterial.color = new Color(0.7f, 0.7f, 0.7f, 1f);
            projMaterial.SetVector(bids.skyMin, -this.Dimensions.extents);
            projMaterial.SetVector(bids.skyMax, this.Dimensions.extents);
            projMaterial.SetVector(bids.exposureIBL, exposureIBL);
            projMaterial.SetTexture(bids.skyCubeIBL, this.specularCube);
            projMaterial.SetMatrix(bids.skyMatrix, skyMatrix);
            projMaterial.SetMatrix(bids.invSkyMatrix, invMatrix);
            projMaterial.SetPass(0);
            GL.PushMatrix();
            GL.MultMatrix(this.transform.localToWorldMatrix);

            mset.GLUtil.DrawCube(center, -radius);

            GL.End();
            GL.PopMatrix();
        }
示例#2
0
        private void ApplyGlobally(ShaderIDs bids)
        {
            //Transform
            Shader.SetGlobalMatrix(bids.skyMatrix, skyMatrix);
            Shader.SetGlobalMatrix(bids.invSkyMatrix, invMatrix);

            Shader.SetGlobalVector(bids.skyMin, skyMin);
            Shader.SetGlobalVector(bids.skyMax, skyMax);

            //Exposures
            Shader.SetGlobalVector(bids.exposureIBL, exposures);
            Shader.SetGlobalVector(bids.exposureLM, exposuresLM);
            Shader.SetGlobalFloat("_EmissionLM", 1f);                                   //a hint for the Beast Lightmapper, rendering is unaffected
            Shader.SetGlobalVector("_UniformOcclusion", Vector4.one);                   //set only on individual renderers and outside the scope of the sky system

            //IBL
            if (specularCube)
            {
                Shader.SetGlobalTexture(bids.specCubeIBL, specularCube);
            }
            else
            {
                Shader.SetGlobalTexture(bids.specCubeIBL, blackCube);
            }
            if (skyboxCube)
            {
                Shader.SetGlobalTexture(bids.skyCubeIBL, skyboxCube);
            }
            //bind spherical harmonics
            for (int i = 0; i < 9; ++i)
            {
                Shader.SetGlobalVector(bids.SH[i], this.SH.cBuffer[i]);
            }
        }
示例#3
0
        private void ApplyToMaterial(Material mat, ShaderIDs bids)
        {
            mat.SetVector(bids.exposureIBL, this.exposures);
            mat.SetVector(bids.exposureLM, this.exposuresLM);
            mat.SetMatrix(bids.skyMatrix, this.skyMatrix);
            mat.SetMatrix(bids.invSkyMatrix, this.invMatrix);

            mat.SetVector(bids.skyMin, skyMin);
            mat.SetVector(bids.skyMax, skyMax);

            if (specularCube)
            {
                mat.SetTexture(bids.specCubeIBL, this.specularCube);
            }
            else
            {
                mat.SetTexture(bids.specCubeIBL, this.blackCube);
            }
            if (skyboxCube)
            {
                mat.SetTexture(bids.skyCubeIBL, this.skyboxCube);
            }
            for (int i = 0; i < 9; ++i)
            {
                mat.SetVector(bids.SH[i], this.SH.cBuffer[i]);
            }
        }
示例#4
0
        private void ApplyToBlock(ref MaterialPropertyBlock block, ShaderIDs bids)
        {
                        #if USE_PROPERTY_BLOCKS
            block.AddVector(bids.exposureIBL, exposures);
            block.AddVector(bids.exposureLM, exposuresLM);

            block.AddMatrix(bids.skyMatrix, skyMatrix);
            block.AddMatrix(bids.invSkyMatrix, invMatrix);

            block.AddVector(bids.skyMin, skyMin);
            block.AddVector(bids.skyMax, skyMax);

            if (specularCube)
            {
                block.AddTexture(bids.specCubeIBL, specularCube);
            }
            else
            {
                block.AddTexture(bids.specCubeIBL, blackCube);
            }

            block.AddVector(bids.SH[0], SH.cBuffer[0]);
            block.AddVector(bids.SH[1], SH.cBuffer[1]);
            block.AddVector(bids.SH[2], SH.cBuffer[2]);
            block.AddVector(bids.SH[3], SH.cBuffer[3]);
            block.AddVector(bids.SH[4], SH.cBuffer[4]);
            block.AddVector(bids.SH[5], SH.cBuffer[5]);
            block.AddVector(bids.SH[6], SH.cBuffer[6]);
            block.AddVector(bids.SH[7], SH.cBuffer[7]);
            block.AddVector(bids.SH[8], SH.cBuffer[8]);
                        #endif
        }
示例#5
0
        private void ApplySkyTransform(ShaderIDs bids)
        {
            Shader.SetGlobalMatrix(bids.skyMatrix, skyMatrix);
            Shader.SetGlobalMatrix(bids.invSkyMatrix, invMatrix);

            Shader.SetGlobalVector(bids.skyMin, skyMin);
            Shader.SetGlobalVector(bids.skyMax, skyMax);
        }
示例#6
0
		private void ApplyGlobally(ShaderIDs bids) {
			//Transform
			Shader.SetGlobalMatrix(bids.skyMatrix, skyMatrix);
			Shader.SetGlobalMatrix(bids.invSkyMatrix, invMatrix);

			Shader.SetGlobalVector(bids.skyMin, skyMin);
			Shader.SetGlobalVector(bids.skyMax, skyMax);

			//Exposures
			Shader.SetGlobalVector(bids.exposureIBL, exposures);
			Shader.SetGlobalVector(bids.exposureLM, exposuresLM);			
			Shader.SetGlobalFloat("_EmissionLM", 1f); 					//a hint for the Beast Lightmapper, rendering is unaffected
			Shader.SetGlobalVector("_UniformOcclusion", Vector4.one); 	//set only on individual renderers and outside the scope of the sky system
			
			//IBL
			if(specularCube)Shader.SetGlobalTexture(bids.specCubeIBL, specularCube);
			else 			Shader.SetGlobalTexture(bids.specCubeIBL, blackCube);
			if(skyboxCube)	Shader.SetGlobalTexture(bids.skyCubeIBL, skyboxCube);
			//bind spherical harmonics
			for(int i=0; i<9; ++i) { Shader.SetGlobalVector(bids.SH[i], this.SH.cBuffer[i]); }
		}
示例#7
0
		private void ApplySkyTransform(ShaderIDs bids) {
			Shader.SetGlobalMatrix(bids.skyMatrix, skyMatrix);
			Shader.SetGlobalMatrix(bids.invSkyMatrix, invMatrix);

			Shader.SetGlobalVector(bids.skyMin, skyMin);
			Shader.SetGlobalVector(bids.skyMax, skyMax);
		}
示例#8
0
		private void ApplyToMaterial(Material mat, ShaderIDs bids) {
			mat.SetVector(bids.exposureIBL,	this.exposures);
			mat.SetVector(bids.exposureLM,	this.exposuresLM);			
			mat.SetMatrix(bids.skyMatrix,		this.skyMatrix);
			mat.SetMatrix(bids.invSkyMatrix,	this.invMatrix);

			mat.SetVector(bids.skyMin, skyMin);
			mat.SetVector(bids.skyMax, skyMax);
					
			if(specularCube) mat.SetTexture(bids.specCubeIBL,	this.specularCube);
			else 			 mat.SetTexture(bids.specCubeIBL,	this.blackCube);
			if(skyboxCube)	 mat.SetTexture(bids.skyCubeIBL, 	this.skyboxCube);
			for(int i=0; i<9; ++i) {
				mat.SetVector(bids.SH[i], this.SH.cBuffer[i]);
			}
		}
示例#9
0
		private void ApplyToBlock(ref MaterialPropertyBlock block, ShaderIDs bids) {
			#if USE_PROPERTY_BLOCKS
			block.AddVector(bids.exposureIBL,	exposures);
			block.AddVector(bids.exposureLM,	exposuresLM);

			block.AddMatrix(bids.skyMatrix,		skyMatrix);
			block.AddMatrix(bids.invSkyMatrix,	invMatrix);

			block.AddVector(bids.skyMin, skyMin);
			block.AddVector(bids.skyMax, skyMax);			

			if(specularCube) block.AddTexture(bids.specCubeIBL, specularCube);
			else 			 block.AddTexture(bids.specCubeIBL, blackCube);

			block.AddVector(bids.SH[0],	SH.cBuffer[0]);
			block.AddVector(bids.SH[1],	SH.cBuffer[1]);
			block.AddVector(bids.SH[2],	SH.cBuffer[2]);
			block.AddVector(bids.SH[3],	SH.cBuffer[3]);
			block.AddVector(bids.SH[4],	SH.cBuffer[4]);
			block.AddVector(bids.SH[5],	SH.cBuffer[5]);
			block.AddVector(bids.SH[6],	SH.cBuffer[6]);
			block.AddVector(bids.SH[7],	SH.cBuffer[7]);
			block.AddVector(bids.SH[8], SH.cBuffer[8]);

			#endif
		}
示例#10
0
        public void Apply(int blendIndex)
        {
            ShaderIDs bids = this.blendIDs[blendIndex];

            ApplyGlobally(bids);
        }