Note: this is an advanced topic. It assumes you have a deep understanding of shaders.
Voxel Play shaders are a collection of custom, hand-made, optimized shaders able to render lot of visual features in the most performant way. To make it easier to read, each Voxel Play shader makes use of macros which encapsulate the shader code involved.
To customize or add effects to the opaque voxel shaders, you can edit the VPVoxelTriangleOpaquePass.cginc file. This file contains both the vertex and fragment shaders. The fragment shader looks like this:
fixed4 frag (v2f i) : SV_Target { UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i); VOXELPLAY_COMPUTE_SCREEN_UV(i); VOXELPLAY_APPLY_PARALLAX(i); VOXELPLAY_COMPUTE_BEVEL(i); // Diffuse fixed4 color = VOXELPLAY_GET_TEXEL_DD(i.uv.xyz); #if defined(VP_CUTOUT) clip(color.a - _CutOff); #endif VOXELPLAY_APPLY_BEVEL(i); VOXELPLAY_APPLY_FRESNEL(color, i.norm, i.wpos); VOXELPLAY_COMPUTE_EMISSION(color) VOXELPLAY_APPLY_BUMPMAP(i); VOXELPLAY_APPLY_TINTCOLOR(color, i); VOXELPLAY_APPLY_OUTLINE_SIMPLE(color, i); VOXELPLAY_APPLY_SPECULAR(color, i.norm, i.wpos); #if defined(IS_CLOUD) VOXELPLAY_APPLY_LIGHTING(color, i); #else VOXELPLAY_APPLY_LIGHTING_AO_AND_GI(color, i); #endif VOXELPLAY_ADD_EMISSION(color) VOXELPLAY_APPLY_FOG(color, i); return color; }
You can insert any code in-between any of these macros to change the color value.
The i.wpos contains the world space position of the "pixel" while the i.norm contains the normal in world space as well.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article