Posts

Showing posts with the label custom

Custom lighting models

Don't think I want to cover writing actual custom lighting models just yet. However, here is how you might implement the Lambert lighting model within your shader. Blinn is done below, with a brief explanation. Essentially they are like mini functions. They must begin with the word "Lighting" and match the name of the lighting model that you specify in the #pragma surface surf ______ Lambert works by taking the dot product of the surface normal and light direction vectors. Where the light is aligned to the surface normal, the surface will seem brighter. As it gets closer to 90degrees/perpendicular the surface will be darker. This value NdotL is multiplied by the surface colour (albedo) ,the colour of any lights (_LightColor0, a built in variable) and the attenuation, which is how intense the light is.  Shader "Dave/customLightingmodel" {     Properties{         _Color("Color",color) = (1,1,1,1)     }     Sub...

setting VFX graph properties using C#

How to set values for your custom properties in VFX Graph. Yeah, there are binders, but I find they expect a rather precise  way of working.. Making your own scripts forces Unity to do what you actually want haha. In my VFX graph, I have a VECTOR 3 value named "realSpawnPos" which I'm using as the spawn position for some particles. It's important to note that "position", whilst it is a Vector3.. doesn't like receiving Vector 3 values. So make sure you set it up as a Vector 3 in the VFX graph. Further to this - Make sure in the VFX Graph, your position node is set to WORLD, if you need to set/get/whatever the world position and not local... your objects are probably nested in a million groups/transforms..   using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.VFX; public class bindPosition : MonoBehaviour {     public GameObject target_thing;     public VisualEffect visualEffect;     void U...