<?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 coding: advanced</title>
		<link>http://www.opengl.org/discussion_boards/</link>
		<description>For experienced OpenGL programmers - advanced topics and discussions</description>
		<language>en</language>
		<lastBuildDate>Wed, 22 May 2013 12:30:41 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 coding: advanced</title>
			<link>http://www.opengl.org/discussion_boards/</link>
		</image>
		<item>
			<title>Problems with projective texture.</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181745-Problems-with-projective-texture?goto=newpost</link>
			<pubDate>Tue, 21 May 2013 15:12:34 GMT</pubDate>
			<description>I want to write a program with opengl to project a final rendered image to a scene, which the scene and the image has the same camera view. 
I want...</description>
			<content:encoded><![CDATA[<div>I want to write a program with opengl to project a final rendered image to a scene, which the scene and the image has the same camera view.<br />
I want to use projective texture to do it, so the opengl render effect will be realistic. <br />
Here is my seudo-code.<br />
<br />
//1.Bind texture<br />
//2.Enable GL_TEXTURE_GEN_?<br />
	GLfloat Splane[4]={1, 0, 0, 0};<br />
	GLfloat Tplane[4]={0, 1, 0, 0};<br />
	GLfloat Rplane[4]={0, 0, 0, 0};<br />
	GLfloat Qplane[4]={0, 0, 0, 1};<br />
<br />
<br />
	glTexGenfv(GL_S,GL_EYE_PLANE,Splane); <br />
	glTexGenfv(GL_T,GL_EYE_PLANE,Tplane); <br />
	glTexGenfv(GL_R,GL_EYE_PLANE,Rplane); <br />
	glTexGenfv(GL_Q,GL_EYE_PLANE,Qplane); <br />
<br />
	glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);<br />
	glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);<br />
	glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);<br />
	glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);<br />
	<br />
	glEnable(GL_TEXTURE_GEN_S);<br />
	glEnable(GL_TEXTURE_GEN_T);<br />
	glEnable(GL_TEXTURE_GEN_R);<br />
	glEnable(GL_TEXTURE_GEN_Q);<br />
//3. Set texture matrix<br />
        glMatrixMode(GL_TEXTURE);  <br />
	glLoadIdentity();   <br />
	gluPerspective();<br />
	gluLookAt();<br />
<br />
//4. Draw the scene<br />
	glMatrixMode(GL_PROJECTION);                        // Select The Projection Matrix<br />
	glLoadIdentity(); <br />
 	gluPerspective();<br />
	gluLookAt();     <br />
	glMatrixMode(GL_MODEVIEW);                        // Select The Projection Matrix<br />
	glLoadIdentity(); <br />
<br />
        DrawScene();<br />
<br />
However, the result is really wierd, the image does not cover the whole scene. I think it might due to the S, T, R, Q Plane parameter. So, how should I set the parameter.<br />
<br />
Many thanks!<br />
flex</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/7-OpenGL-coding-advanced">OpenGL coding: advanced</category>
			<dc:creator>flexwang</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181745-Problems-with-projective-texture</guid>
		</item>
		<item>
			<title>Bindless Textures + Instancing</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181744-Bindless-Textures-Instancing?goto=newpost</link>
			<pubDate>Tue, 21 May 2013 14:36:48 GMT</pubDate>
			<description>I would like to render instanced geometry with a per-instance texture. To do so, I want to create a Vertex Attrib  (that is consumed in a...</description>
			<content:encoded><![CDATA[<div>I would like to render instanced geometry with a per-instance texture. To do so, I want to create a Vertex Attrib  (that is consumed in a per-instance basis) containing the texture handler and create the sampler2D in the shader using the bindless_texture NVIDIA extension. I want to do so because the number of instances is dynamic and they are created an destroyed during runtime so I cannot allocate an statically allocated array of textureHandles as in the example in the extension specification.<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;">//Create the textures and obtain the handles
foreach instance
	glGenTextures(1, &amp;this-&gt;gpuTextureId);
	glBindTexture(GL_TEXTURE_2D, this-&gt;gpuTextureId);
&nbsp;
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ResX, ResY, 0, GL_RGBA, GL_UNSIGNED_BYTE, info); 
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);	// Linear Filtering
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);	// Linear Filtering
&nbsp;
	// Get a handle for the texture.
	this-&gt;gpuTextureHandlerId = glGetTextureHandleNV(this-&gt;gpuTextureId);
&nbsp;
	// Make the handle resident before using it.
	glMakeTextureHandleResidentNV(this-&gt;gpuTextureHandlerId);
endfor
//Pass the handle to the buffer
	#define INSTANCE_TEXTURE_LOCATION 6
&nbsp;
	glGenBuffers(1, &amp;this-&gt;instanceTextureHandlerVboId);
	glBindBuffer(this-&gt;instanceTextureHandlerVboId);
&nbsp;
	glEnableVertexAttribArray(INSTANCE_TEXTURE_LOCATION);
	glVertexAttribPointer(INSTANCE_TEXTURE_LOCATION, 1, GL_UNSIGNED_INT64_NV, GL_FALSE, sizeof(GLuint64), 0); 
	glVertexAttribDivisor(INSTANCE_TEXTURE_LOCATION, 1);
&nbsp;
	glBufferData(GL_ARRAY_BUFFER, sizeof(GLuint64) * this-&gt;numElements, instanceTextureHandle, GL_DYNAMIC_DRAW); //instanceTextureHandle contains the texture handles for all the instances.</pre></div></code><hr />
