Pete´s Messageboard... No ISO/BIOS requests!

Homepage Members Register Login Search Old board


Neuer Thread ...
More : [1] [2] [3]


AuthorTopics » Book an abo for this threadClose Thread Move Thread Fix the thread Print view Delete this thread

<ShadX>
unregistried

...   Created on 04.11.2004 - 13:16Jump to top Quote this post Report this post Edit Delete


Hi Pete.
I have some questions about your vertex/fragment programs with GLSL.
I don't know why you use more then one texture unit for filtering when only one is required,
and i don't know why you use vertex and fragment programs together when only fragment program is required.
Anyway i can give you a fragment program example:

uniform vec4 OGL2Size;
uniform sampler2D OGL2Texture;

void main()
{
float offsetx = 1.0 / OGL2Size.x;
float offsety = 1.0 / OGL2Size.y;

vec2 TCoord = gl_TexCoord[0].xy;

vec4 c = texture2D(OGL2Texture, TCoord); //center
vec4 bl = texture2D(OGL2Texture, TCoord + vec2(-offsetx,-offsety)); //bottom-left
vec4 l = texture2D(OGL2Texture, TCoord + vec2(-offsetx, 0.0)); //left
vec4 tl = texture2D(OGL2Texture, TCoord + vec2(-offsetx, offsety)); //top-left
vec4 t = texture2D(OGL2Texture, TCoord + vec2( 0.0, offsety)); //top
vec4 ur = texture2D(OGL2Texture, TCoord + vec2( offsetx, offsety)); //upper-right
vec4 r = texture2D(OGL2Texture, TCoord + vec2( offsetx, 0.0)); //right
vec4 br = texture2D(OGL2Texture, TCoord + vec2( offsetx, offsety)); //bottom-right
vec4 b = texture2D(OGL2Texture, TCoord + vec2( 0.0,-offsety)); //bottom

gl_FragColor = 8.0 * (c + -0.125 * (bl + l + tl + t + ur + r + br + b));
}

This fragment program was derived from "helloGPGPU_GLSL.cpp" v1.0.2 by Mike Weiblen:

sourceforge.net/project/showfiles.php?group_id=104004&package_id=117303&release_id=245080

It demonstrates a simple post-process edge detection filter but you can use whatever you want.
Some example:

Simple blur filter
gl_FragColor = 0.5 * c + 0.0625 * (l + t + r + b + bl + tl + ur + br)

Gaussian blur filter
gl_FragColor = 0.25 * c + 0.125 * (l + t + r + b) + 0.0625 * (bl + tl + ur + br)

Emboss filter (very funny bump mapping emulation)
gl_FragColor = 0.5 * (c + r + b) + -0.5 * (l + t) + br - tl

Sharpen filter
gl_FragColor = c - (bl + l + tl + t + ur + r + br + b)

bye




guest ...
Real addict
.........

...

Status:Offline
Date registered: 30.07.2004
Post:856
Send Message
...   Created on 04.11.2004 - 15:01Jump to top Quote this post Report this post Edit Delete


Something similar about using less texturing units was figured out on this forum too, but this is a even better solution.

Nevertheless it is still a long way too implement a nice! 2D scaler(like Super2xSaI) via glSlang.

[Dieser Beitrag wurde am 04.11.2004 - 15:44 von guest aktualisiert]




<ShadX>
unregistried

...   Created on 04.11.2004 - 16:38Jump to top Quote this post Report this post Edit Delete


Hi Guest,
excuse my sincerity, but i think that you know less then nothing about GLSL programming...otherwise you would have already made it

p.s.:
the correct formula for emboss filter is
gl_FragColor = c + 0.5 * (r + b) + -0.5 * (l + t) + br - tl
bye




guest ...
Real addict
.........

...

Status:Offline
Date registered: 30.07.2004
Post:856
Send Message
...   Created on 04.11.2004 - 18:30Jump to top Quote this post Report this post Edit Delete


But you are here now...

PS:

Transorm the source code from the 2xSaI scaling algorithm into a glSlang single pass shader and you'll be my hero.

[Dieser Beitrag wurde am 09.10.2005 - 15:32 von guest aktualisiert]




<ShadX>
unregistried

...   Created on 05.11.2004 - 12:32Jump to top Quote this post Report this post Edit Delete


Hi Guest.
you are so touchy...
if you have read my post, you can see:
"This fragment program was derived from "helloGPGPU_GLSL.cpp" v1.0.2 by Mike Weiblen"...I haven't declared that it's mine...
For your request:
//
//2xSaI scaling filter source code adapted for GLSL (not complete, of course, only for Guest's curiosity... if he will want complete it...
//November 05, 2004
//The original source is made available under the terms of the GNU GPL
//


