Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by AndrewAMD. 12/05/23 10:56
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
6 registered members (3run, AndrewAMD, alibaba, fairtrader, ozgur, TipmyPip), 605 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
What about a Relief_Mapping shader... #51778
08/13/05 22:53
08/13/05 22:53
Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
XNASorcerer Offline OP
Expert
XNASorcerer  Offline OP
Expert

Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
Look to this 8 MB video and be amazed. Here: http://fabio.policarpo.nom.br/videos/Doom3_ReliefMapping_Video.zip






Re: What about a Relief_Mapping shader... [Re: XNASorcerer] #51779
08/14/05 01:19
08/14/05 01:19
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
Releif mapping or parralax occlusions look great, but are rather slow.. especially with self shadows. I dont doubt they will become standard in the near future.. but in my own experiments they are slow even on my GeForce 6800, in an actual game map..maybe i just have done a bad implementation.. so maybe i will do some more experiments with it. it does look fantastic I agree.

Re: What about a Relief_Mapping shader... [Re: Matt_Aufderheide] #51780
08/14/05 07:56
08/14/05 07:56
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline
Serious User
Steempipe  Offline
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
The parallax code I am currently working on has fair performance on my ATI 9800. That said, I do need to make a full-on level and tweak from there.
Relief mapping... well... with the code I have tinkered with I have yet to get good results with good performance.

Parallax:



Re: What about a Relief_Mapping shader... [Re: Steempipe] #51781
08/14/05 10:46
08/14/05 10:46
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Steempipe, these looks extremly good! And that are weak word to describe how impressed I am!

Re: What about a Relief_Mapping shader... [Re: Steempipe] #51782
08/14/05 11:59
08/14/05 11:59
Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
XNASorcerer Offline OP
Expert
XNASorcerer  Offline OP
Expert

Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
Steempipe,
I am impress! I have an ATI9700 and I am trying to implement or a normalmpapping or parallax shader with my level geometry, but I am having no success. Maybe you could help me with that. Thanks.

Matt_Aufderheide ,

Inside the page of that video, we can find a patchto apply the relief mapping on Doom3. And as soon that I have some space in my notebook ( I am playing Half Life 2 again, Swat 4 and Colin McRae 2005 )and time, I will install Doom 3 again and experiment it with the Relief Mapping to see the performance. If you wat to try it, here is the patch: http://fabio.policarpo.nom.br/files/Doom3_ReliefMapping.zip

Some links: http://www.inf.ufrgs.br/~oliveira/RTM.html

http://fabio.policarpo.nom.br/relief/index.htm

Re: What about a Relief_Mapping shader... [Re: XNASorcerer] #51783
08/14/05 23:18
08/14/05 23:18
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline
Serious User
Steempipe  Offline
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
Thanks guys!

Sorcerer: Give me some time and I can help you. I am real busy right now with my job. The parallax code needs some more work before it gets posted.

Last edited by Steempipe; 08/14/05 23:19.
Re: What about a Relief_Mapping shader... [Re: Steempipe] #51784
08/15/05 00:22
08/15/05 00:22
Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
XNASorcerer Offline OP
Expert
XNASorcerer  Offline OP
Expert

Joined: Dec 2001
Posts: 2,172
Portugal - Brazil
Ok. Thanks

Re: What about a Relief_Mapping shader... [Re: XNASorcerer] #51785
08/17/05 11:38
08/17/05 11:38
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
I have converted that relif mapping shader, and alhtough it does look good, it is just too slow, when you want multiple lights..my parallax shader does 6 lights no problem, the relief shader really bogs down.. although i think this is the next standard(or something like it) it needs another generation of shader hardware before viable for real games.

That said, its a neat thing, and maybe i will release my shader eventually.. also, i can imagine a scheme where you have an LOD fragment shader when only the pixels nearest you use the relief shader, the further ones use parallax, and the most distant would just use normal mapping.. who knows.. it could work.

Re: What about a Relief_Mapping shader... [Re: Matt_Aufderheide] #51786
08/17/05 13:49
08/17/05 13:49
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline
Senior Expert
ello  Offline
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
how did you get the selfshadowing??


www.earthcontrol.de
quoted: We want to maintain a clean, decent, American family suited forum look... which means you may post zombies or chainsaw massacres, but no erotic.
Re: What about a Relief_Mapping shader... [Re: ello] #51787
08/18/05 01:23
08/18/05 01:23
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
here is the basic HLSL code, you may need to chnage some things, but it will work in A6, although there is still aproblem with the perspective.. for some reason things point in the wrong direction.. but this is fixable.. i just havent bothered.. maybe someone can improve this.. Also, i havent implemented any attenuation, but this is simple to do. I commented out the self shadowing...but you can add back in to try it.. it is slow

Code:

