Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GLSL texture lookups in shader builder



It is in the GLSL language specs (though it is not likely as clear as it should be), the Orange Book (though it has a number of errors) likely has a better discussion and some examples.

Actually the best dsescription is issue 25 of the shader objects spec <http://oss.sgi.com/projects/ogl-sample/registry/ARB/shader_objects.txt>

   25) How are samplers used to access textures?

DISCUSSION: Samplers are special uniforms used in the OpenGL Shading
Language to identify the texture object used for each texture lookup.
The value of a sampler indicates the texture image unit being accessed.
The type of the sampler identifies the target on that texture image
unit. The texture object bound to that texture image unit's target is
then used for the texture lookup. For example, a variable of type
sampler2D selects target TEXTURE_2D on its texture image unit. Binding
of texture objects to targets is done as usual with BindTexture.
Selecting the texture image unit to bind is done as usual with
ActiveTexture.


The location of a sampler needs to be queried with
GetUniformLocationARB, just like any uniform variable, and its value
needs to be set by calling Uniform1i{v}ARB.


In the future, sampler types might allow for binding a texture object
directly, instead of binding to a texture image unit first, to get to a
texture object.

Geoff Stahl 3D Software Engineer Apple

On May 30, 2005, at 8:48 PM, tobias ford wrote:

Thanks!  That was all that I needed.  Where was this documented?

Also, Shader Builder actually crashes a lot for me when using the software renderer. Is this standard or just me and my powerbook?

-------------------
Tobias Ford...
tobias1482 'at' mac.com
tford 'at' soe.sony.com
-------------------
Programmer @ SOE Austin for Star Wars Galaxies

On May 30, 2005, at 6:48 PM, Keith Bauer wrote:


To the best of my knowledge the program below should pass through the second unit texture, but It's always using the first texture.

uniform sampler2D texture0;
uniform sampler2D texture1;



See the list of uniforms on the right? See texture0 and texture1 in there? The values of their X components determine which texture units they're bound to. Set texture0's X to 0 and texture1's X to 1 to get the effect the names suggest, but there are other possibilities too ;)


-Keith






_______________________________________________ Do not post admin requests to the list. They will be ignored. Mac-opengl mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/mac-opengl/email@hidden

This email sent to email@hidden
References: 
 >Re: Motion Blur at 30 fps (From: Lorenzo Puleo <email@hidden>)
 >GLSL texture lookups in shader builder (From: tobias ford <email@hidden>)
 >Re: GLSL texture lookups in shader builder (From: Geoff Stahl <email@hidden>)
 >Re: GLSL texture lookups in shader builder (From: tobias ford <email@hidden>)
 >Re: GLSL texture lookups in shader builder (From: Keith Bauer <email@hidden>)
 >Re: GLSL texture lookups in shader builder (From: tobias ford <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.