Shaders

Pxlink: DTA Camera / Algebra / Rendering / Mat Data
Obsidian: [[DTA]] [[16-02-01-Rendering|Rendering]] / [[08-01-01-Material|matdata]] / [[16-02-01-Substance_Designer|substancedesigner]] / [[09-01-01-U_Optimisation|uoptimization]] [[17-01-01-Modeling]] [[17-01-01-Modeling_Foliage]] [[09-01-01-U_Shaders]]

External links: Cg encyclopedia SeblaGarde blog PBR Iri Shinsoj Substance PBR guide PBR wiki 2018
YT

Shaders

Fragment shader

Shader Language has a single main function that returns a color at the end. Each thread is not just blind but also memoryless.

VS Vertex shader

.

PS Pixel shader (old fragment)

grid of pixels that work paralel

Compute shader

in paralel on gpu subdivisions workgroups and in each group divisions

Mesh shader

Mesh Shaders

  • for new tessalation

Task shader

call based of cam frustrum

PBR

Energy conservation Eyes are less sensitive in dark.

Workflow

Metal / Roughness

A byproduct of using the metal/roughness workflow is that it can produce a white edge artifact, (Unreal)

  • white artefacts on blend
    Specular/glossiness
  • dark artefacts on blend

MaterialX

Layers Horizontal and vertical:

@Cd » W USD: displayColor

MAT: 1) Mat lib

  • matx subnet.  » mtlx standard
  • BEFORE PLUGIN BASE COLOR: convert jpg to aces ACES: karma_OCIO_transform Utility - Linear - sRGB  » ACES - ACEScg
  • BEFORE PLUGIN NORMAL:
  • mtlxgeometrycolor - vertex color // or geompropvalue z parametrem displayColor (Cd in sops)

   
Transparency Specular reflection (coating)
Emission Additive Specular reflection
Specular reflection (metal) Specular reflection
Specular transmision Specular retro-reflection (sheen)

Workflow

Material Standard

My image Name

Mat Nodes

Base nodes

  • mtlx Material Standard Surface - use like default material
  • collect node - pipe at the end and check orange flag as output for color input to base_color

Surface packed

My image Name

surface/volume/light/displace

BRDF Nodes
  • Oren-Nayar - diffuse_brdf
  • Disney Principled BRDF - burley_diffuse_brdf
  • Conductor BRDF - artistic friendly Metalic fresnel (energy compensation for multiple microfacet bounces)
    • D = ddx/beckman
    • G = height corelated smith
    • F = conductor
  • Dielectric
    • D = ddx/beckman
    • G = height corelated smith
    • F = dielectric / schlick
  • Generalized Schlick
  • Thin Film
  • sheen - cloths
Features

Displacement:

  • Collect node - can plug in mtlx in mtlxImage > mtlxRemap Color FA > mtlxDisplacement

Basic
  • Usd Prim Var Reader - bind attribs / get attrib
Math
  • mtlxConstant - value
  • mtlxMultiply
  • mtlxRemap -
  • mtlxMix - lerp
  • mtlxRamp - Slower mix in vex
Noise
  • mtlxFractal 3d - noise
  • mtlxcellnoise 3d
  • mtlxnoise 3d
  • mtlxworley noise 3d
Texture
  • mtlx Image / mtlx Tiled Image - Load texture basic
  • mtlxUsdUVTexture - Load texture - channel options

How to Add normal map:

  • mtlx Image > Normal Map- Load nm texture
UV
  • mtlxTexture coordinates -
  • mtlxTriplanar Projection
Volume:
  • mtlxVolume
    • vdf - volume > mtlx anisotropic vdf set absorption&scattering > mtlx Geompropvalue geomprop: density > set value
    • edf emmition
non mtlx Nodes
  • Curvature
  • Range
  • Color correct
  • Ambient occlusion
  • State vector

Unrela

Options

| Blend models | | Usage | | —- | —- | —- | | | | | LEGACY :

