Commit graph

82 commits

Author SHA1 Message Date
Thomas "elfprince13" Dickerson 1c2b096a72 Whitespace consistency 2017-01-06 23:10:14 -05:00
Thomas "elfprince13" Dickerson 88106f9032 Fixed type inference for nulls in console functions 2017-01-06 17:18:37 -05:00
Azaezel 55b26be9ba account for fov change (also, internal docs) 2016-11-29 15:57:41 -06:00
Azaezel 01419d7935 motion based updates for shadow caching
adds a $pref::Shadows::teleportDis and $pref::Shadows::turnRate (defaults 4, and 1 respectively)
if either is exceeded during a given frame, shadow chaches are forced to refresh themselves.
2016-11-29 14:13:23 -06:00
Anis 60e258e5a9 Merge pull request #1806 from Azaezel/byeByeVarVar2
more unused variable cleanups
2016-10-23 21:04:36 +02:00
Azaezel 1ee127b753 more unused variable cleanups 2016-10-16 14:41:34 -05:00
Azaezel fbfd3ed8ed clang: constructor initialization order
while not a major issue per-se, the sheer number of times the engine has to jump back in memory and backfill data in a given class can add up. First run of... many.,
2016-10-14 18:16:55 -05:00
James Urquhart f91aa639d6 Remove projection offset, add the hmd head matrix. Also tidy up a few things. 2016-09-11 22:42:42 +01:00
Azaezel 13f00ca79d adds toLinear and toGamma helper functions for ColorF, uses the former in adjusting lights. 2016-08-09 14:49:03 -05:00
Areloch dfb8f4f5e5 Makes point and spot lights be correctly culled with zoning like other objects. 2016-06-17 00:47:46 -05:00
Azaezel b6ec969fb3 worst case scenario fallback for if we can't track down why vector lighting seems determined to shift positions periodically based upon some influence by the dynamicrefreshfrequency rate 2016-06-08 19:15:10 -05:00
rextimmy 41e5caf22b Direct3D11 Engine/source changes 2016-03-20 21:52:11 +10:00
Azaezel 9472bfd3ca addresses https://github.com/GarageGames/Torque3D/issues/1537 via the following:
908be4818f/Engine/source/materials/materialDefinition.cpp (L261) denotes power as sharpness, reflected in the size/falloff of a highlight halo *

908be4818f/Engine/source/materials/materialDefinition.cpp (L264) denotes strength as overall brightness of highlights. **

*and sharpness of reflection if using a cubemap.
**  reflected in cubemapped objects as also degree of 'reflection' vs diffuse/albedo coloration.
2016-03-01 20:25:52 -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 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
Areloch cb22357eb2 Merge pull request #1461 from Azaezel/textureLinearization
Diffuse/albedo texture linearization
2016-02-16 01:23:16 -06:00
Azaezel 23c4b52e1f courtessy @Lopuska: opengl occlusion query fix 2016-01-18 00:28:09 -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 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 2002d74b78 Issue found with PVS-Studio:
Many instances of a function or expression being used repeatedly, which can lower performance.

Fixed it in these cases by creating on local var, reference or pointer that's used instead.
2015-07-13 22:51:17 -05:00
Azaezel 6fa44a4e92 further insurance that shadow split stay within bounds. 2015-03-10 06:03:40 -05:00
Luis Anton Rebollo 825912e800 Merge pull request #1223 from Azaezel/detailNormalOrderOfOperations
DeferredBumpFeat order of operations corrections
2015-03-08 22:49:27 +01:00
LuisAntonRebollo ae3128b28b DeferredBumpFeat order of operations corrections. Clean. 2015-03-08 22:30:03 +01:00
Luis Anton Rebollo 7e7025d1ca Merge pull request #1238 from Azaezel/defaultNormal
https://github.com/GarageGames/Torque3D/issues/770 resolution
2015-03-08 22:12:24 +01:00
LuisAntonRebollo 1067da284f Add error msg to Shadergen when GBufferConditioner?LSL::processVert don't have normals defined. 2015-03-08 22:10:22 +01:00
Azaezel bc32da74ca https://github.com/GarageGames/Torque3D/issues/770 resolution suggested by @LuisAntonRebollo 2015-03-03 23:10:47 -06:00
Daniel Buckmaster 84e8cbb4ee Revert recent style cleanup changes. 2015-03-04 11:58:36 +11:00
Daniel Buckmaster 33fcc59543 Merge remote-tracking branch 'origin/style-cleanup' into development
Conflicts:
	Engine/source/T3D/tsStatic.cpp
	Engine/source/console/compiledEval.cpp
	Engine/source/ts/tsMesh.cpp
	Engine/source/ts/tsShape.cpp
