Skip to content

Instantly share code, notes, and snippets.

@jims
Created October 5, 2015 11:49
Show Gist options
  • Save jims/34a2ffebd4f2f63764dc to your computer and use it in GitHub Desktop.
Save jims/34a2ffebd4f2f63764dc to your computer and use it in GitHub Desktop.
pass_macros = [
{ if: "defined(HAS_LIGHTMAP_BAKED_DIFFUSE_LIGHTING) || defined(MATERIAL_TRANSFER)" then: [
{ define: ["NEEDS_LIGHTMAP_UV"] }
] }
{ if: "(defined(HAS_NORMAL) && !defined(WORLD_SPACE_NORMAL)) || defined(TESSELLATION) && defined(HAS_VECTOR_DISPLACEMENT)" then: [
{ define: ["NEEDS_TANGENT_SPACE"] }
] }
{ if: "!defined(HAS_NORMAL) || defined(TESSELLATION) && defined(HAS_HEIGHT_DISPLACEMENT)" then: [
{ define: ["NEEDS_WORLD_SPACE_NORMAL"] }
] }
{ if: "defined(HAS_REFRACTION) && !defined(HAS_NORMAL)" then: [
{ define: ["NEEDS_SCREEN_SPACE_NORMAL"] }
] }
{ if: "!defined(HAS_NORMAL) || defined(NEEDS_EYE_VECTOR) || defined(HAS_VERTEX_OFFSET) || defined(TESSELLATION)
|| defined(TRANSPARENT) || defined(TRANSPARENT_FADE)
|| on_renderer(D3D11) && defined(INSTANCED)" then: [
{ define: ["NEEDS_WORLD_SPACE_POSITION"] }
{ if: "defined(TRANSPARENT) || defined(TRANSPARENT_FADE) || defined(TESSELLATION)" then: [
{ define: ["NEEDS_WORLD_POS_CHANNEL"] }
] }
] }
]
default_patch_interpolation = "linear_barycentric"
channel_declarations = {
vertex_tangent = { type = "float3" }
vertex_binormal = { type = "float3" }
tsm0 = { type = "float3" }
tsm1 = { type = "float3" }
tsm2 = { type = "float3" }
eye_vector = { type = "float3" }
world_space_normal = { type = "float3" }
last_clip_position = { type = "float3" }
vertex_position = { type = "float4" }
vertex_normal = { type = "float3" }
screen_space_normal = { type = "float3" }
lightmap_uv = { type = "float2" }
world_pos = { type = "float3" }
pixel_depth = { type = "float" }
screen_pos = { type = "float2" }
}
stage_linkage = {
vertex = [
{ channels = ["vertex_normal"] input_semantics = ["NORMAL"] }
{ channels = ["vertex_position"] }
{ if: "defined(NEEDS_EYE_VECTOR)" then: [{ channels = ["eye_vector"] }] }
{ if: "defined(NEEDS_LIGHTMAP_UV)" then: [{ channels = ["lightmap_uv"] input_semantics = ["TEXCOORD1"] }] }
{ if: "defined(NEEDS_TANGENT_SPACE)" then: [
{ channels = ["tsm0", "tsm1", "tsm2"] }
{ channels = ["vertex_tangent", "vertex_binormal"] input_semantics = ["TANGENT", "BINORMAL"] }
] }
{ if: "defined(NEEDS_WORLD_SPACE_NORMAL)" then: [{ channels = ["world_space_normal"] }] }
{ if: "defined(NEEDS_SCREEN_SPACE_NORMAL)" then: [{ channels = ["screen_space_normal"] }] }
{ if: "defined(MOTION_VECTOR)" then: [{ channels = ["last_clip_position"] }] }
{ if: "defined(NEEDS_WORLD_POS_CHANNEL)" then: [{ channels = ["world_pos"] }] }
]
hull = []
domain = [
{ if: "defined(NEEDS_TANGENT_SPACE)" then: [{ channels = ["tsm0", "tsm1", "tsm2"] }] }
{ if: "defined(HAS_HEIGHT_DISPLACEMENT)" then: [{ channels = ["world_space_normal"] }] }
// No need to have the defined(TESSELLATION) here as the domain/hull stages are only enabled when tessellation is active
{ channels = ["world_pos"] }
]
pixel = [
{ if: "defined(NEEDS_LIGHTMAP_UV)" then: [{ channels = ["lightmap_uv"] }] }
{ if: "defined(NEEDS_TANGENT_SPACE)" then: [{ channels = ["tsm0", "tsm1", "tsm2"] }] }
{ if: "defined(NEEDS_WORLD_SPACE_NORMAL)" then: [{ channels = ["world_space_normal"] }] }
{ if: "defined(MOTION_VECTOR)" then: [{ channels = ["last_clip_position"] }] }
{ if: "defined(NEEDS_SCREEN_SPACE_NORMAL)" then: [{ channels = ["screen_space_normal"] }] }
{ if: "defined(NEEDS_PIXEL_DEPTH)" then: [{ channels = ["pixel_depth"] }] }
{ if: "defined(NEEDS_SCREEN_POS)" then: [{ channels = ["screen_pos"] }] }
// Only transparent needs world_pos in the pixel shader
{ if: "defined(TRANSPARENT) || defined(TRANSPARENT_FADE)" then: [
{ channels = ["world_pos"] }
] }
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment