Blender V5.0
gpencil_shader_shared.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#ifndef GPU_SHADER
9#endif
10
32
39
40#define GP_IS_STROKE_VERTEX_BIT (1 << 30)
41#define GP_VERTEX_ID_SHIFT 2
42#define GP_CORNER_TYPE_ROUND_BITS 0u
43#define GP_CORNER_TYPE_BEVEL_BITS 63u
44#define GP_CORNER_TYPE_MITER_NUMBER 62u
45
46/* Avoid compiler funkiness with enum types not being strongly typed in C. */
47#ifndef GPU_SHADER
48# define gpMaterialFlag uint
49# define gpLightType uint
50#endif
51
52struct gpMaterial {
57#ifndef GPU_SHADER
64#else
65 /* Some drivers are completely messing the alignment or the fetches here.
66 * We are forced to pack these into float4 otherwise we only get 0.0 as value. */
67 /* NOTE(@fclem): This was the case on MacOS OpenGL implementation.
68 * This might be fixed in newer APIs. */
69 float4 packed1;
70 float4 packed2;
71# define _fill_uv_offset packed1.xy
72# define _alignment_rot packed1.zw
73# define _stroke_texture_mix packed2.x
74# define _stroke_u_scale packed2.y
75# define _fill_texture_mix packed2.z
77# define _flag packed2.w
78#endif
79};
81
82#ifdef GP_LIGHT
83struct gpLight {
84# ifndef GPU_SHADER
85 float3 color;
86 gpLightType type;
87 float3 right;
88 float spot_size;
89 float3 up;
90 float spot_blend;
91 float3 forward;
92 float _pad0;
93 float3 position;
94 float _pad1;
95# else
96 /* Some drivers are completely messing the alignment or the fetches here.
97 * We are forced to pack these into float4 otherwise we only get 0.0 as value. */
98 /* NOTE(@fclem): This was the case on MacOS OpenGL implementation.
99 * This might be fixed in newer APIs. */
100 float4 packed0;
101 float4 packed1;
102 float4 packed2;
103 float4 packed3;
104 float4 packed4;
105# define _color packed0.xyz
106# define _type packed0.w
107# define _right packed1.xyz
108# define _spot_size packed1.w
109# define _up packed2.xyz
110# define _spot_blend packed2.w
111# define _forward packed3.xyz
112# define _position packed4.xyz
113# endif
114};
115BLI_STATIC_ASSERT_ALIGN(gpLight, 16)
116#endif
117
118#ifndef GPU_SHADER
119# undef gpMaterialFlag
120# undef gpLightType
121#endif
#define BLI_STATIC_ASSERT_ALIGN(st, align)
Definition BLI_assert.h:86
@ GP_FILL_TEXTURE_USE
@ GP_STROKE_TEXTURE_STENCIL
@ GP_STROKE_HOLDOUT
@ GP_STROKE_TEXTURE_PREMUL
@ GP_STROKE_ALIGNMENT_STROKE
@ GP_STROKE_ALIGNMENT
@ GP_FILL_TEXTURE_PREMUL
@ GP_STROKE_TEXTURE_USE
@ GP_STROKE_ALIGNMENT_OBJECT
@ GP_FILL_GRADIENT_USE
@ GP_FILL_TEXTURE_CLIP
@ GP_FILL_GRADIENT_RADIAL
@ GP_STROKE_OVERLAP
@ GP_FILL_HOLDOUT
@ GP_STROKE_ALIGNMENT_FIXED
@ GP_LIGHT_TYPE_AMBIENT
@ GP_LIGHT_TYPE_SUN
@ GP_LIGHT_TYPE_POINT
@ GP_LIGHT_TYPE_SPOT
#define gpLightType
#define gpMaterialFlag
VecBase< float, 4 > float4
VecBase< float, 2 > float2
gpMaterialFlag flag