uniform vec4 OGL2Size;
uniform vec4 OGL2Param;
uniform sampler2D OGL2Texture;

void main()
{
float of1x = 1.0 / OGL2Size.x;
float of1y = 1.0 / OGL2Size.y;
float of2x = 2.0 / OGL2Size.x;
float of2y = 2.0 / OGL2Size.y;

vec4 colorA, colorB;
vec4 colorC, colorD;
vec4 colorE, colorF, colorG, colorH;
vec4 colorI, colorJ, colorK, colorL;
vec4 colorM, colorN, colorO, colorP;
vec4 product, product1, product2;


// Map of the pixels:
// I|E F|J
// G|A B|K
// H|C D|L
// M|N O|P


vec2 TCoord = gl_TexCoord[0].xy;

colorA = texture2D(OGL2Texture, TCoord);
colorB = texture2D(OGL2Texture, TCoord + vec2( of1x, 0.0));
colorC = texture2D(OGL2Texture, TCoord + vec2( 0.0,-of1y));
colorD = texture2D(OGL2Texture, TCoord + vec2( of1x,-of1y));
colorE = texture2D(OGL2Texture, TCoord + vec2( 0.0,-of1y));
colorF = texture2D(OGL2Texture, TCoord + vec2( of1x, of1y));
colorG = texture2D(OGL2Texture, TCoord + vec2(-of1x, 0.0));
colorH = texture2D(OGL2Texture, TCoord + vec2(-of1x,-of1y));
colorI = texture2D(OGL2Texture, TCoord + vec2(-of1x, of1y));
colorJ = texture2D(OGL2Texture, TCoord + vec2( of2x, of1y));
colorK = texture2D(OGL2Texture, TCoord + vec2( of2x, 0.0));
colorL = texture2D(OGL2Texture, TCoord + vec2( of2x,-of1y));
colorM = texture2D(OGL2Texture, TCoord + vec2(-of1x,-of2y));
colorN = texture2D(OGL2Texture, TCoord + vec2( 0.0,-of2y));
colorO = texture2D(OGL2Texture, TCoord + vec2( of1x,-of2y));
colorP = texture2D(OGL2Texture, TCoord + vec2( of2x,-of2y));

if ((colorA == colorD) && (colorB != colorC))
{
if ( ((colorA == colorE) && (colorB == colorL)) ||
((colorA == colorC) && (colorA == colorF) && (colorB != colorE) && (colorB == colorJ)) )
{
product = colorA;
}
else
{
product = 0.5 * (colorA + colorB);
}

if (((colorA == colorG) && (colorC == colorO)) ||
((colorA == colorB) && (colorA == colorH) && (colorG != colorC) && (colorC == colorM)) )
{
product1 = colorA;
}
else
{
product1 = 0.5 * (colorA + colorC);
}
product2 = colorA;
}
else
if ((colorB == colorC) && (colorA != colorD))
{
if (((colorB == colorF) && (colorA == colorH)) ||
((colorB == colorE) && (colorB == colorD) && (colorA != colorF) && (colorA == colorI)) )
{
product = colorB;
}
else
{
product = 0.5 * (colorA + colorB);
}

if (((colorC == colorH) && (colorA == colorF)) ||
((colorC == colorG) && (colorC == colorD) && (colorA != colorH) && (colorA == colorI)) )
{
product1 = colorC;
}
else
{
product1 = 0.5 * (colorA + colorC);
}
product2 = colorB;
}
else
if ((colorA == colorD) && (colorB == colorC))
{
if (colorA == colorB)
{
product = colorA;
product1 = colorA;
product2 = colorA;
}
else
{
product1 = 0.5 * (colorA + colorC);
product = 0.5 * (colorA + colorB);
}
........
Bye
p.s.:
your customized random number generator or a deceased granny from a friend can be applied to post-process filtering?




<ShadX>
unregistried

...   Created on 05.11.2004 - 15:51Jump to top Quote this post Report this post Edit Delete


Guest,
this filter increases only the brightness... with a litle blur... unusable...




<ShadX>
unregistried

...   Created on 05.11.2004 - 16:11Jump to top Quote this post Report this post Edit Delete


Ok, waiting for the Pete's answer i have coded a shader like "old way"...
if someone want try it... not Guest, isn't supported by its system (7 texture unit used):
gpuPeteOGL2.slv
// Emboss GLSL vertex program - coded by ShadX free

uniform vec4 OGL2Param;
uniform vec4 OGL2Size;

void main()
{
vec4 offsetx;
vec4 offsety;

gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;


offsetx.x = 1.0/OGL2Size.x;
offsetx.y = 0.0;
offsetx.z = 0.0;
offsetx.w = 0.0;
offsety.x = 0.0;
offsety.y = 1.0/OGL2Size.y;
offsety.z = 0.0;
offsety.w = 0.0;


gl_TexCoord[0] = gl_MultiTexCoord0; //center
//gl_TexCoord[x] = gl_TexCoord[0] - offsetx + offsety; //bottom-left
gl_TexCoord[1] = gl_TexCoord[0] - offsetx ; //left
gl_TexCoord[2] = gl_TexCoord[0] - offsetx - offsety; //top-left
gl_TexCoord[3] = gl_TexCoord[0] - offsety ; //top
//gl_TexCoord[x] = gl_TexCoord[0] + offsetx -offsety; //top-right
gl_TexCoord[4] = gl_TexCoord[0] + offsetx ; //right
gl_TexCoord[5] = gl_TexCoord[0] + offsetx + offsety; //bottom-right
gl_TexCoord[6] = gl_TexCoord[0] + offsety ; //bottom

}

gpuPeteOGL2.slf
// Emboss GLSL shader program - coded by ShadX. Free.

uniform vec4 OGL2Size;
uniform vec4 OGL2Param;
uniform sampler2D OGL2Texture;

void main()
{
vec4 c,bl,l,tl,t,tr,r,br,b,col;

c = texture2DProj(OGL2Texture, gl_TexCoord[0]); //center
//bl = texture2DProj(OGL2Texture, gl_TexCoord[x]); //bottom-left
l = texture2DProj(OGL2Texture, gl_TexCoord[1]); //left
tl = texture2DProj(OGL2Texture, gl_TexCoord[2]); //top-left
t = texture2DProj(OGL2Texture, gl_TexCoord[3]); //top
//tr = texture2DProj(OGL2Texture, gl_TexCoord[x]); //top-right
r = texture2DProj(OGL2Texture, gl_TexCoord[4]); //right
br = texture2DProj(OGL2Texture, gl_TexCoord[5]); //bottom-right
b = texture2DProj(OGL2Texture, gl_TexCoord[6]); //bottom

if (OGL2Param.z==1.0) //light emboss
col = c + 0.25 * (r + b) + -0.25 * (l + t) + 0.5 * (br - tl);
if (OGL2Param.z==2.0) //strong emboss
col = c + 0.5 * (r + b) + -0.5 * (l + t) + (br - tl);
if (OGL2Param.z==3.0) //light reversed emboss
col = c + -0.25 * (r + b) + 0.25 * (l + t) + -0.5 * (br - tl);
if (OGL2Param.z==4.0) //strong reversed emboss
col = c + -0.5 * (r + b) + 0.5 * (l + t) - (br - tl);

}

Guest, this shader run very well on a 3Dlabs Wildcat Realizm 800...
Bye





guest ...
Real addict
.........

...

Status:Offline
Date registered: 30.07.2004
Post:856
Send Message
...   Created on 05.11.2004 - 17:11Jump to top Quote this post Report this post Edit Delete


You contributed to a new approach in shader usage.

Were is the catch?
You'll figure it out one day.

[Dieser Beitrag wurde am 30.09.2005 - 14:09 von guest aktualisiert]




<ShadX>
unregistried

...   Created on 05.11.2004 - 17:29Jump to top Quote this post Report this post Edit Delete


Parsing vertex shader 'guest.slf'....
Failure.

ERROR: 0:22: 'gl_FragColor' : undeclared identifier
ERROR: 0:22: '[' : field selection out of range '3'
ERROR: 0:22: 'pre-mature EOF' : syntax error parse error




<ShadX>
unregistried

...   Created on 05.11.2004 - 17:54Jump to top Quote this post Report this post Edit Delete


only one other thing, Guest: but if the questions are for Pete, why answer you?
are you its guardian angel?




More : [1] [2] [3]

Similarly threads:
Topics Created by Replies Boardname
Programs pRedaTor 0 predator7
Please add ability to run external programs :) 3 guidemaster
Vertex TeamPirnok 5 teampirnok
PSX 3d games vertex shaking 3 pete_bernert
nur ein fragment ErnestoMattig 2 wordshop
Neuer Thread ...





Masthead

This forum is a free service of razyboard.com powered by:
Geizkragen Price Comparison. Top product in the price comparison: Krups Nespresso Essenza (XN2001)
Do you want a free forum in less than two minutes? Then click here!



Verwandte Suchbegriffe:
bump map shader ogl2 | gaussian blur fragment program | post process shader error on edge | ogl2size | fragment program gaussian blur | bumpmap gpupeteogl2 | 2d edge detection glsl | gaussian blur shader
blank