struct a2v
{
float4 pos : POSITION;
float3 normal : NORMAL;
float2 txcoord : TEXCOORD0;
float3 tangent : TEXCOORD1;
};

struct v2f
{
float4 hpos : POSITION;
float2 txcoord : TEXCOORD0;
float3 vpos : TEXCOORD1;
float3 tangent : TEXCOORD2;
float3 binormal : TEXCOORD3;
float3 normal : TEXCOORD4;
float4 lightpos : TEXCOORD5;
float Fog : FOG;
};



// shaders ////////////////////////////

v2f view_space(a2v IN)
{
v2f OUT;

// compute modelview rotation only part
float3x3 modelviewrot;
modelviewrot[0]=(matWorldView[0].xyz);
modelviewrot[1]=(matWorldView[1].xyz);
modelviewrot[2]=(matWorldView[2].xyz);


// vertex position in clip space
OUT.hpos=mul(IN.pos,matWorldViewProj);

// vertex position in view space (with model transformations)
OUT.vpos=mul(IN.pos,matWorldView).xyz;

// light position in view space
OUT.lightpos=mul(vecLightPos,matView);

// tangent space vectors in view space (with model transformations)
OUT.tangent=mul(IN.tangent,-modelviewrot);
OUT.binormal=mul( (cross(IN.tangent,IN.normal)),modelviewrot);
OUT.normal=mul(IN.normal,modelviewrot);

OUT.txcoord=IN.txcoord.xy;

OUT.Fog = 10000;

return OUT;
}

float depth_fact= 0.05f;

float ray_intersect_rm(
in float2 dp,
in float2 ds)
{
const int linear_search_steps=16;
const int binary_search_steps=6;
float depth_step=1.0/linear_search_steps;

// current size of search window
float size=depth_step;
// current depth position
float depth=0.0;
// best match found (starts with last position 1.0)
float best_depth=1.0;

// search front to back for first point inside object
for( int i=0;i<linear_search_steps-1;i++ )
{
depth+=size;
float4 t=tex2D(BumpMapSampler,dp+ds*depth);
// normalize(t.w/=3);
if (best_depth>0.996) // if no depth found yet
if (depth>=t.w)
best_depth=depth; // store best depth
}
depth=best_depth;

// recurse around first point (depth) for closest match
for( int i=0;i<binary_search_steps;i++ )
{
size*=0.5;
float4 t=tex2D(BumpMapSampler,dp+ds*depth);
// normalize(t.w/=3);
if (depth>=t.w)
{
best_depth=depth;
depth-=2*size;
}
depth+=size;
}

return best_depth;
}

float4 relief_map( v2f IN) : COLOR
{
float4 t;
float3 p,v,l,s;//c;
float4 c;//c;
float2 dp,ds,uv;
float d;

// ray intersect in view direction
p = IN.vpos;
v = normalize(p);

if (IN.binormal.x<0 )
{
IN.binormal.x*=-1;
}
if (IN.binormal.y<0 )
{
IN.binormal.y*=-1;
}

if (IN.binormal.z<0 )
{
IN.binormal.z*=-1;
}

s = normalize(float3(dot(v,IN.tangent),dot(v,IN.binormal),dot(v,IN.normal)));
s *= depth_fact*0.2/dot(IN.normal,-v);
dp = IN.txcoord;
ds = s.xy;
d = ray_intersect_rm(dp,ds);

// get rm and color texture points
uv=dp+ds*d;
t=tex2D(BumpMapSampler,uv);
normalize(t);
c=tex2D(ColorMapSampler,uv);

// expand normal from normal map in local polygon space
t.xy=t.xy*2.0-1.0;
t.z=sqrt(1.0-dot(t.xy,t.xy));
t.xyz=normalize(t.x*IN.tangent-t.y*IN.binormal+t.z*IN.normal);

// compute light direction
p += s*d;
l=normalize(p-IN.lightpos.xyz);

/*
/////////////
//selfshadowing--slow and doesnt look good in some cases
// ray intersect in light direction
dp+= ds*d;
s = normalize(float3(dot(l,IN.tangent),dot(l,IN.binormal),dot(l,IN.normal)));
s *= depth_fact*0.2/dot(IN.normal,-l);
dp-= d*s.xy;
ds = s.xy;
float dl = ray_intersect_rm(dp,s.xy);
if (dl<d-0.05) // if pixel in shadow
{
c*=0.4;
c.w=0;
}
///////////////
*/

// compute diffuse and specular terms
float att=saturate(dot(-l,IN.normal.xyz));
float diff=saturate(dot(-l,t.xyz));
float spec=saturate(dot(normalize(-l-v),t.xyz));

// compute final color
float4 finalcolor;
finalcolor.xyz=att*(c*diff+1*(pow(spec,30)*c.w));
finalcolor.w=1.0;

return finalcolor;
}



Page 1 of 2 1 2

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1