<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Maratis forum - Maratis shader syntax question?]]></title>
		<link>http://forum.maratis3d.com/viewtopic.php?id=1024</link>
		<description><![CDATA[The most recent posts in Maratis shader syntax question?.]]></description>
		<lastBuildDate>Thu, 17 Jul 2014 07:46:29 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Maratis shader syntax question?]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=6995#p6995</link>
			<description><![CDATA[<p>Thanks anael. Code worked. Had to make small changes. Thats the code that worked:</p><br /><p>VERT:</p><p>attribute vec3 Vertex;<br />attribute vec3 Normal;<br />attribute vec3 Tangent;<br />attribute vec3 color;</p><p>attribute vec2 TexCoord0;<br />attribute vec2 TexCoord1;<br />attribute vec2 TexCoord2;<br />attribute vec2 TexCoord3;</p><p>uniform mat4 TextureMatrix[4];<br />uniform mat4 ModelViewMatrix;<br />uniform mat4 ProjectionMatrix;<br />uniform mat4 NormalMatrix;<br />uniform mat4 ProjModelViewMatrix;</p><p>// custom varyings interpolated to the pixel shader<br />varying vec2 texCoord;<br />varying vec4 position, Color;</p><p>// vert main<br />void main(void)<br />{<br />&nbsp; &nbsp; position = ModelViewMatrix * vec4(Vertex, 1.0);<br />&nbsp; &nbsp; texCoord = (TextureMatrix[0] * vec4(TexCoord0, 1.0, 1.0)).xy;<br />&nbsp; &nbsp; Color = vec4(color, 1.0);</p><p>&nbsp; &nbsp; gl_Position = ProjModelViewMatrix * vec4(Vertex, 1.0);<br />}</p><p>FRAG:</p><p>uniform float time;<br />uniform sampler2D Texture[8];</p><p>float radius = .5;<br />varying vec2 texCoord;</p><p>void main()<br />{<br />&nbsp; &nbsp; float t = clamp(time / 6., 0., 1.);</p><p>&nbsp; &nbsp; vec2 coords = texCoord.st;<br />&nbsp; &nbsp; vec2 dir = coords - vec2(.5);<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; float dist = distance(coords, vec2(.5));<br />&nbsp; &nbsp; vec2 offset = dir * (sin(dist * 80. - time*15.) + .5) / 30.;</p><p>&nbsp; &nbsp; vec2 texCoord = coords + offset;<br />&nbsp; &nbsp; vec4 diffuse = texture2D(Texture[0], texCoord);</p> <br /><p> &nbsp; &nbsp; gl_FragColor = diffuse * (1. - t);<br />}</p>]]></description>
			<author><![CDATA[dummy@example.com (Skywriter)]]></author>
			<pubDate>Thu, 17 Jul 2014 07:46:29 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=6995#p6995</guid>
		</item>
		<item>
			<title><![CDATA[Re: Maratis shader syntax question?]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=6992#p6992</link>
			<description><![CDATA[<p>use this as a vert shader :</p><div class="codebox"><pre><code>// engine default attributes and uniforms
attribute vec3 Vertex;
attribute vec3 Normal;
attribute vec3 Tangent;
attribute vec3 Color;

attribute vec2 TexCoord0;
attribute vec2 TexCoord1;
attribute vec2 TexCoord2;
attribute vec2 TexCoord3;

uniform mat4 TextureMatrix[4];
uniform mat4 ModelViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 NormalMatrix;
uniform mat4 ProjModelViewMatrix;

// custom varyings interpolated to the pixel shader
varying vec2 texCoord;
varying vec4 position, color;

// vert main
void main(void)
{
    position = ModelViewMatrix * vec4(Vertex, 1.0);
    texCoord = (TextureMatrix[0] * vec4(TexCoord0, 1.0, 1.0)).xy;
    color = vec4(Color, 1.0);

    gl_Position = ProjModelViewMatrix * vec4(Vertex, 1.0);
}</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (anael)]]></author>
			<pubDate>Wed, 16 Jul 2014 22:05:48 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=6992#p6992</guid>
		</item>
		<item>
			<title><![CDATA[Re: Maratis shader syntax question?]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=6991#p6991</link>
			<description><![CDATA[<p>the fixed renderer use the 3d card fixed pipeline, that was before the invention of shaders (mostly deprecated on desktop)<br />Wikipedia : <a href="https://en.wikipedia.org/wiki/Fixed-function">https://en.wikipedia.org/wiki/Fixed-function</a></p><p>the standard renderer uses the 3d card shader pipeline.</p>]]></description>
			<author><![CDATA[dummy@example.com (anael)]]></author>
			<pubDate>Wed, 16 Jul 2014 20:11:53 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=6991#p6991</guid>
		</item>
		<item>
			<title><![CDATA[Re: Maratis shader syntax question?]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=6990#p6990</link>
			<description><![CDATA[<p>Hi anael. I&#039;m totaly new to shaders. How else i can write this code? </p><p>&nbsp; &nbsp; gl_FrontColor&nbsp; = gl_Color;<br />&nbsp; &nbsp; gl_TexCoord[0] = gl_MultiTexCoord0;</p><p>Another question would be, why shaders not working on fixed renderer?</p>]]></description>
			<author><![CDATA[dummy@example.com (Skywriter)]]></author>
			<pubDate>Wed, 16 Jul 2014 19:06:03 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=6990#p6990</guid>
		</item>
		<item>
			<title><![CDATA[Re: Maratis shader syntax question?]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=6989#p6989</link>
			<description><![CDATA[<p>Hi,<br />I will have a look at your shader and come back to you.<br />for now, please look at these shader examples : <a href="http://www.maratis3d.org/?p=548">http://www.maratis3d.org/?p=548</a></p><p>Maratis doesn&#039;t use gl_Color, gl_MultiTexCoord0 or gl_TexCoord (they are deprecated)</p><p>here is a basic shader from the link above :</p><p>VERT:<br /></p><div class="codebox"><pre><code>attribute vec3 Vertex;
attribute vec2 TexCoord0;
uniform mat4 TextureMatrix[8];
uniform mat4 ProjModelViewMatrix;
varying vec2 texCoord[1];
                            
void main(void)
{
    gl_Position = ProjModelViewMatrix * vec4(Vertex, 1.0);
    texCoord[0] = (TextureMatrix[0] * vec4(TexCoord0, 1.0, 1.0)).xy;
}</code></pre></div><p>FRAG:<br /></p><div class="codebox"><pre><code>uniform bool AlphaTest;
uniform float MaterialOpacity;
uniform sampler2D Texture[8];
varying vec2 texCoord[1];
void main(void)
{
    float w = texture2D(Texture[0], texCoord[0]).w;
    if(AlphaTest)
        if(w &lt; 0.5) discard;
    gl_FragColor = vec4(1.0, 1.0, 1.0, w * MaterialOpacity);
}</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (anael)]]></author>
			<pubDate>Wed, 16 Jul 2014 18:56:20 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=6989#p6989</guid>
		</item>
		<item>
			<title><![CDATA[Maratis shader syntax question?]]></title>
			<link>http://forum.maratis3d.com/viewtopic.php?pid=6987#p6987</link>
			<description><![CDATA[<p>Hi, im learning glsl. I want to create a water ripple on the plane, but in maratis it looks just white color. Can someboady tell me whats wrong with this code:</p><p>VERT shader<br />attribute vec3 Vertex;<br />//attribute vec3 Color;</p><p>uniform mat4 ProjModelViewMatrix;<br />&nbsp; <br />void main()<br />{<br />&nbsp; &nbsp; gl_Position&nbsp; &nbsp; = ProjModelViewMatrix * vec4(Vertex, 1.0);<br />&nbsp; &nbsp; gl_FrontColor&nbsp; = gl_Color;<br />&nbsp; &nbsp; gl_TexCoord[0] = gl_MultiTexCoord0;<br />}</p><p>FRAG shader</p><p>uniform float time;</p><p>uniform sampler2D Texture[8];</p><p>float radius = .5;</p><p>void main()<br />{<br />&nbsp; &nbsp; float t = clamp(time / 6., 0., 1.);</p><p>&nbsp; &nbsp; vec2 coords = gl_TexCoord[0].st;<br />&nbsp; &nbsp; vec2 dir = coords - vec2(.5);<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; float dist = distance(coords, vec2(.5));<br />&nbsp; &nbsp; vec2 offset = dir * (sin(dist * 80. - time*15.) + .5) / 30.;</p><p>&nbsp; &nbsp; vec2 texCoord = coords + offset;<br />&nbsp; &nbsp; vec4 diffuse = texture2D(Texture[0], texCoord);</p><p>&nbsp; &nbsp; //vec4 mixin = texture2D(Texture[1], texCoord);</p><p> &nbsp; &nbsp; gl_FragColor = diffuse * (1. - t);<br />}</p>]]></description>
			<author><![CDATA[dummy@example.com (Skywriter)]]></author>
			<pubDate>Wed, 16 Jul 2014 18:47:23 +0000</pubDate>
			<guid>http://forum.maratis3d.com/viewtopic.php?pid=6987#p6987</guid>
		</item>
	</channel>
</rss>
