Commit graph

75 commits

Author SHA1 Message Date
Areloch
ee6d9961e3 Merge pull request #1582 from Azaezel/SubSurf
Reimplements a form of subsurface scattering
2016-05-25 13:35:44 -05:00
Azaezel
d79b9a2988 removes w=z trick (was causing fisheye, effectively) 2016-05-18 06:38:13 -05:00
Azaezel
88356ae37f subsurface followup: cleanups and corrections for vectorlightP, fillins for spot, point, and opengl equivalents 2016-04-15 16:06:10 -05:00
Azaezel
00cc949011 reimplements a form of subsurface scattering 2016-04-15 00:20:55 -05:00
Areloch
60ffb8e902 Merge pull request #1568 from Azaezel/soSensitive9001
case sensitivity typofix
2016-04-10 09:28:47 -05:00
Azaezel
df3cb6cb44 case sensitivity typofix 2016-03-25 18:46:25 -05:00
rextimmy
3a9b50f702 Direct3D11 common shader changes. 2016-03-20 21:50:21 +10:00
Azaezel
1c854b6009 opengl crashfix pow(x,y) needed to be passed matching vartypes. 2016-02-29 04:17:42 -06:00
Areloch
c0e29d4a22 Correction for 2 of the render bin settings, as well as correcting the water shader over-exposing it's reflections. 2016-02-27 13:13:12 -06:00
Azaezel
8c5810adad The final step (barring any overlooked missing bits, requested refactors, and of course, rolling in dependencies already submitted as PRs) consists of:
renderPrePassMgr.cpp related:
A) shifting .addFeature( MFT_XYZ); calls from ProcessedShaderMaterial::_determineFeatures to ProcessedPrePassMaterial::_determineFeatures
B) mimicking the "// set the XXX if different" entries from RenderMeshMgr::render in RenderPrePassMgr::render
C) fleshing out ProcessedPrePassMaterial::getNumStages() so that it shares a 1:1 correlation with ProcessedShaderMaterial::getNumStages()
D) causing inline void Swizzle<T, mapLength>::ToBuffer( void *destination, const void *source, const dsize_t size )  to silently fail rather than fatally assert if a source or destination buffer is not yet ready to be filled. (support for #customTarget scripted render targets)

Reflections:
A) removing reflectRenderState.disableAdvancedLightingBins(true); entries. this would otherwise early out from prepass and provide no color data whatsoever.
B) removing the fd.features.addFeature( MFT_ForwardShading ); entry forcing all materials to be forward lit when reflected.
C) 2 things best described bluntly as working hacks:
C1) when reflected, a scattersky is rotated PI along it's z then x axis in order to draw properly.
C2) along similar lines, in terraincellmaterial, we shut off culling if it's a prepass material.

Skies: scattersky is given a pair of rotations for reflection purposes, all sky objects are given a z value for depth testing.
2016-02-16 02:50:49 -06:00
Azaezel
5ed06fff9d Script:
by and large, Opengl branch compatibility alterations, though do again note the inclusion of
   sampler["lightBuffer"] = "#lightinfo";
   sampler["colorBuffer"] = "#color";
   sampler["matInfoBuffer"] = "#matinfo";

and
   samplerNames[5] = "$lightBuffer";
   samplerNames[6] = "$colorBuffer";
   samplerNames[7] = "$matInfoBuffer";
entries. This is where the engine knows to pass along a given rendertarget for input into a predefined shader, as opposed to the prior phase's output to targets within procedural ones.

Shader:
the XXXLight.hlsl/glsls account for alterations in inputs, check for emissive and translucency, apply Felix's Normal Mapped Ambient. and pass the results along to  AL_DeferredOutput for final computation before returning the result.
the lighting.hlsl/.glsl consissts of removal of the overridden engine-specific phong specular variant, and defines the  AL_DeferredOutput  method, which equates to the previously used pixspecular feature defined along the lines of
http://books.google.com/books?id=GY-AAwAAQBAJ&pg=PA112&lpg=PA112&dq=blinn+phong+specular+gloss+hlsl&source=bl&ots=q9SKJkmWHB&sig=uLIHX10Zul0X0LL2ehSMq7IFBIM&hl=en&sa=X&ei=DbcsVPeWEdW1yASDy4LYDw&ved=0CB4Q6AEwAA#v=onepage&q=gloss%20&f=false

