HDR Post Processor Issues

rated by 0 users
This post has 12 Replies | 2 Followers

Top 100 Contributor
Posts 42
SunBurn_Community_Licensee
Duckocide Posted: 01-09-2011 7:15 AM

Sunburn 2.0.10

I'm currently running in to difficulties with the provided HDR Post processor and the screen going blank.  

On first use (through the code snippets below), things are fine. However, As I move from location to location in the game, the Scene is knocked down, Environment disposed and items loaded again (for the new scene). 

 

// Clear out the SceneInterface

SceneInterface.Clear();

// Create the HDR post processor.

highDynamicRangePostProcessor = new HighDynamicRangePostProcessor(graphics);

SceneInterface.PostProcessManager.AddPostProcessor(highDynamicRangePostProcessor);

:

 

Scene scene = Content.Load<Scene>("LocationData/Location.00/light_rig");

SceneInterface.LightManager.Submit(scene);

:

// Load the scene settings.

SceneEnvironment = Content.Load<SceneEnvironment>("LocationData/Location.00/scene_environment");

And then in Draw()...
sceneState.BeginFrameRendering(View, Projection, gameTime, SceneEnvironment, frameBuffers, true);
SceneInterface.BeginFrameRendering(sceneState);

Now, the thing is, if I take away the addition of the HDR processor, things are fine. Any ideas anyone?

 

 

 

 

 

Top 10 Contributor
Posts 5,368
Employee
SunBurn_Studio_Licensee

Hi Duckocide,

In SunBurn 2.0 clearing the scene no longer removes the post processors, you can safely set these on load and not worry about re-adding them later.

I tested clearing the scene (and not re-adding) in the HDR example and this works correctly.

Let me know if this helps!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Top 100 Contributor
Posts 42
SunBurn_Community_Licensee

As ever, thanks for the prompt reply Bob. Alas no, I modified the code to only add the process once. 

 

                // Create the HDR post processor.

                if (highDynamicRangePostProcessor == null)

                {

                    highDynamicRangePostProcessor = new HighDynamicRangePostProcessor(graphics);

                    SceneInterface.PostProcessManager.AddPostProcessor(highDynamicRangePostProcessor);

                }

