Voila une vidéo de l'effet en post process :
https://www.youtube.com/watch?v=KK3TEiI7HrQ
Pour être plus précis :
- Il existe plusieurs "points" émanant un aura coloré. L'environnement est donc noir et blanc sauf aux abord de ces points de couleur que je passe dans le shader avec un buffer.
- Cet effet a d'abord été réalisé avec un post process, mais celui ne fonctionne pas avec les particules car ils n'ont pas de ZWrite.
J'ai pour l'instant intégré cet effet sur le shader de terrain. Mais celui-ci est un peu complexe (j'ai commencé la programmation shader il y a peu de temps) et je n'arrive pas à modifier le lighting du shader.
Effectivement, réaliser l'effet sur une pass post lighting serait une bonne solution je pense, mais je ne sais pas comment le faire.
Voila le shader de terrain modifié, pour l'instant je n'ai mis que la camera comme "point de couleur", mais l'implémentation du buffer n'est pas un problème :
Code : Tout sélectionner
Shader "Nature/Terrain/Standard-custom" {
Properties{
// set by terrain engine
[HideInInspector] _Control("Control (RGBA)", 2D) = "red" {}
[HideInInspector] _Splat3("Layer 3 (A)", 2D) = "white" {}
[HideInInspector] _Splat2("Layer 2 (B)", 2D) = "white" {}
[HideInInspector] _Splat1("Layer 1 (G)", 2D) = "white" {}
[HideInInspector] _Splat0("Layer 0 (R)", 2D) = "white" {}
[HideInInspector] _Normal3("Normal 3 (A)", 2D) = "bump" {}
[HideInInspector] _Normal2("Normal 2 (B)", 2D) = "bump" {}
[HideInInspector] _Normal1("Normal 1 (G)", 2D) = "bump" {}
[HideInInspector] _Normal0("Normal 0 (R)", 2D) = "bump" {}
[HideInInspector][Gamma] _Metallic0("Metallic 0", Range(0.0, 1.0)) = 0.0
[HideInInspector][Gamma] _Metallic1("Metallic 1", Range(0.0, 1.0)) = 0.0
[HideInInspector][Gamma] _Metallic2("Metallic 2", Range(0.0, 1.0)) = 0.0
[HideInInspector][Gamma] _Metallic3("Metallic 3", Range(0.0, 1.0)) = 0.0
[HideInInspector] _Smoothness0("Smoothness 0", Range(0.0, 1.0)) = 1.0
[HideInInspector] _Smoothness1("Smoothness 1", Range(0.0, 1.0)) = 1.0
[HideInInspector] _Smoothness2("Smoothness 2", Range(0.0, 1.0)) = 1.0
[HideInInspector] _Smoothness3("Smoothness 3", Range(0.0, 1.0)) = 1.0
// used in fallback on old cards & base map
[HideInInspector] _MainTex("BaseMap (RGB)", 2D) = "white" {}
[HideInInspector] _Color("Main Color", Color) = (1,1,1,1)
}
SubShader{
Tags {
"Queue" = "Geometry-100"
"RenderType" = "Opaque"
}
CGPROGRAM
#pragma surface surf Standard vertex:SplatmapVert finalcolor:SplatmapFinalColor finalgbuffer:SplatmapFinalGBuffer fullforwardshadows noinstancing
#pragma multi_compile_fog
#pragma target 3.0
// needs more than 8 texcoords
#pragma exclude_renderers gles psp2
#include "UnityPBSLighting.cginc"
#pragma multi_compile __ _TERRAIN_NORMAL_MAP
#define TERRAIN_STANDARD_SHADER
#define TERRAIN_SURFACE_OUTPUT SurfaceOutputStandard
#include "Assets\_Project\Materials\Shaders\Builtin terrain\CustomTerrainSplatmapCommon.cginc"
half _Metallic0;
half _Metallic1;
half _Metallic2;
half _Metallic3;
half _Smoothness0;
half _Smoothness1;
half _Smoothness2;
half _Smoothness3;
// Récupère un coeficient de distance entre la le pixel et la camera basé sur une distance maximum afin d'obtenir un dégradé
float getCoef(float3 worldPos, float3 cameraPos, float maxDistance)
{
float dist = distance(worldPos, cameraPos);
float coef = dist / maxDistance;
float clampCoef = clamp(coef, 0, 1);
return clampCoef;
}
void surf(Input IN, inout SurfaceOutputStandard o)
{
half4 splat_control;
half weight;
fixed4 mixedDiffuse;
half4 defaultSmoothness = half4(_Smoothness0, _Smoothness1, _Smoothness2, _Smoothness3);
SplatmapMix(IN, defaultSmoothness, splat_control, weight, mixedDiffuse, o.Normal);
o.Albedo = mixedDiffuse.rgb;
// Calcul d'un coefficiant permettant de lerper entre la couleur de base et la couleur en grayscale
float coef = getCoef(IN.worldPos, _WorldSpaceCameraPos, 20);
float3 lum = Luminance(mixedDiffuse.rgb);
float3 finalCol = lerp(o.Albedo, lum, coef);
// Output terrain color
o.Albedo = finalCol;
o.Alpha = weight;
o.Smoothness = mixedDiffuse.a;
o.Metallic = dot(splat_control, half4(_Metallic0, _Metallic1, _Metallic2, _Metallic3));
}
ENDCG
}
Dependency "AddPassShader" = "Hidden/TerrainEngine/Splatmap/Standard-AddPass-custom"
Dependency "BaseMapShader" = "Hidden/TerrainEngine/Splatmap/Standard-Base-custom"
// Fallback "Nature/Terrain/Diffuse"
}