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(); }
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]); } }
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]); } }
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 }
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); }
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]); } }
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]); } }
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 }
public void Apply(int blendIndex) { ShaderIDs bids = this.blendIDs[blendIndex]; ApplyGlobally(bids); }