also includes visualizers

Long term impact: This area, along with the \game\shaders\common\lighting\advanced\lightingUtils.hlsl/.glsl pair will be where we plug in properly attenuated Cook-Torrence later, presuming the impact is not to hefty.
2016-02-16 02:29:54 -06:00
Azaezel
196b214eae engine:
defines and alters a series of material features for deferred shading in order to define a fully fleshed out multiple render target gbuffer patterned after the general principles outlined http://www.catalinzima.com/xna/tutorials/deferred-rendering-in-xna/creating-the-g-buffer/ (though I cannot stress enough *not* using the identical layout)

script:
removes dead material features (ie: those that never functioned to begin with)

shader:
bool getFlag(float flags, int num) definition for retreiving data from the 3rd (matinfo) gbuffer slot's red channel (more on that shortly)

purpose:
_A)_ Small primer on how material features function:
When a https://github.com/GarageGames/Torque3D/search?utf8=%E2%9C%93&q=_determineFeatures call is executed, certain conditions trigger a given .addFeature(MFT_SOMEFEATURE) call based upon material definition entries, be it a value, a texture reference, or even the presence or lack thereof for another feature. In general terms, the first to be executed is ProcessedShaderMaterial::_determineFeatures followed by ProcessedPrePassMaterial::_determineFeatures. The next commit will provide the bindings there. For now it's enough to understand that one of those two will trigger the shadergen subsystem, when rendering a material, to check it's associated list of features and spit out a shader if one is not already defined, or reference a pre-existing one that includes codelines determined by that list of features.

Relevant execution of this is as follows:
DeclareFeatureType( MFT_DeferredDiffuseMap ); - Name
ImplementFeatureType( MFT_DeferredDiffuseMap, MFG_Texture, 2.0f, false ); - Codeline Insertion Order
FEATUREMGR->registerFeature( MFT_DeferredDiffuseMap, new DeferredDiffuseMapHLSL ); - Hook to class which actually generates code
alternately    FEATUREMGR->registerFeature( MFT_Imposter, new NamedFeatureHLSL( "Imposter" ) ); - a simple feature that serves no purpose further than as a test of it's existence (to modify other features for instance)

class DeferredDiffuseMapHLSL : public ShaderFeatureHLSL - Class definition
{
getName  -embeded in the proceedural shader as a remline both up top and before actual code insertions
processPix  - pixel shader codeline insertions
getOutputTargets - used to determine which buffer is written to (assumes only one. depending on branched logic, older features that may be run for either forward or deferred rendering depending on circumstance may have a logical switch based on additional feature flags. as an example:  TerrainBaseMapFeatHLSL::getOutputTargets)
getResources - associated with the Resources struct, closely aligned with the hardware regestry
 getBlendOp - used to determine what blend operation to use if a material requires a second pass (defaults to overwriting)
setTexData - ???
processVert - vertex shader codeline insertions
};

_B)_
The resultant Gbuffer layout defined by the previous commit therefore is as follows:
defaultrendertarget (referred to in shaders as out.col or col depending on GFX plugin) contains either lighting and normal data, or color data depending on if it is used in a deferred or forward lit manner (note for forward lit, this data is replaced as a second step with color. why custommaterials have traditionally had problems with lighting)
color1 (referred to in shaders as out.col1 or col1 depending on GFX plugin) RGB color data and an A for blending operations (including transparency)
color2 (referred to in shaders as out.col2 or col2 depending on GFX plugin) contains:
 red channel comprising material flags such as metalness, emissive, ect,
 green channel for translucency (light shining through, as oposed to  see-through transparency), blue for
 blue for specular strength (how much light influences net color)
 alpha for specular power (generally how reflective/glossy an object is)

long term purpose:
further down the line, these will be used to condition data for use with a PBR subsystem, with further corrections to the underlying mathematics, strength being replaced by roughness, and power by metalness
2016-02-16 02:23:23 -06:00
Azaezel
5b5c6b9907 Deferred Shading
Phase 1: buffers
engine:
provides the following hooks and methods
A) render target "color", and "matinfo". these correspond to texture[0] = "#color";  texture[2] = "#matinfo"; entries in scripts
B) utilizes the independentMrtBitDepth method added GarageGames#857 to set color to an 8RGBA if cards support it
C) adds an RenderPrePassMgr::_initShaders() method to support void RenderPrePassMgr::clearBuffers(). This operates as a pseudo-postfx by rendering a veiwspace plane which fills the screen, then calls a shader which fills both the introduced rendertarget buffers and the prepass buffer to relevant defaults (white with full alpha for prepass, black with full alpha for color and material respectively)

