Blender V4.5
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
43/* Avoid compiler funkiness with enum types not being strongly typed in C. */
44#ifndef GPU_SHADER
45# define gpMaterialFlag uint
46# define gpLightType uint
47#endif
48
49struct gpMaterial {
54#ifndef GPU_SHADER
61#else
62 /* Some drivers are completely messing the alignment or the fetches here.
63 * We are forced to pack these into float4 otherwise we only get 0.0 as value. */
64 /* NOTE(@fclem): This was the case on MacOS OpenGL implementation.
65 * This might be fixed in newer APIs. */
66 float4 packed1;
67 float4 packed2;
68# define _fill_uv_offset packed1.xy
69# define _alignment_rot packed1.zw
70# define _stroke_texture_mix packed2.x
71# define _stroke_u_scale packed2.y
72# define _fill_texture_mix packed2.z
74# define _flag packed2.w
75#endif
76};
78
79#ifdef GP_LIGHT
80struct gpLight {
81# ifndef GPU_SHADER
82 float3 color;
83 gpLightType type;
84 float3 right;
85 float spot_size;
86 float3 up;
87 float spot_blend;
88 float3 forward;
89 float _pad0;
90 float3 position;
91 float _pad1;
92# else
93 /* Some drivers are completely messing the alignment or the fetches here.
94 * We are forced to pack these into float4 otherwise we only get 0.0 as value. */
95 /* NOTE(@fclem): This was the case on MacOS OpenGL implementation.
96 * This might be fixed in newer APIs. */
97 float4 packed0;
98 float4 packed1;
99 float4 packed2;
100 float4 packed3;
101 float4 packed4;
102# define _color packed0.xyz
103# define _type packed0.w
104# define _right packed1.xyz
105# define _spot_size packed1.w
106# define _up packed2.xyz
107# define _spot_blend packed2.w
108# define _forward packed3.xyz
109# define _position packed4.xyz
110# endif
111};
112BLI_STATIC_ASSERT_ALIGN(gpLight, 16)
113#endif
114
115#ifndef GPU_SHADER
116# undef gpMaterialFlag
117# undef gpLightType
118#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