这段时间实在太懒了。往年,十个这玩意都写好了。
现在基本的数据结构已经确定了。shader的代码(骨架类)既可以单独用,也可以由Node串起来。
预计Shader的用法为
//加载一个由SimpleTrans.hlsl 为基础骨架,加上Skin, Morph两个Node动态生成的Shader.
HXShader hShader = m_ShaderMgr.load(L"SimpleTrans<Skin, Morph>");
//加载SimpleTrans.hlsl。
HXShader hShader = m_ShaderMgr.load(L"SimpleTrans");
这样用法可以防止在引擎中产生Shader爆炸,只需要写几个基础骨架,并加一些 Node, Node符合规范就可以随意组合了。
不过目前所有的额外信息都需要从.hlsl本身里解析,所以需要一定的规范,一个简单的Shader大概如下。
//一个用来演示的Shader基础类, PixelShader
///{{Declaration
//视频处理的PS
sampler2D YTextue;
sampler2D UTextue;
sampler2D VTextue;
float cTime;
struct PS_INPUT
{
float2 Texcoord : TEXCOORD0;
};
///}}
/*
///{{ParamTable //Shader的参数描述表
texture YTexture : <file="" , manager="" , width="" , height="" /> ;
float cTime : TIME ;
///}}
*/
///{{SourceCode
float4 main( PS_INPUT Input ) : COLOR0
{
//===采样输入器=====================================
float3 yuvColor;
yuvColor.x = tex2D( YTextue, Input.Texcoord ).x;
yuvColor.y = tex2D( UTextue, Input.Texcoord ).x;
yuvColor.z = tex2D( VTextue, Input.Texcoord ).x;
//==================================================
///}}
/*
///{{Socket = Name // Socket = 名字, 在这里定义一个插入点
Input
{
float3 yuvColor : YUVCOLOR;
}
Output
{
float4 RGBColor : COLOR0;
}
///}}
*/
///{{DefaultCode = Name
//默认的代码 ,如果Name指定的插槽没有插入Node。则该代码才会被编译进去
float4 RGBColor = float4(yuvColor,1.0);
///}}
///{{SourceCode
//==================================================
return RGBColor;
}
///}}
一个简单的Node如下
/*
///{{Slot = Description
Input
{
float4 yuvColorIn : YUVCOLOR; // 类型 名字 : 语义
}
Output
{
float4 : COLOR0;
}
///}}
*/
///{{Declaration
float4 CS_YUV2RGB(float4 yuvColorIn);
///}}
///{{SourceCode
float4 CS_YUV2RGB(float4 yuvColorIn)
{
//==ColorSpace======================================
float3 delYuv = float3(-16.0/255.0 , -128.0/255.0 , -128.0/255.0);
float3 yuvColor = yuvColorIn.xyz + delYuv;
float3 matYUVRGB1 = float3(1.164, 2.018 , 0.0 );
float3 matYUVRGB2 = float3(1.164, -0.391 , -0.813 );
float3 matYUVRGB3 = float3(1.164, 0.0 , 1.596 );
float4 rgbColor;
rgbColor.x = dot(yuvColor,matYUVRGB1);
rgbColor.y = dot(yuvColor,matYUVRGB2);
rgbColor.z = dot(yuvColor,matYUVRGB3);
rgbColor.w = 1.0f;
//==================================================
return rgbColor;
}
///}}
分享到:
相关推荐
Amplify Shader Editor is an award-winning node-based shader creation tool inspired by industry leading editors. An open and tightly integrated solution, it provides a familiar and consistent ...
Shader Forge is a node-based shader editor, aiming to push the visual quality of Unity to new heights, giving you the artistic freedom of shader creation in a visual and intuitive way - no code ...
Shadero Sprite is a real time node-based shader tool for Unity 5, 2017 and 2018 NEW! Forum : https://forum.vetasoft.store/ Discuss with us about Shadero Sprite and more ! Description Shadero Sprite...
Amplify Shader Editor (ASE) is a node-based shader creation tool inspired by industry leading software. An open and tightly integrated solution, it provides a familiar and consistent development ...
Shader Forge is a node-based shader editor, aiming to push the visual quality of Unity to new heights, giving you the artistic freedom of shader creation in a visual and intuitive way - no code ...
Amplify Shader Editor (ASE) is a node-based shader creation tool inspired by industry leading software. An open and tightly integrated solution, it provides a familiar and consistent development ...
Amplify Shader Editor (ASE) is a node-based shader creation tool inspired by industry leading software. An open and tightly integrated solution, it provides a familiar and consistent development ...
Shader Forge is a node-based shader editor, aiming to push the visual quality of Unity to new heights, giving you the artistic freedom of shader creation in a visual and intuitive way - no code ...
Amplify Shader Editor (ASE) is a node-based shader creation tool inspired by industry leading software. An open and tightly integrated solution, it provides a familiar and consistent development ...
Shadero Sprite is a real time node-based shader editor. Shadero was made to be a real production time saver. Beautiful and fast, it creates many astonishing effects with the several premade and fully ...
Shadero Sprite is a real time node-based shader tool for Unity 5, 2017 and 2018
It is based on the Disney principled model also known as the „PBR“ shader, making it compatible with other software such as Pixar’s Renderman® and Unreal Engine®. Image textures painted or baked...
Diving deep into Cycles you will learn Cycle’s node-based material system, how to set-up a 3D scene for rendering, how to create a natural and man-made materials as well as the correct organization ...