Jump to content
  • Advertisement
Sign in to follow this  
Ishraam

Sun projected on Skydome

This topic is 4775 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

Hello ^^, I'm having a problem with something that should be rather simple : I have a skydome (a sphere), on which I wanna map a sun texture at the sun's position - which basically rotates around the center of the scene. And theres's a strange circle appearing (and rotating with the sun) : PROBLEM : I wanna get rid of that ugly brown circle ! To render this 'sky', I project the sun texture on the skydome using a camera (placed at the center of the scene). The camera always looks at the sun. 1. So I build a projective matrix (sun_texture_matrix)like this : Matrix sun_texture_matrix = camera.view_matrix * camera.proj_matrix * texture_space_matrix; with view_matrix = Matrix.LookAtLH(position, rotation_center, new Vector3(0,1,0)); proj_matrix = Matrix.PerspectiveFovLH((float)(Math.PI / 4.0f),1.0f, 1.0f, 100.0f); texture_space_matrix = |0.5f 0 0 0 | |0 -0.5f 0 0 | |0 0 0 0 | |0.5f 0.5f 1.0f 1.0f| 2. Then VS and PS : VS_OUTPUT VS(VS_INPUT input) { VS_OUTPUT output=(VS_OUTPUT)0; output.outPos = mul(input.inPos, WorldViewProj); output.outPos.z = output.outPos.w; output.texcoord = input.texcoord; output.sun_texcoord = mul(input.inPos,sun_texture_matrix); /* // this one part is to prevent a second sun to be rendered 'on the opposite side' if( output.sun_texcoord.w >= 0) output.sun_texcoord.zw = 0; */ return output; } float4 PS( in float2 texcoord : TEXCOORD0, in float4 sun_texcoord: TEXCOORD1 ) : COLOR0 { float4 sun_col = tex2Dproj(sun_sampler, sun_texcoord * 10.0f); // sun version return sun_col; } I can't find what's wrong - of course the texture is clean. Any of you guys has an idea ??

Share this post


Link to post
Share on other sites
Advertisement
sure :

sampler sun_sampler = sampler_state
{
texture = <sun_tex>;
minfilter = LINEAR;
mipfilter = LINEAR;
magfilter = LINEAR;
addressU = CLAMP;
addressV = CLAMP;
};

Share this post


Link to post
Share on other sites
Okay, so what does it look like if you remove these lines of code:

/*
// this one part is to prevent a second sun to be rendered 'on the opposite side'
if( output.sun_texcoord.w >= 0)
output.sun_texcoord.zw = 0;
*/




obviously -- you'd get two suns, but is the brown circle doubled in width?

Also, could you post the code to the "sun_texture_matrix"?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi,

I think the tri-linear filter causes the ring.
I am not sure why this artifact appears.

Share this post


Link to post
Share on other sites
sirob :
I can't say for sure that it is doubled in width, cause the ring is not 'clean' when I remove the comment (in other words, when I remove the other sun)

All I can say, is that one of the 2 suns (the 'wrong sun')is bigger than the other one.
And the smaller the sun is, the bigger the crown is (yep, not the contrary).

To change the size of the sun I must change the (float)(Math.PI / 4.0f) parameter of the PerspectiveFovLH(...) method.

And here is an example of the sun_texture_matrix:



AP:
I can't understand why the tri-linear would cause this.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
oh I just noticed I mistyped this
view_matrix = Matrix.LookAtLH(position, rotation_center, new Vector3(0,1,0));
when it should be :

view_matrix = Matrix.LookAtLH(rotation_center,position,new Vector3(0,1,0));

But I'm still stuck : the ugly crown is still there (though now the wrong sun and the right one have the same size)

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!