Skip to main content
GameDev.net gamedev.net
🔒 Locked

GL_ARB_shadow ???

Started by silvermace May 24, 2003 at 7:24 PM 17 replies 3.5k views
Original Post
silvermace
silvermace
i have an implementation but now i want to do a few things currently the shadow is solid (ie. totaly opaque) i would like to make it semi-transparent and also, how would i go about softening the aliasing problems with it, without a glReadPixels call (very slow on ATI cards ) anyone, thanx :D
A GOOD friend will come bail you out of jail... but, a TRUE friend will be sitting next to you saying, "Damn, we fucked up." Ingite 3D Game Engine Home -- Just click it
Jallen
Jallen
You can do both those things in a fragment program.
---I write code.DelphiGL (http://delphigl.cfxweb.net)
silvermace
silvermace
yea, can you gimme some actual help ???
:D resources, i have never used Fragment programs before, and esp nothing to do with shadows...



A GOOD friend will come bail you out of jail...
but, a TRUE friend will be sitting next to you saying, "Damn, we fucked up."
Ingite 3D Game Engine Home -- Just click it
Jallen
Jallen
Fragment programs let you fetch from textures and blend them together in whatever way you want. If you want your shadows to be "transparent" instead of just pure black, you would just fetch from the shadow map (which would return a 0 or 1 when ARB_shadow is being used) and then multiply that value by 0.5 instead of just using the value directly.

If you want to antialias your shadowmaps, you can fetch from the shadowmap several times in different locations then blend those values together to produce a antialiased shadow edge.
---I write code.DelphiGL (http://delphigl.cfxweb.net)
silvermace
silvermace
ok, ive coded a loader for GL_ARB_fragment program, how do i use it, im currently using 2 tmu''s to blend the textures 2gether

FragmentProgram.Bind();

glActiveTexture(1);
ObjectTexture.Bind();

glActiveTexture(2);
Shadow.Bind();

???
is this right because my simple fragment program isnt working...

  
!!ARBfp1.0

TEMP temp;
ATTRIB tex0 = fragment.texcoord[0];
ATTRIB col0 = fragment.color;

PARAM pink = { 1.0, 0.5, 0.5, 1.0 );

OUTPUT out = result.color;

TEX temp, tex0, texture[0], 2D;
MOV out, temp;

MUL out, temp, pink;


if you want the loader code, i will post it, but i just wrote it and i dont think there are any errors in that, i think im just using it wrong



A GOOD friend will come bail you out of jail...
but, a TRUE friend will be sitting next to you saying, "Damn, we fucked up."
Ingite 3D Game Engine Home -- Just click it
Jallen
Jallen
You are binding your textures to texunits 1 and 2 but in your fragment program you are fetching from texunit 0.
---I write code.DelphiGL (http://delphigl.cfxweb.net)
silvermace
silvermace
ok, fixed that, now it crashes if i use GL_ARB_shadow as well, is this a driver bug???



A GOOD friend will come bail you out of jail...
but, a TRUE friend will be sitting next to you saying, "Damn, we fucked up."
Ingite 3D Game Engine Home -- Just click it
Jallen
Jallen
Sounds like it, what driver and vid card?

Where does it crash? Have you stepped through it in a debugger?
---I write code.DelphiGL (http://delphigl.cfxweb.net)
silvermace
silvermace
no, not a driver bug, im just stupid :D
for anyone else, disable the fragment program when you render the shaow map

can you help me with the fragment program, ive never used any of this stuff (except a bit in directx 9, but that was HLSL)

how would i go about doing this?

do you have MSN Jallen?
im online now: silvermace007@hotmail.com

thanx
Basiror
Basiror
cant you use your shadowmap

create a luminace texture

specify a alpha value via glColor4f(...)
enable blending

blendfunc src alpha, one-src alpha

and draw itin orthographic mode?
http://www.8ung.at/basiror/theironcross.html
silvermace
silvermace
that dosnt work, im using GL_ARB_shadow map so i dont think that thats alowed, do you have a reference i could look at, or have you coded something similar ?

thanx
Basiror
Basiror
well you could draw the shadows with stencil enable and then use the stencil as a luminace map
http://www.8ung.at/basiror/theironcross.html
silvermace
silvermace
thanx for that, but fragment programs look pretty cool, i would still like to implement it in a fragment program, do you think this is possible?

thanx for any pointers
Jallen
Jallen
Its definitely possible in a fragment program. What problems are you having?
---I write code.DelphiGL (http://delphigl.cfxweb.net)
silvermace
silvermace
i setup the texture matrix for GL_TEXTURE1_ARB (the shadow map)
and use this fragment program, the base textures come out fine, but there is no sign of the shadow map, so i have no idea what is going on...


  
!!ARBfp1.0

TEMP temp1;
TEMP temp2;
TEMP res;

ATTRIB tex0 = fragment.texcoord[0];
ATTRIB tex1 = fragment.texcoord[1];
ATTRIB col0 = fragment.color;

OUTPUT out = result.color;

TEX temp1, tex0, texture[0], 2D;
TEX temp2, tex1, texture[1], 2D;

MOV out, temp2;
MUL out, temp1, temp2;

END


here are the results:
NO FRAGMENT PROGRAM:


WITH FRAGMENT PROGRAM

Jallen
Jallen
You probably need to do a projective texture lookup for the shadowmap, try using TXP instead of TEX.
---I write code.DelphiGL (http://delphigl.cfxweb.net)
silvermace
silvermace
you wouldnt happen to know how to do this would you ???
because im lost, i replaced TEX with TXP but now what ??
Jallen
Jallen
You might want to look at the ARB_fragment_program specification if you are confused about the TXP instruction.
---I write code.DelphiGL (http://delphigl.cfxweb.net)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.