Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (TipmyPip, AndrewAMD), 1,151 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Need help with realtime local reflections [Re: Hummel] #408186
09/27/12 01:13
09/27/12 01:13
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Well this is an almost perfect result, great work!
Still, I'm buffled too why I don't get the screenspace implementation to work. Have you had a look at the source code and the example from the Litheon guy from gamedev.net and compared it with my code from my first post?


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Need help with realtime local reflections [Re: Superku] #408212
09/27/12 13:48
09/27/12 13:48
Joined: Mar 2006
Posts: 2,252
Hummel Offline
Expert
Hummel  Offline
Expert

Joined: Mar 2006
Posts: 2,252
I had a quick look but haven't compared it to yours. However, I've noticed that he is using screen space derivatives (ddx/ddy) somehow.

Re: Need help with realtime local reflections [Re: Hummel] #408213
09/27/12 14:03
09/27/12 14:03
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Yes, but he only uses them for a gradient mip map selection.
I think an interesting part in the source code is the following:

Code:
// Transform the View Space Reflection to Screen Space
   // This because we want to ray march in to the depth buffer in Screen Space (thus you can use the default hardware depthbuffer)
   // Depth is linear in Screen Space per Screen Pixel
   float3 vspPosReflect = Input.ViewPos +  vspReflect;
   float3 sspPosReflect = mul(float4(vspPosReflect, 1.0), g_mProj).xyz / vspPosReflect.z;
   float3 sspReflect = sspPosReflect - Input.ScreenPos;


Two thoughts come to my mind: How does his projection matrix look like and esp. why does he divide by vspPosReflect.z (including the z-component of ssPosReflect)?
I had to adapt my code as follows to get somehow passable results:

Code:
// transform from view to screen space
	float4 tPos = mul(float4(viewpos+dir,1), matProj);
	tPos.xy = tPos.xy/tPos.w;
	float3 screenDir = tPos.xyz-projViewPos;



"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Need help with realtime local reflections [Re: Superku] #408215
09/27/12 14:56
09/27/12 14:56
Joined: Mar 2006
Posts: 2,252
Hummel Offline
Expert
Hummel  Offline
Expert

Joined: Mar 2006
Posts: 2,252
He is just dividing by linear depth since vspPosReflect is in view space. He could have also done the following:
Code:
float3 vspPosReflect = Input.ViewPos +  vspReflect;
   float4 sspPosReflect = mul(float4(vspPosReflect, 1.0), g_mProj).xyzw;
sspPosReflect.xyz /= sspPosReflect.w;
   float3 sspReflect = sspPosReflect.xyz - Input.ScreenPos;

And since Input.ScreenPos uses non-linear depth in the z-value too they cancel out each other.
I tried something alike (I didn't divide the z value, though...) but ended up with the same problem like you. So the magic seems to hide somewhere else.

Re: Need help with realtime local reflections [Re: Hummel] #408402
09/30/12 16:17
09/30/12 16:17
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
I've got a simple suggestion to improve the quality (you see it on the right side):



I changed the line return tex2D(CameraSampler, screenPos.xy); in reflect.fx to
Code:
float Intensity = saturate(1.0f - distance(screenPos.xy, float2(0.5f, 0.5f)) * 2.0f);
Intensity = Intensity * (2.0f - Intensity);
return tex2D(CameraSampler, screenPos.xy) * Intensity;



POTATO-MAN saves the day! - Random
Re: Need help with realtime local reflections [Re: Kartoffel] #408403
09/30/12 16:22
09/30/12 16:22
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Thank you for the suggestion. The real shader of course blends out the reflection smoothly where no data is available, I've posted only the relevant part for the calculation of the reflection.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Need help with realtime local reflections [Re: Superku] #408404
09/30/12 16:28
09/30/12 16:28
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
oh, ok smile


POTATO-MAN saves the day! - Random
Page 2 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