View Issue Details

IDProjectCategoryView StatusLast Update
0032606Open CASCADEOCCT:Visualizationpublic2023-03-19 18:18
ReporterageAssigned Tosmoskvin 
PrioritynormalSeverityfeature 
Status closedResolutionfixed 
Product Version7.5.0 
Target Version7.7.0Fixed in Version7.6.1 
Summary0032606: Visualization - add a shader for sky V3d_View::BackgroundSkydome()
DescriptionIt is needed to add an option to show shader-generated sky as a background
Steps To Reproducenot required
TagsNo tags attached.
Test case numberopengl background skydome

Attached Files

  • Sunset_With_Clouds2.PNG (602,767 bytes)

Activities

git

2021-10-18 07:26

administrator   ~0104693

Branch CR32606 has been created by CheskoArt.

SHA-1: 13c39fc8f01325cd116de96ea45196bf77cf10be


Detailed log of new commits:

Author: achesnok
Date: Fri Oct 15 01:50:13 2021 +0300

    Added skydome background

kgv

2021-10-18 10:39

developer   ~0104694

> Added skydome background CR32606
Please don't forget that first commit in git branch should start with a full bug title, e.g.
> 0032606: Visualization - add a shader for sky

kgv

2021-10-18 18:35

developer   ~0104716

