<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Last Ray of Hope &#187; Cg</title>
	<atom:link href="http://www.lastrayofhope.com/tag/cg/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lastrayofhope.com</link>
	<description>Home of Kaluriel Hargrove</description>
	<lastBuildDate>Wed, 27 Jan 2010 21:56:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Cg/HLSL Saturate</title>
		<link>http://www.lastrayofhope.com/2009/04/13/cghlsl-saturate/</link>
		<comments>http://www.lastrayofhope.com/2009/04/13/cghlsl-saturate/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 01:19:43 +0000</pubDate>
		<dc:creator>Kaluriel</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Shaders]]></category>
		<category><![CDATA[Cg]]></category>
		<category><![CDATA[glsl]]></category>
		<category><![CDATA[shader]]></category>

		<guid isPermaLink="false">http://www.lastrayofhope.com/?p=1175</guid>
		<description><![CDATA[I&#8217;ve been converting my Cg shaders I wrote for my AGT work in university into GLSL, however I came by an annoying problem, Cg uses a function that doesn&#8217;t exist in GLSL, but does exist in HLSL. I eventually found documentation on what it does and so looked up the GLSL equivilant. The Cg version [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been converting my Cg shaders I wrote for my AGT work in university into GLSL, however I came by an annoying problem, Cg uses a function that doesn&#8217;t exist in GLSL, but does exist in HLSL. I eventually found documentation on what it does and so looked up the GLSL equivilant. The Cg version shown below&#8230;</p>
<blockquote><p>float3 outValue = saturate( inValue );</p></blockquote>
<p>Becomes the following when converted to GLSL&#8230;</p>
<blockquote><p>vec3 outValue = clamp( inValue, 0.0, 1.0 );</p></blockquote>
<p>Thought this might be useful for others who might be having the same problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lastrayofhope.com/2009/04/13/cghlsl-saturate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Texture Splat Shader</title>
		<link>http://www.lastrayofhope.com/2008/02/26/texture-splat-shader/</link>
		<comments>http://www.lastrayofhope.com/2008/02/26/texture-splat-shader/#comments</comments>
		<pubDate>Tue, 26 Feb 2008 17:56:54 +0000</pubDate>
		<dc:creator>Kaluriel</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Shaders]]></category>
		<category><![CDATA[Cg]]></category>

		<guid isPermaLink="false">http://www.lastrayofhope.com/?p=660</guid>
		<description><![CDATA[A shader for using an RGBA Map to texture map a primitive with four textures. The first texture is the base texture splat map. The image on this blog entry is a texture splat map that I&#8217;ve used, anywhere there is a green component is grass, anywhere there is blue is sand/dirt, and anywhere there [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.lastrayofhope.com/wp-content/uploads/2008/02/ground.png"><img class="alignleft size-medium wp-image-2611" title="Texture Splat Base" src="http://www.lastrayofhope.com/wp-content/uploads/2008/02/ground-300x300.png" alt="Texture Splat Base" width="180" height="180" /></a>A shader for using an RGBA Map to texture map a primitive with four textures.</p>
<p>The first texture is the base texture splat map. The image on this blog entry is a texture splat map that I&#8217;ve used, anywhere there is a green component is grass, anywhere there is blue is sand/dirt, and anywhere there is red is rock/road. The colour component acts as a blend value.</p>
<p>The other three textures represent the area I just mentioned, there is room for texture to be applied to the same texture splat if the alpha channel is used, but I prefer to save that for use as a height map in the vertex stage.</p>
<pre class="brush: cpp;">
// --- [ structs ] --------------------------------------------
//
struct VS_OUTPUT
{
float4 position : POSITION;
float2 uv : TEXCOORD0;
};

struct VS_INPUT
{
float4 position : POSITION;
float2 uv : TEXCOORD0;
};

// --- [ vertex program ] -------------------------------------
//
VS_OUTPUT main_vp( VS_INPUT In, uniform float4x4 worldViewProj )
{
VS_OUTPUT Out;

Out.position = mul(worldViewProj, In.position );
Out.uv = In.uv;

return Out;
}

// --- [ fragment program ] -----------------------------------
//
float4 main_fp( float2 uv : TEXCOORD0, uniform sampler2D texBase, uniform sampler2D tex0, uniform sampler2D tex1, uniform sampler2D tex2 ) : COLOR
{
float3 colour = tex2D(texBase, uv).rgb;
return tex2D(tex0, uv) * colour.r + tex2D(tex1, uv) * colour.g + tex2D(tex2, uv) * colour.b;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lastrayofhope.com/2008/02/26/texture-splat-shader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Basic Water Shader</title>
		<link>http://www.lastrayofhope.com/2008/02/13/basic-water-shader/</link>
		<comments>http://www.lastrayofhope.com/2008/02/13/basic-water-shader/#comments</comments>
		<pubDate>Wed, 13 Feb 2008 17:50:32 +0000</pubDate>
		<dc:creator>Kaluriel</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Shaders]]></category>
		<category><![CDATA[Cg]]></category>

		<guid isPermaLink="false">http://www.lastrayofhope.com/?p=655</guid>
		<description><![CDATA[A very simple vertex shader for creating basic wave motion. I designed this shader for use with the Tales of Phantasia Remake for the river in Totus Village. And despite its simplicity it turned out quite well. // --- [ structs ] -------------------------------------------- // struct VS_OUTPUT { float4 position : POSITION; float2 uv : TEXCOORD0; [...]]]></description>
			<content:encoded><![CDATA[<p>A very simple vertex shader for creating basic wave motion. I designed this shader for use with the Tales of Phantasia Remake for the river in Totus Village. And despite its simplicity it turned out quite well.</p>
<pre class="brush: cpp;">
// --- [ structs ] --------------------------------------------
//
struct VS_OUTPUT
{
float4 position : POSITION;
float2 uv : TEXCOORD0;
};

struct VS_INPUT
{
float4 position : POSITION;
float2 uv : TEXCOORD0;
};

// --- [ vertex program ] -------------------------------------
//
VS_OUTPUT main_vp( VS_INPUT In, uniform float4x4 worldViewProj, uniform float time )
{
VS_OUTPUT Out;

Out.position = In.position;
Out.position.y = In.position.y + 0.10 * ( sin( ( In.position.z + ( time * 30 ) ) + ( In.position.x + ( time * 30 ) ) ) ) - 0.10;
Out.position = mul(worldViewProj, Out.position);
Out.uv.x = ( In.uv.x - time * 5 ) * 0.5;
Out.uv.y = ( In.uv.y + time * 10 ) * 0.5;

return Out;
}

// --- [ fragment program ] -----------------------------------
//
float4 main_fp( float2 uv : TEXCOORD0, uniform sampler2D tex0 ) : COLOR
{
return tex2D(tex0, uv);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.lastrayofhope.com/2008/02/13/basic-water-shader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
