0
\$\begingroup\$

I'm adding cubemap shadow for point lights. Rendering each face in a separate texture2D seems to work (see picture, right, rendering from yellow point light view). With the same pipeline I can't get it working for cubemap or I'm not able to see it correctly in my visualisation panel. I'm using the almost same code as in the GSCubemap demo for DX10 except I want to render only in the depth buffer so I don't set pixelshader. Note : my cubemap is D24S8 and current shadow is from another directional light, there's no shadows from point lights at the moment.

here the modified code

  struct VS_INPUT
 {
    float3 Pos : POSITION;
    float3 Norm : NORMAL;
     float4 Col : COLOR0;
   float2 Tex : TEXCOORD0;
};

struct GS_INPUT
{
    float4 Pos      : SV_POSITION;
};

 struct PS_CUBEMAP_IN
{
     float4 Pos : SV_POSITION;
      uint RTIndex : SV_RenderTargetArrayIndex;
};

The LightPos[2].xyz below is the position of the yellow point light

     GS_INPUT VS_CubeMap( VS_INPUT input )
 {
     GS_INPUT output = (GS_INPUT)0.0f;
     output.Pos = mul( float4(input.Pos,1), World ); output.Pos.xyz -= LightPos[2].xyz;
    return output;
 }

below LightViewCube[f] are the 6 view matrices for the 6 faces from the yellow point light view. Projection is projection matrix

 [maxvertexcount(18)]
 void GS_CubeMap( triangle GS_INPUT input[3], inout TriangleStream<PS_CUBEMAP_IN> CubeMapStream )
{
    for( int f = 0; f < 6; ++f )
     {
         PS_CUBEMAP_IN output;
         output.RTIndex = f;
         for( int v = 0; v < 3; v++ )
         {
             output.Pos = mul( input[v].Pos, LightViewCube[f] );
             output.Pos = mul( output.Pos, Projection );
             CubeMapStream.Append( output );
          }
          CubeMapStream.RestartStrip();
     }
  }

  float PS_CubeMap( PS_CUBEMAP_IN input ) : SV_Target
  {
       return 0;
  }

for viewing the cubemap in 6 different quad panels I do the following to calculate the 3D uvw direction coordinates based on the 2D coordinate of my quad used as panel (Face is the index of the cubemap face):

 float3 UVW = float3(Input.Tex,1);//default value
 float2 UV2 = Input.Tex*2 - float2(1,1);
 switch ( Face )
 {
    case 0:UVW = float3 (1, -UV2.y, -UV2.x);break;//X+
    case 1:UVW = float3 (-1, -UV2.y, UV2.x);break;//X-
    case 2:UVW = float3 (UV2.x, 1, UV2.y);break;//Y+
    case 3:UVW = float3 (UV2.x, -1, -UV2.y);break;//Y-
    case 4:UVW = float3 (UV2.x, -UV2.y, 1);break;//Z+
    case 5:UVW = float3 (UV2.x, -UV2.y, -1);break;//Z-
 }

I've tried either at the vertex or pixel shader level but get the same half black quad for the first panel (Face=0) and full red for the others (left panel image).

enter image description here

\$\endgroup\$
3
  • \$\begingroup\$ Cubemaps are conventional. Generally we try to avoid questions here that can be answered with "Yes". Did you encounter any specific problem implementing a cube map that we can help you overcome? \$\endgroup\$
    – DMGregory
    Mar 24, 2022 at 11:46
  • \$\begingroup\$ I'm just starting with cubemaps and never did before. Starting from the gscubmap dx10 demo. \$\endgroup\$
    – philB
    Mar 24, 2022 at 11:54
  • \$\begingroup\$ Want to edit your question to ask that? \$\endgroup\$
    – DMGregory
    Mar 24, 2022 at 11:55

1 Answer 1

0
\$\begingroup\$

I've solved my problem that was simply due to geometry shader not compiled (silly me). This get the shadow cubemap rendering working and confirmed the code used for panel views was correct.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .