Shader macro?

Node-based Shader Editor

Shader macro?

Postby Rokki » Mon Apr 02, 2018 8:32 am

Hi,
How do I use the Shader macro? Custom expression?
Will ASE generate the following code:
             Struct v2f
             {
                 V2F_SHADOW_CASTER;
             };
             V2f vert( appdata_base v)
             {
                 V2f o;
                 TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
                 Return o;
             }
             Float4 frag(v2f i):SV_Target
             {
                 SHADOW_CASTER_FRAGMENT(i)
             }



Thanks.
Rokki
 
Posts: 5
Joined: Sun Mar 25, 2018 9:33 am

Re: Shader macro?

Postby Amplify_Borba » Mon Apr 02, 2018 4:37 pm

Hey there, thank you for getting in touch!

You may use Macros with the Custom Expression node in Call Mode, which is set in the node parameters.

I'm afraid that I don't fully understand your next question, as you've posted code for a vertex frag shader, which goes into Shader Templates territory. Could you provide further details in order for us to best help you?
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Shader macro?

Postby Rokki » Tue Apr 03, 2018 1:24 am

Amplify_Borba wrote:Hey there, thank you for getting in touch!

You may use Macros with the Custom Expression node in Call Mode, which is set in the node parameters.

I'm afraid that I don't fully understand your next question, as you've posted code for a vertex frag shader, which goes into Shader Templates territory. Could you provide further details in order for us to best help you?





Thank you for your reply.

The code is obtained from here:
https://docs.unity3d.com/Manual/SL-Vert ... mples.html
Shader name is "Lit/Shadow Casting".

In Frag Shader,What I Need is:
fixed4 frag (v2f i) : SV_Target
{
SHADOW_CASTER_FRAGMENT(i)
}

So I modified the template like this:
fixed4 frag (v2f i /*ase_frag_input*/) : SV_Target
{
/*ase_frag_code:i=v2f*/

/*ase_frag_out:TestFragOutput;Float4*//*end*/
}
and I used Custom Expression with call mode.

finally,I got this:
fixed4 frag (v2f i ) : SV_Target
{
float localMyCustomExpression2 = ( 0 );
SHADOW_CASTER_FRAGMENT(i)
float4 temp_cast_0 = (localMyCustomExpression2).xxxx;
temp_cast_0
}

How do I output the exact expression directly, is there any other way or technique?
Rokki
 
Posts: 5
Joined: Sun Mar 25, 2018 9:33 am

Re: Shader macro?

Postby Amplify_Borba » Tue Apr 03, 2018 10:21 am

Thank you for providing additional details.

Just for clarification, while macros should function correctly through custom expression nodes, the parse that is done to their code might have some caveats which would have to be investigated on a case by case basis. You'll have to specify which macro that you've tried using is causing an unexpected behavior and send us the template file that you're using, so that we can test and correct it on our side.

I'm sharing a template that, despite having multiple empty passes, provides support for the Light Attenuation node so that you won't have to use that macro specifically.

MultiPassHair.zip
(1.32 KiB) Downloaded 223 times


Feel free to check it out and let me know if you have any further questions, thanks!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Shader macro?

Postby Rokki » Wed Apr 04, 2018 12:03 am

Thank you so much.
My template was simply modified from unlit, and it has not yet been completed.
Thank you for your template file.
Rokki
 
Posts: 5
Joined: Sun Mar 25, 2018 9:33 am

Re: Shader macro?

Postby Amplify_Borba » Wed Apr 04, 2018 11:12 am

No problem, glad to have helped!

Please let me know if you have any follow-up questions, thanks!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 73 guests

cron