script:
\game\tools\worldEditor\main.cs adds additional hooks similar to GarageGames#863 for colorbuffer, specular map, and backbuffer display
\game\core\scripts\client\lighting\advanced\deferredShading.cs adds the clearbuffer shader, visualizers, and the ShaderData( AL_DeferredShader )  +  PostEffect( AL_DeferredShading ) which combine the various buffers into the output which reaches the screen under normal conditions, as well as the extended debug visualizers.
again, note the lines

   texture[0] = "#color";
   texture[1] = "#lightinfo";
   texture[2] = "#matinfo";
   target = "$backBuffer";
in particular for the core tie-in.

shader:
\game\shaders\common\lighting\advanced\deferredColorShaderP.hlsl
\game\shaders\common\lighting\advanced\gl\deferredClearGBufferP.glsl
the previously mentioned shaders which clear the buffers to specified colors

\game\shaders\common\lighting\advanced\deferredShadingP.hlsl
\game\shaders\common\lighting\advanced\gl\deferredShadingP.glsl
the tie-in shaders

the rest are visualizers

purpose: to expose methodology that allows one to render color, lighting and material information such as specular and gloss which effect the result of both when combined

long term intent: the previous prepass lighting methodology while serviceable, unfortunately had the side effect of throwing out raw color information required by more modern pipelines and methodologies. This preserves that data while also allowing the manipulation to occur only on a screenspace (or reflected speudo-screenspace) basis.
2016-02-16 01:50:58 -06:00
Areloch
cb22357eb2 Merge pull request #1461 from Azaezel/textureLinearization
Diffuse/albedo texture linearization
2016-02-16 01:23:16 -06:00
Areloch
a90eb9762b Re-submission of the Volumetric Fog PR, with cleanup. 2015-12-01 00:10:13 -06:00
Areloch
92aa785bb2 Merge pull request #1442 from Azaezel/shadow_caching
This all seems to work pretty well.
2015-11-12 12:49:58 -06:00
Azaezel
ce2964d2d0 diffuse/albedo texture linearization
http://http.developer.nvidia.com/GPUGems3/gpugems3_ch24.html
2015-11-11 13:52:46 -06:00
Azaezel
24f7dc8314 rtparams(#) needs to match the ssaomask register 2015-11-02 23:01:43 -06:00
Areloch
8253bcc343 Merge pull request #1446 from rextimmy/water_vertex_format_fix
Looks to work fine. Thanks!
2015-10-24 02:12:46 -05:00
rextimmy
9c6ff1775b Removed unused vertex colors from GFXWaterVertex 2015-10-22 21:54:35 +10:00
rextimmy
246785a8bf Removed unused vertex formats from ScatterSky 2015-10-16 21:30:39 +10:00
Azaezel
2753f562e8 shadow caching
SPECIAL NOTE: highly suggest https://github.com/GarageGames/Torque3D/pull/1441 or a variation thereof to prevent debug spew and false-postives for occlusion results.

With significant research, development and prototyping assistance from both @andr3wmac (shaders and partial hook work), and @LuisAntonRebollo (additional culling)

System operates as follows:
1) materials are given an additional castDynamicShadows boolean entry. (Default at time of writing is true by request. Personal usage at time of writing defaults to false. value is default-initialized in materialDefinition.cpp. script/gui exposed)
2) lights are given a staticRefreshFreq and dynamicRefreshFreq (in milliseconds). script/gui exposed
3) materials are (effectively) sorted into dynamic and static shadowmap render lists based on flag. (see shadowMapPass.cpp)
4) initial shadowmaps are generated for each light and 'list'.
5) as each refreshFreq times out, the relevant shadowmap for a given light is refreshed.

