Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flat colors render mode #524

Closed
ghost opened this issue Dec 3, 2019 · 10 comments
Closed

Flat colors render mode #524

ghost opened this issue Dec 3, 2019 · 10 comments

Comments

@ghost
Copy link

ghost commented Dec 3, 2019

System information

  • SolveSpace version: 3.0~690f87c
  • Operating system: Debian 9.x stretch (x86_64)

Expected behavior

Add an option "Show flat color view of solid model" to enable "flat colors" render: (direct RGB values without any gradient shades; independent of light direction)

Actual behavior

Actual render has gradient shades, according to default "light direction" setting.

pic.1

pic.2

And it's non-trivial task to get near "flat colors" render in SolveSpace.

pic.3

As workaround I use next settings:

light direction                 intensity     
  #0    ( 0.00, 0.00, 10000.00)[c]  1.00 [c]
  #1    ( 0.00, 0.00, 0.00)[c]  0.50 [c]

(10000 used for #0 light source Z, because with 10, 100 and 1000 value gradient shades still appear visually)

pic.4

Additional information

As side note, seems like there no way to reset "light direction" setting to default values:

light direction                 intensity     
  #0    (-1.00, 1.00, 0.00)[c]  1.00 [c]
  #1    ( 1.00, 0.00, 0.00)[c]  0.50 [c]

So, it would be good to add button for reset "light direction" too.

pic.5

@ghost
Copy link
Author

ghost commented Dec 3, 2019

Think, such mode would be especially useful for export 2D view to PDF and SVG.

@ghost
Copy link
Author

ghost commented May 14, 2020

I just wondered when tried to place reference image behind solid model while "Hide shaded view of solid model" + "Don't draw occluded lines" (or "Stipple occluded lines") modes are toggled — it looks like "flat render" which just use background color for as flat color fill for all triangle meshes.

pic.1

If toggle occluded lines mode to "Draw occluded lines" this effect disappear:

pic.2

If so, maybe this is the start point to requested "Show flat color view of solid model" to be added as 3rd level mode to shaded view modes button?

@phkahler
Copy link
Member

One option is to set the intensity of both light sources to 0.0. There is still an ambient light which will show the model but will not be as bright as you may want (white shows as a uniform grey). Proper flat shading might just be turning off the existing lights and changing the ambient brightness which is no a UI option.

@phkahler
Copy link
Member

@Symbian9 Digging all the way down to the shader code it looks like simply setting the ambient lighting to 1.0 would effectively disable the 2 lights and produce the desired effect. Unfortunately that parameter isn't in the UI at the moment.

@ghost
Copy link
Author

ghost commented Jul 13, 2020

simply setting the ambient lighting to 1.0 would effectively disable the 2 lights and produce the desired effect. Unfortunately that parameter isn't in the UI at the moment.

Nice.

@phkahler, I hope, you would be able to solve this issue & add some UI controls for enhanced control for render parameters into "Property Browser".

@phkahler
Copy link
Member

phkahler commented Jul 15, 2020

@whitequark what would you think of automatically setting the ambient lighting to 1.0 when both lights are set to zero brightness? That would not involve a UI change but should provide flat coloring if wanted.

@Evil-Spirit Related to shading, what is the coordinate system for the lights? I thought the position was x,y,z with +x to the right, +y up and +z out of the screen. But when mucking about with the shader code it seems there might be some sign flipping going on between the UI and the shader, is that correct?

@Symbian9 what is wrong with your solution to place the light at 10,000? Is it just the lack of any way to reset it to normal without writing it down or remembering?

@whitequark
Copy link
Contributor

whitequark commented Jul 15, 2020

what would you think of automatically setting the ambient lighting to 1.0 when both lights are set to zero brightness?

That seems really hard to discover. I think a checkbox like [✔] Flat shading that hides the configuration for the lights if set would work fine. The implementation could be the same otherwise.

@Evil-Spirit
Copy link
Collaborator

@phkahler

Related to shading, what is the coordinate system for the lights

Actually don't remember. One of the lights direction probably is in camera space.

@ghost
Copy link
Author

ghost commented Jul 16, 2020

what is wrong with your solution to place the light at 10,000? Is it just the lack of any way to reset it to normal without writing it down or remembering?

Beside it looks as needed on screen & on export 2D view to PNG, placing the light at Z: 10000 would not provide "truly" flat colors & on export 2D view into PDF & SVG with "🗹 export shaded 2D triangles it still exported with shaded colors.

pic.1

So my solution with 10000 could not fully solve this issue.

That seems really hard to discover. I think a checkbox like 🗹 Flat shading that hides the configuration for the lights if set would work fine. The implementation could be the same otherwise.

@whitequark, it would be great! Also, on implementing this solution add related CLI option too, please!

@phkahler
Copy link
Member

I think a checkbox like [✔] Flat shading that hides the configuration for the lights if set would work fine.

@whitequark I'm leaning more towards adding the Ambient parameter to the lighting config. I've also been experimenting with shaders and may have another parameter at some point.

phkahler added a commit to phkahler/solvespace that referenced this issue Jul 17, 2020
phkahler added a commit to phkahler/solvespace that referenced this issue Jul 18, 2020
phkahler added a commit to phkahler/solvespace that referenced this issue Jul 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants