#Custom use of URPTriplanar shader Q

1 messages · Page 1 of 1 (latest)

frank escarp
#

I am referring to the shader GraphGrid from this aset: https://assetstore.unity.com/packages/essentials/starter-assets-thirdperson-urp-196526
The one with the blue digital flikering effect.
How can this shader be customised to be used with a brush on terrain layers and apply the same shader effect to terrain shader.
I'm using Unity 6.2. URP. Saw that there are some terrain shaders in Unity 6.3 but not sure if this helps me.

Get the Starter Assets - ThirdPerson | URP package from Unity Technologies and speed up your game development process. Find this & other Essentials options on the Unity Asset Store.

novel arrow
frank escarp
novel arrow
#

You may also consider decal renderers
They can project a triplanar or any kind of texture within their volume on anything opaque
Could potentially be more practical than working the grid shader into Terrain

frank escarp
novel arrow
#

Shader Graph's sample Production Ready Shaders that can be found in package manager under its entry includes animated decal shaders

#

The "caustics" example is much like triplanar and quite animated

#

Specifically it seems to be using a cheaper approximate way to do triplanar projection but you can just as well use any kind of projection you need

#

@frank escarp The "material projection" decal example has the old familiar triplanar
No animation but that's not directly tied to projection

frank escarp
novel arrow
#

"animation" is an inexact term in this context and as far as I know there are no situations where a shader cannot be made to animate

frank escarp
novel arrow
#

Flickery sine wave copied directly from the shader in starter assets
The Face Normal sub-graph copied from Production Ready Shaders' "material projection" shader I mentioned earlier
Decal shaders can't directly get world normals with the Normal Vector node, so solving that would've been tricky without an example

#

This is also something that seems to have changed by version 6.3. as the new template uses a slightly different method for URP for some reason:

#ifndef GET_SCENE_NORMAL
#define GET_SCENE_NORMAL
    #if  !defined(SHADERGRAPH_PREVIEW)
        #if defined(UNIVERSAL_PIPELINE_CORE_INCLUDED) //URP
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareNormalsTexture.hlsl"
            void GetSceneNormal_float(float2 ScreenPos, out float3 WorldNormal)
            {
                WorldNormal = SampleSceneNormals(ScreenPos);
            }
            void GetSceneNormal_half(float2 ScreenPos, out float3 WorldNormal)
            {
                WorldNormal = SampleSceneNormals(ScreenPos);
            }
        #else //HDRP
            #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/NormalBuffer.hlsl"
            void GetSceneNormal_float(float2 ScreenPos, out float3 WorldNormal)
            {
                uint2 positionSS = ScreenPos * _ScreenSize.xy;
                NormalData normalData;
DecodeFromNormalBuffer(positionSS, normalData);
                WorldNormal = normalData.normalWS;
            }
        #endif
    #else
        void GetSceneNormal_float(float2 ScreenPos, UnityTexture2D _CameraNormalsTexture, out float3 WorldNormal)
        {
            WorldNormal = float3(0,1,0);
        }
        void GetSceneNormal_half(float2 ScreenPos, UnityTexture2D _CameraNormalsTexture, out float3 WorldNormal)
        {
            WorldNormal = float3(0,1,0);
        }
    #endif
#endif
frank escarp
frank escarp
novel arrow
frank escarp
frank escarp
novel arrow
#

The code is for 6.3.

novel arrow
#

I don't really mean for you to replicate the setup, but to get it from the importable sample

#

Or rather not replicate the setup just based on the image, but to get the original nodes

#

When you import the samples it'll give the version of the sample that is most appropriate for your editor and URP version

#

I'm not sure if the custom function node has dependencies or if it's compatible with 6.2. so you should check what kind of nodes you get from the samples for your version

frank escarp
novel arrow
frank escarp
novel arrow
#

Or what graph settings you have

frank escarp
#

everything is the same as you provided, I fix it for showing the flickering, but when it goes, the grid lines are going as well, which is not desired.

#

moreover, can this use a mask, to make the projection in a not so uniform geometry and defined as the square projection? I wanted to have this placed on terrain, looking like a splash , for example.

novel arrow
novel arrow
novel arrow
#

Also, are the materials in your world using a custom shader, like a toon shader of some kind

#

Decals attempt to override certain properties of the material behind them
If the materials don't have those properties, as is often the case with custom shader, the decal could fail
I don't recall off the top of my head what's the process for making a decal shader that just replaces color instead of overriding properties
But what you can test is the scene included in the shader samples to verify the decal feature is working in general, then you can test the included decal materials in your scene to verify that they do work with your assets also

frank escarp
#

I am not sure, I just created a node, typed face normal, and I got that. Input>Geometry>FaceNormal.
No, those dont have custom shaders, and even thou it was mostly related to the terrain. the objects were just to see the depth in that moment.

#

I believe the decals are not a good solution for my case if the projection cannot be edited to have another shape, then I will disregard the attempt. I just wanted to edit the appearences of some parts of the terrain. Including the objects from that space into the projection was nice, but I don't think its what i need.

novel arrow
novel arrow
novel arrow