Special notes:
dynamicRefreshFreq for all lights is set to a (script exposed) 8MS refresh timer.
StaticRefreshFreq for the lions share of lights defaults to 250 MS (1/4 of a second)
scattersky's embedded light, which is intended to operate in a mobile manner, defaults to 8
to reiterate, these are all customizable per-light via script/inspector gui in the case of alternate project needs.
2015-10-13 18:12:19 -05:00
Areloch
5ee096de20 Added in explicit setting to vec2 in the shader functions per Az's suggestion, to avoid GLSL problems 2015-08-29 12:41:35 -05:00
Areloch
71c19a6151 Companion PR to #719
Adds the OGL side. redoing it to make sure the PR history is clean.
2015-08-28 00:27:08 -05:00
Areloch
95ab3a33a5 Merge pull request #719 from rextimmy/dxtnm-parallax-fix
Fix to allow parallax mapping with dxtnm textures via the red channel.
2015-08-27 23:59:20 -05:00
Azaezel
2f33de3615 case sensitivity fixe for linux 2015-08-06 04:00:56 -05:00
Daniel Buckmaster
009bff7f88 Merge pull request #863 from Azaezel/GlowbufferVisualizer
glow buffer debug visualiser
2015-07-01 22:24:16 +10:00
Azaezel
462aeefb36 opengl crashfix: cannot self-multiply a uniform. use a temp-variable. 2015-05-16 14:11:40 +10:00
Luis Anton Rebollo
0e346fed9f Merge pull request #1241 from J0linar/Vignette_Final
vignette_final
2015-03-08 18:43:10 +01:00
LuisAntonRebollo
049de72cc5 Fix waterBasicP.glsl for HDR. 2015-03-08 12:56:24 +01:00
Miodrag Sejic
351d5f08e9 vignette_final
+added: gui slider for maximum exposure of vignetting
+changed: shaders to logical min/max floats
this pr contains the glsl shaders as well and therefore makes the
https://github.com/GarageGames/Torque3D/pull/1225 Pull Request obsolete
2015-03-07 14:03:12 +01:00
LuisAntonRebollo
3ad04d050c Fix shadows on Basic Lighting. 2015-02-15 22:26:05 +01:00
Luis Anton Rebollo
2d3f711443 Merge pull request #1128 from Azaezel/cloudlayer
cloudlayer hdr packing
2015-02-07 20:50:29 +01:00
Anis
3937afdc19 Update vectorLightP.glsl 2015-01-28 23:43:29 +01:00
Anis
9e090a2ef7 Update lighting.glsl 2015-01-28 23:36:43 +01:00
Azaezel
86770cb3c1 cloudlayer hdr packing
fixes for #1126
2015-01-25 17:56:17 -06:00
Luis Anton Rebollo
84d072f25c Merge pull request #1027 from bpay/ambient-normals
Allow normals on shadowed surfaces
2015-01-24 23:05:51 +01:00
LuisAntonRebollo
3336bffad2 Changes for Linux. 2015-01-19 01:44:36 +01:00
LuisAntonRebollo
aa35157eef PlatformSDL implementation. 2015-01-19 01:17:37 +01:00
LuisAntonRebollo
4e530f413e Fix glowBlurP.glsl shader. 2014-12-25 19:40:42 +01:00
LuisAntonRebollo
cf195152d6 Workaround for OpenGL terrain blend on Intel drivers. 2014-12-16 00:30:50 +01:00
LuisAntonRebollo
0718875ac3 OpenGL Intel - Fix a error on DOF_DownSample_P.glsl. 2014-12-11 22:58:02 +01:00
LuisAntonRebollo
b0efd865d9 Use factor of ambient light with camera direction for allow normals on shadowed surfaces. 2014-12-09 19:46:06 -05:00
LuisAntonRebollo
c20f29c672 Merge pull request #1003 from Lopuska/ribbon_opengl
Ribbon port for opengl
2014-12-05 22:58:38 +01:00
Anis A. Hireche
d16a236937 ribbon_opengl 2014-12-03 22:19:02 +01:00
LuisAntonRebollo
ed0febea39 Clean GLSL fragment shader out. 2014-11-30 23:00:18 +01:00
LuisAntonRebollo
4409a12af6 Fix GLSL out fragment shader color. 2014-11-30 05:32:40 +01:00
LuisAntonRebollo
ff83e8c209 Merge remote-tracking branch 'GG-Github/development' into fix_opengl_new_terrain_blend 2014-11-30 04:47:38 +01:00
Anis A. Hireche
18213a7fa9 missing some file 2014-11-27 20:56:25 +01:00
LuisAntonRebollo
5bcd1458c4 Templates changes for OpenGL shaders. 2014-11-08 20:19:50 +01:00