Files
XCEngine/docs/api/rhi/opengl/shader/set-vec3-array.md

35 lines
864 B
Markdown
Raw Normal View History

# OpenGLShader::SetVec3
设置三维向量 uniform 变量(数组重载版本)。
```cpp
void SetVec3(const char* name, const float* values);
```
通过名称查找并设置着色器中的三维向量 uniform 变量,使用浮点数数组作为输入。
**参数:**
- `name` - uniform 变量名称
- `values` - 指向 3 个 float 元素的数组指针
**返回:** 无
**线程安全:** ❌(需要在渲染线程调用)
**示例:**
```cpp
// 设置光照方向
float lightDir[3] = { 0.5f, 1.0f, 0.3f };
shader->SetVec3("u_lightDir", lightDir);
// 设置法线
float normal[3] = { 0.0f, 1.0f, 0.0f };
shader->SetVec3("u_normal", normal);
```
## 相关文档
- [OpenGLShader 总览](shader.md) - 返回类总览
- [SetVec3 (xyz)](../../shader/set-vec3.md) - xyz分量版本
- [SetVec4 (float*)](set-vec4-array.md) - 四维向量数组版本