Hi all,
I'm trying to create a edge detection/outline shader based on [this guide][1]. While working on it I ran into issues getting the normal data through the method specified in the guide (rendering to a second camera) because our project is using the high definition render pipeline and is deferred. To get around this, I learned I could sample the _NormalBufferTexture instead to get a packed version of the normal buffer, which I've been able to output to the screen.
![alt text][2]
The issue is, in order to access the function I need to unpack the normal buffer (DecodeFromNormalBuffer I believe) I need to include
"com.unity.render-pipelines.high-definition/Runtime/Material/NormalBuffer.hlsl"
in the shader. When I do this though, it spits out this error:
"unrecognized identifier 'real3' at com.unity.render-pipelines.core@4.6.0-preview/ShaderLibrary/Packing.hlsl"
This is most likely due to me not having the
"Common.hlsl"
include, but whenever I do include that file it seems to conflict with the "StdLib.hlsl"
include from the post processing package because it spits out a bunch of 'redefinition' errors and warnings for functions and macros that I assume are shared by both files.
I've tried a lot of things like reordering my include calls, renaming and deleting things in the Package files, and directly creating the functions in the shader but these attempts have either created more errors or just not worked at all.
I was wondering if anyone else may know how to solve this issue, or if there are any ways I can do the unpacking without any additional includes.
Thanks!
[1]: https://roystan.net/articles/outline-shader.html?fbclid=IwAR26tdfinzWb-BeAy2yOXpFRKdG9VrWmvhqc0iBNNL5jBbPBpW3wt606fbw
[2]: /storage/temp/136388-normies.jpg
↧
Unpacking Normal Buffer in Post Processing Shader (HDRP)
↧
How I can get rid of the trail renderer overlapping?
I can't get rid of the trail renderer overlapping?
Image 1
![Trail Renderer Overlapping Problem][1]
Image 2 - Trail Renderer color settings
![Trail Renderer color settings][2]
My last shader:
Shader "TrailWithZWrite" {
Properties{
_Color("Main Color", Color) = (1,1,1,0.5)
_AlphaTex("Base (RGB) Trans (A)", 2D) = "white" {}
//_ExtrusionAmount("Z Extrusion Amount", Float) = 0
}
SubShader{
Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
LOD 100
ZWrite On
ZTest Less
Blend SrcAlpha One
//Offset 0, -5000
Pass{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
fixed4 _Color;
sampler2D _AlphaTex;
//float _ExtrusionAmount;
float4 _AlphaTex_ST;
struct v2f {
float4 pos : SV_POSITION;
half4 color : COLOR0;
float2 uv : TEXCOORD0;
};
v2f vert(appdata_full v)
{
v2f o;
//float3 camDirObjSpace = normalize(ObjSpaceViewDir(v.vertex));
//v.vertex.xyz += _ExtrusionAmount * camDirObjSpace;
o.color = v.color;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord, _AlphaTex);
return o;
}
fixed4 frag(v2f i) : SV_Target
{
fixed4 texcol = tex2D(_AlphaTex, i.uv) * i.color;
return texcol * _Color;
}
ENDCG
}
}
FallBack "Unlit/Transparent Cutout"
}
[1]: /storage/temp/136439-trailrendereroverlappingproblem1.png
[2]: /storage/temp/136441-trailrendereroverlappingproblem3.png
↧
↧
Why is my object blurry???
So i created an unlit shader and my object is blurry when i zoom out… I wanna know why!!!
![alt text][1]
It is blur when i'm zoom out but when i'm zoom in, it is "On-blur"
![alt text][2]
Please Help :)
[1]: /storage/temp/136406-screenshot-1.png
[2]: /storage/temp/136407-screenshot-2.png
↧
How to create outlined particles or sprites?
Hi everyone,
I'm trying to make some blob like think for 2D.
My plan is to place sprites(or particles using sprites if possible) like below and use some shader to only show non-overlapping edges.
Example: from this ![alt text][1] to this ![alt text][2]
I believe using shaders can achieve what I want to do but I am no expert in shader stuff and completely lost :( I would really appreciate if one can enlighten me where I can begin with. [1]: /storage/temp/136460-스크린샷-2019-04-15-오후-71046.png [2]: /storage/temp/136459-스크린샷-2019-04-15-오후-71029.png
I'm trying to make some blob like think for 2D.
My plan is to place sprites(or particles using sprites if possible) like below and use some shader to only show non-overlapping edges.
Example: from this ![alt text][1] to this ![alt text][2]
I believe using shaders can achieve what I want to do but I am no expert in shader stuff and completely lost :( I would really appreciate if one can enlighten me where I can begin with. [1]: /storage/temp/136460-스크린샷-2019-04-15-오후-71046.png [2]: /storage/temp/136459-스크린샷-2019-04-15-오후-71029.png
↧
What is the best way I could recolor all the pixels of a certain country on a texture of a political map(for achieving a map mode system such as in a grand strategy game)?
I'm using a texture of a political map where all the countries are painted with a unique color. I can assign data and know what the pointer is clicking/hovering over.
So an example of an overlay would be:
Germany is color coded gray and has a high GDP. The shader draws dark blue where all the gray colored pixels are in the texture to show a high average GDP in the area of Germany.
Moldova is color coded green and has a low GDP. The shader draws light blue where all the green colored pixels are in the texture to show a low average GDP in the area of Moldova.
The darkness of the blue is determined by a dynamic GDP value from the data of a country.
It would be very preferable if the texture of the map remains in 1 piece due to the normal map(hills and depressions)
An answer to this would be to have a conditional in the shader per color of the color coded countries, but it would be extremely slow.
Another answer would be to somehow flood fill all the countries and recolor them in order to create a new texture, but it would also be slow.
Looking to achieve such an effect as demonstrated in this video about Crusader Kings 2 map modes https://www.youtube.com/watch?v=hllUdi73h70
↧
↧
What basic shader is needed for change the color on particle system with particles based on a spritesheet?
Hi
I have a particle system loaded with a material what have loaded a spritesheet. As far as i know that is the only way for having a spritesheet working on a particle system.
My problem is that if i try to activate color parameters,nothing happens with Unlit/Transparent shader.
Changing shader for Legacy/Particles/Additive make it's works, but particles are semi-transparent and i want them on full opacity.
Do you know what shader i need? I think this is something very simple and doesn't requiere complex custom shaders...
↧
MK Glow only works in Scene View
Hi, I just imported MK Glow and opened the example scene and ran.
![alt text][1]
in this picture, left side is the Scene view, and the right side is the Game view.
However, I don't see any of the glowing effect like I would see in the Scene view.
Just in case I did something wrong, I followed this tutorial https://www.youtube.com/watch?v=9Ztd1XXmUGI, and made my own shape to glow, but it has exactly the same problem with the example scene.
![alt text][2]
As you can see, left side (Scene view) has the glow on the circle, but the right side (Game view) has zero glow. If I adjust the minimum value of the Threshhold from MK Glow script to below zero, everything in the camera starts to glow, which I don't want.
What am I doing wrong?
[1]: /storage/temp/136502-mkglow.png
[2]: /storage/temp/136503-sunglow.png
↧
Cannot access render pipelines - missing from Package manager (Unity 2018.3.12f1)
Hi there,
I finally upgraded my Unity from 2017 to 2018.3.12f1 because I would like to learn how to use the shader graph and Lightweight Pipeline. However, I cannot find either of these in the package manager, or anywhere else. I've made a new project file and still nothing.
Help, please... and thanks in advance.
↧
Abnormal behavior issues in Unity uGUI Alpha Mask Shader
Used Unity version is 2018.1.0f2.
Shader code is a simple code that only applies alpha by adding mask texture to code generated by Unity.![alt text][1]
Code (Shader):
Shader "UI/Masking"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_MaskTex ("Texture", 2D) = "white" {}
}
SubShader
{
// No culling or depth
Blend SrcAlpha OneMinusSrcAlpha
Cull Off ZWrite Off ZTest Always
tags { "Queue" = "Transparent" }
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
sampler2D _MainTex;
sampler2D _MaskTex;
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
fixed4 mask = tex2D(_MaskTex, i.uv);
// fixed4 result = col.rgb
col.a = mask.a;
// just invert the colors
// col.rgb = 1 - col.rgb;
return col;
}
ENDCG
}
}
}
The Editor View it works just as well as the picture (upload picture name - Image_1).
If you play a Unity, the Alpha area changes (upload picture name - Image_2).
I've tested it and found that the cause of the problem
Image contained in SpriteAtlas provided by Unity
It happens when used.
Am I doing something wrong with the Atlas setting? (upload picture name - Image_3)
[1]: /storage/temp/136544-image-2.png
↧
↧
Write to a file after a button has been pressed?,How to write to a file after pressing a button?
I have created a stop watch using text. I have a button when pressed stops the stopwatch. I want to store that time of the stop watch when stopped in a text file?
this is the stopwatch code -
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class StopWatch : MonoBehaviour
{
float timer;
float seconds;
float minutes;
float hours;
bool start;
[SerializeField] Text StopwatchText;
// Start is called before the first frame update
void Start()
{
start = true;
timer = 0;
}
// Update is called once per frame
void Update()
{
StopWatchCalcul();
}
void StopWatchCalcul()
{
if (start)
{
timer += Time.deltaTime;
seconds = (int)(timer % 60);
minutes = (int)((timer / 60) % 60);
hours = (int)(timer / 3600);
StopwatchText.text = hours.ToString("00") + ":" + minutes.ToString("00") + ":" + seconds.ToString("00");
}
}
public void stopTimer()
{
start = false;
}
},I have a stop watch created that stops when I press a button. I would like to store the time of the stopwatch to a file when the button is pressed?
This is the code for the stopwatch.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class StopWatch : MonoBehaviour
{
float timer;
float seconds;
float minutes;
float hours;
bool start;
[SerializeField] Text StopwatchText;
// Start is called before the first frame update
void Start()
{
start = true;
timer = 0;
}
// Update is called once per frame
void Update()
{
StopWatchCalcul();
}
void StopWatchCalcul()
{
if (start)
{
timer += Time.deltaTime;
seconds = (int)(timer % 60);
minutes = (int)((timer / 60) % 60);
hours = (int)(timer / 3600);
StopwatchText.text = hours.ToString("00") + ":" + minutes.ToString("00") + ":" + seconds.ToString("00");
}
}
public void stopTimer()
{
start = false;
}
}
↧
How do I adapt this vertex manipulation shader so that my object (point cloud) keeps its original colouring?
Hello!
(Photos attached below might help to better explain)
I am currently attempting to use *this* vertex manipulation shader on a point cloud object:
Shader "Tutorial/015_vertex_manipulation" {
//show values to edit in inspector
Properties {
_Color ("Tint", Color) = (0, 0, 0, 1)
_MainTex ("Texture", 2D) = "white" {}
_Smoothness ("Smoothness", Range(0, 1)) = 0
_Metallic ("Metalness", Range(0, 1)) = 0
[HDR] _Emission ("Emission", color) = (0,0,0)
_Amplitude ("Wave Size", Range(0,1)) = 0.4
_Frequency ("Wave Freqency", Range(1, 8)) = 2
_AnimationSpeed ("Animation Speed", Range(0,5)) = 1
}
SubShader {
//the material is completely non-transparent and is rendered at the same time as the other opaque geometry
Tags{ "RenderType"="Opaque" "Queue"="Geometry"}
CGPROGRAM
//the shader is a surface shader, meaning that it will be extended by unity in the background
//to have fancy lighting and other features
//our surface shader function is called surf and we use our custom lighting model
//fullforwardshadows makes sure unity adds the shadow passes the shader might need
//vertex:vert makes the shader use vert as a vertex shader function
//addshadows tells the surface shader to generate a new shadow pass based on out vertex shader
#pragma surface surf Standard fullforwardshadows vertex:vert addshadow
#pragma target 3.0
sampler2D _MainTex;
fixed4 _Color;
half _Smoothness;
half _Metallic;
half3 _Emission;
float _Amplitude;
float _Frequency;
float _AnimationSpeed;
//input struct which is automatically filled by unity
struct Input {
float2 uv_MainTex;
};
void vert(inout appdata_full data){
float4 modifiedPos = data.vertex;
modifiedPos.y += sin(data.vertex.x * _Frequency + _Time.y * _AnimationSpeed) * _Amplitude;
float3 posPlusTangent = data.vertex + data.tangent * 0.01;
posPlusTangent.y += sin(posPlusTangent.x * _Frequency + _Time.y * _AnimationSpeed) * _Amplitude;
float3 bitangent = cross(data.normal, data.tangent);
float3 posPlusBitangent = data.vertex + bitangent * 0.01;
posPlusBitangent.y += sin(posPlusBitangent.x * _Frequency + _Time.y * _AnimationSpeed) * _Amplitude;
float3 modifiedTangent = posPlusTangent - modifiedPos;
float3 modifiedBitangent = posPlusBitangent - modifiedPos;
float3 modifiedNormal = cross(modifiedTangent, modifiedBitangent);
data.normal = normalize(modifiedNormal);
data.vertex = modifiedPos;
}
//the surface shader function which sets parameters the lighting function then uses
void surf (Input i, inout SurfaceOutputStandard o) {
//sample and tint albedo texture
fixed4 col = tex2D(_MainTex, i.uv_MainTex);
col *= _Color;
o.Albedo = col.rgb;
//just apply the values for metalness, smoothness and emission
o.Metallic = _Metallic;
o.Smoothness = _Smoothness;
o.Emission = _Emission;
}
ENDCG
}
FallBack "Standard"
}
This successfully creates the wave-like effect on the object i wanted. However, the problem is that when I do this it replaces the vertexcolor shader on the point cloud and so the point cloud goes black and no longer retains its original colouring.
This is the code for the vertexcolor shader:
Shader "Custom/VertexColor" {
SubShader {
Pass {
LOD 200
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
struct VertexInput {
float4 v : POSITION;
float4 color: COLOR;
};
struct VertexOutput {
float4 pos : SV_POSITION;
float4 col : COLOR;
};
VertexOutput vert(VertexInput v) {
VertexOutput o;
o.pos = UnityObjectToClipPos(v.v);
o.col = v.color;
return o;
}
float4 frag(VertexOutput o) : COLOR {
return o.col;
}
ENDCG
}
}
}
Is there any way I can adapt the vertexmanipulation shader so that the point cloud retains its original colouring (like it does with the vertexcolour shader) whilst still creating the wave-like effect I wanted?
I hope this makes sense - I’m sorry I’m relatively new to shader coding in unity. Below I have attached a couple of screenshots which might make it clearer.
Any help would be massively appreciated!
Many thanks in advance,
Tom
![alt text][1]
This is the point cloud with the vertexcolor shader - when you can see its colouring.
![alt text][2]
And this is the point cloud with the vertex manipulation shader - it creates the wave-effect I want but makes the point cloud completely black.
[1]: /storage/temp/136661-screenshot-2019-04-18-at-213054.png
[2]: /storage/temp/136662-screenshot-2019-04-18-at-213250.png
↧
How to choose FFT Window type
Hi. I noticed there are this types on the FFTwindow function from Unity
**Rectangular** W[n] = 1.0.
**Triangle** W[n] = TRI(2n/N).
**Hamming** W[n] = 0.54 - (0.46 * COS(n/N) ).
**Hanning** W[n] = 0.5 * (1.0 - COS(n/N) ).
**Blackman** W[n] = 0.42 - (0.5 * COS(n/N) ) + (0.08 * COS(2.0 * n/N) ).
**BlackmanHarris** W[n] = 0.35875 - (0.48829 * COS(1.0 * n/N)) + (0.14128 * COS(2.0 * n/N)) - (0.01168 * COS(3.0 * n/N)).
How do I know which one is the best to use in my case and why? I did some research but it still not very clear to me, they all seem to be ok to use in different situations. If anyone know a good article or something about this topic would be very useful too!
↧
creating shader to highlight overlap of objects in screen spcae
How can I make a shader that highlights the intersection of objects in SCREEN space (NOT world space)? Basically I want to be able to find the areas that overlap and then alter the appearance of those areas. Below is a very crude example of what I want. Ideally the solution would be able to account for an arbitrary number of overlaps. From what I've read it seems I would need to use stencil shaders but I have a hard time understanding how those work and how I would apply them.
Any help would be appreciated. If there is an already existing solution then that would be great too.
EDIT: I think I've figured out the general idea for the stencil shader, but I'm wondering if there is a way to get the output data from the first pass of the materials to for additional computation in the second pass. I.e. is there a way that I can see that the color of two overlapping boxes were red and blue, and add those colors together in the second box.
![alt text][1]
[1]: /storage/temp/136734-screen-shot-2019-04-20-at-125412-am.png
↧
↧
Cannot create required material because shader is null
I just recently upgraded my project to 2019.1 from 2018.3 and I get this one error in the console :
`Cannot create required material because shader is null`
There is no other information about this error like which material cannot be created or which shader is null. Is there a way to get information on how to fix this error?
EDIT: Sometimes the error comes with one extra line :
Cannot create required material because shader is null
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
↧
Outline flat mesh
Hello all.
I am attempting to outline a flat code generated mesh to create a spell indicator.
![alt text][1]
[1]: /storage/temp/136776-example.png
currently every example i can find is using a shader to invert the edge normals of a mesh at a certain threshold... however seeing as all my normals are simply vertical how would i achieve an outline?
I have tried all the shaders on here: http://wiki.unity3d.com/index.php/Silhouette-Outlined_Diffuse as well as other multiple shaders and it only turns the underside of my mesh blue (which makes sense as its the inverted normal)
Any help would be greatly appreciated.
↧
Toon shader indirect light culling shadow issue
Hey i have a question that bothers me since a month now and prevents my shader to be finished.
I want to have my toon shader culling light intensity and color for "not important" lighting but dont want to have that normal style looking shadow on top of it.
the pictures are summing it up pretty good what i have atm and what i want to accomplish.
I guess i need the Indirect Diffuse light Node but i dont know how to work with it and since my shader is created in the "Amplify Shader Editor" no one i know knows how to help me either.
i would love to get this done so if anyone can help me please tell me :)
what i have atm:
Indirect set to not Important (this needs fix)
![alt text][1]
Indirect set to not Important from another shader i used before i made my own and i want to have it like this
![alt text][2]
[1]: /storage/temp/136828-indirect-bad.jpg
[2]: /storage/temp/136829-indirect-other-shader-good.jpg
↧
How to create color balance shader?
Hi guys. I have been trying to implement my own color balance that i will apply on camera, For that i used this formula:
**R** = 255 / ***Rw*** * R1
**G** = 255 / ***Gw*** * G1
**B** = 255 / ***Bw*** * B1
Where ***Rw Gw*** and ***Bw*** represents the value of a colour component believed to represent White and *R1 G1* and *B1* representing the original value of a colour component before implementing the colour balance formula.
I tried to implement it like this:
public class ColorBalance : MonoBehaviour
{
[Range(0,255)]
public int R = 0;
[Range(0, 255)]
public int G = 0;
[Range(0, 255)]
public int B = 0;
[Range(0, 255)]
public int Alpha = 255;
public Material material;
private void OnRenderImage(RenderTexture source, RenderTexture destination)
{
material.SetVector("_RGB", new Vector4(255f/R, 255f/G ,255f/ B, 255f/Alpha));
Graphics.Blit(source, destination, material);
}
}
Where material had shader like this:
Shader "PostProcessing/ColorBalance"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_RGB("_RGB", Float) = (0.01,0.01,0.01, 1)
}
SubShader
{
Cull Off ZWrite Off ZTest Always
Pass
{
Tags {"Queue" = "Transparent" "RenderType" = "Transparent" }
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
uniform float4 _RGB;
sampler2D _MainTex;
half4 _MainTex_ST;
fixed4 frag (v2f_img i) : Color
{
fixed4 col = (1.0/ _RGB) * tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv, _MainTex_ST));
return col;
}
ENDCG
}
}
Fallback off
}
But the end result was not correct.
Original:
![alt text][1]
Red 255 from my method:
![alt text][2]
So what am i doing wrong? Is it correct way of doing it?
Please help.
[1]: /storage/temp/136835-pers.png
[2]: /storage/temp/136837-per2.png
↧
↧
Add alpha channel support to this shader?
Sorry for a beginner question, I have never done shader at all. so I have this shader which I want the engine to read alpha channel in the Main Texture property. All answers I found here tells me to add alpha after #pragma surface surf lambert but this shader doesn't even have that...
Shader "Roystan/Toon"
{
Properties
{
_Color("Color", Color) = (1,1,1,1)
_MainTex("Main Texture", 2D) = "white" {}
// Ambient light is applied uniformly to all surfaces on the object.
[HDR]
_AmbientColor("Ambient Color", Color) = (0.4,0.4,0.4,1)
[HDR]
_SpecularColor("Specular Color", Color) = (0.9,0.9,0.9,1)
// Controls the size of the specular reflection.
_Glossiness("Glossiness", Float) = 32
[HDR]
_RimColor("Rim Color", Color) = (1,1,1,1)
_RimAmount("Rim Amount", Range(0, 1)) = 0.716
// Control how smoothly the rim blends when approaching unlit
// parts of the surface.
_RimThreshold("Rim Threshold", Range(0, 1)) = 0.1
}
SubShader
{
Pass
{
// Setup our pass to use Forward rendering, and only receive
// data on the main directional light and ambient light.
Tags
{
"Queue"="Transparent"
"LightMode" = "ForwardBase"
"PassFlags" = "OnlyDirectional"
}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// Compile multiple versions of this shader depending on lighting settings.
#pragma multi_compile_fwdbase
#include "UnityCG.cginc"
// Files below include macros and functions to assist
// with lighting and shadows.
#include "Lighting.cginc"
#include "AutoLight.cginc"
struct appdata
{
float4 vertex : POSITION;
float4 uv : TEXCOORD0;
float3 normal : NORMAL;
};
struct v2f
{
float4 pos : SV_POSITION;
float3 worldNormal : NORMAL;
float2 uv : TEXCOORD0;
float3 viewDir : TEXCOORD1;
// Macro found in Autolight.cginc. Declares a vector4
// into the TEXCOORD2 semantic with varying precision
// depending on platform target.
SHADOW_COORDS(2)
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.worldNormal = UnityObjectToWorldNormal(v.normal);
o.viewDir = WorldSpaceViewDir(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
// Defined in Autolight.cginc. Assigns the above shadow coordinate
// by transforming the vertex from world space to shadow-map space.
TRANSFER_SHADOW(o)
return o;
}
float4 _Color;
float4 _AmbientColor;
float4 _SpecularColor;
float _Glossiness;
float4 _RimColor;
float _RimAmount;
float _RimThreshold;
float4 frag (v2f i) : SV_Target
{
float3 normal = normalize(i.worldNormal);
float3 viewDir = normalize(i.viewDir);
// Lighting below is calculated using Blinn-Phong,
// with values thresholded to creat the "toon" look.
// https://en.wikipedia.org/wiki/Blinn-Phong_shading_model
// Calculate illumination from directional light.
// _WorldSpaceLightPos0 is a vector pointing the OPPOSITE
// direction of the main directional light.
float NdotL = dot(_WorldSpaceLightPos0, normal);
// Samples the shadow map, returning a value in the 0...1 range,
// where 0 is in the shadow, and 1 is not.
float shadow = SHADOW_ATTENUATION(i);
// Partition the intensity into light and dark, smoothly interpolated
// between the two to avoid a jagged break.
float lightIntensity = smoothstep(0, 0.01, NdotL * shadow);
// Multiply by the main directional light's intensity and color.
float4 light = lightIntensity * _LightColor0;
// Calculate specular reflection.
float3 halfVector = normalize(_WorldSpaceLightPos0 + viewDir);
float NdotH = dot(normal, halfVector);
// Multiply _Glossiness by itself to allow artist to use smaller
// glossiness values in the inspector.
float specularIntensity = pow(NdotH * lightIntensity, _Glossiness * _Glossiness);
float specularIntensitySmooth = smoothstep(0.005, 0.01, specularIntensity);
float4 specular = specularIntensitySmooth * _SpecularColor;
// Calculate rim lighting.
float rimDot = 1 - dot(viewDir, normal);
// We only want rim to appear on the lit side of the surface,
// so multiply it by NdotL, raised to a power to smoothly blend it.
float rimIntensity = rimDot * pow(NdotL, _RimThreshold);
rimIntensity = smoothstep(_RimAmount - 0.01, _RimAmount + 0.01, rimIntensity);
float4 rim = rimIntensity * _RimColor;
float4 sample = tex2D(_MainTex, i.uv);
return (light + _AmbientColor + specular + rim) * _Color * sample;
}
ENDCG
}
// Shadow casting support.
UsePass "Legacy Shaders/VertexLit/SHADOWCASTER"
}
}
----------
For a clearer explanation, take a look at this image ![alt text][1]
those black parts are actually transparent from photoshop saved as PNG.
Is it the shader's fault, or is there anything I should tweak on unity to make it accept alpha as transparency?
[1]: /storage/temp/136906-screenshot-5.png
↧
Oculus rendeing bug
Good day!
In there is a problem when rendering the Oculus.
1 screen - render camera in normal game.
2 screen - render camera with Oculus.
The problem is trees sprite. In Oculus has no sprites of foliage. I think the Shader's broken.
How can this be fixed?
Trees from SpeedTree. It was once that they had drawn, but was green (again, I think that something with the Shader)
![alt text][1]
![alt text][2]
[1]: /storage/temp/136921-1.jpg
[2]: /storage/temp/136922-2.jpg
↧
Migrating from 2018.3.x to 2019.1
After upgrading from 2018.3.x to 2019.1 nearly all of my shaders broke, prefabs were removed from my scenes, I was spammed with nearly 200 errors from the Shader Graph (which I didn't have installed) and Text Mesh Pro v2.0.0 (which I did have installed, but says it's 2019.1 verified in the package manager) I tried several different things but none worked. I eventually created a new project and moved my Assets over which solved the Shader Graph issue, but is still causing the same problems with Text Mesh Pro. Additionally, the [2019.1 upgrade guide](https://docs.unity3d.com/Manual/UpgradeGuide20191.html) provides essentially no information. Did I do something wrong? Are these bugs in the release?
↧