引言
vForge 内置功能丰富、模块化可驻的着色器源代码编辑器,复制、粘贴、关键词搜索和编译等该有的工具栏按钮都一应俱全。 编辑器着色器源代码为彩色,符合预期,可反映各种命令,有利于使代码更整洁。
代码编辑器显示相应库中选中着色器的顶点和像素着色器源代码。
工具栏
着色器被选中时,代码编辑器会显示 3 个编辑器选项卡:
第一个选项卡显示了可用于库中所有着色器的源代码。 不同着色器可引用该源代码中各不相同的函数入口点。
第二个选项卡显示顶点着色器的通路专用源代码。
第三个选项卡显示像素着色器的通路专用源代码。
编译着色器时,如果专用源代码可用,库的源代码会被忽略。
预定义代码块
预定义文本块图标可打开一个下拉列表,其内容会根据当前活动的编辑器选项卡动态改变。
选项卡 1 - 库源代码
可用菜单选项如下:
Common Shader Macros(通用着色器宏):
Vertex Shader Macros(顶点着色器宏):
Pixel Shader Macros(像素着色器宏):
Example Plain DX10 ConstatntBufferFrame: cbuffer g_GlobalConstantBufferFrame : register (b0) { float4x4 matP : packoffset(c0); // projection matrix float4x4 matEye : packoffset(c4); // eye matrix float4x4 matInvEye : packoffset(c8); // inverse eye matrix float4 contextCP : packoffset(c12); // context clip planes: near, far, 1/(far-near) float4 contextPPright : packoffset(c13); // context projection plane right float4 contextPPup : packoffset(c14); // context projection plane up float4 contextPPdir : packoffset(c15); // context projection plane direction float4 timer : packoffset(c16); // Time: timer, time difference float4 eyePos : packoffset(c17); // eye position float4 eyeDir : packoffset(c18); // eye direction float4 depthFog : packoffset(c19); // linear depth fog parameter: near, far, 1/(far-near) float4 depthFogCol : packoffset(c20); // linear depth fog color float4 gAmbientCol : packoffset(c21); // global ambient color float4 lightmapMul : packoffset(c22); // lightmap multiplier (skalar) }
选项卡 2 - 顶点着色器
Example Color: #include <Shaders/VisionCommon.inc> // #include <Shaders/VisionCommon.inc> #ifdef _VISION_DX10 cbuffer g_GlobalConstantBufferObject : register (b1) { float4x4 matMVP : packoffset(c4); // model view projection matrix } #else float4x4 matMVP : register(c8); #endif struct VS_IN { float3 ObjPos : POSITION; float4 Color : COLOR; }; struct VS_OUT { float4 ProjPos : SV_Position; float4 Color : COLOR; }; VS_OUT vs_main( VS_IN In ) { VS_OUT Out; Out.ProjPos = mul( matMVP, float4(In.ObjPos, 1.0f) ); Out.Color = In.Color; return Out; }
选项卡 3 - 像素着色器
Example Simple: #include <Shaders/VisionCommon.inc> #ifdef _VISION_DX10 Texture2D <float4> BaseTexture : register(t0); sampler BaseTextureSampler : register(s0); #else sampler2D BaseTexture : register(s0); #endif struct PS_IN { float4 ProjPos : SV_Position; float2 UV0 : TEXCOORD0; }; float4 ps_main( PS_IN In ) : SV_Target { float4 diffuse = vTex2D(BaseTexture, BaseTextureSampler, In.UV0); return diffuse; }
测试编译和日志
您可以随时按下测试编译图标来检查代码的有效性。 编译完成后将显示日志,任何问题和错误都会在其中列出。 鼠标左键单击任意日志条目可展开该项内容,显示报告的更多详情。
提示:着色器日志可固定在编辑器面板中,或收起为代码窗口底部的图标。
预定义符号
为了简化着色器的编写过程,您可以按 CTRL + 空格键查看预定义符号列表,例如数据类型和函数。 然后,您可以选择一个符号,该符号将被插入到代码中。 例如,在文档中添加”float4”的结果如下:
|
Vision引擎中着色器源代码编辑器
猜你喜欢
转载自projectanarchy.iteye.com/blog/2122665
今日推荐
周排行