cloud.fx

来自「java实现的简单的分形树。简单易学!是学习分形知识的很好的例子。其java语法」· FX 代码 · 共 83 行

FX
83
字号

// Cloud rendering.
//
// Outputs color into RT0, normal/Z into RT1.
// Clouds aren't affected by atmospheric scattering here, and are over-edge
// diffuse shaded.
//
// Versions: vs1.1, ps2.0

#include "_shared.fx"
#include "_library.fx"


// --------------------------------------------------------------------------
//  vertex shader

struct VS_OUTPUT {
	float4 pos		: POSITION;
	float4 normalZ	: TEXCOORD0;
	float4 color	: COLOR0;
};

VS_OUTPUT vsMain (
	float4	pos : POSITION,
	float3	normal : NORMAL )
{
    VS_OUTPUT o;
	o.pos = mul( pos, mWVP );
	float3 n = mul( normal, (float3x3)mWorld );
	
	// slightly over-edge directional light
	float cosang = ( dot( n, vLightDir ) + 1.0 ) * 0.5;
	o.color.xyz = cosang * vScatterSunColor * 0.5 + 0.5;
	o.color.w = 1;

	// normal/Z
	o.normalZ = gNormalZ( o.pos, n );

	return o;
}

// --------------------------------------------------------------------------
//  pixel shader

struct PS_INPUT {
	float4 normalZ : TEXCOORD0;
	float4 color : COLOR0;
};

struct PS_OUTPUT {
	half4 color : COLOR0;
	half4 normalZ : COLOR1;
};

PS_OUTPUT psMain( PS_INPUT i ) : COLOR
{
	PS_OUTPUT o;
	// color
	o.color = i.color;

	// normal/Z
	o.normalZ = float4( i.normalZ.xyz, i.normalZ.w );

	return o;
}


// --------------------------------------------------------------------------
//  effect

technique tec0 {
	pass P0 {
		VertexShader = compile vs_1_1 vsMain();
		PixelShader = compile ps_2_0 psMain();
	}
	pass PLast {
	}
}
technique tecDummy {
	pass P0 {
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?