Fresnel shader help

I am looking to make a shader which fades out at the edge of the object.
Had a look at the plasma example and this changes emissive with material.chunks.emissiveConstPS = fs;
and
vec3 getEmission() ()

How would I do the same for the Diffuse Colour, so I can fade the Alpha with a dotproduct at the edge?

What does material.chunks.emissiveConstPS have to be for diffuse also does getEmission() needs to be renamed

Any idea would be welcome

Hi @rleinfellner,

You can find the original shader chunks here, so you can copy and further edit the shader code:

https://github.com/playcanvas/engine/tree/master/src/graphics/program-lib/chunks

For the diffuse here is how you can override the default values for a simple material (no detail map):

    m.chunks.diffusePS = `
#ifdef MAPCOLOR
uniform vec3 material_diffuse;
#endif

#ifdef MAPTEXTURE
uniform sampler2D texture_diffuseMap;
#endif

void getAlbedo() {
    dAlbedo = vec3(1.0);

    #ifdef MAPCOLOR
        dAlbedo *= material_diffuse.rgb;
    #endif

    #ifdef MAPTEXTURE
        dAlbedo *= gammaCorrectInput(addAlbedoDetail(texture2D(texture_diffuseMap, $UV).$CH));
    #endif

    #ifdef MAPVERTEX
        dAlbedo *= gammaCorrectInput(saturate(vVertexColor.$VC));
    #endif
}
`
    m.update();
1 Like

Many thanks for this

Any idea why sqrt() is not defined, it should be a standard shader function

Ignore me its defined but editor does not know that



Look at engine source at github