LEGACY: Ps/Vs Cost Usage
Sss      
Preintegrated Skin cheaper to render than the Sss method    
Subsurface Profile higher-end skin rendering    
2 Sided Foliage   simulate transmision, for cloths (non solid materials)  
Hair   multiple specular highlights: 1) color of light, 2) mix of hair and light color.  
Cloth   “fuzz” layer  
Single Layer Water   translucent in opaque mode  
Thin Translucent   colored glass (background) white specular highlight and the tinted background are needed  
Translucency Mode Ps/Vs Cost Usage
Volume Non Directional pixel cheapest pixel  
Volume Directional pixel    
Volume Per-Vertex Non Directional vert cheapest vert  
Volume Per-Vertex Directional vert    
Surface Translucency Volume   low per pixel but blurry glass, water
Surface forward Shading forward most expensive. Each light per pixel glass, water

Thin Transparent shading model and material expression, you are able to accurately represent tinted and colored transparent material


Decals

There are 11 blend modes that decals can use:

DBuffer decals.

You can access this buffer in other materials.

  • set decal response in material. (what is not set need to be blended with DBuffer texture inside of material)

The DBuffer decals can be used with lighting. These are not on by default and must be enabled in the Project Settings > Rendering section.

   
Translucent Can use Diffuse, Metallic, Specular, Roughness, Emissive, Opacity, and Normal
Stain Is a modulate type blend with Diffuse and Opacity.
Normal Uses the Opacity and Normal channels and only affects the Normal map layer it is projecting on.
Emissive Uses Emissive and Opacity only.
Volumetric Distance Function Use the output of signed distance in Opacity depending on Light Vector.
   
DBuffer Translucent Color, Normal, Roughness This is non-metallic and will use the Color, Opacity, Roughness, and Normal to work with baked lighting.
DBuffer Translucent Color This is non-metallic and will use only the Color and Opacity to work with baked lighting.
DBuffer Translucent Color, Normal This is non-metallic and will use the Color and Normal to work with baked lighting.
DBuffer Translucent Color, Roughness This is non-metallic and will use the Color and Roughness to work with baked lighting.
DBuffer Translucent Normal This will only use the Opacity and Normal channels to work with baked lighting.
DBuffer Translucent Normal, Roughness This will only use the Roughness, Opacity, and Normal to work with baked lighting.
DBuffer Translucent Roughness This will only use the Roughness and Opacity to work with baked lighting.

Unreal material nodes

Camera vector is a vector, that points from pixel to camera position. (observatiion vector) CameraDirectionVector, is a vector, that corresponds to direction, where camera is pointing in worldspace.

Strata

Specular workflow BSDF layering is expensive

https://youtu.be/rIktWZ-lpWw

Blend Materials

Add - not physically correct Horizontal layers blend materials

  • background / foreground Vertical layers - one on top of other and define what thick first layer is. Expensive
  • top / bottom with thickness Coverage weight (how strong material is)

Slab « is a material

Substrate Slab BSDF:

BSDF - Bidirectional scattering distribution functions F0 v3 - Reflection at facing angle - can use to color highlights (Reflective indexes ) F90 - Reflection at side of object. Anisotropy - stretching highlight SSS MFP - Subsurface mean free path (Opacity)- densityof material and effect of absorption (in cm) SSS MFP Scale - SSS Phase Anisotropy - Negative values negative scattering, 0 - scatter in both dir Second roughness - Second roughness weight on 0 is using only first and 1 will use only second. Fuzz Roughness s - Emulate fuzz

Metal

SMF Metal - node help to convert metallic workflow but can be achieved by Diffuse Albedo and F0

  • Diffuse - diffuse is separated so 0,0,0
  • F0 - should be color of metal
Silk fabric
Thin-film
  • f0 & f90
  • dif - 0

Triplanar

Basic Biplanar dithered and optimized

Features

Motion Vectors

https://www.sidefx.com/tutorials/create-motion-vectors-for-time-warping-image-sequences/

6D Lightmaps.
Biplanar projection:

https://www.shadertoy.com/view/ws3Bzf
https://iquilezles.org/www/articles/biplanar/biplanar.htm

IOR: most dielectrics 1.5.

Unreal simplified disney model

Dense details Landscape

  • Paralax / wpo /
  • Tessal / vs
  • Virtual texture - runtime Vertual Texture https://youtu.be/kxsQ5m2IAXs