Skip to main content
Velvet X-ray Shader        

Description

Velvet shader similar to mario galaxy for apply to your materials.

velvet_shader.jpg

Usage

Just give the material shader/velvet to your object.

velvetshader.cg

Copy to clipboard
// ----------------------------------------------------------- void main_vs( float4 position : POSITION, float3 normal : NORMAL, float2 texCoord : TEXCOORD0, out float4 outPosition : POSITION, out float2 outTexCoord : TEXCOORD0, out float3 outVertexPos : TEXCOORD1, out float3 outNormal : TEXCOORD2, uniform float4x4 worldViewProjMatrix, uniform float4x4 worldViewMatrix ) { outTexCoord = texCoord; outPosition = mul(worldViewProjMatrix, position); outVertexPos = mul(worldViewMatrix, position).xyz; outNormal = normal; } void main_ps( float2 uv : TEXCOORD0, float3 position : TEXCOORD1, float3 normal : TEXCOORD2, out float4 outColor : COLOR, uniform sampler2D texture, uniform float3 eyePosition) { float3 N = normalize(normal); float3 eyeDir = normalize(eyePosition - position.xyz); outColor = tex2D(texture,uv); outColor += 1-saturate( dot(eyeDir,N) *2 ); }

velvetshader.material

Copy to clipboard
vertex_program velvetshader_vs cg { source velvetshader.cg entry_point main_vs profiles vs_1_1 arbvp1 } fragment_program velvetshader_ps cg { source velvetshader.cg entry_point main_ps profiles ps_2_0 arbfp1 } material test3 { technique { pass { vertex_program_ref velvetshader_vs { param_named_auto worldViewProjMatrix worldviewproj_matrix } fragment_program_ref velvetshader_ps { param_named_auto eyePosition camera_position_object_space } texture_unit { texture blue_jaiqua.jpg 2d } } } }