There are a lot of glass shaders. Can you suggest the best desktop one that includes transparency, reflections , fresnel, etc…?
for making this

There are a lot of glass shaders. Can you suggest the best desktop one that includes transparency, reflections , fresnel, etc…?
for making this

The standard shader transparent mode should look pretty close to that cockpit assuming you have a decent enough probe to capture the sky etc
AH! Oh… Thank HippoCoder ! I was using “Fade mode” by inertia… Transparency mode is much better (sharp and bright) than the fade mode. Is so nice that looks like Is missing refraction option, but is working nice and well!
Unity5 “Fade” mode shader on the left and on the “Transparency” mode on right.
reflection will work fine with probes (reflect clouds or nearby reflection probes) but the light passing through the glass - refraction - is not supported by standard shader. For this, you can try using command buffers: Unity Blog
Or perhaps someone has a free asset. There are paid ones of course but I think you know those.
Ok I’m trying to understand what and how to use the command buffer. I was able to make a transparent Unity5 shader and It was fun until I get stuck in the refraction.
Here is a screenshot
In order from left to right: Unity5 Fade, Unity5 Transparent and this Custom



Here is the code
Shader "Custom/Glass" {
Properties {
_ColorMult("Luminocity", Range(-1,2)) = 1.1
_Color ("Color", Color) = (1,1,1,0.37)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.973
_Metallic ("Metallic", Range(0,1)) = 0.916
_Reflection("Reflection Intencity", Range(0.1,10)) = 5.2
_Saturation("Reflection Saturation", Range(0.6,2.2)) = 1.2
_DotProduct("Rim effect", Range(-1,1)) = 0.044
_Fresnel("Fresnel Coefficient", Range(-1,10)) = 5.0
_Refraction("Refration Index", float) = 0.9
_Reflectance("Reflectance", Range(-1,1)) = 1.0
}
SubShader {
Tags {
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType"="Transparent"
}
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
// take out "fullforwardshadows" and add "alpha:fade"
#pragma surface surf Standard fullforwardshadows alpha:fade
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _MainTex;
float _ColorMult;
float _Reflection;
float _DotProduct;
float _Saturation;
float _Fresnel;
float _Refraction;
float _Reflectance;
struct Input {
float2 uv_MainTex;
float3 worldNormal;
float3 viewDir;
};
half _Glossiness;
half _Metallic;
fixed4 _Color;
samplerCUBE _Cube;
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
// #pragma instancing_options assumeuniformscaling
UNITY_INSTANCING_CBUFFER_START(Props)
// put more per-instance properties here
UNITY_INSTANCING_CBUFFER_END
void surf (Input IN, inout SurfaceOutputStandard o) {
// Albedo comes from a texture tinted by color
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb * _ColorMult;
// Metallic and smoothness come from slider variables
o.Metallic = _Metallic * _Saturation;
o.Smoothness = _Glossiness;
// Add transparency in the center (if more perpendicular)
// And more reflections in the side (if more angle).
float border = 1 - (abs(dot(IN.viewDir,IN.worldNormal)));
float alpha = (border * (1 - _DotProduct) + _DotProduct);
o.Alpha = ((c.a * _Reflection) * alpha);
o.Emission = c.a;
}
ENDCG
}
// Fallback to your shader: with a given name
//Fallback "SimpleTransparent";
}
Is missing refraction sections code; [source [/URL]
float4 frag(vertexOutput input) : COLOR
{
float refractiveIndex = 1.5;
float3 refractedDir = refract(normalize(input.viewDir),
normalize(input.normalDir), 1.0 / refractiveIndex);
return texCUBE(_Cube, refractedDir);
}
Or another better source [link2]
//Refraction Texture Grab
float2 offset = NewNormals * _DistAmt * _GrabTexture_TexelSize.xy;
IN.proj.xy = offset * IN.proj.z + IN.proj.xy;
half4 col = tex2Dproj( _GrabTexture, UNITY_PROJ_COORD(IN.proj));
What I purchase was not better than Unity 5 shader. Shader forge was ok but I like the new Unity5 standard shader asset as input. Probably I will try this new visual shader scripting that Unity is offering. But I wish to know more about all other glass pay options. (public and private, free and pay)](https://en.wikibooks.org/wiki/Cg_Programming/Unity/Curved_Glass)
With a grabtexture, it’s not a “real” refraction, it’s just displacing the pixels of what has already been drawn onscreen.
The refract() is better, you sample a pixel in the envmap. If you want to sample a pixel of the 3D geometry around you, you can refract() inside a reflection probe.
Thanks, Pode! probably you refer to The Cg Tutorial - Chapter 7. Environment Mapping Techniques
or the optimise vr
http://http.developer.nvidia.com/Cg/refract.html
?
In Shader Forge is simple because has a Refraction input. But coding the shader using refract() into the Unity5 shader is out of my capacity. If is possible same help.
Adding NormalMap on top of the “Custom Glass”: Duplicate the transparent game object and scale it to 0.99 Then import the GlassRefraction Standard Asset Package Effect. Assets → Import package → Effects… Then apply the GlassRefractive material to this new smaller GameObject. You get the shader that supports a normal map but still is missing the refraction.

For my purposes, this glass shader is far better than any other solution I’ve found so far. Thank you very much!