</div><br />
As for the 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;">#version 430
#extension GL_NV_bindless_texture : require
#extension GL_NV_gpu_shader5 : require 
&nbsp;
in vec2 ex_textCoord;
layout(location = 6) in  uint64_t in_textHandler;
&nbsp;
out vec4 out_Color;
&nbsp;
void main(void)
{
	sampler2D s = sampler2D(in_textHandler);
	out_Color = texture(s, ex_textCoord);
}</pre></div></code><hr />
</div>The problem is that I cannot send the 64-bit pointer to the shader. If it was a Uniform I could use &quot;glUniformHandleui64NV(location, instanceTextureHandle[i]);&quot; I use GL_UNSIGNED_INT64_NV or GL_DOUBLE in the glVertexAttribPointer without success.<br />
<br />
Can it be done?<br />
<br />
Thanks in advance.<br />
<br />
Nicolau</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/7-OpenGL-coding-advanced">OpenGL coding: advanced</category>
			<dc:creator>nsunyer</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181744-Bindless-Textures-Instancing</guid>
		</item>
		<item>
			<title>simultaneous localization and mapping with OpenGL ( 2D ) ?</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181725-simultaneous-localization-and-mapping-with-OpenGL-%28-2D-%29?goto=newpost</link>
			<pubDate>Fri, 17 May 2013 20:54:27 GMT</pubDate>
			<description><![CDATA[Hello all,  
What I'm trying to do simply is creating a virtual map by using opengl based on the concept of simultaneous localization and mapping....]]></description>
			<content:encoded><![CDATA[<div>Hello all, <br />
What I'm trying to do simply is creating a virtual map by using opengl based on the concept of simultaneous localization and mapping. I've seen some simulations by using opengl for this purpose but without further details ( Showing off ). Is there any tutorial or any source focusing on this interesting topic at least for 2D map?</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/7-OpenGL-coding-advanced">OpenGL coding: advanced</category>
			<dc:creator>CroCodile</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181725-simultaneous-localization-and-mapping-with-OpenGL-%28-2D-%29</guid>
		</item>
		<item>
			<title>screen-space reflections</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181724-screen-space-reflections?goto=newpost</link>
			<pubDate>Fri, 17 May 2013 20:29:47 GMT</pubDate>
			<description><![CDATA[hey, it's been a while since i asked here some question about implementation of something... and this is the case, cause i'm puzzled. before trying...]]></description>
			<content:encoded><![CDATA[<div>hey, it's been a while since i asked here some question about implementation of something... and this is the case, cause i'm puzzled. before trying to implement i thought it was simple: just take view direction and eye-space normal from gbuffer, calculate reflection vector and ray-march along it until depth-hit. well... that doesn't work(and i can't wrap my head around the reason why and how it should work). and i started to investigate implementations i could find on internet. the problem is there are no papers on this topic, only a couple of really dirty and confusing examples.<br />
<br />
first of all, all of them seem to transform reflection vector to clip space, but i don't quite get why. <a href="http://www.gamedev.net/blog/1323/entry-2254101-real-time-local-reflections/" target="_blank" rel="nofollow">this</a> example has comment saying it's for sampling from &quot;default hardware depthbuffer&quot;. i have no idea, what it means. other examples don't say that and do sample in regular way, but still use clip space for some reason. he also uses some weird sampling method with gradients and some paraboloid parameter. i've dropped that example at this point, cause i have no idea what's he doing and i don't wanna that in my code.<br />
<br />
here's another example: <a href="http://pastie.org/private/zofibyyegp2hlfeloxjg" target="_blank" rel="nofollow">http://pastie.org/private/zofibyyegp2hlfeloxjg</a><br />
i've tried to implement it in my code, with glsl... and here's what ive got:<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;
#version 330
uniform sampler2D colorMap;  //color
uniform sampler2D normalMap; //eye space normal &amp; linear depth
uniform sampler2D positionMap; //eye space positions
&nbsp;
uniform vec4 ratio; //ratio.x - inverse resolution
&nbsp;
//matrices from main view
uniform mat4 inverseProjectionMatrix;
uniform mat4 projectionMatrix;
&nbsp;
layout(location = 0) out vec4 outColor;
in vec2 texCoord0;
&nbsp;
const int numSamples = 128;
&nbsp;
void main(void)
{
    vec4 color = vec4(0.0);
    vec4 surfaceData = texture(normalMap, texCoord0);
    float depth = surfaceData.w;
&nbsp;
    vec3 eyeSpaceNormal = normalize(surfaceData.xyz);
    vec3 eyeSpacePosition = normalize(texture(positionMap, texCoord0).xyz);
&nbsp;
    vec4 viewDir = inverseProjectionMatrix * vec4(0.0, 0.0, 1.0, 1.0);
    viewDir /= viewDir.w;
&nbsp;
    vec4 reflectionVector = normalize(projectionMatrix * vec4(reflect(viewDir.xyz, eyeSpaceNormal), 1.0));
    float refLength = length(reflectionVector.xy);
    reflectionVector = normalize(reflectionVector)/refLength * ratio.x;
    reflectionVector.z *= depth;
&nbsp;
    vec3 currentPosition = vec3(reflectionVector.x, reflectionVector.y, depth + reflectionVector.z);
&nbsp;
    int currentSamples = 0;
    while(currentSamples &lt; numSamples) {
        float sampledDepth = texture(normalMap, texCoord0 + currentPosition.xy).w;
        float difference = currentPosition.z - sampledDepth;
        if(difference &gt; 0.0025) {
            color = texture(colorMap, texCoord0 + currentPosition.xy);
            break;
        }
        currentPosition += reflectionVector.xyz;
        currentSamples++;
    }
    outColor = vec4(color.rgb, 1.0);
}</pre></div></code><hr />
</div>at least it looks like raymarching occurs in somewhat correct direction. but i get something resembling correct reflections only under certain angles. and it also reacts to camera rotation a lot;</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/7-OpenGL-coding-advanced">OpenGL coding: advanced</category>
			<dc:creator>Nowhere-01</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181724-screen-space-reflections</guid>
		</item>
		<item>
			<title>MRT : write to a single output</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181717-MRT-write-to-a-single-output?goto=newpost</link>
			<pubDate>Thu, 16 May 2013 20:48:12 GMT</pubDate>
			<description><![CDATA[Hi, 
 
I use a FBO and MRT as following : 
 
- Texture "0" is attached to my FBO's COLOR_BUFFER_0 
- Texture "1" is attached to my FBO's...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I use a FBO and MRT as following :<br />
<br />
- Texture &quot;0&quot; is attached to my FBO's COLOR_BUFFER_0<br />
- Texture &quot;1&quot; is attached to my FBO's COLOR_BUFFER_1<br />
<br />
Then I draw a set of objects :<br />
<br />
- objects of type &quot;A&quot; need to write to Texture &quot;0&quot;<br />
- objects of type &quot;B&quot; need to write to Texture &quot;1&quot;<br />
- objects of type &quot;C&quot; need to write to Texture &quot;0&quot; and Texture &quot;1&quot;<br />
- additive blending is always enabled for both Texture &quot;0&quot; and Texture &quot;1&quot;<br />
<br />
Currently I do the output selection in &quot;A&quot;, &quot;B&quot; and &quot;C&quot; shaders :<br />
<br />
- &quot;A&quot; shader only write to &quot;gl_FragData[0]&quot;<br />
- &quot;B&quot; shader only write to &quot;gl_FragData[1]&quot;<br />
- &quot;C&quot; shader write to &quot;gl_FragData[0]&quot; and &quot;gl_FragData[1]&quot;<br />
<br />
Everything work as expected on my NVidia card, but :<br />
<br />
- do the OpenGL specification allow to do this ?<br />
- is there any drawback ? (perfomances...)<br />
<br />
<br />
Thanks.</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/7-OpenGL-coding-advanced">OpenGL coding: advanced</category>
			<dc:creator>Aurelien</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181717-MRT-write-to-a-single-output</guid>
		</item>
		<item>
			<title>Pointer alignment</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181713-Pointer-alignment?goto=newpost</link>
			<pubDate>Thu, 16 May 2013 16:14:08 GMT</pubDate>
			<description>I am sending some opengl commands over a network. Anyway when I unpack them from memory the pointers to the start of chunks of memory might not be...</description>
			<content:encoded><![CDATA[<div>I am sending some opengl commands over a network. Anyway when I unpack them from memory the pointers to the start of chunks of memory might not be DWORD aligned.<br />
<br />
For functions like<br />
glDeleteTextures which takes an array of GLints<br />
does that matter ? I know on some platforms it might be an issue but I am coding under win32</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/7-OpenGL-coding-advanced">OpenGL coding: advanced</category>
			<dc:creator>dukey</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181713-Pointer-alignment</guid>
		</item>
		<item>
			<title><![CDATA[ping-pong between two FBO's small error]]></title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181672-ping-pong-between-two-FBO-s-small-error?goto=newpost</link>
			<pubDate>Fri, 10 May 2013 20:12:37 GMT</pubDate>
			<description><![CDATA[hey, i was working on painting the terrain heightmap lately. so i used 2 fbo's, drawing a fullscreen quad with heightmap texture and a quad with a...]]></description>
			<content:encoded><![CDATA[<div>hey, i was working on painting the terrain heightmap lately. so i used 2 fbo's, drawing a fullscreen quad with heightmap texture and a quad with a brush texture in front of it while painting. mechanically it works fine, but if i use resulting texture from any of fbo's directly to draw terrain, i notice constant shivering in certain spots. so i nailed it down to fbo's content:<br />
<br />
heightBuffer[0] and heightBuffer[1] contents:<br />
<a href="http://www.opengl.org/discussion_boards/attachment.php?attachmentid=1023&amp;d=1368215933" id="attachment1023" rel="Lightbox_0" ><img src="http://www.opengl.org/discussion_boards/attachment.php?attachmentid=1023&amp;d=1368215933&amp;thumb=1" border="0" alt="Click image for larger version.&nbsp;

Name:	Nowhere-0_Editor-Context1-Texture19level0.jpg&nbsp;
Views:	19&nbsp;
Size:	2.9 KB&nbsp;
ID:	1023" class="thumbnail" style="float:CONFIG" /></a>   <a href="http://www.opengl.org/discussion_boards/attachment.php?attachmentid=1024&amp;d=1368215947" id="attachment1024" rel="Lightbox_0" ><img src="http://www.opengl.org/discussion_boards/attachment.php?attachmentid=1024&amp;d=1368215947&amp;thumb=1" border="0" alt="Click image for larger version.&nbsp;

Name:	Nowhere-0_Editor-Context1-Texture20level0.jpg&nbsp;
Views:	26&nbsp;
Size:	2.9 KB&nbsp;
ID:	1024" class="thumbnail" style="float:CONFIG" /></a> <br />
looks the same, right? but they're not.<br />
<br />
here's the multiplied difference:<br />
<a href="http://www.opengl.org/discussion_boards/attachment.php?attachmentid=1025&amp;d=1368215990" id="attachment1025" rel="Lightbox_0" ><img src="http://www.opengl.org/discussion_boards/attachment.php?attachmentid=1025&amp;d=1368215990&amp;thumb=1" border="0" alt="Click image for larger version.&nbsp;

Name:	difference.jpg&nbsp;
Views:	32&nbsp;
Size:	2.4 KB&nbsp;
ID:	1025" class="thumbnail" style="float:CONFIG" /></a><br />
<br />
so there's constant error at those spots. but i can't see the reason. at first i thought it was due to low precision(unsigned byte), so i switched framebuffer attachment type to float and changed all corresponding code, but it didn't change anything. maybe someone else here will notice mistake, here's some code(sorry for fixed pipeline, this project was before i switched to OGL 3+):<br />
<br />
ping-pong between fbo's drawing fullscreen quad and brush:<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 updateHeightMap() {
    fboManager.bind(heightEditBufferIDs&#91;Counter % 2&#93;);
    glPushMatrix();
&nbsp;
    glViewport(0, 0, 1024, 1024);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0.0f, 1024.0f, 0.0f, 1024.0f, 0.1f, 10.0f);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
&nbsp;
    glDepthMask(0);
    SShader&#91;3&#93;.applyProgram(10);
&nbsp;
    glPushMatrix();
    glTranslatef(512.0f, 512.0f, -1.0f);
    glScalef(512.0f, 512.0f, 1.0f);
&nbsp;
  //heightmap
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, fboManager&#91;heightEditBufferIDs&#91;Counter % 2 == 0&#93;&#93;.rtList&#91;0&#93;.textureObject);
    glUniform1i(SShader&#91;shaderId&#93;.shaderSet&#91;programId&#93;.uniform_colorMap, 0);
&nbsp;
    glBindVertexArray(quadVertexArrayObjectId);
    glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, 0);
    glPopMatrix();
&nbsp;
  //brush
    if(terrainEditorMode &amp;&amp; lmDown) {
        //irrelevant, currently drawing\not drawing onto heightmap doesn't affect problem
    }
&nbsp;
    glBindVertexArray(0);
&nbsp;
    glPopMatrix();
    glDepthMask(1);
    fboManager.unbind();
}</pre></div></code><hr />
</div><br />
fragment shader used to draw fullscreen quad:<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 120
uniform sampler2D colorMap;
void main(void)
{
    vec4 Color = texture2D(colorMap, gl_TexCoord&#91;0&#93;.st);
    gl_FragColor = Color;
}</pre></div></code><hr />
</div></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=1023&amp;d=1368215933" 
rel="Lightbox_1250708" id="attachment1023"
><img class="thumbnail" src="http://www.opengl.org/discussion_boards/attachment.php?attachmentid=1023&amp;stc=1&amp;thumb=1&amp;d=1368215933" 
alt="Click image for larger version.&nbsp;

Name:	Nowhere-0_Editor-Context1-Texture19level0.jpg&nbsp;
Views:	N/A&nbsp;
Size:	2.9 KB&nbsp;
ID:	1023"/></a>
&nbsp;

<a href="http://www.opengl.org/discussion_boards/attachment.php?attachmentid=1024&amp;d=1368215947" 
rel="Lightbox_1250708" id="attachment1024"
><img class="thumbnail" src="http://www.opengl.org/discussion_boards/attachment.php?attachmentid=1024&amp;stc=1&amp;thumb=1&amp;d=1368215947" 
alt="Click image for larger version.&nbsp;

Name:	Nowhere-0_Editor-Context1-Texture20level0.jpg&nbsp;
Views:	N/A&nbsp;
Size:	2.9 KB&nbsp;
ID:	1024"/></a>
&nbsp;

<a href="http://www.opengl.org/discussion_boards/attachment.php?attachmentid=1025&amp;d=1368215990" 
rel="Lightbox_1250708" id="attachment1025"
><img class="thumbnail" src="http://www.opengl.org/discussion_boards/attachment.php?attachmentid=1025&amp;stc=1&amp;thumb=1&amp;d=1368215990" 
alt="Click image for larger version.&nbsp;

Name:	difference.jpg&nbsp;
Views:	N/A&nbsp;
Size:	2.4 KB&nbsp;
ID:	1025"/></a>
&nbsp;

			</div>
		</fieldset>
	

	

	

	

	</div>
]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/7-OpenGL-coding-advanced">OpenGL coding: advanced</category>
			<dc:creator>Nowhere-01</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181672-ping-pong-between-two-FBO-s-small-error</guid>
		</item>
		<item>
			<title>Tessellation with Transform Feedback</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181664-Tessellation-with-Transform-Feedback?goto=newpost</link>
			<pubDate>Thu, 09 May 2013 19:45:09 GMT</pubDate>
			<description>Right now I want to generate a mesh with a tessellation shader and have that go into a different program/vertex/tessellation shader...  
 
I got the...</description>
			<content:encoded><![CDATA[<div>Right now I want to generate a mesh with a tessellation shader and have that go into a different program/vertex/tessellation shader... <br />
<br />
I got the mesh generating just fine with the tessellation shader, which outputs 'quads'. I'm having issues with the transform feedback aspect though so I can't even start the second pass yet...<br />
<br />
The initialization looks like:<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;">	//Transform feedback output buffer
	glGenBuffers(1, &amp;TransformFeedbackBuffer);
	glBindBuffer(GL_ARRAY_BUFFER, TransformFeedbackBuffer);
	glBufferData(GL_ARRAY_BUFFER, 4096*3*4, 0, GL_STATIC_DRAW);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, 0);
&nbsp;
	//transform feedback object
	glGenTransformFeedbacks(1, &amp;TransformFeedbackObject);
	glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, TransformFeedbackObject);	
	glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, TransformFeedbackBuffer);
	glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);</pre></div></code><hr />
</div><br />
And in the render loop:<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;">		// enable / disable wireframe
		glPolygonMode( GL_FRONT_AND_BACK, wireframe ? GL_LINE : GL_FILL);printGLError();
&nbsp;
		glEnable(GL_RASTERIZER_DISCARD);printGLError(); 
		//set up the program
		glUseProgram(program);printGLError();
&nbsp;
		glBindBufferBase( GL_UNIFORM_BUFFER , 1, ubo);printGLError();
		glBufferData(GL_UNIFORM_BUFFER, sizeof(TessellationParams), &amp;tessellationParameters, GL_STREAM_DRAW);printGLError();
&nbsp;
		GLint numfeedbackwritten;
&nbsp;
		glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, TransformFeedbackObject);printGLError();
		glBeginTransformFeedback(GL_TRIANGLES);printGLError();
		{
			glBindBuffer(GL_ARRAY_BUFFER, vbo);
			glEnableVertexAttribArray(0);
			glPatchParameteri( GL_PATCH_VERTICES, 1);
&nbsp;
			//draw a single patch
			GLuint queryObject;
			glGenQueries(1, &amp;queryObject);printGLError();
&nbsp;
			glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, queryObject);printGLError();
				glDrawArrays( GL_PATCHES, 0, 1);printGLError();
			glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);printGLError();
&nbsp;
&nbsp;
			glGetQueryObjectiv(queryObject, GL_QUERY_RESULT, &amp;numfeedbackwritten);
			printf(&quot;Tris drawn to feedback buffer: %d\n&quot;, numfeedbackwritten);
&nbsp;
			glDisableVertexAttribArray(0);
			glBindBuffer(GL_ARRAY_BUFFER, 0);
		}
		glEndTransformFeedback();printGLError();
		glDisable(GL_RASTERIZER_DISCARD);printGLError();</pre></div></code><hr />
</div><br />
The printGLError() says Invalid Operation on the glDrawArrays call... Also, I'm not sure how to render it to the screen afterwards. I think this is right? <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;">		glUseProgram(0);
		glBindBuffer(GL_ARRAY_BUFFER, TransformFeedbackBuffer);printGLError();
		glEnableVertexAttribArray(0);
&nbsp;
		GLuint queryObject2;
		glGenQueries(1, &amp;queryObject2);printGLError();
&nbsp;
		glBeginQuery(GL_PRIMITIVES_GENERATED, queryObject2);
			glDrawArrays( GL_TRIANGLES, 0, numfeedbackwritten);printGLError();
		glEndQuery(GL_PRIMITIVES_GENERATED);
&nbsp;
		glGetQueryObjectiv(queryObject2, GL_QUERY_RESULT, &amp;numfeedbackwritten);
		printf(&quot;Tris drawn to display: %d\n&quot;, numfeedbackwritten);</pre></div></code><hr />
</div><br />
But it's hard to tell since I'm getting no tris being drawn in either case. I think glDrawTransformFeedback should work too...<br />
<br />
Is this setup even possible? The feedback says it only works on points, lines and tris, and the tess shader I want to have it as a quad input (but triangle output).</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/7-OpenGL-coding-advanced">OpenGL coding: advanced</category>
			<dc:creator>stratius</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181664-Tessellation-with-Transform-Feedback</guid>
		</item>
		<item>
			<title>Backface Rendering</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181662-Backface-Rendering?goto=newpost</link>
			<pubDate>Thu, 09 May 2013 06:34:03 GMT</pubDate>
			<description>Hello, 
 
I write a Volume Renderer and want to implement Empty Space Leaping for a better performance. I have seperate my volume in several...</description>
			<content:encoded><![CDATA[<div>Hello,<br />
<br />
I write a Volume Renderer and want to implement Empty Space Leaping for a better performance. I have seperate my volume in several minivolumes where my visible parts are. Now I have many cubes and want to render the backfaces of the scene and in a second part I want to render the frontface of the scene.<br />
<br />
For rendering the frontface you have to render it like a normal scene. (DepthFunc Lequal, DepthValue 1.0, Cullface Back)<br />
<br />
My problem is when i try to render the backface, i don't get the result I want to see. My idea is to turn all the setting for frontface rendering (DepthFunc, DepthValue 0.0, Cullface Front). Is there any failure in my renderpipeline? Maybe a false order of the functions? Or is my idea for backface rendering false?<br />
<br />
What I don't understand is that when I change the DepthFunc I have no change in de result of the image. At the moment I have no pictures to demonstrate the problem, but maybe somebody can help me. I try to get some screenshots.<br />
<br />
<br />
My Renderfunction can you see here:<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;">private void RenderPass2(int tex_coordBuffer, Vector2 wh, Vector3 eyePos)
{
   GL.BindFramebuffer(FramebufferTarget.Framebuffer, p2_fboID);
   GL.DrawBuffer(DrawBufferMode.ColorAttachment0);
&nbsp;
   GL.DepthFunc(DepthFunction.Greater);
   GL.Enable(EnableCap.DepthTest);
&nbsp;
   GL.ClearDepth(0.0f);
&nbsp;
   GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
&nbsp;
   GL.ClearColor(0.0f, 1.0f, 0.0f, 1.0f);
&nbsp;
   GL.Enable(EnableCap.CullFace);
   GL.CullFace(Front);
&nbsp;
&nbsp;
   _manager.ActivateShader(p2_shaderID);
   GL.MatrixMode(MatrixMode.Modelview);
   GL.PushMatrix();
   GL.MultMatrix(_volume.transform&#91;0&#93;);
&nbsp;
   // setup texture for depth buffer
   GL.Enable(EnableCap.Texture2D);
   GL.ActiveTexture(TextureUnit.Texture0);
   GL.BindTexture(TextureTarget.Texture2D, tex_coordBuffer);
   GL.Uniform1(p2_coordBuffer, 0);
&nbsp;
   // create transform matrix for volume cs
   Vector3 x_dir = new KTC_Geometrie_Source.Vectors.Vector3(_volume.x_dir.X, _volume.x_dir.Y, _volume.x_dir.Z);
   Vector3 y_dir = new KTC_Geometrie_Source.Vectors.Vector3(_volume.y_dir.X, _volume.y_dir.Y, _volume.y_dir.Z);
   Vector3 z_dir = new KTC_Geometrie_Source.Vectors.Vector3(_volume.z_dir.X, _volume.z_dir.Y, _volume.z_dir.Z);
   Vector3 origin = new KTC_Geometrie_Source.Vectors.Vector3(_volume.origin.X, _volume.origin.Y, _volume.origin.Z);
&nbsp;
   Matrix4X4 m = Matrix4X4.ChangeKS(x_dir, y_dir, z_dir, origin);
&nbsp;
   Matrix4 transform = new Matrix4(1.0f / m.A11, m.A12, m.A13, m.A14,
                                              m.A21, 1.0f / m.A22, m.A23, m.A24,
                                              m.A31, m.A32, 1.0f / m.A33, m.A34,
                                              m.A41, m.A42, m.A43, m.A44);
&nbsp;
    Vector4 eye = Vector4.Transform(new Vector4(eyePos), transform);
&nbsp;
    GL.Uniform4(p2_camPos, eye);
    GL.Uniform2(p2_wh, wh);
    GL.UniformMatrix4(p2_changeCS, false, ref transform);
&nbsp;
    GL.BindBuffer(BufferTarget.ArrayBuffer, DEBUG_verticeID);
    GL.BindBuffer(BufferTarget.ElementArrayBuffer, DEBUG_indiceID);
&nbsp;
    GL.EnableVertexAttribArray(p2_inVertex);
    GL.VertexAttribPointer(p2_inVertex, 3, VertexAttribPointerType.Float, false, 0, IntPtr.Zero);
    GL.DrawElements(BeginMode.Quads, DEBUG_COUNT, DrawElementsType.UnsignedInt, IntPtr.Zero);
&nbsp;
    GL.DisableVertexAttribArray(p2_inVertex);
    GL.PopMatrix();
    _manager.DeactivateShader();
&nbsp;
    GL.Disable(EnableCap.Texture2D);
    GL.Disable(EnableCap.DepthTest);
    GL.Disable(EnableCap.CullFace);
&nbsp;
    GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
}</pre></div></code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/7-OpenGL-coding-advanced">OpenGL coding: advanced</category>
			<dc:creator>miujin</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181662-Backface-Rendering</guid>
		</item>
		<item>
			<title>Loading Texture - Taoframework.</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181648-Loading-Texture-Taoframework?goto=newpost</link>
			<pubDate>Wed, 08 May 2013 12:11:18 GMT</pubDate>
			<description><![CDATA[Hey all. I've been searching for hours on how to load an image and apply a texture to my particles with no resolve. 
The following is my code which...]]></description>
			<content:encoded><![CDATA[<div>Hey all. I've been searching for hours on how to load an image and apply a texture to my particles with no resolve.<br />
The following is my code which runs, but nothing appears on the screen. When I remove the texture code, the particles<br />
do what they're supposed to do, but they're still simple GlPoints...<br />
Any pointers will be appreciated.<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;">private static int&#91;&#93; index;
        private static int width;
        private static int height;
&nbsp;
        /// &lt;summary&gt;
        ///  TEXTURE CODE
        /// &lt;/summary&gt;
&nbsp;
&nbsp;
        &#91;EnvironmentPermissionAttribute(SecurityAction.LinkDemand, Unrestricted = true)&#93;//For codeanalyst
        public static void Texture()
        {
            index = new int&#91;1&#93;;
            Gl.glGenTextures(1, index);
            //LoadTexture(path);
        }
&nbsp;
        &#91;EnvironmentPermissionAttribute(SecurityAction.LinkDemand, Unrestricted = true)&#93;//For codeanalyst
        public static  void LoadTexture(string path)
        {
            Bitmap image;
&nbsp;
            try
            {
                image = new Bitmap(path);
&nbsp;
                image.RotateFlip(RotateFlipType.RotateNoneFlipY);
                Rectangle rect = new Rectangle(0, 0, image.Width, image.Height);
                height = image.Height;
                width = image.Width;
                BitmapData bitmapdata = image.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
&nbsp;
                Gl.glEnable(Gl.GL_TEXTURE_2D);									// Enable 2D Texture Mapping
               // Gl.glDisable(Gl.GL_DEPTH_TEST);									// Disable Depth Testing
                Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE);							// Set Blending Mode
                Gl.glEnable(Gl.GL_BLEND);	
                Gl.glEnable(Gl.GL_TEXTURE_GEN_S); //enable texture coordinate generation
                Gl.glEnable(Gl.GL_TEXTURE_GEN_T);
&nbsp;
                Gl.glBindTexture(Gl.GL_TEXTURE_2D, index&#91;0&#93;);
                Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA, image.Width, image.Height,
                                0, Gl.GL_BGRA, Gl.GL_UNSIGNED_BYTE, bitmapdata.Scan0);
                Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR);
                Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);
                Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_CLAMP);
                Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_CLAMP);
                image.UnlockBits(bitmapdata);
                image.Dispose();
            }
            catch (ArgumentException)
            {
                Environment.Exit(0);
            }
        }
&nbsp;
        public static void Activate()
        {
            Gl.glBindTexture(Gl.GL_TEXTURE_2D, index&#91;0&#93;);
        }
&nbsp;
        public int GetWidth
        {
            get { return width; }
        }
&nbsp;
        public int GetHeight
        {
            get { return height; }
        }
&nbsp;
        /////END OF TEXTURE CODE
&nbsp;
&nbsp;
        public static void DisplayRainSystem()
        {
&nbsp;
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);
            Texture();
            LoadTexture(&quot;particle.bmp&quot;);
            Activate();
&nbsp;
            float spost = 0.0f;											// Starting Texture Coordinate Offset
            float alphainc = 0.9f / 2;								// Fade Speed For Alpha Blending
            float alpha = 0.2f;											// Starting Alpha Value
&nbsp;
            Gl.glPointSize(2.5f);
&nbsp;
            int RandomColour = R.Next(4) + 1;
            if (RandomColour == 1) Gl.glColor3f(0.0f, 0.0f, 1.0f);
            if (RandomColour == 2) Gl.glColor3f(0.0f, 0.1f, 1.0f);
            if (RandomColour == 3) Gl.glColor3f(0.0f, 0.2f, 1.0f);
            if (RandomColour == 4) Gl.glColor3f(0.0f, 0.5f, 1.0f);
            if (RandomColour == 5) Gl.glColor3f(0.0f, 0.8f, 1.0f);
&nbsp;
            Gl.glBegin(Gl.GL_POINTS);
&nbsp;
            for (int i = 0; i &lt;= RS.RainParticles.Count - 1; i++)
            {
                RainParticle RP = (RainParticle)RS.RainParticles&#91;i&#93;;
                Gl.glVertex2d(RP.xpos, RP.ypos);
            }
&nbsp;
            Gl.glFlush();
            Gl.glEnd();    
&nbsp;
        }</pre></div></code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/7-OpenGL-coding-advanced">OpenGL coding: advanced</category>
			<dc:creator>intenseza</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181648-Loading-Texture-Taoframework</guid>
		</item>
		<item>
			<title>Strategies for optimizing OpenGL-based animated/zoomable 2D UI rendering</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181645-Strategies-for-optimizing-OpenGL-based-animated-zoomable-2D-UI-rendering?goto=newpost</link>
			<pubDate>Wed, 08 May 2013 02:34:39 GMT</pubDate>
			<description><![CDATA[Hey! I'm trying to improve the graphics performance of my app (http://audulus.com if you're curious). Here's a screen shot: 
 
Image:...]]></description>
			<content:encoded><![CDATA[<div><div style="text-align: left;">Hey! I'm trying to improve the graphics performance of my app (<a href="http://audulus.com" target="_blank" rel="nofollow">http://audulus.com</a> if you're curious). Here's a screen shot:<br />
<br />
<img src="https://dl.dropboxusercontent.com/u/45540223/Audulus/Welcome.png" border="0" alt="" /><br />
<br />
I've built a scene graph to represent the 2D UI. The UI is mostly procedural (few pre-rendered images) and a lot of it is animated. I'm wondering if folks around here have some advice on optimization strategies for this kind of thing. More info over on Stackoverflow:</div><br />
<a href="http://stackoverflow.com/questions/16379701/strategies-for-optimizing-opengl-based-animated-zoomable-2d-ui-rendering" target="_blank" rel="nofollow">http://stackoverflow.com/questions/1...d-ui-rendering</a><br />
<br />
<div style="text-align: left;">Many thanks!<br />
- Taylor</div></div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/7-OpenGL-coding-advanced">OpenGL coding: advanced</category>
			<dc:creator>Taylor Holliday</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181645-Strategies-for-optimizing-OpenGL-based-animated-zoomable-2D-UI-rendering</guid>
		</item>
		<item>
			<title>Individual Textur Projection</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181609-Individual-Textur-Projection?goto=newpost</link>
			<pubDate>Thu, 02 May 2013 11:47:11 GMT</pubDate>
			<description>Hey Guys, 
i try to make it short: 
 
- got a texture on zylinder 
- have a projection along a path 
- want to project the textur to an object at the...</description>
			<content:encoded><![CDATA[<div>Hey Guys,<br />
i try to make it short:<br />
<br />
- got a texture on zylinder<br />
- have a projection along a path<br />
- want to project the textur to an object at the end of the path (own projection, no parallel or anything else)<br />
<br />
any ideas how i could do this, i have no clue right now...^^</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/7-OpenGL-coding-advanced">OpenGL coding: advanced</category>
			<dc:creator>CapoDaster</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181609-Individual-Textur-Projection</guid>
		</item>
		<item>
			<title>FBO and glTexImage2D</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181591-FBO-and-glTexImage2D?goto=newpost</link>
			<pubDate>Wed, 01 May 2013 05:23:24 GMT</pubDate>
			<description>Hi all, 
 
I have a question about the relation of Frame Buffer Object and texture linking with it. 
 
After using the function...</description>
			<content:encoded><![CDATA[<div>Hi all,<br />
<br />
I have a question about the relation of Frame Buffer Object and texture linking with it.<br />
<br />
After using the function glFramebufferTexture2D, we will link a FBO and a texture together.<br />
<br />
Does it mean that if we use function glTexImage2D and put the final parameter zero, the pointer of context(color buffer etc....) will be used by this texture ?<br />
<br />
So when I modify the color buffer(ex. clear the color buffer by red) will cause the variation of bind texture?<br />
<br />
Thanks.</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/7-OpenGL-coding-advanced">OpenGL coding: advanced</category>
			<dc:creator>LaLaChen</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181591-FBO-and-glTexImage2D</guid>
		</item>
		<item>
			<title>VSM Shadows inverted falloff</title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181589-VSM-Shadows-inverted-falloff?goto=newpost</link>
			<pubDate>Tue, 30 Apr 2013 21:56:38 GMT</pubDate>
			<description>Hi, 
 
I am trying to implement VSM Shadow Maps with OpenGL 3.3.  
Everything worked fine so far but now I have the same problem as OniDaito who...</description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I am trying to implement VSM Shadow Maps with OpenGL 3.3. <br />
Everything worked fine so far but now I have the same problem as OniDaito who created this thread in 2011:  <a href="http://www.opengl.org/discussion_boards/showthread.php/174233-VSM-Shadows-Falloff-inverted" target="_blank">http://www.opengl.org/discussion_boa...lloff-inverted</a><br />
<br />
My VSM code is based on this tutorial (<a href="http://fabiensanglard.net/shadowmappingVSM/index.php" target="_blank" rel="nofollow">fabiensanglard.net/shadowmappingVSM/index.php</a>) and it's basically plain VSM with a Gussian blur applied to it.<br />
<br />
Fragment Shader:<br />
<a href="http://pastebin.com/TgbZFcCf" target="_blank" rel="nofollow">pastebin.com/TgbZFcCf</a><br />
<br />
If I use &quot;return max(p_max, 0.4);&quot; in chebyshevUpperBound(), I get this result:<br />
<a href="http://s24.postimg.org/93zm0skpx/image.jpg" target="_blank" rel="nofollow">s24.postimg.org/93zm0skpx/image.jpg</a><br />
<br />
If i use &quot;return max(1.0 - p_max, 0.0);&quot;, this result: (proposed in the above mentioned thread from 2011)<br />
<a href="http://s21.postimg.org/9o7ahhux3/image.jpg" target="_blank" rel="nofollow">s21.postimg.org/9o7ahhux3/image.jpg</a><br />
<br />
The first one looks pretty good but the gradient/falloff is inverted. (The shadow is bright close to the object and dark farther away)<br />
<br />
Has anyone an idea on how to fix this?<br />
Thanks.<br />
<br />
<b>PS: I am sorry for not using [IMG] and [CODE]. The forum complained always about &quot;too many URL's and forbidden words&quot;. Probably a mod can fix this when he sees it. :)</b></div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/7-OpenGL-coding-advanced">OpenGL coding: advanced</category>
			<dc:creator>fruel05</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181589-VSM-Shadows-inverted-falloff</guid>
		</item>
		<item>
			<title><![CDATA[VAO/VBO indices [re]ordering]]></title>
			<link>http://www.opengl.org/discussion_boards/showthread.php/181573-VAO-VBO-indices-re-ordering?goto=newpost</link>
			<pubDate>Sun, 28 Apr 2013 06:52:00 GMT</pubDate>
			<description><![CDATA[Hi, 
 
I begin to play a little with "advanced" things like Vertex Buffer Objects, normal/light/shadow mappings and others instancing or render to...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I begin to play a little with &quot;advanced&quot; things like Vertex Buffer Objects, normal/light/shadow mappings and others instancing or render to texture methods<br />
<br />
I have founded a tutorial repository at <a href="http://www.opengl-tutorial.org/" target="_blank" rel="nofollow">http://www.opengl-tutorial.org/</a> that have tutorials for them and found on them a function indexVBO() on the common/vboindexer.cpp file that have given my interrest<br />
<br />
This fonction translate vertices, textures, normals coordinates and &quot;multi-indexed&quot; triangles as founded into .OBJ files into a VBO that contain a common array of vertices / textures / normals  that is make for that to can be directly used by a index array that contain a list of &quot;optimised&quot; indices to use for to render in OpenGL the object stored into this .obj file<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;">// Returns true iif v1 can be considered equal to v2 
bool is_near(float v1, float v2){ 
    return fabs( v1-v2 ) &lt; 0.01f; 
} 
&nbsp;
// Searches through all already-exported vertices 
// for a similar one. 
// Similar = same position + same UVs + same normal 
bool getSimilarVertexIndex(  
    glm::vec3 &amp; in_vertex,  
    glm::vec2 &amp; in_uv,  
    glm::vec3 &amp; in_normal,  
    std::vector&lt;glm::vec3&gt; &amp; out_vertices, 
    std::vector&lt;glm::vec2&gt; &amp; out_uvs, 
    std::vector&lt;glm::vec3&gt; &amp; out_normals, 
    unsigned short &amp; result 
){ 
    // Lame linear search 
    for ( unsigned int i=0; i&lt;out_vertices.size(); i++ ){ 
        if ( 
            is_near( in_vertex.x , out_vertices&#91;i&#93;.x ) &amp;&amp; 
            is_near( in_vertex.y , out_vertices&#91;i&#93;.y ) &amp;&amp; 
            is_near( in_vertex.z , out_vertices&#91;i&#93;.z ) &amp;&amp; 
            is_near( in_uv.x     , out_uvs     &#91;i&#93;.x ) &amp;&amp; 
            is_near( in_uv.y     , out_uvs     &#91;i&#93;.y ) &amp;&amp; 
            is_near( in_normal.x , out_normals &#91;i&#93;.x ) &amp;&amp; 
            is_near( in_normal.y , out_normals &#91;i&#93;.y ) &amp;&amp; 
            is_near( in_normal.z , out_normals &#91;i&#93;.z ) 
        ){ 
            result = i; 
            return true; 
        } 
    } 
    // No other vertex could be used instead. 
    // Looks like we'll have to add it to the VBO. 
    return false; 
} 
&nbsp;
void indexVBO_slow( 
    std::vector&lt;glm::vec3&gt; &amp; in_vertices, 
    std::vector&lt;glm::vec2&gt; &amp; in_uvs, 
    std::vector&lt;glm::vec3&gt; &amp; in_normals, 
&nbsp;
    std::vector&lt;unsigned short&gt; &amp; out_indices, 
    std::vector&lt;glm::vec3&gt; &amp; out_vertices, 
    std::vector&lt;glm::vec2&gt; &amp; out_uvs, 
    std::vector&lt;glm::vec3&gt; &amp; out_normals 
){ 
    // For each input vertex 
    for ( unsigned int i=0; i&lt;in_vertices.size(); i++ ){ 
&nbsp;
        // Try to find a similar vertex in out_XXXX 
        unsigned short index; 
        bool found = getSimilarVertexIndex(in_vertices&#91;i&#93;, in_uvs&#91;i&#93;, in_normals&#91;i&#93;,     out_vertices, out_uvs, out_normals, index); 
&nbsp;
        if ( found ){ // A similar vertex is already in the VBO, use it instead ! 
            out_indices.push_back( index ); 
        }else{ // If not, it needs to be added in the output data. 
            out_vertices.push_back( in_vertices&#91;i&#93;); 
            out_uvs     .push_back( in_uvs&#91;i&#93;); 
            out_normals .push_back( in_normals&#91;i&#93;); 
            out_indices .push_back( (unsigned short)out_vertices.size() - 1 ); 
        } 
    } 
}</pre></div></code><hr />
</div>(the fast version is identical but use a std::map and his iterator for to more speedly found the SimilarVertexIndex)<br />
<br />
<br />
This remember me a discussion about a method for to optimally organize vertices/textures/normals/colors coordinates into vertex arrays and  that using separate indices for each set of vertices, textures, normals and colors coordinates isn't a good thing because of the method used for the vertex caching into the GPU<br />
<br />
But have the order on which the &quot;desindexed before but reindexed after&quot; final indices are generated can have a big impact on performance ?<br />
<br />
I think that yes because for example one triangle can use the first vertice, one the middle and the last vertice generated, so the GPU cache is certainly very too small for to can cache alls differents vertices used by a big and/or detailled object :(<br />
<br />
Can we ask the size of the vertices cache of the used GPU  on OpenGL ?<br />
<br />
If not, what are the miminal and maximal sizes of vertex caches that we find on various GPU cards ?</div>

]]></content:encoded>
			<category domain="http://www.opengl.org/discussion_boards/forumdisplay.php/7-OpenGL-coding-advanced">OpenGL coding: advanced</category>
			<dc:creator>The Little Body</dc:creator>
			<guid isPermaLink="true">http://www.opengl.org/discussion_boards/showthread.php/181573-VAO-VBO-indices-re-ordering</guid>
		</item>
	</channel>
</rss>