+Standard_EXPORT Standard_Boolean OpenGl_BackgroundArray::createSkydomeArray() const
...
@@ -580,7 +649,7 @@ void OpenGl_BackgroundArray::Render (const Handle(OpenGl_Workspace)& theWorkspac
     if (aCtx->Camera()->Tile().IsValid())
     {
       aWorldView.SetDiagonal (OpenGl_Vec4 (2.0f / aTileSize.x(), 2.0f / aTileSize.y(), 1.0f, 1.0f));
-      if (myType == Graphic3d_TOB_GRADIENT)
+      if (myType == Graphic3d_TOB_GRADIENT || myType == Graphic3d_TOB_SKYDOME)

As far as I can see, the skybox is rendered as a cube.
Could you try reusing OpenGl_BackgroundArray::createCubeMapArray()?
I guess the same array could be initialized.
And also use Graphic3d_TOB_CUBEMAP rendering path instead of Graphic3d_TOB_GRADIENT to properly handle stereoscopic / VR output.

+Standard_EXPORT Standard_Boolean OpenGl_BackgroundArray::createSkydomeArray() const

Standard_EXPORT is normally expected only in header files.

git

2021-10-19 02:30

administrator   ~0104722

Branch CR32606 has been updated forcibly by CheskoArt.

SHA-1: 681ad4b3bb4ea1f6f96c0671ab9ad76732c769bf

CheskoArt

2021-10-19 02:33

developer   ~0104723

Work in progress yet. Ok, i will try to reuse Cubemap.

CheskoArt

2021-10-19 02:33

developer  

Sunset_With_Clouds2.PNG (602,767 bytes)

git

2021-11-06 17:46

administrator   ~0105052

Branch CR32606 has been updated forcibly by CheskoArt.

SHA-1: dab11880a9e627506cbac89dd48010bd209ccc59

git

2021-11-06 17:55

administrator   ~0105053

Branch CR32606 has been updated forcibly by CheskoArt.

SHA-1: 9fe553b61c9dd78211198f00ee9350dca1ce0523

git

2021-11-06 18:39

administrator   ~0105054

Branch CR32606 has been updated forcibly by CheskoArt.

SHA-1: f7fedc19a7bf889b207e9d1fe76e280c863d3366

git

2021-11-11 00:01

administrator   ~0105093

Branch CR32606 has been updated forcibly by CheskoArt.

SHA-1: 4cc6b85278a0e23c2b42c5b12a46ecb98a048516

CheskoArt

2021-11-11 02:12

developer   ~0105098

Please review the patch.
Test results: http://jenkins-test-12.nnov.opencascade.com/view/CR32606-master-achesnok/view/ALL/

kgv

2021-11-11 12:37

developer   ~0105118

  - Added new 'vskydome' DRAW command.

It would be better moving `vskydome` functionality directly to `vbackground`.

+  if (theSunDirection.Modulus() < Precision::Confusion())
+    mySunDirection = Graphic3d_Vec3(0.0f, 1.0f, 0.0f);

It is preferred putting if/else body into figure brackets even for single-liners.

+  if (theSunDirection.Modulus() < Precision::Confusion())
+    mySunDirection = Graphic3d_Vec3(0.0f, 1.0f, 0.0f);
+
+  mySunDirection = theSunDirection.Normalized();

mySunDirection initialization to (0,1,0) has no effect.

+  //! Set sun direction (must be not null-length vec).
+  //! Sun direction with negative Y component represents moon with (-X, -Y, -Z) direction.
+  Standard_EXPORT void SetSunDirection (const Graphic3d_Vec3& theSunDirection);

Please use gp_Dir here as a more straightforward interface (it is not a performance-critical part).

+  Graphic3d_Vec3     SunDirection() const { return mySunDirection; }

Please return `const &`.

+  Standard_ShortReal Foggy() const { return myHaze; }
+  Standard_ShortReal Cloudy()  const { return myCloudy; }

I would expect these parameters being named "fogginess" and "cloudiness".
Better using the same name for class properties instead of "myHaze".

+  //! @param theCloudy [in] cloud intensity, 0.0 means no cloud at all and 1.0 - high clody.

Please use "@param[in] theCloudy" syntax for Doxygen.

+  //! Get cloud intensity.
+  Standard_ShortReal Cloudy()  const { return myCloudy; }

Please document valid range of properties and their default values.

+  //! Get time (parameter) of cloud simulation.
+  Standard_ShortReal TimeParameter() const { return myTime; }

Please document time units, it's meaning and valid range.

+#include "Aspect_SkydomeBackground.hxx"

Angle brackets.

+  myHaze = theFoggy < 0.0f ? 0.0f : theFoggy;

It is better raising an exception on invalid input rather than silently ignoring it.

+
+

Redundant double empty line.

+Standard_EXPORT Handle(Graphic3d_ShaderProgram) Graphic3d_ShaderManager::getBgSkydomeProgram() const

Standard_EXPORT is normally not supposed to be used in .cxx file - only in .hxx at method declaration.

+    OpenGl_FrameBuffer::BufferDump(aCtx, aFBO, *aSide, Graphic3d_BufferType::Graphic3d_BT_RGBA);

OpenGl_FrameBuffer::BufferDump() is very expensive.
It is desired performing skydom rendering directly into CubeMap texture.
Take a look onto OpenGl_PBREnvironment as an example of code creating FBO for a cubemap texture.

+float smoothStarField (vec2 theSamplePos)

`in` attribute is missing.

+float smoothNoise (vec3 p)
+{
+    vec3 i = floor (p);

Broken indentation. Variable names do not meet Coding Style.

+float clouds (in vec3 aTs, in float theTime)

theTs.

kgv

2021-11-11 12:41

developer   ~0105121

+vskydome -size 128 -cloud 0.3 -sunDir 1.0 0.5 0.0
+vbackground -sky
+vaxo
+vdump $imagedir/${casename}.png

Please extend test case with more variations of parameters.

kgv

2021-11-11 14:32

developer   ~0105129

git

2021-12-01 01:37

administrator   ~0105549

Branch CR32606 has been updated forcibly by CheskoArt.

SHA-1: 3a6069c5d6f81fe640632ef62373d2ea05d1bfad

CheskoArt

2021-12-01 01:40

developer   ~0105550

Fixed all remarks. Please review patch.

git

2021-12-28 13:44

administrator   ~0106228

Branch CR32606_1 has been created by kgv.

SHA-1: 00d1afb5ecd5ec008e2d47cd3ffe8533fdc3c94c


Detailed log of new commits:

Author: achesnok
Date: Fri Oct 15 01:50:13 2021 +0300

    0032606: Visualization - add a shader for sky V3d_View::SkydomeAspect()
    
    Introduced V3d_View::SkydomeAspect() property for generating skydome cubemap environment.
    Skydome features: day/night cycle, 2 types of clouds, atmosphere, water surface, stars, fog.

git

2021-12-28 14:54

administrator   ~0106229

Branch CR32606_1 has been updated forcibly by kgv.

SHA-1: a18cf43e1eec6880e7f26a5025c89a058c1dbf22

git

2021-12-28 15:08

administrator   ~0106230

Branch CR32606_1 has been updated forcibly by kgv.

SHA-1: b39817a280d2935063614a385c36f4739951d28a

kgv

2021-12-28 15:29

developer   ~0106232

It's strange, but ANGLE / OpenGL ES implementation compiles new shader the whole minute, though a normal OpenGL driver do that im Augenblick...

git

2021-12-28 16:39

administrator   ~0106234

Branch CR32606_1 has been updated forcibly by kgv.

SHA-1: 9f2bde29d4895a05fc6dc8e0e40f95715377f750

CheskoArt

2021-12-28 17:00

developer   ~0106235

I have a suspicion that this is because of loop unrolling. Two nested 'for' loops lead to THE_NbSamples * THE_NbSamplesLigth iterations. I've noticed that decreasing value of these parameters speeds up compilation time. It may be worth to try to prevent unrolling somehow.
I found out that GLSL ES spec forces iteration count to be constant expression and not all driver vendors support loop unrolling '#pragama' directive.

kgv

2021-12-28 19:32

developer   ~0106236

Please raise the patch
- OCCT: branch CR32606_1.

http://jenkins-test-occt/view/CR32606_1-master-KGV/

smoskvin

2021-12-31 12:49

administrator   ~0106253

Combination -
OCCT branch : IR-2021-12-30
master SHA - 16a263dc17600ac13a5110bd7028ba558d1a0700
49e51745631c52b6c452c65adae4d6dfa21a1b1e
Products branch : IR-2021-12-30 SHA - fe496634abbd6a631b6f674703746ef8605cfe87
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Debian80-64:
OCCT
Total CPU difference: 18220.12000000046 / 18175.980000000385 [+0.24%]
Products
Total CPU difference: 11659.240000000125 / 11591.590000000113 [+0.58%]
Windows-64-VC14:
OCCT
Total CPU difference: 19997.15625 / 19974.59375 [+0.11%]
Products
Total CPU difference: 13120.265625 / 13088.65625 [+0.24%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention

git

2022-01-02 13:36

administrator   ~0106256

Branch CR32606 has been deleted by mnt.

SHA-1: 3a6069c5d6f81fe640632ef62373d2ea05d1bfad

git

2022-01-02 13:36

administrator   ~0106257

Branch CR32606_1 has been deleted by mnt.

SHA-1: 9f2bde29d4895a05fc6dc8e0e40f95715377f750

Related Changesets

occt: master 16a263dc

2021-10-15 01:50:13

achesnok


Committer: smoskvin Details Diff
0032606: Visualization - add a shader for sky V3d_View::BackgroundSkydome()

Introduced V3d_View::SkydomeAspect() property for generating skydome cubemap environment.
Skydome features: day/night cycle, 2 types of clouds, atmosphere, water surface, stars, fog.
Affected Issues
0032606
add - src/Aspect/Aspect_SkydomeBackground.cxx Diff File
add - src/Aspect/Aspect_SkydomeBackground.hxx Diff File
mod - src/Aspect/FILES Diff File
mod - src/Graphic3d/Graphic3d_CView.cxx Diff File
mod - src/Graphic3d/Graphic3d_CView.hxx Diff File
mod - src/Graphic3d/Graphic3d_ShaderManager.cxx Diff File
mod - src/Graphic3d/Graphic3d_ShaderManager.hxx Diff File
mod - src/OpenGl/OpenGl_ShaderManager.cxx Diff File
mod - src/OpenGl/OpenGl_ShaderManager.hxx Diff File
mod - src/OpenGl/OpenGl_View.cxx Diff File
mod - src/OpenGl/OpenGl_View.hxx Diff File
mod - src/Shaders/FILES Diff File
add - src/Shaders/Shaders_SkydomBackground_fs.pxx Diff File
add - src/Shaders/SkydomBackground.fs Diff File
mod - src/V3d/V3d_View.cxx Diff File
mod - src/V3d/V3d_View.hxx Diff File
mod - src/ViewerTest/ViewerTest_ViewerCommands.cxx Diff File
add - tests/opengl/data/background/skydome Diff File

Issue History

Date Modified Username Field Change
2021-10-04 14:38 age New Issue
2021-10-04 14:38 age Assigned To => CheskoArt
2021-10-11 14:47 CheskoArt Status new => assigned
2021-10-18 07:26 git Note Added: 0104693
2021-10-18 08:46 CheskoArt File Added: Sunset.PNG
2021-10-18 10:39 kgv Note Added: 0104694
2021-10-18 18:35 kgv Note Added: 0104716
2021-10-19 02:30 git Note Added: 0104722
2021-10-19 02:33 CheskoArt Note Added: 0104723
2021-10-19 02:33 CheskoArt File Deleted: Sunset.PNG
2021-10-19 02:33 CheskoArt File Added: Sunset_With_Clouds2.PNG
2021-11-06 17:46 git Note Added: 0105052
2021-11-06 17:55 git Note Added: 0105053
2021-11-06 18:39 git Note Added: 0105054
2021-11-11 00:01 git Note Added: 0105093
2021-11-11 02:12 CheskoArt Note Added: 0105098
2021-11-11 02:12 CheskoArt Assigned To CheskoArt => kgv
2021-11-11 02:12 CheskoArt Status assigned => resolved
2021-11-11 12:37 kgv Note Added: 0105118
2021-11-11 12:38 kgv Assigned To kgv => CheskoArt
2021-11-11 12:38 kgv Severity minor => feature
2021-11-11 12:38 kgv Status resolved => assigned
2021-11-11 12:41 kgv Note Added: 0105121
2021-11-11 14:32 kgv Note Added: 0105129
2021-12-01 01:37 git Note Added: 0105549
2021-12-01 01:40 CheskoArt Note Added: 0105550
2021-12-01 01:40 CheskoArt Assigned To CheskoArt => kgv
2021-12-01 01:40 CheskoArt Status assigned => resolved
2021-12-28 13:44 git Note Added: 0106228
2021-12-28 14:54 git Note Added: 0106229
2021-12-28 15:08 git Note Added: 0106230
2021-12-28 15:08 kgv Summary Visualization - add a shader for sky => Visualization - add a shader for sky V3d_View::BackgroundSkydome()
2021-12-28 15:08 kgv Test case number => opengl background skydome
2021-12-28 15:29 kgv Note Added: 0106232
2021-12-28 16:39 git Note Added: 0106234
2021-12-28 17:00 CheskoArt Note Added: 0106235
2021-12-28 19:32 kgv Assigned To kgv => bugmaster
2021-12-28 19:32 kgv Status resolved => reviewed
2021-12-28 19:32 kgv Note Added: 0106236
2021-12-31 12:49 smoskvin Status reviewed => tested
2021-12-31 12:49 smoskvin Note Added: 0106253
2022-01-02 13:24 smoskvin Changeset attached => occt master 16a263dc
2022-01-02 13:24 smoskvin Assigned To bugmaster => smoskvin
2022-01-02 13:24 smoskvin Status tested => verified
2022-01-02 13:24 smoskvin Resolution open => fixed
2022-01-02 13:36 git Note Added: 0106256
2022-01-02 13:36 git Note Added: 0106257
2023-03-19 18:18 vglukhik Status verified => closed
2023-03-19 18:18 vglukhik Fixed in Version => 7.6.1