2015-03-01 22:30:22 +11:00
Daniel Buckmaster baf594aee7 Merge pull request #1006 from BeamNG/fix_lighting_with_zero_lights
Fix lighting errors when all lights are disabled.
2015-03-01 21:06:34 +11:00
Daniel Buckmaster 6c92ab065e Merge remote-tracking branch 'jamesu/console_stack_fix2' into development
Conflicts:
	Engine/source/console/console.cpp
2015-03-01 20:33:29 +11:00
Azaezel 0325aaf5bb good catch 2015-02-25 12:50:00 -06:00
Azaezel ea29f5203d DeferredBumpFeat order of operations corrections 2015-02-23 15:35:10 -06:00
Ben Payne 0ffd7f5620 Fix member vars left uninitialized in constructors 2015-02-20 18:41:51 -05:00
James Urquhart f44a3f27d6 Fix stack balancing problems by refactoring execution calls
- Con::executef now uses a template
- All public execution functions now restore the console stack upon return
- Fixed bad parameters on some callbacks
- Reverts get*Arg behavior
2015-02-08 00:08:18 +00:00
Daniel Buckmaster 014b566014 Merge remote-tracking branch 'gg/development-3.6' into development
Conflicts:
	Engine/source/T3D/gameFunctions.cpp
2015-01-29 21:17:38 +11:00
LuisAntonRebollo 19afd0c22b . 2015-01-25 02:01:11 +01:00
Daniel Buckmaster ae284a89ec Merge branch 'development' into defineconsolemethod
Conflicts:
	Engine/source/materials/materialDefinition.cpp
2014-12-26 13:22:16 +11:00
Azaezel a3fab3d4c4 Projected Shadow fix
With Permission from Jeff Faust.

   // AFX CODE BLOCK (bug-fix) <<
   // For ShapeBase objects this causes the shader to fade along with the
   // object and also prevents a rectangular shadow artifact from occuring
   // once the visibility is zero.
2014-12-22 17:52:02 -06:00
Azaezel c6cdfafe4e cleaned up variant of https://github.com/GarageGames/Torque3D/pull/768 alterations: opengl support, in-shader bug-reporting, direction vector fit to material slider-bar. 2014-12-21 14:07:42 -06:00
Daniel Buckmaster 9396ae7176 Merge remote-tracking branch 'Winterleaf/Development-Console' into defineconsolemethod
Conflicts:
	Engine/source/T3D/missionMarker.cpp
2014-12-21 21:23:55 +11:00
Daniel Buckmaster 33ff180593 Merge branch 'development' into style-cleanup
Conflicts:
	Engine/source/console/astNodes.cpp
	Engine/source/console/codeBlock.cpp
	Engine/source/console/compiledEval.cpp
	Engine/source/ts/collada/colladaAppMesh.cpp
	Engine/source/ts/tsShape.cpp
	Engine/source/ts/tsShapeConstruct.cpp
2014-12-15 12:15:55 +11:00
LuisAntonRebollo f166e5286d Fix lighting errors when all lights are disabled. 2014-12-03 23:46:12 +01:00
LuisAntonRebollo 1d3f3fdfe4 Fix OpenGL changes formating. 2014-11-30 23:09:11 +01:00
LuisAntonRebollo 32e8725931 Merge pull request #983 from Azaezel/stray_mSamplerNames
DeferredMinnaert feautre was missing samplernames
2014-11-30 04:59:24 +01:00
Azaezel bea3563c3d const U64 maxValPerChannel = (U64)1 << mBitsPerChannel; 2014-11-29 21:50:02 -06:00
Azaezel 2e112802e5 DeferredMinnaert feautre was missing samplernames 2014-11-29 21:44:05 -06:00
LuisAntonRebollo a4bf61f07b Fix x64 builds. 2014-11-30 04:00:58 +01:00
LuisAntonRebollo 98e3651db5 Merge pull request #940 from BeamNG/add_opengl_support
Add/Activate OpenGL render.
2014-11-30 02:48:13 +01:00
LuisAntonRebollo b731f3cbe5 Merge pull request #932 from BeamNG/reduce_RT_changes
Reduce innecesary changes on Render Target textures.
2014-11-30 02:22:52 +01:00
LuisAntonRebollo b632d06c97 Merge pull request #930 from BeamNG/separate_opengl_from_os
Separate OpenGL code from Linux or Mac.
2014-11-30 02:22:28 +01:00