0
Écarté

Shader Coordination + Screen Space Real-time Reflection

Mike Lightz il y a 9 ans mis à jour par Freya Holmér (Developer) il y a 9 ans 3
Hiya , I brought Candela SSRR package and I wanted to use it on my shader I've made in SF.
Candela applies reflection on every shader runs by Unity3D. it's a image effect and runs on
Diffuse , Defaults and ...

But on shaderforge , shaders has a problem ...

It doesn't work with Forward render path but when I set on deferred pre-pass it works perfectly !

But another problem ...
The intensity of real time reflections sets by Shader main color alpha ... _color.a
but it doesn't work on SF shader.

Sounds important thing ! Here's a simple shader of candela default material :


Shader "CandelaSSRR/Cubemap Specular SSR" {Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
_Shininess ("Shininess", Range (0.01, 1)) = 0.078125
_ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
_MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
_Reflectivity ("Reflectivity (A)", 2D) = "white" {}
_SpecTex ("Specular(RGB) Roughness(A)", 2D) = "white" {}
_Cube ("Reflection Cubemap", Cube) = "_Skybox" { TexGen CubeReflect }
}
SubShader {
LOD 300
Tags { "RenderType"="Opaque" }

CGPROGRAM
#pragma surface surf BlinnPhong

sampler2D _MainTex;
sampler2D _SpecTex;
sampler2D _Reflectivity;
samplerCUBE _Cube;

fixed4 _Color;
fixed4 _ReflectColor;
half _Shininess;

struct Input {
float2 uv_MainTex;
float3 worldRefl;
};

void surf (Input IN, inout SurfaceOutput o) {
fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
half4 SPG = tex2D(_SpecTex, IN.uv_MainTex);
half4 REF = tex2D(_Reflectivity, IN.uv_MainTex);

///ALL
fixed4 reflcol = texCUBE (_Cube, IN.worldRefl);

tex.a = REF.a;

_SpecColor = _SpecColor*SPG;

fixed4 c = tex * _Color;

o.Albedo = c.rgb;
o.Gloss = tex.a;
o.Specular = _Shininess*SPG.a;


reflcol *= tex.a;
o.Emission = reflcol.rgb *_ReflectColor.rgb;
o.Alpha = _Color.a*tex.a;
}
ENDCG
}

FallBack "Reflective/VertexLit"
}


Or another one :

Shader "CandelaSSRR/Bumped Specular SSR" {Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
_Shininess ("Shininess", Range (0.03, 1)) = 0.078125
_MainTex ("Base (RGB) Reflectivity (A)", 2D) = "white" {}
_Reflectivity ("Reflectivity (A)", 2D) = "white" {}
_SpecTex ("Specular(RGB) Roughness(A)", 2D) = "white" {}
_BumpMap ("Normalmap", 2D) = "bump" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 400

CGPROGRAM
#pragma surface surf BlinnPhong
#pragma target 3.0
#pragma glsl


sampler2D _MainTex;
sampler2D _BumpMap;
sampler2D _SpecTex;
sampler2D _Reflectivity;

fixed4 _Color;
half _Shininess;

struct Input {
float2 uv_MainTex;
float2 uv_BumpMap;
};

void surf (Input IN, inout SurfaceOutput o) {
fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
float4 SPG = tex2D(_SpecTex, IN.uv_MainTex);
float4 REF = tex2D(_Reflectivity, IN.uv_MainTex);

tex.a = REF.a;

_SpecColor = _SpecColor*SPG;

o.Albedo = tex.rgb * _Color.rgb;
o.Gloss = REF.a;
o.Alpha = tex.a * _Color.a;
o.Specular = _Shininess*SPG.a;
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
}
ENDCG
}

FallBack "Specular"
}



I think it's o.Alpha parameter but I can't write shader .


Anyway to compile this shader in SF ? with adding code part in my shader source or ... ?

sorry if section is wrong ... :)

Solution

Solution
Écarté
If you're on Unity 4 you'll have to do it manually in that case, as the Unity 4 version of SF is no longer supported
+1
À l'étude
Try connecting your intensity value to opacity, without changing its blending mode
In deferred everything blocked and on forward mode it doesn't work :(



I'm using unity 4. candela hasn't version for unity 5 ...
Solution
Écarté
If you're on Unity 4 you'll have to do it manually in that case, as the Unity 4 version of SF is no longer supported