>> It only displays the center because the GLSL Grid's size is too big -- it
>> should be 2 wide at most, and it looks to be 3 and a fraction. The Width
>> and Height inputs control this, so you can see which patches control this
>> (Image Dimensions, I think)
>
> But isn't that the sort of thing that Image Dimensions is supposed to be for?
> Even when I set it to 1 or 2 manually, the center cut behavior does not
> change.
I haven't looked closer, but if the grid is less than 2 across and AspectRatio
high, it should fit on screen unless something else is changing it (perhaps its
set closer to the camera or something?)
>> Render In Image probably needs a clear patch. If that doesn't help, please
>> post a sample composition that shows the problem you're encountering.
>
> Well, when I add a clear patch, if I enable it, it goes black, if I then
> disable it, things are fine. Until I change something like the input image,
> etc... then I need to manually clear it to black, then disable it.
it went black because the clear patch was layer 2 -- set it to 1 (so it clears
first, then draws other stuff) and you should be good to go. The layer number
is the number in the corner of the patch.
>> Also, the fragment doesn't go to the vertex - it's the other way around:
>> Vertex Shaders operate on the vertices supplied (possibly changing them, and
>> setting up data for the fragment shader), and then the fragment shader runs
>> for each pixel defined by the (possibly changed) vertices. There are
>> typically many many more fragments ("pixels", but not always) than there are
>> vertices, so vertex-shader-supplied data is interpolated across the
>> fragments by the GPU. You happened to want data interpolated in that
>> manner, which made it pretty simple. :)
>
> Okay, but how does this Vertex:
>
> varying vec4 pixelColor;
> uniform sampler2DRect texture;
>
> void main()
> {
> //Transform vertex by modelview and projection matrices
> gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
>
> //Forward current color and texture coordinates after applying texture
> matrix
> gl_FrontColor = gl_Color;
> gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
>
> pixelColor = texture2DRect(texture, gl_TexCoord[0].xy);
> }
>
> and this Fragment:
>
> varying vec4 pixelColor;
>
> void main()
> {
> //Multiply color by texture
> gl_FragColor = gl_Color * pixelColor;
> }
>
> Specify to interpolate the pixel values found at the vertices of the
> triangles? I understand that GLSL Grid is determining the size of the
> triangles. I just don't get how it's only sampling the corner points and
> providing an interpolation between them as the values for the intermediate
> pixels.
It's implied by the "varying" -- the varying is defined 3 times per triangle
(once per vertex), and the gpu will interpolate its value when a pixel is
rendered that falls between the three corners of the triangle. when I said
"it's free", I meant that quite literally -- the gpu does this _automatically_
for varyings and per-vertex builtins (like the normal, or gl_Color).
In fact, the above could be even simpler:
pixelColor can go away, and the vertex shader can set gl_FrontColor to glColor
* texture2DRect(texture, gl_TexCoord[0].xy). Then the fragment shader is
simply "gl_FragColor = gl_Color;". no per-pixel math at all.
The way GL works is that you specify vertices (the triangle corners), and
various attributes at those vertices (colors, normals, texture coordinates,
whatever), and the pixels in the middle get in-the-middle values automatically.
It's just part of the contract that when you specify those per-vertex, the
fragment shader gets interpolated values as it walks across the triangle. You
don't need to ask it to do that, because that's what it's built to do
automatically. (very anticlimactic, I know)
--
Christopher Wright
[email protected]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com
This email sent to [email protected]