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

Additional Shaders and Graphical Effects #112

Open
wants to merge 56 commits into
base: master
Choose a base branch
from

Conversation

Zabot
Copy link

@Zabot Zabot commented Aug 21, 2016

Product of Google Summer of Code 2016. The last summer of code commit was f89c2ad.

More config, usage, and demo information coming soon.

Procedural Textures

Texture layers can be configured to use Perlin noise instead of reading from a file. This effect allows surfaces to still have a textured, visually interesting appearance, without the obvious wrapping, scaling, and repeating that occurs when using a static texture.

Materials can also be configured to use Perlin noise to calculate surface normal vectors for lighting calculations, producing effects like water ripples and even more interesting texture, though this feature is still experimental.

Config Parameters

  • material_NAME_textureN_procedural (default false) -- Enables a procedural texture for this layer.
  • material_NAME_textureN_baseColor (default #FFFFFF) -- The base color of the layer. The color of the layer will vary, centered around this value.
  • material_NAME_textureN_deviation (default #969664) -- The maximum difference between the final color of a pixel and baseColor on each channel.
  • material_NAME_textureN_xScale and material_NAME_textureN_yScale (default 1.0) -- The relative frequency of the noise in the x and y direction. Higher values produce higher frequency noise.
  • material_NAME_normalDeviation (default 0.0) -- The maximum deviation of a perceived normal from the true normal of a plane. Higher values produce a more extreme effect.

Procedural Sky

Instead of a black background, the scene can be filled with a clear sky, generated by simulating the scattering caused by the atmosphere. This sky is then saved as a skybox, so the performance impact is minimal. Generating the sky procedurally allows the user to see the sun move across the sky, as well as produce sunsets. The sky is can also be used to determine the color of the sunlight in the scene, causing an orange hue to be splashed across the scene at sunset.

Config Parameters

  • skybox (default "none") -- The type of skybox to use. Set to procedural for the procedural sky, and static to provide a list of images to use.
  • skybox_posx, skybox_negx, ... -- The images to use for each face of the skybox if you are using a static skybox. Note that useEnvLighting will be disabled if you use a static skybox.
  • timeAndDate (default "Jan 1 12:00") -- The time to use for calculating the position of the sun in the sky.
  • scatterColor (default #8CB3CC) -- The ambient sky color. The amount of light scattered from each channel by the sky. The higher a channel is, the more of that color you see when the sun is high in the sky, and the less you see when the sun is lower in the sky.
  • useEnvLighting (default false) -- Use the color of the sky to calculate the ambient scene lighting.

Multiple Light Sources

Street lamps now have an associated point light source on top. There aren't any associated configuration options, but additional light sources can be added to any object with Target.drawLight(). Lights can be individually toggled in the shader by flipping the last bit of lightIndex. As of now, all lights are turned on and off at the same time of day, but with some additional work, a staggered effect could be produced.

Reflections

Materials can be configured to be reflective. Reflective materials will reflect both the skybox, and the world geometry, depending on configuration options. If world geometry reflection is enabled, cubemaps will be rendered at the height of the viewer camera in each reflective object, and those cubemaps used to calculate the reflection of the world geometry on the surface.

Another experimental feature, planar reflections, is also possible for flat objects on the XZ plane with height Y = 0 (primarily water sources). The camera is reflected across the Y = 0 plane, and the view from the other side is rendered to a texture. That texture is then used to calculate the true reflections off the planar surface. This feature may cause significant performance impacts as the scene has to be rendered twice.

Config Parameters

  • showSkyReflections (default false) -- Enables reflections of the skybox off reflective surfaces.
  • geomReflections (default "cubemap") -- Controls how reflections of world geometry are calculated. As of now the only options are none and cubemap. none disables world geometry reflections, and cubemap renders a cubemap of the world from inside each reflective object to calculate reflections from.
  • showGroundReflections (default false) -- Enables planar reflections where possible.
  • material_NAME_reflectance (default 0.0) -- Sets how much of the material remains visible on a reflective surface. 1.0 means the surfaces reflects perfectly and none of the original material is visible, 0.0 means the surface is not reflective.
  • material_NAME_textureN_reflmap (default false) -- Indicates that a texture is a reflectance map. Places where the texture is black will be reflective, while white indicates no reflection.

Known Bugs

  • Reflective objects are not reflective if geometry reflection is enabled
  • Reflections are not rendered when SSAO is enabled
  • Using geometry reflections with reflectance maps causes exceptions
  • Shadows do not move to reflect position of the sun
  • Normals behave unusually when using procedural normals
  • Ground reflections are drawn using an orthographic projection
  • Enabling SkyboxView while no texture is configured causes an exception
  • Enabling cubemap geometry reflections causes the rendered scene to shrink to the size of the cubemap
  • Reflectance maps have to be the same size as the texture on layer 1

Zabot added 30 commits May 24, 2016 19:28
Only one reflection map is generated per building, instead of one per
primitive.
Reflection maps are updated whenever the view changes.
@tordanik
Copy link
Owner

Thanks for the pull request, great work overall! I'm still going through it, but here's a few issues I've noticed so far:

  • Enabling the SkyboxView when no skybox texture is configured causes an exception. Ideally, this option should be disabled (greyed out) if that is the case.
  • The Sky class has static information that prevents using it in a multithreaded way (which is not a problem now, but will be in the future). Perhaps it's possible to integrate the functionality more elegantly?

@zamasu
Copy link

zamasu commented Aug 23, 2016

please use JTattoo or somthing like his to change to custome the UI it could be better @Zabot

@zamasu
Copy link

zamasu commented Aug 25, 2016

And JOGLTargetShader.java doesn't work ,

@Zabot
Copy link
Author

Zabot commented Aug 25, 2016

@klobot, can you describe what is happening?

@zamasu
Copy link

zamasu commented Aug 26, 2016

An execption occured , the programm started then after few second is closing ,
SkyShader skyShader; is not used at all ? ont the class ?

@zamasu
Copy link

zamasu commented Aug 29, 2016

problem solved ,it was crazy easy , you just forgot to debug but it works on mine now

@Zabot
Copy link
Author

Zabot commented Aug 29, 2016

@klobot That's great! Can you post a gist or a commit with your fixes so I can merge them?

@tordanik tordanik mentioned this pull request Jan 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants