Hi Harald
Ok I'm trying it out now. Pls bear in mind most of my coding knowledge is C# based.. so shader coding is still alien to me.
I am getting red errors, obviously something isn't right. But can you take a look at the shader changes? What is causing the red error? The console isn't very helpful.. Unity just says
Shader error in 'Universal Render Pipeline/Spine/Sprite': undeclared identifier 'LightweightFragmentBlinnPhongSimplified' at /ProjectY/Packages/com.esotericsoftware.spine.urp-shaders-4.0-Unity2019.3-2021-12-10/Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl(262) (on d3d11) ....
I combined both the two branches as you suggested and inserted the lerp snippet from your previous post. Is this the right way to do it?
#if defined(SPECULAR)
half2 metallicGloss = getMetallicGloss(input.texcoord.xy);
half metallic = metallicGloss.x;
half smoothness = metallicGloss.y; // this is 1 minus the square root of real roughness m.
half3 specular = half3(0, 0, 0);
half4 emission = half4(0, 0, 0, 1);
APPLY_EMISSION_SPECULAR(emission, input.texcoord.xy)
half4 pixelPBR = LightweightFragmentPBRSimplified(inputData, texureColor, metallic, specular, smoothness, emission.rgb, input.vertexColor);
half3 emissionA = half3(0, 0, 0);
APPLY_EMISSION(emissionA, input.texcoord.xy)
//LINE 262
---
isn't pixelLam declared here? :\
half4 pixelLam = LightweightFragmentBlinnPhongSimplified(inputData, texureColor, emissionA, input.vertexColor);
//LINE 262
float4 _lambertResult = pixelLam;
float4 _pbrResult = pixelPBR;
float4 _test = lerp(_lambertResult, _pbrResult, metallicGloss);
#endif
later on down the shader I get a red error telling me the return is incorrect.
#if defined(_RIM_LIGHTING)
_test.rgb = applyRimLighting(input.positionWS.xyz, normalWS, _test);
#endif
COLORISE(_test)
APPLY_FOG_LWRP(_test, input.fogFactorAndVertexLight.x)
return _test;
}
I'm not sure if I should be returning test from the specular "branch" ? In the original shader its returning
//#if defined(_RIM_LIGHTING)
// pixel.rgb = applyRimLighting(input.positionWS.xyz, normalWS, pixel);
//#endif
//
// COLORISE(pixel)
// APPLY_FOG_LWRP(pixel, input.fogFactorAndVertexLight.x)
//
// return pixel;
//}
However, this pixel was only found in the
//#if defined(SPECULAR)
// half2 metallicGloss = getMetallicGloss(input.texcoord.xy);
// half metallic = metallicGloss.x;
// half smoothness = metallicGloss.y; // this is 1 minus the square root of real roughness m.
//
// half3 specular = half3(0, 0, 0);
// half4 emission = half4(0, 0, 0, 1);
// APPLY_EMISSION_SPECULAR(emission, input.texcoord.xy)
// half4 pixel = LightweightFragmentPBRSimplified(inputData, texureColor, metallic, specular, smoothness, emission.rgb, input.vertexColor);
//#else
// half3 emission = half3(0, 0, 0);
// APPLY_EMISSION(emission, input.texcoord.xy)
// half4 pixel = LightweightFragmentBlinnPhongSimplified(inputData, texureColor, emission, input.vertexColor);
//#endif
branch, as far as I could tell. Which I now changed to the _test lerp
Thanks for the help! 🙂