好吧,我已经查看了所有相关问题,包括RenderSettings Skybox lerp-我只是想在着色器或材质(特别是分配给RenderSettings.skybox
的材质)之间使用。
我忍受实际着色器的原因是我将天空盒设置为使用多维数据集贴图的自定义旋转天空盒着色器。我试图保留分配给该材质的多维数据集贴图,但是没有用。这是现有的旋转天空盒着色器:
// Made with Amplify Shader Editor
// Available at the Unity Asset Store - http://u3d.as/y3X
Shader "Skybox/Cubemap Extended"
{
Properties
{
[Gamma][Header(Cubemap)]_TintColor("Tint Color", Color) = (0.5,0.5,0.5,1)
_Exposure("Exposure", Range( 0 , 8)) = 1
[NoScaleOffset]_Tex("Cubemap (HDR)", CUBE) = "black" {}
[Header(Rotation)][Toggle(_ENABLEROTATION_ON)] _EnableRotation("Enable Rotation", Float) = 0
[IntRange]_Rotation("Rotation", Range( 0 , 360)) = 0
_RotationSpeed("Rotation Speed", Float) = 1
[Header(Fog)][Toggle(_ENABLEFOG_ON)] _EnableFog("Enable Fog", Float) = 0
_FogHeight("Fog Height", Range( 0 , 1)) = 1
_FogSmoothness("Fog Smoothness", Range( 0.01 , 1)) = 0.01
_FogFill("Fog Fill", Range( 0 , 1)) = 0.5
[HideInInspector]_Tex_HDR("DecodeInstructions", Vector) = (0,0,0,0)
[HideInInspector] __dirty( "", Int ) = 1
}
SubShader
{
Tags{ "RenderType" = "Background" "Queue" = "Background+0" "IgnoreProjector" = "True" "ForceNoShadowCasting" = "True" "IsEmissive" = "true" "PreviewType"="Skybox" }
LOD 100
Cull Off
ZWrite Off
CGPROGRAM
#include "UnityShaderVariables.cginc"
#pragma target 2.0
#pragma shader_feature _ENABLEFOG_ON
#pragma shader_feature _ENABLEROTATION_ON
#pragma surface surf Unlit keepalpha noshadow noambient novertexlights nolightmap nodynlightmap nodirlightmap nofog nometa noforwardadd vertex:vertexDataFunc
struct Input
{
float3 vertexToFrag774;
float3 worldPos;
};
uniform half4 _Tex_HDR;
uniform samplerCUBE _Tex;
uniform half _Rotation;
uniform fixed _RotationSpeed;
uniform fixed4 _TintColor;
uniform half _Exposure;
uniform fixed _FogHeight;
uniform fixed _FogSmoothness;
uniform fixed _FogFill;
inline half3 DecodeHDR1189( half4 Data )
{
return DecodeHDR(Data, _Tex_HDR);
}
void vertexDataFunc( inout appdata_full v, out Input o )
{
UNITY_INITIALIZE_OUTPUT( Input, o );
float3 ase_worldPos = mul( unity_ObjectToWorld, v.vertex );
float lerpResult268 = lerp( 1.0 , ( unity_OrthoParams.y / unity_OrthoParams.x ) , unity_OrthoParams.w);
fixed CAMERA_MODE300 = lerpResult268;
float3 appendResult1129 = (float3(ase_worldPos.x , ( ase_worldPos.y * CAMERA_MODE300 ) , ase_worldPos.z));
float3 normalizeResult1130 = normalize( appendResult1129 );
float mulTime701 = _Time.y * 1;
float3 appendResult56 = (float3(cos( radians( ( _Rotation + ( mulTime701 * _RotationSpeed ) ) ) ) , 0.0 , ( sin( radians( ( _Rotation + ( mulTime701 * _RotationSpeed ) ) ) ) * -1.0 )));
float3 appendResult266 = (float3(0.0 , CAMERA_MODE300 , 0.0));
float3 appendResult58 = (float3(sin( radians( ( _Rotation + ( mulTime701 * _RotationSpeed ) ) ) ) , 0.0 , cos( radians( ( _Rotation + ( mulTime701 * _RotationSpeed ) ) ) )));
float3 normalizeResult247 = normalize( ase_worldPos );
#ifdef _ENABLEROTATION_ON
float3 staticSwitch1164 = mul( float3x3(appendResult56, appendResult266, appendResult58), normalizeResult247 );
#else
float3 staticSwitch1164 = normalizeResult1130;
#endif
o.vertexToFrag774 = staticSwitch1164;
}
inline fixed4 LightingUnlit( SurfaceOutput s, half3 lightDir, half atten )
{
return fixed4 ( 0, 0, 0, s.Alpha );
}
void surf( Input i , inout SurfaceOutput o )
{
half4 Data1189 = texCUBE( _Tex, i.vertexToFrag774 );
half3 localDecodeHDR1189 = DecodeHDR1189( Data1189 );
fixed4 CUBEMAP222 = ( float4( localDecodeHDR1189 , 0.0 ) * unity_ColorSpaceDouble * _TintColor * _Exposure );
float3 ase_worldPos = i.worldPos;
float3 normalizeResult319 = normalize( ase_worldPos );
float lerpResult678 = lerp( saturate( pow( (0.0 + (abs( normalizeResult319.y ) - 0.0) * (1.0 - 0.0) / (_FogHeight - 0.0)) , ( 1.0 - _FogSmoothness ) ) ) , 0.0 , _FogFill);
fixed FOG_MASK359 = lerpResult678;
float4 lerpResult317 = lerp( unity_FogColor , CUBEMAP222 , FOG_MASK359);
#ifdef _ENABLEFOG_ON
float4 staticSwitch1179 = lerpResult317;
#else
float4 staticSwitch1179 = CUBEMAP222;
#endif
o.Emission = staticSwitch1179.rgb;
o.Alpha = 1;
}
ENDCG
}
}
我需要使用新的Cubemap作为此着色器的纹理。由于我无法直接执行此操作,因此我尝试了以下操作:
RenderSettings.skybox.Lerp(RenderSettings.skybox, blendedSkybox, 3f);
在我的Update()
方法中,但这没做。我是着色器的新手-如何在这些多维数据集贴图之间或对RenderSettings
天空盒材质进行LERP?
我不想使用混合着色器,因为同样,此现有着色器会旋转,而混合着色器不会旋转。
float t = 0f;
// Update is called once per frame
void Update () {
//if (Input.GetKeyDown("return"))
//{
// BlendBetweenSkyboxes(skyboxes[0], skyboxes[1]);
//}
RenderSettings.skybox.Lerp(overallSkybox, blendedSkybox, t);
// .. and increase the t interpolater
t += 0.1f * Time.deltaTime;
// now check if the interpolator has reached 1.0
// and swap maximum and minimum so game object moves
// in the opposite direction.
if (t > 1.0f)
{
print("done");
}