-
Notifications
You must be signed in to change notification settings - Fork 1
Graphics
Namespace: WIDVE.Graphics
Location: Utilities/Graphics
The Graphics namespace contains an assortment of scripts and objects designed to make simple graphics techniques in Unity a bit easier to use.
Most of the Graphics scripts will work in any rendering pipeline. Any scripts that are specific to a single pipeline are placed in a subfolder with its own assembly definition file. These scripts will not be included in a project unless their Define Constraint is present in the Project Settings. Current render pipeline scripts and their define constraints are listed below.
| Render Pipeline | Define Constraint |
|---|---|
| UniversalRenderingPipeline | WIDVE_URP |
The ShaderProperties objects serves as a reference for all Color, float, Vector, and Texture properties of a specific shader. This is necessary because the code for accessing shader properties is accessible only within the Unity Editor, and not available when making a build. Any script or component that needs to access or edit a shader's properties should use a ShaderProperties object to do so.
Each ShaderProperties object references a single shader. Therefore, for each shader that needs to be used, a new ShaderProperties object must be created. This object should be given the same name as the original shader so it is easy to find. To set up the new ShaderProperties object, drag a shader into its SourceShader field and press the Set Properties button. All properties available to that shader will be cataloged and saved in the ShaderProperties object for future use.
Property names and settings are collected via script and should not be edited by hand. The only exception to this is certain float properties which represent an enum. There is an IsEnum checkbox for float properties that should be checked if the float property represents an integer enum value, and left unchecked otherwise. This is necessary because normal float values will be interpolated when interpolating between different materials, while enum float values will simply be set (as any interpolated value would likely be invalid). The code attempts to identify enum values by searching for Unity's [Enum...] attribute in the shader code, but if the shader code has an unusual structure this attribute may not be caught. In this case, the flag must be set manually.
| Property | Description |
|---|---|
SourceShader |
Properties will be collected from this shader |
ColorProperties |
List of all Color properties of the shader |
FloatProperties |
List of all float properties of the shader |
VectorProperties |
List of all Vector properties of the shader |
TextureProperties |
List of all Texture properties of the shader |
Note: not all Texture properties and operations are currently supported.
The FaceCamera component serves as a simple billboarding script. It makes objects face the camera in both the scene view and the game view.
Designed to work alongside the Interpolator script
The Fader script is a simpler version of the LerpMaterial script. Rather than lerp all properties of a material, the Fader script simply adjust the alpha value of all Color properties between 0 and 1 based on the provided value.
If the material being faded is already a transparent material, then the FadeMode should be set to SingleMaterial. If the initial material is opaque, then the SeparateMaterials mode should be used. In this mode, two materials can be specified. The OpaqueMaterial will be used whenever the Fader's alpha value is set to 1, otherwise the TransparentMaterial will be used.