[SOLVED] Character damage demo broken in Engine v1.55

I uploaded the fixed demo to my user page for everyone to check out: https://playcanvas.com/project/967840/overview/character-damage-demoshaderfix

I think it’s important to keep these demos working as the engine updates. If they no longer work after each update it might cause some confusion and push some devs away.

Here is the change log:
@Leonidas thanks for your help here!

DamageMetalnessPS - file
simply changed the name of the “void getSpecularity()”
function to “void getMetalness()”

DamageFresnelSchlickPS - file
changed this:

void getFresnel() {
    applyDamage2();
    
    float fresnel = 1.0 - max(dot(dNormalW, dViewDirW), 0.0);
    float fresnel2 = fresnel * fresnel;
    fresnel *= fresnel2 * fresnel2;
    fresnel *= dGlossiness * dGlossiness;
    dSpecularity = dSpecularity + (1.0 - dSpecularity) * fresnel;
    #ifdef CLEARCOAT
        fresnel = 1.0 - max(dot(ccNormalW, dViewDirW), 0.0);
        fresnel2 = fresnel * fresnel;
        fresnel *= fresnel2 * fresnel2;
        fresnel *= ccGlossiness * ccGlossiness;
        ccSpecularity = ccSpecularity + (1.0 - ccSpecularity) * fresnel;
    #endif

   }

to this

vec3 getFresnel(float cosTheta, vec3 f0) {
        applyDamage2();

    float fresnel = 1.0 - max(dot(dNormalW, dViewDirW), 0.0);
    float fresnel2 = fresnel * fresnel;
    fresnel *= fresnel2 * fresnel2;
    fresnel *= dGlossiness * dGlossiness;
    dSpecularity = dSpecularity + (1.0 - dSpecularity) * fresnel;
    #ifdef CLEARCOAT
        fresnel = 1.0 - max(dot(ccNormalW, dViewDirW), 0.0);
        fresnel2 = fresnel * fresnel;
        fresnel *= fresnel2 * fresnel2;
        fresnel *= ccGlossiness * ccGlossiness;
        ccSpecularity = ccSpecularity + (1.0 - ccSpecularity) * fresnel;
    #endif

    float glossSq = dGlossiness * dGlossiness;
    return f0 + (max(vec3(glossSq), f0) - f0) * fresnel;
}

@mvaligursky Thanks for the tip. I realized the “getEmission()” function needed to be changed to “dEmission”.

DamageEndPS - file
simply changed “getEmission()” to “dEmission”

2 Likes