Page 1 sur 1

[MY] Shader et LightWeightedRenderPipeline

Publié : 07 Sep 2019 11:19
par Artcraft
Salut à tous,

J'essaie d'utiliser ce shader avec le Light Weighted Render Pipeline mais il ne fonctionne pas..
Aucune erreur n’apparaît donc je comprend pas la raison...

Le shader :

Code : Tout sélectionner

Shader "Custom/Sin Wave" {
	Properties{
		_Tile("Tile", Range(0.0,1.0)) = 0.5
		_Color ("Color", Color) = (1.0,1.0,1.0,0.5)
		_ForegroundColor("Foreground Color", Color) = (1,1,1,0)
		_BackgroundColor("Background Color", Color) = (0,0,0,0)
		_ForegroundMask("Foreground Mask", 2D) = "white" {}
		_ForegroundCutoff("Foreground Cutoff", Range(0,1)) = 0.5
		_BackgroundCutoff("Background Cutoff", Range(0,1)) = 0.5
		_Radius("Radius", Range(0.0,1.0)) = 0.5
	}
		SubShader
		{
			Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
			Lighting Off
			LOD 100
			ZWrite Off
			Blend SrcAlpha OneMinusSrcAlpha 
			CGPROGRAM

			#pragma surface surf Standard alpha:fade
			#pragma target 3.0
			sampler2D _ForegroundMask;
			struct Input {
			float2 uv_ForegroundMask;
		};

		fixed4 _ForegroundColor;
		fixed4 _BackgroundColor;
		fixed4 _Color;
		half _ForegroundCutoff;
		half _BackgroundCutoff;
		half _Radius;
		half _Tile;

		void surf(Input IN, inout SurfaceOutputStandard color:alpha) 
		{

			fixed x = (-0.5 + IN.uv_ForegroundMask.x) * _Tile;
			fixed y = (-0.5 + IN.uv_ForegroundMask.y) * 2;
			fixed radius = 0.5 + sin(x * 3.1415926535) * _Radius; 
			radius -= (0.5 * y + 0.5);
			clip(radius - _BackgroundCutoff);
			clip(_ForegroundCutoff - radius);
			color.Albedo = _Color;
			color.Alpha = _Color.a;
		}
			ENDCG
	}
	FallBack "Unlit/Transparent"
	
}
Il fonctionne très bien avec le pipeline normal...

Re: [MY] Shader et LightWeightedRenderPipeline

Publié : 07 Sep 2019 12:13
par Max
Bonjour,

Je ne suis pas un pro en matière de shader, mais je pense que tu ne peux pas utiliser tel quel ton shader avec le pipe LWRP. Déjà il me semble qu'il faut certaines dépendances spécifiques, genre #include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Core.hlsl".
Pareil au niveau de tes tags, avec probablement le Tags{... "RenderPipeline" = "LightweightPipeline" ....}

Après, avec le LWRP tu as l'avantage de pouvoir profiter du ShaderGraph, pour essayer de reproduire/adapter plus facilement ton shader.

Re: [MY] Shader et LightWeightedRenderPipeline

Publié : 07 Sep 2019 12:26
par Artcraft
yo,

j'ai rajouté #include "UnityCG.cginc"

et le tag mais rien ne se passe...

aaaaah j'en chie ça m’énerve !