Skip to content

Built-in fog #4

@ghost

Description

All shaders that are applied to in-game objects will require this
functionality. It should be possible, through a general shader API or a
specific define, to provide this functionality to any shader willing to use
it.
Example:
gl_FragCoord = APPLY_FOG(color);

where APPLY_FOG would be a define that either returns the provided color
(if fog is disabled) or apply the fogging.


How is this information going to be exposed to an arbitrary shader?
One solution is to define UserWorldParameters inside the material which would specify
what kind of user globals the shader can take. The world uniform updater checks which
are exposed in the system and if there are any matches between the material and
exposed vars then they are sent as uniforms.

How will these globals be exposed and what classes are allowed to expose them?
The class responsible for assigning these globals to the materials will contain them
and accept requests from user code to add them to the list. Classes like
SceneProcessor should be allowed to set them. Singlepass shadow-supporting shaders
will accept ug_ShadowMap[] for example, ShadowSceneProcesor generates shadow maps for
scene and exposes ug_ShadowMap[].

What about fog?
This is a fixed-pipeline state that is stored inside RenderState. How will the user
specify fog? In the Material definition, RenderState ONLY contains whether the
material should be fogged or not. No other fog-related state is allowed to be set
inside the material. There must be a way to set the other fog-state through the
Renderer since it may or may not be using fixed-pipeline. Renderers only supporting
shaders will set the g_FogParams and g_FogColor depending on the params the user
specified. While Renderers only supporting fixed-pipeline will set these parameters
using glFog and such and achieve the same result.
Reformulation: Material techniques that use shaders must expose g_FogParams and
g_FogColor, while Material techniques that do not use shaders must specify Fog Off
inside the RenderState block to disable fogging for the material.

Reference on googlecode: https://code.google.com/p/jmonkeyengine/issues/detail?id=64

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions