BeforeColorAmountプロパティはfloatかrangeの値を持たない?的なことを言われるのですが公式のShaderリファレンスを見ても解決方法がわからず、「doesn't have a float or range property」で検索しても解決方法がわからなかったので質問させていただきました。
発生している問題・エラーメッセージ
Material 'Custom_Gradation (Instance)' with Shader 'Custom/Gradation' doesn't have a float or range property 'BeforeColorAmount' #0 GetStacktrace(int) #1 DebugStringToFile(DebugStringToFileData const&) #2 Material::GetFloat(ShaderLab::FastPropertyName) #3 Material_CUSTOM_GetFloatImpl(ScriptingBackendNativeObjectPtrOpaque*, int) #4 (Mono JIT Code) (wrapper managed-to-native) UnityEngine.Material:GetFloatImpl (UnityEngine.Material,int) #5 mono_jit_runtime_invoke #6 do_runtime_invoke #7 mono_runtime_invoke #8 scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool) #9 ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool) #10 Coroutine::InvokeMoveNext(ScriptingExceptionPtr*) #11 Coroutine::Run(bool*) #12 DelayedCallManager::Update(int) #13 InitPlayerLoopCallbacks()::UpdateScriptRunDelayedDynamicFrameRateRegistrator::Forward() #14 ExecutePlayerLoop(NativePlayerLoopSystem*) #15 ExecutePlayerLoop(NativePlayerLoopSystem*) #16 PlayerLoop() #17 PlayerLoopController::UpdateScene(bool) #18 PlayerLoopController::UpdateSceneIfNeeded() #19 Application::TickTimer() #20 -[EditorApplication TickTimer] #21 __NSFireTimer #22 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ #23 __CFRunLoopDoTimer #24 __CFRunLoopDoTimers #25 __CFRunLoopRun #26 CFRunLoopRunSpecific #27 RunCurrentEventLoopInMode #28 ReceiveNextEventCommon #29 _BlockUntilNextEventMatchingListInModeWithFilter #30 _DPSNextEvent #31 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] #32 -[NSApplication run] #33 NSApplicationMain #34 EditorMain(int, char const**) #35 main #36 start #37 ???
該当のソースコード
C#
1Shader "Custom/Gradation" 2{ 3 Properties 4 { 5 _MainTex( "2D Texture", 2D ) = "white" {} 6 _BeforeColor ("Before Color", Color) = (0.8,0.8,0,1) 7 _AfterColor ("After Color", Color) = (1,0,0,1) 8 _BeforeColorAmount("Before Color Amount", Range(-1, 1)) = -1 9 } 10 SubShader 11 { 12 Tags 13 { 14 "RenderType"="Opaque" 15 "Queue" = "Transparent" 16 "LightMode" = "ForwardBase" 17 } 18 LOD 100 19 Pass 20 { 21 CGPROGRAM 22 #pragma vertex vert 23 #pragma fragment frag 24 #include "UnityCG.cginc" 25 #include "UnityLightingCommon.cginc" 26 27 fixed4 _BeforeColor; 28 fixed4 _AfterColor; 29 fixed _BeforeColorAmount; 30 31 struct appdata 32 { 33 half4 vertex : POSITION; 34 half2 uv : TEXCOORD0; 35 float3 normal : NORMAL; 36 }; 37 38 struct v2f 39 { 40 half4 vertex : SV_POSITION; 41 fixed4 color : COLOR0; 42 half2 uv : TEXCOORD0; 43 }; 44 45 v2f vert(appdata v) 46 { 47 v2f o; 48 o.vertex = UnityObjectToClipPos(v.vertex); 49 o.uv = v.uv; 50 half3 worldNormal = UnityObjectToWorldNormal(v.normal); 51 half nl = max(0, dot(worldNormal, _WorldSpaceLightPos0.xyz)); 52 o.color = nl * _LightColor0; 53 o.color.rgb += ShadeSH9(half4(worldNormal,1)); 54 55 return o; 56 } 57 58 fixed4 frag(v2f i) : COLOR 59 { 60 fixed amount = clamp(i.uv.y + _BeforeColorAmount, 0,1.0); 61 i.color = lerp(_AfterColor, _BeforeColor, amount) * i.color; 62 63 return i.color; 64 } 65 ENDCG 66 } 67 } 68} 69
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/04/25 20:41