skies and matWorld

Posted By: HeelX

skies and matWorld - 04/16/13 07:15

Hi,

when setting a pan != 0, my skycubes won't change. I wrote then a simple shader to sample from the sky as cubemap:

Code:
effect_load(mtl_sky, "skyCube.fx");

g_entSky = ...
bmap_to_cubemap(bmap_for_entity(g_entSky, 0));


Code:
Out.Pos = mul(In.Pos, matWorldViewProj);
Out.Tex = (mul(float4(In.Pos.xyz, 1), (float4x4)matWorld)).xyz - vecViewPos.xyz;

...

return float4(texCUBE(skin, normalize(In.Tex)).rgb, 1);



The skycube is rendered as desired, but when changing the pan of my sky entity, it doesn't rotate, so it seems to me that matWorld isn't properly set.

Is this intended or a bug?, I dont know smile
Posted By: jcl

Re: skies and matWorld - 04/16/13 07:49

Skies are backgrounds, they have no world matrix AFAIK.
Posted By: HeelX

Re: skies and matWorld - 04/16/13 12:35

I just want to rotate my skycube, like I can do if it is a CYLINDER, because the sun is in a wrong place. So, I guess I have to build my rotation matrix by myself.
Posted By: jcl

Re: skies and matWorld - 04/16/13 12:59

Yes. The sky cube is internally generated just from 6 sprites. You can relatively easily emulate that either with normal sprites, or with a cube model that you can then also rotate.
Posted By: HeelX

Re: skies and matWorld - 04/16/13 14:45

Hm, there must be a world matrix because if it were an identity-matrix,
Code:
float3 vec = (mul(float4(In.Pos.xyz, 1), (float4x4)matWorld)).xyz - vecViewPos.xyz;

would be reduced to
Code:
float3 vec = In.Pos.xyz - vecViewPos.xyz;


but this doesn't work for me.

On the other hand, I face other problems: when I replace matWorldViewProj in my calculation of Out.Pos with
Code:
mul(matWorld, matViewProj)



The sky gets clipped:


This doesn't happen, when I concatenate matWorldView with matProj like this:
Code:
mul(matWorldView, matProj)

© 2024 lite-C Forums