For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Shadows

Jake Stewart's picture
Forums: 

Hi,

I'm currently trying to add Ray tracing Shadows to my project but am having quite a bit of difficulty in doing so. So far I've been using the provided source demos and the online documentation to enable Shadows but I'm having a hard time figuring out how to actually turn it on or get it working.

At the moment I've used the following to enable anti-aliasing which works as intended but the only things I've found relating to shadows are the RenderParams.IsShadowEnabled = True; and that seems to do nothing.

	GetDocument()->GetAISContext()->CurrentViewer()->InitActiveViews();
	Handle(V3d_View) aView = GetDocument()->GetAISContext()->CurrentViewer()->ActiveView();
	Graphic3d_RenderingParams& RenderParams = aView->View()->ChangeRenderingParams();

	if (IsSamplingOn) 
		RenderParams.NbMsaaSamples = 32;
	else 
		RenderParams.NbMsaaSamples = 16; 

	RenderParams.Method = Graphic3d_RM_RAYTRACING;
	RenderParams.IsShadowEnabled = true;
	RenderParams.IsReflectionEnabled = true;
	GetDocument()->GetAISContext()->UpdateCurrentViewer();

I've been looking around and haven't seen anything else regarding the use of shadows in OpenCascade, so was hoping for a bit of advice on where I can get started.

Cheers

Kirill's picture

When you having some questions related to visualization, it is always better sharing some screenshots demonstrating the issue.

To see shadows in the viewer, you also need defining proper light sources.
E.g., headlight might cast shadows in direction from the eye, so that although shadows are rendered, they are just never seen.
Also, perspective projection might be more illustrative than orthographic.

Jake Stewart's picture

Hi,

Sorry for the late reply, but I have managed to get a a reasonable screenshot of a board demonstrating the issue.

From the design you can see the light source is coming from the left hand side (Indicated by the red arrow) and is casting shade over components of the board as shown in the two smaller red circles. However as seen in the larger red circle a shadow isn't coming off the component towards the text "J15". 

To narrow it down entirely I've used a single Directional Light using specified position coordinates, and I have made sure the view is Prospective not Orthographic. I have also attempted to use a positional light but the light is too dim to be able to see if a shadow would be produced (Can you increase the brightness?) I'm not 100% on the eye situation as I have taken over this project from someone else. So I'm in and out on learning what needs to be done.

Cheers

Attachments: 
Jake Stewart's picture

Hi,

Forgot to mention this project is utilsing Opencascade 7.2.0. Not sure if that makes any immediate effects in terms of Shadowing ability over most other versions of the Opencascade toolkit.

Kirill's picture

Make sure you have evaluated and checked sample "Visualization -> Ray tracing" coming with Draw Harness - it displays a bottle on a desk with enabled shadows.
If sample works on your machine, you can look into script and underlying Draw Harness commands implementation to check what could be missing in your code.

You can also check if Ray Tracing works on your workstation correctly by opening your model in Open CASCADE CAD Assistant (Ray Tracing and its options can be managed in application settings).

Jake Stewart's picture

Great shout on the CAD Assistant, didn't even think to try that on the designs. So it works flawlessly on the CAD assist, and I've tested the sample Harness and that is working so my code is definitely at fault. I'll keep digging into that and hopefully come back with something

Cheers