Jump to content
  • Advertisement
Sign in to follow this  
DrGUI

No per-pixel reflections?

This topic is 4835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there I was a bit disappointed that I couldn't get per-pixel reflections with shader model 2.0; it had to use interpolated texture coordinates. Of course, on my curved surface, that gave a bad ripple effect when it moved. I'm surprised that with dependent texture reads into 2D textures that you can't do the same with cube textures. Do I have to tesselate my model LOADS to get it smooth?

Share this post


Link to post
Share on other sites
Advertisement
You couldn't get environment mapping with PS2.0? But...it's possible to do that on, like, PS1.1. Could I see your shader code?

Share this post


Link to post
Share on other sites
Yes, but at the moment I'm on a great summer school doing robotics, autonomous control!! We're all having a pinic in Hyde park soon yay!! Lots of cake...[grin]

However I remember the error being '(something) texture reads are not supported in shader model ps2_0'. Which I think is strange with dependent texture reads being supported.

I was interpolating the view vector and normal into the pixel shader. Now in the pixel shader I was normalizing them both, reflecting the view vector across the normal using the 'reflect' intrinsic and using that vector to lookup in the cubemap.

Pity the infrared sensors on our boe-bot didn't work :( One kept on switching from 0 to 1 rapidly making the boe-bot jitter. But programming the whiskers was cool!!

Share this post


Link to post
Share on other sites
That's odd, I wrote this shader for cubemapping and it works just fine:

float3 CamPos;
float4x4 World;
float4x4 ViewProj;

//----------------------------------------------------------------------------------

void VS(
in float4 iPos : POSITION,
in float3 iNormal : NORMAL,
out float4 oPos : POSITION,
out float4 oWorldPos : TEXCOORD0,
out float3 oNormal : TEXCOORD1)
{
oWorldPos=mul(iPos,World);
oNormal=normalize(mul(iNormal,(float3x3)World));
oPos=mul(oWorldPos,ViewProj);
}

//---------------------------------------------------------------------------------

texture EnvMap;

sampler Sampler0=sampler_state
{
texture=<EnvMap>;
};

void PS(
in float4 iWorldPos : TEXCOORD0,
in float3 iNormal : TEXCOORD1,
out float4 oColor : COLOR0)
{
float3 TexCoords=normalize(reflect(normalize(iWorldPos.xyz-CamPos),iNormal));
oColor=texCUBE(Sampler0,TexCoords);
}

//---------------------------------------------------------------------------------

technique T0
{
pass P0
{
vertexshader=compile vs_1_1 VS();
pixelshader=compile ps_2_0 PS();
}
}

Share this post


Link to post
Share on other sites
Thanks for the code Drakex, I'll have to try that when I get back home, on saturday methinks.

Our proper project now is modifying and programming a robot to serve drinks on the presentation day. But it's ridiculously powerful as it's from a competition, so much so that we had to zone off an area when running it [grin]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!