#ifdef SHADER_TARGET_SURFACE_ANALYSIS
//Codes that Surface Shader should work
#endif
Category: Shader in Unity
Volumetric shader
Geometry Shader streams
w component
I have been so confusing about the w component for ages, until I read this:
Explaining Homogeneous Coordinates & Projective Geometry
So I quickly made a simple to shader to test it out:
To summarize, w component is the
The W dimension is the distance from the projector to the screen(object).
when w > 1, the object looks far (smaller)
when w = 1, the size remains the same
when w = 0, it’s actually covering the whole screen
This is the reason why we have make sure the w component is correct when we are doing _Object2World and _World2Object
Also a interesting point to note from the blog post:
If W=1, then it is a point light. If W=0, then it is a directional light.
(Thanks Kemal for the tutorial links!)
All shader stages
Update: Download this shader here 🙂
Shader Model and features
2.5: derivatives
3.0: 2.5 + interpolators10 + samplelod + fragcoord (also contains fragdepth)
3.5: 3.0 + interpolators15 + mrt4 + + integers + 2darray + instancing
4.0: 3.5 + [mrt8] + geometry
4.5: 3.5 + compute + randomwrite (so it means it has no 4.0 features)
4.6: 4.0 + [cubearray] + tesshw + tessellation (so it means it has no 4.5 features)
5.0: 4.0 + 4.5 + 4.6 + [interpolators32] (it has everything)
[Pink] : Mobile won’t implies it
info from @Aras
Official documentation about shader model supports for different Graphics APIs:
https://docs.unity3d.com/2021.2/Documentation/Manual/SL-ShaderCompileTargets.html
// UNITY_SHADER_NO_UPGRADE
To prevent shader from code upgrade
Dynamic batching and Deferred
Vert and Frag + Zwrite On in Deferred are not dynamically batched
(it means transparent shaders will be batched)
unless the shader writes into GBuffer. But then, putting “DisableBatching” = “True” into this shader, it is still batched!
Standard Shader study [WIP]
[Good for shader debug] UAV RandomWriteTarget
Send data to c# script from shader: vert/frag and surface shaders!
Continue reading “[Good for shader debug] UAV RandomWriteTarget”