<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>OpenGL Discussion and Help Forums - OpenGL Shading Language</title>
		<link>http://www.opengl.org/discussion_boards/</link>
		<description>Discussion about the OpenGL Shading Language and related ARB extensions</description>
		<language>en</language>
		<lastBuildDate>Mon, 20 May 2013 00:53:18 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.opengl.org/discussion_boards/images/misc/rss.png</url>
			<title>OpenGL Discussion and Help Forums - OpenGL Shading Language</title>
			<link>http://www.opengl.org/discussion_boards/</link>
		</image>
		<item>
			<title>Shader Performance</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181728-Shader-Performance?goto=newpost</link>
			<pubDate>Sat, 18 May 2013 04:00:43 GMT</pubDate>
			<description>A short while ago there was a thread on measuring performance of different shader subroutines. 
I have been having a look at nVidia NVPerfKit sdk. It...</description>
			<content:encoded><![CDATA[<div>A short while ago there was a thread on measuring performance of different shader subroutines.<br />
I have been having a look at nVidia NVPerfKit sdk. It appears to have counters that give the instruction rate by shader stage; ie vertex, tesselation, geometry  and fragment.<br />
<br />
I have not used this. Has anyone else looked at this data.</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/15-OpenGL-Shading-Language">OpenGL Shading Language</category>
			<dc:creator>tonyo_au</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181728-Shader-Performance</guid>
		</item>
		<item>
			<title>image2DArray :only first layer work</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181711-image2DArray-only-first-layer-work?goto=newpost</link>
			<pubDate>Thu, 16 May 2013 14:32:41 GMT</pubDate>
			<description><![CDATA[I attempt to use the image load/store function.I need several images,and if they are indexed ,it's convienient for coding,so I want to use the...]]></description>
			<content:encoded><![CDATA[<div>I attempt to use the image load/store function.I need several images,and if they are indexed ,it's convienient for coding,so I want to use the image2DArray uniform.But it seems that only the first layer of the image2DArray works.In another word, the iimage2DArray perform like an iimage.<br />
<br />
the fragment shader(only used by fs):<br />
<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">#version 420                                                                                                                                                    
coherent uniform layout(r32i) iimage2DArray sigmal;                                                                       
out vec4 FragColor;                                                                                                                                                 
void main()                                                                       
{                                                                               
    ivec2 coord = ivec2(gl_FragCoord.xy);
    int increment=100;
    int v=imageAtomicAdd(sigmal,ivec3(coord,**1**),increment);  //the promlem is that it seems 
                                                            //the coordinate z has no influence
    FragColor =vec4(coord/screenSize,v/1000.0f,1);
&nbsp;
}</pre></div></code><hr />
</div>the c++ code: binding:<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">glGenTextures(1,&amp;image);
glBindTexture(GL_TEXTURE_2D_ARRAY,image);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB,0);
//Allocate the storage.
glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_R32I, width, height, layerCount);
&nbsp;
glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, width, height, layerCount, GL_RED_INTEGER, GL_INT, clearData);     //
&nbsp;
glBindImageTexture(0, image, 0, GL_TRUE, 0, GL_READ_WRITE, GL_R32I);
&nbsp;
//Always set reasonable texture parameters
glTexParameteri(GL_TEXTURE_2D_ARRAY,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D_ARRAY,GL_TEXTURE_MAG_FILTER,GL_LINEAR);</pre></div></code><hr />
</div>render:<br />
<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">glBindTexture(GL_TEXTURE_2D_ARRAY,image);
shader.use();
shader.setUniform(&quot;sigmal&quot;,0);
glBindVertexArray(vao);
glDrawArrays(GL_TRIANGLES, 0, 6);
shader.unuse();
glMemoryBarrier(GL_TEXTURE_FETCH_BARRIER_BIT);
int *data=new int&#91;viewport&#91;2&#93;*viewport&#91;3&#93;*layerCount&#93;;
glBindTexture(GL_TEXTURE_2D_ARRAY,image);
glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB,0);
glGetTexImage(GL_TEXTURE_2D_ARRAY, 0 , GL_RED_INTEGER, GL_INT,data );
printf(&quot;%d %d\n&quot;,data&#91;0&#93;,data&#91;viewport&#91;2&#93;*viewport&#91;3&#93;&#93;);</pre></div></code><hr />
</div>The printf result is data[0] which I think is the first texel of the first layer increase frame by frame,whereas,data[viewport[2]*viewport[3]] which I think is the first texel of the second layer doesn't change.I think the reasonable result is opposite.</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/15-OpenGL-Shading-Language">OpenGL Shading Language</category>
			<dc:creator>Fenado</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181711-image2DArray-only-first-layer-work</guid>
		</item>
		<item>
			<title>Double precision: Extensions for trigonometry and transcendental functions?</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181702-Double-precision-Extensions-for-trigonometry-and-transcendental-functions?goto=newpost</link>
			<pubDate>Wed, 15 May 2013 23:28:59 GMT</pubDate>
			<description>The standard double precision extension only defines addition, multiplication, divison, square-root and a few clamping and comparison functions for...</description>
			<content:encoded><![CDATA[<div>The standard double precision extension only defines addition, multiplication, divison, square-root and a few clamping and comparison functions for double precision datatype. I was wondering if any vendor provides an extension that also provides trigonometry and transcendental functions for double precision?</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/15-OpenGL-Shading-Language">OpenGL Shading Language</category>
			<dc:creator>rahulgarg</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181702-Double-precision-Extensions-for-trigonometry-and-transcendental-functions</guid>
		</item>
		<item>
			<title>Beginner: Implementing both colours and textures in fragment shader (for picking)</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181680-Beginner-Implementing-both-colours-and-textures-in-fragment-shader-%28for-picking%29?goto=newpost</link>
			<pubDate>Sun, 12 May 2013 01:34:05 GMT</pubDate>
			<description><![CDATA[Hi all, this is my first post. 
 
I am learning about shaders in a very piecemeal fashion so don't be surprised if I seem to not understand really...]]></description>
			<content:encoded><![CDATA[<div>Hi all, this is my first post.<br />
<br />
I am learning about shaders in a very piecemeal fashion so don't be surprised if I seem to not understand really obvious things.<br />
<br />
I have to implement picking in a program (for uni) with shaders with objects that are arrays of vertices and texture co-ordinates parsed from Collada files.<br />
<br />
I started off trying to do ray picking but I just couldn't make it work. I then decided to try colour id picking because that's what I did in my previous graphics course which didn't introduce shaders.<br />
<br />
I always wanted to draw some axes on the screen to help with debugging but never could, I didn't really understand what the shader we were given did at the time so I didn't worry about it. But now if I want to implement colour id picking I will have to be able to draw in colour and not in textures.<br />
<br />
I've now learned a tiny bit about shaders and tried this in my fragment shader:<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">varying  vec2 vTexCoord; 
uniform sampler2D myTexture;
&nbsp;
void main (void)  
{
	if(gl_Color.r &lt;= 0.01 &amp;&amp; gl_Color.g &lt;= 0.01 &amp;&amp; gl_Color.b &lt;= 0.01)
	{
		gl_FragColor =  texture2D(myTexture, vTexCoord); 
	}
	else
	{
		gl_FragColor = gl_Color; 
	}
}</pre></div></code><hr />
</div><br />
The shader used to just have gl_FragColor =  texture2D(myTexture, vTexCoord); in the main ().<br />
<br />
In my drawing part, if not in picking mode I enable textures and colour in black, and if in picking mode I disable textures and draw in the colour id of the object.<br />
<br />
I may have mistakes in my drawing code, but I am sure that my shader code has mistakes because my matrix handles return -1. I can't seem to find any info on the net about testing what colour you have in the shader and doing different things based on the colour. So my shader code was just a blind guess as to what might work but I can't think of any other guesses to try.<br />
<br />
Thanks heaps if anyone can help. And/or point me to some good shader tutorials.</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/15-OpenGL-Shading-Language">OpenGL Shading Language</category>
			<dc:creator>Quantumcat</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181680-Beginner-Implementing-both-colours-and-textures-in-fragment-shader-%28for-picking%29</guid>
		</item>
		<item>
			<title>Problem of environment mapping</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181656-Problem-of-environment-mapping?goto=newpost</link>
			<pubDate>Wed, 08 May 2013 16:50:11 GMT</pubDate>
			<description>Hi, all. 
 
I encounter a odd phenomenon when I make a environment mapping effect on a cube. 
 
It is shown as follow : 
 
Attachment 1020...</description>
			<content:encoded><![CDATA[<div>Hi, all.<br />
<br />
I encounter a odd phenomenon when I make a environment mapping effect on a cube.<br />
<br />
It is shown as follow :<br />
<br />
<a href="http://www.opengl.org/discussion_boards/attachment.php?attachmentid=1020&amp;d=1368107874" id="attachment1020" rel="Lightbox_0" ><img src="http://www.opengl.org/discussion_boards/attachment.php?attachmentid=1020&amp;d=1368107874&amp;thumb=1" border="0" alt="Click image for larger version.&nbsp;

Name:	&#26410;&#21629;&#21517;.jpg&nbsp;
Views:	34&nbsp;
Size:	15.3 KB&nbsp;
ID:	1020" class="thumbnail" style="float:CONFIG" /></a><br />
<br />
<br />
Does some one encounter same situation as like as mine ?<br />
<br />
(P.S I calculate the reflect vector in world matrix, I don't use the gl_NormalMatrix. My cube only have a translation, no rotation and scale.)</div>


	<div style="padding:10px">

	
		<fieldset class="fieldset">
			<legend>Attached Thumbnails</legend>
			<div style="padding:10px">
			
<a href="http://www.opengl.org/discussion_boards/attachment.php?attachmentid=1020&amp;d=1368107874" 
rel="Lightbox_1250649" id="attachment1020"
><img class="thumbnail" src="http://www.opengl.org/discussion_boards/attachment.php?attachmentid=1020&amp;stc=1&amp;thumb=1&amp;d=1368107874" 
alt="Click image for larger version.&nbsp;

Name:	&#26410;&#21629;&#21517;.jpg&nbsp;
Views:	N/A&nbsp;
Size:	15.3 KB&nbsp;
ID:	1020"/></a>
&nbsp;

			</div>
		</fieldset>
	

	

	

	

	</div>
]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/15-OpenGL-Shading-Language">OpenGL Shading Language</category>
			<dc:creator>LaLaChen</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181656-Problem-of-environment-mapping</guid>
		</item>
		<item>
			<title>Shadow mapping with multiple shadows</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181630-Shadow-mapping-with-multiple-shadows?goto=newpost</link>
			<pubDate>Mon, 06 May 2013 17:17:50 GMT</pubDate>
			<description><![CDATA[I've implemented shadow mapping using ARB extensions following the tutorial on paulsprojects.net/tutorials/smt/smt.html I've modified the code to add...]]></description>
			<content:encoded><![CDATA[<div>I've implemented shadow mapping using ARB extensions following the tutorial on paulsprojects.net/tutorials/smt/smt.html I've modified the code to add another light source. I've created and initialized 2 more matrices (lightViewMatrix2 and lightProjectionMatrix2) and another shadowMap texture. At step 3 of the tutorial, after binding the first shadowmap texture, I've binded the second one. The result I get is that I see only the intersections between the 2 shadows produced by the 2 different light sources. I've initialized all the matrices in the init function as shown in the tutorial, this is my display function.<br />
<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">void Display(void){
//First pass - from light's point of view
//Calculate &amp; save matrices LIGHT 1
glPushMatrix();
    glLoadIdentity();
    gluLookAt(  lightPosition&#91;0&#93;, lightPosition&#91;1&#93;, lightPosition&#91;2&#93;,
                0.0f, 0.0f , 0.0f,
                0.0f, 1.0f, 0.0f);
    glGetFloatv(GL_MODELVIEW_MATRIX, lightViewMatrix);
glPopMatrix();
&nbsp;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
&nbsp;
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(lightProjectionMatrix);
&nbsp;
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(lightViewMatrix);
&nbsp;
//Use viewport the same size as the shadow map
glViewport(0, 0, shadowMapSize, shadowMapSize);
&nbsp;
//Draw back faces into the shadow map
glCullFace(GL_FRONT);
&nbsp;
//Disable color writes, and use flat shading for speed
glShadeModel(GL_FLAT);
glColorMask(0, 0, 0, 0);
&nbsp;
//Draw the scene
DrawScene();
&nbsp;
//Read the depth buffer into the shadow map texture
glBindTexture(GL_TEXTURE_2D, shadowMapTexture&#91;0&#93;);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, shadowMapSize, shadowMapSize);
&nbsp;
&nbsp;
//First pass - from light's point of view
//Calculate &amp; save matrices LIGHT 2
glPushMatrix();
    glLoadIdentity();
    gluLookAt(  lightPosition2&#91;0&#93;, lightPosition2&#91;1&#93;, lightPosition2&#91;2&#93;,
                0.0f, 0.0f , 0.0f,
                0.0f, 1.0f, 0.0f);
    glGetFloatv(GL_MODELVIEW_MATRIX, lightViewMatrix2);
glPopMatrix();
&nbsp;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
&nbsp;
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(lightProjectionMatrix2);
&nbsp;
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(lightViewMatrix2);
&nbsp;
//Use viewport the same size as the shadow map
glViewport(0, 0, shadowMapSize, shadowMapSize);
&nbsp;
//Draw the scene
DrawScene();
&nbsp;
//Read the depth buffer into the shadow map texture
glBindTexture(GL_TEXTURE_2D, shadowMapTexture&#91;1&#93;);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, shadowMapSize, shadowMapSize);
&nbsp;
//restore states
glCullFace(GL_BACK);
glShadeModel(GL_SMOOTH);
glColorMask(1, 1, 1, 1);
&nbsp;
&nbsp;
//2nd pass - Draw from camera's point of view
glClear(GL_DEPTH_BUFFER_BIT);
&nbsp;
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(cameraProjectionMatrix);
&nbsp;
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(cameraViewMatrix);
&nbsp;
glViewport(0, 0, windowWidth, windowHeight);
&nbsp;
float white2&#91;3&#93;={0.2f,0.2f,0.2f};
&nbsp;
//light to represent shadowed areas
glLightfv(GL_LIGHT1, GL_POSITION, VECTOR4D(lightPosition));
glLightfv(GL_LIGHT1, GL_AMBIENT, white2);
glLightfv(GL_LIGHT1, GL_DIFFUSE, white2);
glLightfv(GL_LIGHT1, GL_SPECULAR, black1);
glEnable(GL_LIGHT1);
glEnable(GL_LIGHTING);
&nbsp;
DrawScene();
&nbsp;
&nbsp;
//3rd pass
//Draw with bright light LIGHT1
glLightfv(GL_LIGHT1, GL_DIFFUSE, white1);
glLightfv(GL_LIGHT1, GL_SPECULAR, white1);
&nbsp;
//Calculate texture matrix for projection
//This matrix takes us from eye space to the light's clip space
//It is postmultiplied by the inverse of the current view matrix when specifying texgen
static MATRIX4X4 biasMatrix(0.5f, 0.0f, 0.0f, 0.0f,
                            0.0f, 0.5f, 0.0f, 0.0f,
                            0.0f, 0.0f, 0.5f, 0.0f,
                            0.5f, 0.5f, 0.5f, 1.0f);    //bias from &#91;-1, 1&#93; to &#91;0, 1&#93;
&nbsp;
MATRIX4X4 textureMatrix=biasMatrix*lightProjectionMatrix*lightViewMatrix;
&nbsp;
//Set up texture coordinate generation.
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_S, GL_EYE_PLANE, textureMatrix.GetRow(0));
glEnable(GL_TEXTURE_GEN_S);
&nbsp;
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_T, GL_EYE_PLANE, textureMatrix.GetRow(1));
glEnable(GL_TEXTURE_GEN_T);
&nbsp;
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_R, GL_EYE_PLANE, textureMatrix.GetRow(2));
glEnable(GL_TEXTURE_GEN_R);
&nbsp;
glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_Q, GL_EYE_PLANE, textureMatrix.GetRow(3));
glEnable(GL_TEXTURE_GEN_Q);
&nbsp;
//Bind &amp; enable shadow map texture
glBindTexture(GL_TEXTURE_2D, shadowMapTexture&#91;0&#93;);
glEnable(GL_TEXTURE_2D);
&nbsp;
//Enable shadow comparison
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE);
&nbsp;
//Shadow comparison should be true (ie not in shadow) if r&lt;=texture
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
&nbsp;
//Shadow comparison should generate an INTENSITY result
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_INTENSITY);
&nbsp;
//Set alpha test to discard false comparisons
glAlphaFunc(GL_GEQUAL, 0.99f);
glEnable(GL_ALPHA_TEST);
&nbsp;
DrawScene();
&nbsp;
//3rd pass
//Draw with bright light LIGHT2
&nbsp;
MATRIX4X4 textureMatrix2=biasMatrix*lightProjectionMatrix2*lightViewMatrix2;
&nbsp;
//Set up texture coordinate generation.
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_S, GL_EYE_PLANE, textureMatrix2.GetRow(0));
glEnable(GL_TEXTURE_GEN_S);
&nbsp;
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_T, GL_EYE_PLANE, textureMatrix2.GetRow(1));
glEnable(GL_TEXTURE_GEN_T);
&nbsp;
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_R, GL_EYE_PLANE, textureMatrix2.GetRow(2));
glEnable(GL_TEXTURE_GEN_R);
&nbsp;
glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_Q, GL_EYE_PLANE, textureMatrix2.GetRow(3));
glEnable(GL_TEXTURE_GEN_Q);
&nbsp;
//Bind &amp; enable shadow map texture
glBindTexture(GL_TEXTURE_2D, shadowMapTexture&#91;1&#93;);
glEnable(GL_TEXTURE_2D);
&nbsp;
//Enable shadow comparison
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE);
&nbsp;
//Shadow comparison should be true (ie not in shadow) if r&lt;=texture
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
&nbsp;
//Shadow comparison should generate an INTENSITY result
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_INTENSITY);
&nbsp;
//Set alpha test to discard false comparisons
glAlphaFunc(GL_GEQUAL, 0.99f);
glEnable(GL_ALPHA_TEST);
&nbsp;
DrawScene();
&nbsp;
//Disable textures and texgen
glDisable(GL_TEXTURE_2D);
&nbsp;
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_GEN_R);
glDisable(GL_TEXTURE_GEN_Q);
&nbsp;
//Restore other states
glDisable(GL_LIGHTING);
glDisable(GL_ALPHA_TEST);
&nbsp;
&nbsp;
//Set matrices for ortho
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(-1.0f, 1.0f, -1.0f, 1.0f);
&nbsp;
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
&nbsp;
//reset matrices
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
&nbsp;
glFinish();
glutSwapBuffers();}</pre></div></code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/15-OpenGL-Shading-Language">OpenGL Shading Language</category>
			<dc:creator>xrwnis</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181630-Shadow-mapping-with-multiple-shadows</guid>
		</item>
		<item>
			<title>Spec. clarification: gl_VertexID, is the generation by glDrawElements optional?</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181615-Spec-clarification-gl_VertexID-is-the-generation-by-glDrawElements-optional?goto=newpost</link>
			<pubDate>Fri, 03 May 2013 07:55:01 GMT</pubDate>
			<description>The Specification defines: 
 
gl_VertexID is a vertex language input variable that holds an integer index for the vertex. The index is impliclty...</description>
			<content:encoded><![CDATA[<div>The Specification defines:<br />
<br />
gl_VertexID is a vertex language input variable that holds an integer index for the vertex. The index is impliclty generated by glDrawArrays and other commands that do not reference the content of the GL_ELEMENT_ARRAY_BUFFER, <span class="highlight">or explicitly generated from the content of the GL_ELEMENT_ARRAY_BUFFER by commands such as glDrawElements.</span><br />
<br />
I would like to know, if the &quot;or&quot; part of the specification is optional. Since this is ignored by a server released few days ago.  Also I would like to know if re-indexing with random ordering is allowed e.g:<br />
<br />
index<sub>x</sub> &lt; index<sub>y</sub> =&gt;  gl_VertexID<sub>x</sub> &gt;  gl_VertexID<sub>y</sub> == true</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/15-OpenGL-Shading-Language">OpenGL Shading Language</category>
			<dc:creator>yousry</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181615-Spec-clarification-gl_VertexID-is-the-generation-by-glDrawElements-optional</guid>
		</item>
		<item>
			<title>GLSL function execution time estimation</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181578-GLSL-function-execution-time-estimation?goto=newpost</link>
			<pubDate>Sun, 28 Apr 2013 23:12:12 GMT</pubDate>
			<description>On the first glance the following question looks silly, but after trying to answer on it I realized it is quite difficult (or even impossible). 
...</description>
			<content:encoded><![CDATA[<div>On the first glance the following question looks silly, but after trying to answer on it I realized it is quite difficult (or even impossible).<br />
<br />
<b>How can we estimate execution time of some function inside a shader?</b><br />
<br />
I have made a sample vertex shader like this:<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">#version 330
out  float out_val;
void main(void)
{
    out_val = someFun(gl_VertexID * 1e-6);
}</pre></div></code><hr />
</div>allocate 80MB buffer for transform feedback, embrace glDrawArrays() with glQueryCounter()<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">glQueryCounter(m_nStartTimeID, GL_TIMESTAMP);
glDrawArrays(GL_POINTS, first, count);
glQueryCounter(m_nEndTimeID, GL_TIMESTAMP);</pre></div></code><hr />
</div>and call it for count=1e7.<br />
<br />
Can you guess what happens? Elapsed time does not depend on the complexity of the function. There is a fixed portion for setup (about 14.7us on my laptop) and a portion that directly depends on the number of vertices (about 22.5ms for 1e7 vertices).<br />
<br />
Does anybody have any suggestion on measuring GLSL function execution time?<br />
<br />
In fact, I need to compare efficiency of some implementations. So it is not important to have absolute values. On the other hand, I don't want to measure execution time of the application when they are applied, since it is quite specific and subjected to optimization related to certain implementation.<br />
<br />
Thank you in advance!</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/15-OpenGL-Shading-Language">OpenGL Shading Language</category>
			<dc:creator>Aleksandar</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181578-GLSL-function-execution-time-estimation</guid>
		</item>
		<item>
			<title>scrolling normal maps to scrolling bump map</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181575-scrolling-normal-maps-to-scrolling-bump-map?goto=newpost</link>
			<pubDate>Sun, 28 Apr 2013 14:15:51 GMT</pubDate>
			<description>I was wondering if it was possible to have 2 scrolling normal maps which can then be applied to a texture to create a moving bump map?  Where the...</description>
			<content:encoded><![CDATA[<div>I was wondering if it was possible to have 2 scrolling normal maps which can then be applied to a texture to create a moving bump map?  Where the texture will be stationary if that makes sense.  I can attempt to clarify further, sorry I am not good at explaining myself.</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/15-OpenGL-Shading-Language">OpenGL Shading Language</category>
			<dc:creator>Johnathon332</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181575-scrolling-normal-maps-to-scrolling-bump-map</guid>
		</item>
		<item>
			<title>Shader error and Identity Matrix</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181574-Shader-error-and-Identity-Matrix?goto=newpost</link>
			<pubDate>Sun, 28 Apr 2013 07:30:43 GMT</pubDate>
			<description>Hi. I have a simple shader line  gl_Position = u_MVPMatrix *(u_InverseBindMatrix) *(a_Position); I have u_inversebindmatrix set to Identity matrix...</description>
			<content:encoded><![CDATA[<div>Hi. I have a simple shader line  gl_Position = u_MVPMatrix *(u_InverseBindMatrix) *(a_Position); I have u_inversebindmatrix set to Identity matrix using Matrix.setidentityM(); If I render without the line *u_InverseBindMatrix, then my cube shows up. If I leave it in, however, nothing shows up. I thought the identity matrix left equations unchanged. Any ideas?</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/15-OpenGL-Shading-Language">OpenGL Shading Language</category>
			<dc:creator>Alecto</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181574-Shader-error-and-Identity-Matrix</guid>
		</item>
		<item>
			<title>Texture not animating only shows black model</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181564-Texture-not-animating-only-shows-black-model?goto=newpost</link>
			<pubDate>Sat, 27 Apr 2013 09:48:08 GMT</pubDate>
			<description><![CDATA[hey guys I am trying to animate my texture using a bump map however it just comes up as a black model...well kind of dark blue 
 
<div...]]></description>
			<content:encoded><![CDATA[<div>hey guys I am trying to animate my texture using a bump map however it just comes up as a black model...well kind of dark blue<br />
<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">attribute highp vec3  inVertex;
&nbsp;
uniform highp   mat4  MVPMatrix;
uniform mediump vec3  LightDir;
uniform mediump vec3  EyePos;
uniform mediump vec2  inTexCoord;
uniform mediump vec2 watermovementX;
uniform mediump vec2 watermovementY;
uniform mediump vec2 waterSX;
uniform mediump vec2 waterSY;
&nbsp;
varying mediump vec3  EyeDir;
varying mediump vec2  TexCoord;
varying mediump vec2  TexCoord2;
varying mediump vec2  RefCoord;
varying mediump float WaterToEyeLength;
&nbsp;
void main()
{
	// Transform position
	gl_Position = MVPMatrix * vec4(inVertex,1.0);
	mediump vec2 waterCoord = inTexCoord;
	TexCoord = waterCoord.xy * waterSX; //this line scales the bump map
	TexCoord += watermovementX; //this line translates the bump map
	TexCoord2 = waterCoord.xy * waterSY;
	TexCoord2 += watermovementY;
&nbsp;
	RefCoord = inTexCoord;
	mediump vec3 WaterToEye = EyePos - inVertex;
	WaterToEyeLength = length(WaterToEye);
}</pre></div></code><hr />
</div><br />
FRAGMENT<br />
<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">uniform sampler2D  n_mapTex;
uniform sampler2D  n_mapTex2;
uniform sampler2D  reflectionTex;
uniform lowp float distortion;
uniform lowp vec4  WaterColour;
&nbsp;
varying mediump vec2  TexCoord;
varying mediump vec2  TexCoord2;
varying mediump vec2  RefCoord;
varying mediump float WaterToEye;
&nbsp;
void main()
{	
	//calculate water movement
	lowp vec3 aNormal = vec3(0.0, 0.0, 1.0);
	aNormal = texture2D(n_mapTex, TexCoord).xyz;
	aNormal += texture2D(n_mapTex, TexCoord2).xyz;
	aNormal -= 1.0;
	lowp vec2 watermovement = aNormal.st;
	mediump vec2 texMove = watermovement * (distortion/WaterToEye);
	gl_FragColor = texture2D(reflectionTex, texMove);
}</pre></div></code><hr />
</div><br />
code to update<br />
<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">waterTran += water_Vel * DT;
	waterTran = PVRTVec2(	fmod(waterTran.x, 1.0f), fmod(waterTran.y, 1.0f));
	waterTran2 += water_Vel2 * DT;
	waterTran2 = PVRTVec2(	fmod(waterTran2.x, 1.0f), fmod(waterTran2.y, 1.0f));
&nbsp;
&nbsp;
	glUniform2fv(m_ShaderProgram.auiLoc&#91;eW_Move&#93;,1, &amp;waterTran.x);
	glUniform2fv(m_ShaderProgram.auiLoc&#91;eWaterS&#93;,1, &amp;water_S.x);
	glUniform2fv(m_ShaderProgram.auiLoc&#91;eW_Move2&#93;,1, &amp;waterTran2.x);
	glUniform2fv(m_ShaderProgram.auiLoc&#91;eWaterS2&#93;,1, &amp;water_S2.x);
	glUniform1f(m_ShaderProgram.auiLoc&#91;eDist&#93;, pertubation);</pre></div></code><hr />
</div><br />
DT = delta time</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/15-OpenGL-Shading-Language">OpenGL Shading Language</category>
			<dc:creator>Johnathon332</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181564-Texture-not-animating-only-shows-black-model</guid>
		</item>
		<item>
			<title>opengl origin....</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181562-opengl-origin?goto=newpost</link>
			<pubDate>Sat, 27 Apr 2013 04:11:01 GMT</pubDate>
			<description>i am very new to opengl ...please let me know where is the origin of opengl window.... 
and by default is it orthographic projection??</description>
			<content:encoded><![CDATA[<div>i am very new to opengl ...please let me know where is the origin of opengl window....<br />
and by default is it orthographic projection??</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/15-OpenGL-Shading-Language">OpenGL Shading Language</category>
			<dc:creator>qawded</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181562-opengl-origin</guid>
		</item>
		<item>
			<title>uniform struct array</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181557-uniform-struct-array?goto=newpost</link>
			<pubDate>Fri, 26 Apr 2013 16:59:46 GMT</pubDate>
			<description><![CDATA[Hi, all. 
 
I try to write a structure and declare an array as follow : 
 
<div class="bbcode_container"> 
                <div...]]></description>
			<content:encoded><![CDATA[<div>Hi, all.<br />
<br />
I try to write a structure and declare an array as follow :<br />
<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">struct ShadowMapping
{
	mat4            light_coordinate_system;
	sampler2DShadow shadow_map;
	int             shadow_map_width;
	int             shadow_map_height;
};
&nbsp;
...
&nbsp;
//shadow mapping info
uniform ShadowMapping shadow_mapping_list&#91;8&#93;; //declaration
uniform int           shadow_mapping_number;</pre></div></code><hr />
</div><br />
Then I use the array in my shading program(fragment shader).<br />
<br />
If the condition in for loop is large than 1, I won't get all location of variables in my shader.<br />
<br />
So how can I use the uniform struct array in my shader?<br />
<br />
P.S. I post my code occurring the problem.<br />
<br />
<div class="bbcode_container">
                <div class="bbcode_description">Code :</div>
                <hr /><code class="bbcode_code"><div class="" style="font-family:monospace;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;
        int i;
        for( i = 0 ; i &lt; shadow_mapping_number ; i++)//if I modify the shadow_mapping_number to a constant 1, it's working. Otherwise, it's failure.
	{
		//use the uniform struct array by the form : shadow_mapping_list&#91;i&#93;.light_coordinate_system, and etc... .
	}</pre></div></code><hr />
</div><br />
And my version of glsl is #version 120<br />
Graphics card is Nvidia GTX 460<br />
<br />
By the way, the complied result is on error occurred in any shader.<br />
<br />
Thanks.</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/15-OpenGL-Shading-Language">OpenGL Shading Language</category>
			<dc:creator>LaLaChen</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181557-uniform-struct-array</guid>
		</item>
		<item>
			<title>Extracting a value from a fragment shader</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181546-Extracting-a-value-from-a-fragment-shader?goto=newpost</link>
			<pubDate>Wed, 24 Apr 2013 17:03:59 GMT</pubDate>
			<description>Hi all, 
 
I am implementing hdr light adaptation, until I found a small technical problem. 
I need to calculate this value inside a fragment shader...</description>
			<content:encoded><![CDATA[<div>Hi all,<br />
<br />
I am implementing hdr light adaptation, until I found a small technical problem.<br />
I need to calculate this value inside a fragment shader where I make other things too:<br />
<br />
<a href="http://www.opengl.org/discussion_boards/attachment.php?attachmentid=1016"  title="Name:  
Views: 
Size:  ">Attachment 1016</a><br />
<br />
I have the LumAverage value (from a 1x1 sampler2D texture), but how can I export the LumAdapted calculated value in order to use it in the next frame (it will be LumAdapted_i-1 in the next frame)?<br />
<br />
Thanks for you time ;)</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/15-OpenGL-Shading-Language">OpenGL Shading Language</category>
			<dc:creator>frigopie</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181546-Extracting-a-value-from-a-fragment-shader</guid>
		</item>
		<item>
			<title>cube map shader texture binding</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181538-cube-map-shader-texture-binding?goto=newpost</link>
			<pubDate>Tue, 23 Apr 2013 22:44:41 GMT</pubDate>
			<description>Hi, 
I have set up a few classes which basically encapsulate the dynamic cube map generation code as in the superbible, 4th ed. p 616 based on...</description>
			<content:encoded><![CDATA[<div>Hi,<br />
I have set up a few classes which basically encapsulate the dynamic cube map generation code as in the superbible, 4th ed. p 616 based on framebufferobjects. <br />
Now, I want to provide this texture(cube) to a shader for coloring a sphere. The shader code seems to be correct, because if I use static images, it looks ok.<br />
However, when I try to generate images dynamically, something goes wrong: I get (static) random images (which are currently on the gpu memory) painted onto the sphere.<br />
For painting the 6 sides of the texture-cube, I use glFramebufferTexture2D as in the book, but I am not sure what really goes wrong. <br />
How do I bind the texture-cube to the shader-variable?<br />
Currently, I use something like:<br />
glActiveTexture(GL_TEXTURE0);<br />
glBindTexture(GL_TEXTURE_CUBE_MAP, cubeMapId);<br />
setUniformValue(cubeMapTexLocation, 0);  // cubeMapTexLocation is the location of the cubeMapTex variable, a samplerCube, in the shader<br />
<br />
Is there an easy way to check the 6 images in the framebuffer after having rendered them (GL_TEXTURE_CUBE_MAP_POSITIVE_X,...?<br />
<br />
Any ideas what is wrong here?</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/15-OpenGL-Shading-Language">OpenGL Shading Language</category>
			<dc:creator>AJOM566</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181538-cube-map-shader-texture-binding</guid>
		</item>
	</channel>
</rss>