But I still get a blank screen :(

If I comment out the post process addition (i.e Don;t have one, no issues), everything is fine from location to location. I'll carry on playing around. Is ii that the light_rig.xml is legacy? I.e. it's not a contemporary scene and environment xml file causing a problem in sunburn (these files go back a few versions now)?

 

<root>

  <LightRig>

    <LightGroups>

      <GroupList>

        <item_0>

          <LightGroup>

            <Name>Hab Module</Name>

            <ShadowType>AllObjects</ShadowType>

            <Position>

              <Vector3>

                <X>0.02008188</X>

                <Y>1.766027</Y>

                <Z>0.02428218</Z>

              </Vector3>

            </Position>

            <Radius>0</Radius>

            <ShadowQuality>0.5</ShadowQuality>

            <ShadowPrimaryBias>1</ShadowPrimaryBias>

            <ShadowSecondaryBias>0.2</ShadowSecondaryBias>

            <ShadowPerSurfaceLOD>True</ShadowPerSurfaceLOD>

            <ShadowRenderLightsTogether>True</ShadowRenderLightsTogether>

            <ShadowGroup>False</ShadowGroup>

            <Lights>

              <LightList>

                <item_0>

                  <AmbientLight>

                    <Name>Ambient Lighting</Name>

                    <Enabled>True</Enabled>

                    <DiffuseColor>

                      <Vector3>

                        <X>1</X>

                        <Y>1</Y>

                        <Z>1</Z>

                      </Vector3>

                    </DiffuseColor>

                    <Intensity>0.01</Intensity>

                    <Depth>0.15</Depth>

                  </AmbientLight>

                </item_0>

                <item_1>

                  <PointLight>

                    <Name>Emergency Light</Name>

                    <Enabled>True</Enabled>

                    <DiffuseColor>

                      <Vector3>

                        <X>0.8431373</X>

                        <Y>0.2039216</Y>

                        <Z>0.04705882</Z>

                      </Vector3>

                    </DiffuseColor>

                    <Intensity>1</Intensity>

                    <FillLight>True</FillLight>

                    <FalloffStrength>0.5</FalloffStrength>

                    <ShadowType>AllObjects</ShadowType>

                    <Position>

                      <Vector3>

                        <X>0</X>

                        <Y>11.52727</Y>

                        <Z>46.32502</Z>

                      </Vector3>

                    </Position>

                    <Radius>40</Radius>

                    <ShadowQuality>0.5</ShadowQuality>

                    <ShadowPrimaryBias>1</ShadowPrimaryBias>

                    <ShadowSecondaryBias>0.2</ShadowSecondaryBias>

                    <ShadowPerSurfaceLOD>True</ShadowPerSurfaceLOD>

                  </PointLight>

                </item_1>

                <item_2>

                  <PointLight>

                    <Name>Emergency Light Copy</Name>

                    <Enabled>True</Enabled>

                    <DiffuseColor>

                      <Vector3>

                        <X>0.8431373</X>

                        <Y>0.2078431</Y>

                        <Z>0.05098039</Z>

                      </Vector3>

                    </DiffuseColor>

                    <Intensity>1</Intensity>

                    <FillLight>True</FillLight>

                    <FalloffStrength>0.5</FalloffStrength>

                    <ShadowType>AllObjects</ShadowType>

                    <Position>

                      <Vector3>

                        <X>0</X>

                        <Y>11.53</Y>

                        <Z>-46.33</Z>

                      </Vector3>

                    </Position>

                    <Radius>40</Radius>

                    <ShadowQuality>0.5</ShadowQuality>

                    <ShadowPrimaryBias>1</ShadowPrimaryBias>

                    <ShadowSecondaryBias>0.2</ShadowSecondaryBias>

                    <ShadowPerSurfaceLOD>True</ShadowPerSurfaceLOD>

                  </PointLight>

                </item_2>

                <item_3>

                  <PointLight>

                    <Name>Laptop</Name>

                    <Enabled>True</Enabled>

                    <DiffuseColor>

                      <Vector3>

                        <X>0.2509804</X>

                        <Y>0.4078431</Y>

                        <Z>0.6509804</Z>

                      </Vector3>

                    </DiffuseColor>

                    <Intensity>0.3</Intensity>

                    <FillLight>False</FillLight>

                    <FalloffStrength>0</FalloffStrength>

                    <ShadowType>None</ShadowType>

                    <Position>

                      <Vector3>

                        <X>16.90664</X>

                        <Y>0.5830954</Y>

                        <Z>11.12371</Z>

                      </Vector3>

                    </Position>

                    <Radius>10.5</Radius>

                    <ShadowQuality>0.5</ShadowQuality>

                    <ShadowPrimaryBias>1</ShadowPrimaryBias>

                    <ShadowSecondaryBias>0.2</ShadowSecondaryBias>

                    <ShadowPerSurfaceLOD>True</ShadowPerSurfaceLOD>

                  </PointLight>

                </item_3>

                <item_4>

                  <SpotLight>

                    <Name>NoticeBoardSpotLight</Name>

                    <Enabled>True</Enabled>

                    <DiffuseColor>

                      <Vector3>

                        <X>1</X>

                        <Y>0.972549</Y>

                        <Z>0.7450981</Z>

                      </Vector3>

                    </DiffuseColor>

                    <Intensity>2</Intensity>

                    <FillLight>True</FillLight>

                    <FalloffStrength>1</FalloffStrength>

                    <ShadowType>AllObjects</ShadowType>

                    <Position>

                      <Vector3>

                        <X>16.94345</X>

                        <Y>21.3857</Y>

                        <Z>10.81955</Z>

                      </Vector3>

                    </Position>

                    <Radius>24.5</Radius>

                    <Direction>

                      <Vector3>

                        <X>0.5609189</X>

                        <Y>-0.8274674</Y>

                        <Z>0.02583969</Z>

                      </Vector3>

                    </Direction>

                    <Angle>65</Angle>

                    <Volume>2</Volume>

                    <ShadowQuality>1</ShadowQuality>

                    <ShadowPrimaryBias>1</ShadowPrimaryBias>

                    <ShadowSecondaryBias>0.7</ShadowSecondaryBias>

                    <ShadowPerSurfaceLOD>True</ShadowPerSurfaceLOD>

                  </SpotLight>

                </item_4>

                <item_5>

                  <PointLight>

                    <Name>CogWheelHouse1</Name>

                    <Enabled>True</Enabled>

                    <DiffuseColor>

                      <Vector3>

                        <X>0.7647059</X>

                        <Y>0.9803922</Y>

                        <Z>0.3607843</Z>

                      </Vector3>

                    </DiffuseColor>

                    <Intensity>1</Intensity>

                    <FillLight>False</FillLight>

                    <FalloffStrength>0</FalloffStrength>

                    <ShadowType>AllObjects</ShadowType>

                    <Position>

                      <Vector3>

                        <X>17.38465</X>

                        <Y>3.331026</Y>

                        <Z>-49.28797</Z>

                      </Vector3>

                    </Position>

                    <Radius>8</Radius>

                    <ShadowQuality>0.5</ShadowQuality>

                    <ShadowPrimaryBias>1</ShadowPrimaryBias>

                    <ShadowSecondaryBias>0.2</ShadowSecondaryBias>

                    <ShadowPerSurfaceLOD>True</ShadowPerSurfaceLOD>

                  </PointLight>

                </item_5>

                <item_6>

                  <PointLight>

                    <Name>CogWheelHouse1 Copy</Name>

                    <Enabled>True</Enabled>

                    <DiffuseColor>

                      <Vector3>

                        <X>0.7647059</X>

                        <Y>0.9803922</Y>

                        <Z>0.3607843</Z>

                      </Vector3>

                    </DiffuseColor>

                    <Intensity>1</Intensity>

                    <FillLight>False</FillLight>

                    <FalloffStrength>0</FalloffStrength>

                    <ShadowType>AllObjects</ShadowType>

                    <Position>

                      <Vector3>

                        <X>-17.38</X>

                        <Y>3.331026</Y>

                        <Z>49.29</Z>

                      </Vector3>

                    </Position>

                    <Radius>8</Radius>

                    <ShadowQuality>0.5</ShadowQuality>

                    <ShadowPrimaryBias>1</ShadowPrimaryBias>

                    <ShadowSecondaryBias>0.2</ShadowSecondaryBias>

                    <ShadowPerSurfaceLOD>True</ShadowPerSurfaceLOD>

                  </PointLight>

                </item_6>

                <item_7>

                  <PointLight>

                    <Name>CogWheelHouse1 Copy</Name>

                    <Enabled>True</Enabled>

                    <DiffuseColor>

                      <Vector3>

                        <X>0.7647059</X>

                        <Y>0.9803922</Y>

                        <Z>0.3607843</Z>

                      </Vector3>

                    </DiffuseColor>

                    <Intensity>1</Intensity>

                    <FillLight>False</FillLight>

                    <FalloffStrength>0</FalloffStrength>

                    <ShadowType>AllObjects</ShadowType>

                    <Position>

                      <Vector3>

                        <X>17.38</X>

                        <Y>3.331026</Y>

                        <Z>49.29</Z>

                      </Vector3>

                    </Position>

                    <Radius>8</Radius>

                    <ShadowQuality>0.5</ShadowQuality>

                    <ShadowPrimaryBias>1</ShadowPrimaryBias>

                    <ShadowSecondaryBias>0.2</ShadowSecondaryBias>

                    <ShadowPerSurfaceLOD>True</ShadowPerSurfaceLOD>

                  </PointLight>

                </item_7>

                <item_8>

                  <PointLight>

                    <Name>CogWheelHouse1 Copy</Name>

                    <Enabled>True</Enabled>

                    <DiffuseColor>

                      <Vector3>

                        <X>0.7647059</X>

                        <Y>0.9803922</Y>

                        <Z>0.3607843</Z>

                      </Vector3>

                    </DiffuseColor>

                    <Intensity>1</Intensity>

                    <FillLight>False</FillLight>

                    <FalloffStrength>0</FalloffStrength>

                    <ShadowType>AllObjects</ShadowType>

                    <Position>

                      <Vector3>

                        <X>-17.38</X>

                        <Y>3.331026</Y>

                        <Z>-49.28797</Z>

                      </Vector3>

                    </Position>

                    <Radius>8</Radius>

                    <ShadowQuality>0.5</ShadowQuality>

                    <ShadowPrimaryBias>1</ShadowPrimaryBias>

                    <ShadowSecondaryBias>0.2</ShadowSecondaryBias>

                    <ShadowPerSurfaceLOD>True</ShadowPerSurfaceLOD>

                  </PointLight>

                </item_8>

              </LightList>

            </Lights>

          </LightGroup>

        </item_0>

      </GroupList>

    </LightGroups>

  </LightRig>

</root>

 

 

 

 

 

 

<root>

  <SceneEnvironment>

    <VisibleDistance>500</VisibleDistance>

    <FogEnabled>True</FogEnabled>

    <FogColor>

      <Vector3>

        <X>0.1333333</X>

        <Y>0.1529412</Y>

        <Z>0.2235294</Z>

      </Vector3>

    </FogColor>

    <FogStartDistance>30</FogStartDistance>

    <FogEndDistance>100</FogEndDistance>

    <ShadowFadeStartDistance>200</ShadowFadeStartDistance>

    <ShadowFadeEndDistance>250</ShadowFadeEndDistance>

    <ShadowCasterDistance>250</ShadowCasterDistance>

    <BloomAmount>3</BloomAmount>

    <BloomThreshold>0.9</BloomThreshold>

    <DynamicRangeEnabled>True</DynamicRangeEnabled>

    <ExposureAmount>1.25</ExposureAmount>

    <DynamicRangeTransitionMaxScale>2</DynamicRangeTransitionMaxScale>

    <DynamicRangeTransitionMinScale>0.5</DynamicRangeTransitionMinScale>

    <DynamicRangeTransitionTime>0.5</DynamicRangeTransitionTime>

    <DynamicRangeSaturationAmount>1</DynamicRangeSaturationAmount>

    <DynamicRangeDarkenAmount>0.1</DynamicRangeDarkenAmount>

    <DynamicRangeCinematicAmount>0.5</DynamicRangeCinematicAmount>

    <Gravity>1</Gravity>

    <EditorIconScale>1</EditorIconScale>

    <EditorDefaultObjectScale>0.1</EditorDefaultObjectScale>

  </SceneEnvironment>

  <classes>

    <SceneEnvironment fullname="SynapseGaming.LightingSystem.Core.SceneEnvironment" assembly="SynapseGaming-SunBurn-Pro" fullyqualifiedname="SynapseGaming.LightingSystem.Core.SceneEnvironment, SynapseGaming-SunBurn-Pro, Version=2.0.10.1, Culture=neutral, PublicKeyToken=c23c60523565dbfd" />

    <Vector3 fullname="Microsoft.Xna.Framework.Vector3" assembly="Microsoft.Xna.Framework" fullyqualifiedname="Microsoft.Xna.Framework.Vector3, Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553" />

  </classes>

</root>

 

Top 10 Contributor
Posts 5,368
Employee
SunBurn_Studio_Licensee

Hi Duckocide,

Using an old light rig is fine - SunBurn actually loads it as a scene (which replaced light rigs in 2.0), and will automatically upgrade the xml contents to the new scene format next time you save in the editor.  The environment xml is largely the same and only has new properties in 2.0.

Are you unloading the scene interface, resource manager, or frame buffers when switching areas?  This should be fine, but it could affect the post processing if there is a bug of some sort.

Let me know if this helps!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Top 100 Contributor
Posts 42
SunBurn_Community_Licensee

Well, I've found what is causing it. Fixing it is another matter. 

Within the game, I generate a lot of animated textures and so I'm changing GraphicsDevice.RenderTarget a fai bit. This seems to make "mince meat" of the rendering when changing location (new animated textures come and go). I've used the GetRenderTargets() method to get a copy of the RenderTarget bindings before my own SetRenderTarget() call. At the end of my rendering, I do a SetRenderTargets() to (I hoped) return the GraphicsDevice to it's correct target collection config. However, render is still somewhat of a mess, so I'm missing something.

So, assuming the render target handling described above is fine (appreciate advice). When looking at the rendering (on screen), it appears the render is clamping Normal, Specular (I think) and Parallax textures. Removing the post processor, all is well ... 

Any thoughts anyone?    

Top 100 Contributor
Posts 42
SunBurn_Community_Licensee

Following some advice from Bob and others on Twitter (Many thanks). I'm told switching RenderTargets during a frame build for dynamic texture building isn't a good idea. So, I'm going to refactor and introduce a "pre-sunburn frame build" dynamic texture rendering concept. Will take a some time, but will remove any messing about with render targets during a frame build. 

Top 100 Contributor
Posts 42
SunBurn_Community_Licensee

I've now got alternative render target code outside of the Sunburn render sequence, but activating the HDR post processor still causes this odd POINTCLAMP effect for the Normal, Specular (i think) and parallax. Also, when I try to launch the Sunburn editor, I get the following error...

"XNA Framework HiDef profile requires TextureFilter to be Point when using texture format HalfVector4." (even when preferred graphics detail settings are medium).

On the dynamic texture builds. I'm really starting to lose the logic on this. I can't fathom why adding the standard HDR post processor would cause these issues. Removing it and everything appears fine. I'll continue tinkering and report back here anything I find.    

 

Top 10 Contributor
Posts 5,368
Employee
SunBurn_Studio_Licensee

Hi Duckocide,

When you build the dynamic textures are you using effects, spritebatch, or something else?

If using xna stock effects please try the SunBurn replacements (SunBurnBasicEffect, ...), these resolve a bug in XNA 4.0 that can cause the filtering exception and visual issue.

If the xna stock effects are loaded with a model please use SunBurn's replacement xna model processor ("Model - XNA Framework (for SunBurn)") - it loads SunBurnBasicEffect instead of BasicEffect and avoids the xna issue.

Let me know if this helps!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Top 100 Contributor
Posts 42
SunBurn_Community_Licensee

Hi Bob

Yes, I'm using spritebatch to build the dynamic textures (most objects are static textures though). I am using some "stock" XNA component effects (such as Lens Flare). I also draw my own Transparent models using (now) SunBurnBasicEffect after the Sunburn render sequence. 

I've changed all affected models to be "XNA Model (for Sunburn)" content processor and changed the code to cast effects to SunBurnBasicEffect. I still get the same issue if I add HDR post processor. Very strange. Everything gets stuck on Pointclamp textures - Miss my Anisotropic sampling :-P   

 

Top 10 Contributor
Posts 5,368
Employee
SunBurn_Studio_Licensee

Hi Duckocide,

Are you able to isolate the issue in a test project?  If so we can take a look to see what's happening.

Let me know if this helps!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Top 100 Contributor
Posts 42
SunBurn_Community_Licensee

OK. I've got the HDR processor working now. Changing GraphicsDevice RenderTarget (for my own rendering) before calling EndFrameFrameRendering() on SceneInterface and SceneState looks like the cause. 

Just when I thought I understood what I'm doing(!) ... I've now have another issue that I hope someone can help me with. 

My general rendering sequence is as follows 

1. Render my dynamic textures (i.e. mess with RenderTarget etc)

2. Render my Galactic scale models (Sun, earth, Moon etc) ... Does not use Sunburn

3. Clear Depth Buffer 

4. SunBurn Render

5. Render my semi-transparent blended alpha models, quads etc. 

The problem is in 5 where the Depth Buffer appears to have been reset and transparent models are not being occluded by previous Sunburn rendered models? Does HDR post processor do this?

Top 10 Contributor
Posts 5,368
Employee
SunBurn_Studio_Licensee

Hi Duckocide,

The depth buffer is not reset, instead it's replaced with the back buffer's depth buffer.

For the HDR processor to work everything between BeginFrameRendering() and EndFrameRendering() (eg: the entire scene) is rendered to a render target.  That target is then rendered (using the HDR effect) to the back buffer.

The depth information created when the scene is rendered only exists in the render target's depth buffer, when the device switches to the back buffer the scene's depth information is no longer available.

However the good news is you probably want the HDR to affect transparent objects, so moving the rendering of transparent objects in between Render() and EndFrameRendering() will solve both problems.

Let me know if this helps!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Top 100 Contributor
Posts 42
SunBurn_Community_Licensee

Yes, that explains it. With the EndFrame after the Transparent renders, all is well ;-)

Thanks. 

Page 1 of 1 (13 items) | RSS