private void Update() { if (manager.Player == null) { return; } if (langType == 0) { return; } Vector3 pos = manager.Player.position; pos -= StreamerManager.GetCurrentMove(); int xPosCurrent = (xSceneSize != 0) ? (int)(Mathf.FloorToInt(pos.x / xTileSize)) : 0; int zPosCurrent = (zSceneSize != 0) ? (int)(Mathf.FloorToInt(pos.z / zTileSize)) : 0; if (xPosCurrent != xPos || zPosCurrent != zPos) { xPos = xPosCurrent; zPos = zPosCurrent; for (int z = -1; z < 2; z++) { for (int x = -1; x < 2; x++) { GameObject obj = GetBillboardObject(xPos + x, zPos + z); if (obj) { obj.SetActive(true); } } } } }
private void Update() { if (manager.Player == null) { return; } Vector3 pos = manager.Player.position; pos -= StreamerManager.GetCurrentMove(); int xPosCurrent = (xSceneSize != 0) ? (int)(Mathf.FloorToInt(pos.x / xTileSize)) : 0; int zPosCurrent = (zSceneSize != 0) ? (int)(Mathf.FloorToInt(pos.z / zTileSize)) : 0; if (xPosCurrent != xPos || zPosCurrent != zPos || ForceRefresh) { xPos = xPosCurrent; zPos = zPosCurrent; ForceRefresh = false; Refresh(); } }
protected void SendParamsToShader() { if (mat == null || !mat.HasProperty(ot_NormalMap0)) { return; } Shader.SetGlobalFloat(ot_OceanPosition, position); // Wave function animation //Shader.SetGlobalVector(ot_WaveScales, waveScales); //Shader.SetGlobalVector(ot_WaveLengths, waveLengths); //Shader.SetGlobalVector(ot_WaveExponents, waveExponents); //Shader.SetGlobalVector(ot_WaveOffsets, waveOffsets); //Shader.SetGlobalVector(ot_WaveDirection01, waveDirection01); //Shader.SetGlobalVector(ot_WaveDirection23, waveDirection23); //Shader.SetGlobalVector(ot_WaveConstants, waveConstants); //Shader.SetGlobalVector(ot_WaveDerivativeConstants, waveDerivativeConstants); Shader.SetGlobalVector(ot_WorldMove, StreamerManager.GetCurrentMove()); // Texture animations Vector2 normalMapScale0 = mat.GetTextureScale(ot_NormalMap0); //Vector2 normalMapScale1 = mat.GetTextureScale(ot_NormalMap1); //Vector2 foamMapScale = mat.GetTextureScale(ot_FoamMap); #if !UNITY_EDITOR mat.SetTextureOffset(ot_NormalMap0, VH.Mul(normalMapOffset0, normalMapScale0)); //mat.SetTextureOffset(ot_NormalMap1, VH.Mul(normalMapOffset1, normalMapScale1)); //mat.SetTextureOffset(ot_FoamMap, VH.Mul(foamMapOffset, foamMapScale)); #else if (Application.isPlaying) { mat.SetTextureOffset(ot_NormalMap0, VH.Mul(normalMapOffset0, normalMapScale0)); //mat.SetTextureOffset(ot_NormalMap1, VH.Mul(normalMapOffset1, normalMapScale1)); //mat.SetTextureOffset(ot_FoamMap, VH.Mul(foamMapOffset, foamMapScale)); } #endif // General Vector3 lightDir = Vector3.up; if (sun != null) { lightDir = -sun.transform.forward; } Shader.SetGlobalVector(ot_LightDir, lightDir); Vector4 dwColorUnlit = mat.GetColor(ot_DeepWaterColorUnlit); //float dwIntensityZenith = mat.GetFloat(ot_DeepWaterIntensityZenith); //float dwIntensityHorizon = mat.GetFloat(ot_DeepWaterIntensityHorizon); //float dwIntensityDark = mat.GetFloat(ot_DeepWaterIntensityDark); //float dwScalar = 0.0f; //if (lightDir.y >= 0.0f) //{ // dwScalar = Mathf.Lerp(dwIntensityHorizon, dwIntensityZenith, lightDir.y); //} //else //{ // dwScalar = Mathf.Lerp(dwIntensityHorizon, dwIntensityDark, -lightDir.y); //} //Shader.SetGlobalVector(ot_DeepWaterColor, dwColorUnlit * dwScalar); Shader.SetGlobalVector(ot_DeepWaterColor, dwColorUnlit); }