!!ATIfs1.0
StartOutputPass;
SampleMap r0, t0.str; # Dirt
SampleMap r1, t1.str; # Grass
SampleMap r2, t2.str; # Rock
SampleMap r3, t3.str; # Snow
SampleMap r4, t4.str; # Blend Map
MUL r0, r4.r, r0;
MAD r0, r4.g, r1, r0;
MAD r0, r4.b, r2, r0;
MAD r0, r4.a, r3, r0;
EndPass;
Thanks for all the help
fragment program help needed
I am using this to do my fragment program with ati_text_fragment_shader and would like to transfer it into arb_fragment_shader and can''t seem to get the same resluts?
hmmm do you mean GLSL or ARB_fragment_program ?
Either way, i'll bite coz i'm bored
In THEORY thats how it can be done in GLSL, note the use of Texture3D, thats simply because you appear to be using 3D textures (lookup against str in the code above) however that could just be me not understanding the code, in which case replace texture3D with texture2D and drop the 'p' from the texcoord part (p being GLSL's r).
Let me know if it works or not, its my first bit of code, hehe
edit: changed glsl code to 2D version base on comments below
[Phantom Web | OpenGL Window Framework ]
"i wonder why i do that... type words which are nuffin like the word i wanted every now and badger"
[edited by - _the_phantom_ on May 26, 2004 12:44:40 AM]
Either way, i'll bite coz i'm bored
// Vertex programvoid main(void){ gl_TexCoord[0] = glMultiTexCoord0; // dirt gl_TexCoord[1] = glMultiTexCoord1; // grass gl_TexCoord[2] = glMultiTexCoord2; // rock gl_TexCoord[3] = glMultiTexCoord3; // snow gl_TexCoord[4] = glMultiTexCoord4; // blendmap gl_Position = fTransform();}// fragment programuniform sampler2D dirttexture;uniform sampler2D grasstexture;uniform sampler2D rocktexture;uniform sampler2D snowtexture;uniform sampler2D blendmap;void main(void){ vec4 bmap = texture2D(blendmap, gl_TexCoord[4]); vec4 dirt = texture2D(dirttexture, gl_TexCoord[0])*bmap.r; dirt += texture2D(grasstexture, gl_TexCoord[1])*bmap.g; dirt += texture2D(rocktexture, gl_TexCoord[2])*bmap.b; dirt += texture2D(snowtexture, gl_TexCoord[3])*bmap.a; glFragColor = dirt;}
In THEORY thats how it can be done in GLSL, note the use of Texture3D, thats simply because you appear to be using 3D textures (lookup against str in the code above) however that could just be me not understanding the code, in which case replace texture3D with texture2D and drop the 'p' from the texcoord part (p being GLSL's r).
Let me know if it works or not, its my first bit of code, hehe
edit: changed glsl code to 2D version base on comments below
[Phantom Web | OpenGL Window Framework ]
"i wonder why i do that... type words which are nuffin like the word i wanted every now and badger"
[edited by - _the_phantom_ on May 26, 2004 12:44:40 AM]
quote:Original post by _the_phantom_
hmmm do you mean GLSL or ARB_fragment_program ?
Either way, i''ll bite coz i''m bored
// Vertex programvoid main(void){ gl_TexCoord[0] = glMultiTexCoord0; // dirt gl_TexCoord[1] = glMultiTexCoord1; // grass gl_TexCoord[2] = glMultiTexCoord2; // rock gl_TexCoord[3] = glMultiTexCoord3; // snow gl_TexCoord[4] = glMultiTexCoord4; // blendmap gl_Position = fTransform();}// fragment programuniform sampler2D dirttexture;uniform sampler2D grasstexture;uniform sampler2D rocktexture;uniform sampler2D snowtexture;uniform sampler2D blendmap;void main(void){ vec4 bmap = texture3D(blendmap, gl_TexCoord[4].stp); vec4 dirt = texture3D(dirttexture, gl_TexCoord[0].stp)*bmap.r; dirt += texture3D(grasstexture, gl_TexCoord[1].stp)*bmap.g; dirt += texture3D(rocktexture, gl_TexCoord[2].stp)*bmap.b; dirt += texture3D(snowtexture, gl_TexCoord[3].stp)*bmap.a; glFragColor = dirt;}
In THEORY thats how it can be done in GLSL, note the use of Texture3D, thats simply because you appear to be using 3D textures (lookup against str in the code above) however that could just be me not understanding the code, in which case replace texture3D with texture2D and drop the ''p'' from the texcoord part (p being GLSL''s r).
Let me know if it works or not, its my first bit of code, hehe
[Phantom Web | OpenGL Window Framework ]
"i wonder why i do that... type words which are nuffin like the word i wanted every now and badger"
ARB_fragment_program is what I am using. I want to blend 4 textures using a 5th as a blendmap. Hope that clears up any confusion? Thanks
heh, bitching, still, i''ll have to give that GLSL stuff a try sometime
right... arb_fragment_shader... tbh, from a quick look at the spec this should be dead easy...
Again, this looks right in theory, god knows how it performs (havent taken issues of co-issuing, temp varible useage etc into account) or if it even works, but based on what you''ve given it looks sane.
(again, not understanding the str stuff in the orignal code, however based on your later comments i''m guessing things are infact 2D textures)
right... arb_fragment_shader... tbh, from a quick look at the spec this should be dead easy...
!!ARBfp1.0OUTPUT fragColor = result.color;TEMP blendmap, temp, col;#fetch the blendmap;TXP blendmap, fragment.texcoord[4], texture[4], 2D;TXP temp, fragment.texcoord[0], texture[0], 2D;MUL col, blendmap.r, temp;TXP temp, fragment.texcoord[1], texture[1], 2D;MAD col, blendmap.g, temp, col;TXP temp, fragment.texcoord[2], texture[2], 2D;MAD col, blendmap.b, temp, col;TXP temp, fragment.texcoord[3], texture[3], 2D;MAD fragColor, blendmap.a, temp, col;
Again, this looks right in theory, god knows how it performs (havent taken issues of co-issuing, temp varible useage etc into account) or if it even works, but based on what you''ve given it looks sane.
(again, not understanding the str stuff in the orignal code, however based on your later comments i''m guessing things are infact 2D textures)
well, it was mostly a guess
how do you mean ''isnt working'' ?
screen shots?
any error infomation?
how do you mean ''isnt working'' ?
screen shots?
any error infomation?
Sorry about the double post, I deleted but anyway. My final texture is all washed out white? Here the fragment code now that I am using
Is my blendmap wrong? Something about all rgba = 4? Not sure how 4 is suppose to work when I am using 8bit values of 0-255 in a .tga format?
!!ARBfp1.0PARAM const = {.25, .25, .25, .25};TEMP blendmap, temp, col;TXP blendmap, fragment.texcoord[4], texture[4], 2D;MUL blendmap, blendmap, const;TXP temp, fragment.texcoord[0], texture[0], 2D;MUL col, blendmap.r, temp;TXP temp, fragment.texcoord[1], texture[1], 2D;MAD col, blendmap.g, temp, col;TXP temp, fragment.texcoord[2], texture[2], 2D;MAD col, blendmap.b, temp, col;TXP temp, fragment.texcoord[3], texture[3], 2D;MAD result.color, blendmap.a, temp, col;END
Is my blendmap wrong? Something about all rgba = 4? Not sure how 4 is suppose to work when I am using 8bit values of 0-255 in a .tga format?
quote:Original post by MARS_999
Is my blendmap wrong? Something about all rgba = 4? Not sure how 4 is suppose to work when I am using 8bit values of 0-255 in a .tga format?
No idea if your blend map is wrong or not.
What do you mean by ''all rgba=4''?
By the sounds of it you are either getting color satuation OR your textures arent bound properly.
You could debug it by just firstly using code to texture the using one texture, then try adding the grabbing of the blendmap texel, then try adding the MUL instruction, then add a 2nd texture to the mix and so on until it doesnt work, then you''ll know rougthly where the problem is
ah it works? Very odd indeed. But all that matters is it works now. What I was referring to on the RGBA = 4 is all channels or one of the channels must be equal to 255 or 1. You can''t have 255,255,255,255 or 255,1,0,0 no dice....
thanks phantom
thanks phantom
what was the problem in the end then?
Just so I/others know for future reference...
and no problem, happy I could help
Just so I/others know for future reference...
and no problem, happy I could help
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement