<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Maratis forum - Maratis shader syntax question?]]></title>
	<link rel="self" href="http://forum.maratis3d.com/extern.php?action=feed&amp;tid=1024&amp;type=atom"/>
	<updated>2014-07-17T07:46:29Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.maratis3d.com/viewtopic.php?id=1024</id>
		<entry>
			<title type="html"><![CDATA[Re: Maratis shader syntax question?]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=6995#p6995"/>
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Skywriter]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2629</uri>
			</author>
			<updated>2014-07-17T07:46:29Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=6995#p6995</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Maratis shader syntax question?]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=6992#p6992"/>
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[anael]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2</uri>
			</author>
			<updated>2014-07-16T22:05:48Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=6992#p6992</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Maratis shader syntax question?]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=6991#p6991"/>
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[anael]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2</uri>
			</author>
			<updated>2014-07-16T20:11:53Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=6991#p6991</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Maratis shader syntax question?]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=6990#p6990"/>
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Skywriter]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2629</uri>
			</author>
			<updated>2014-07-16T19:06:03Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=6990#p6990</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Maratis shader syntax question?]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=6989#p6989"/>
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[anael]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2</uri>
			</author>
			<updated>2014-07-16T18:56:20Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=6989#p6989</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Maratis shader syntax question?]]></title>
			<link rel="alternate" href="http://forum.maratis3d.com/viewtopic.php?pid=6987#p6987"/>
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Skywriter]]></name>
				<uri>http://forum.maratis3d.com/profile.php?id=2629</uri>
			</author>
			<updated>2014-07-16T18:47:23Z</updated>
			<id>http://forum.maratis3d.com/viewtopic.php?pid=6987#p6987</id>
		</entry>
</feed>
