# Sun projected on Skydome

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

## 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 on other sites
Is the texture set to Clamp, and not mirror or tile?

##### Share on other sites
sure :

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

##### 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 on other sites
Hi,

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

##### 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 on other sites
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 on other sites
oups, that was me

##### Share on other sites
And here is the sun texture matrix : (the previous one was wrong because of a typo)

up!

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 14
• 46
• 22
• 27
• ### Forum Statistics

• Total Topics
634046
• Total Posts
3015224
×