Commit Graph

38 Commits

Author SHA1 Message Date
iwubcode c3a370839a VideoCommon: add helper functions to handle generating custom lighting code for a custom pixel shader 2023-08-20 18:53:27 -05:00
Pokechu22 85025612bc LightingShaderGen: Make s_lighting_struct not inline
This generated warnings on the freebsd builder.
2021-12-22 15:17:52 -08:00
Pierre Bourdon e149ad4f0a
treewide: convert GPLv2+ license info to SPDX tags
SPDX standardizes how source code conveys its copyright and licensing
information. See https://spdx.github.io/spdx-spec/1-rationale/ . SPDX
tags are adopted in many large projects, including things like the Linux
kernel.
2021-07-05 04:35:56 +02:00
Stenzek 51724c1ccd LightingShaderGen: Always calculate lighting for both color channels
Cel-damage depends on lighting being calculated for the first channel
even though there is no color in the vertex format (defaults to the
material color). If lighting for the channel is not enabled, the vertex
will use the default color as before.

The default value of the color is determined by the number of elements in
the vertex format. This fixes the grey cubes in Super Mario Sunshine.

If the color channel count is zero, we set the color to black before the
end of the vertex shader. It's possible that this would be undefined
behavior on hardware if a vertex color index that was greater than the
channel count was used within TEV.
2020-11-20 15:54:04 -08:00
Lioncash 4b21bc7508 LightingShaderGen: Transition over to fmt 2020-07-24 13:50:09 -04:00
Stenzek efb9759862 LightingShaderGen: Always calculate lighting for both color channels
Cel-damage uses the color from the lighting stage of the vertex pipeline
as texture coordinates, but sets numColorChans to zero.

We now calculate the colors in all cases, but override the color before
writing it from the vertex shader if numColorChans is set to a lower value.
2017-11-22 01:52:18 +10:00
Lioncash 273ace7bb7 LightingShaderGen: Remove unnecessary includes 2017-02-01 01:06:00 -05:00
degasus 083be0832f LightingShader: Drop xfmem usage.
Our shaders must only depend on the UID, not on any global state.
2016-10-04 10:13:46 +02:00
Scott Mansell d958388617 VideoCommon: Fix some warnings. 2016-06-26 23:10:31 +12:00
Scott Mansell 1a831cfc7d Multithreadded Shadergen: Second Pass over vertex/lighting Shadergens
As much as possible, the asserts have been moved out of the GetUID
function. But there are some places where asserts depend on variables
that aren't stored in the shader UID.
2016-06-26 16:13:21 +12:00
Scott Mansell 53c402dbc5 Multithreadded Shadergen: First Pass over vertex/lighting Shadergens
The only code which touches xfmem is code which writes directly into
uid_data.

All the rest now read their parameters out of uid_data.

I also simplified the lighting code so it always generated seperate
codepaths for alpha and color channels instead of trying to combine
them on the off-chance that the same equation works for all 4 channels.

As modern (post 2008) GPUs generally don't calcualte all 4 channels
in a single vector, this optimisation is pointless. The shader compiler
will undo it during the GLSL/HLSL to IR step.

Bug Fix: The about optimisation was also broken, applying the color light
         equation to the alpha light channel instead of the alpha light
	 euqation. But doesn't look like anything trigged this bug.
2016-06-26 16:13:19 +12:00
Pierre Bourdon 3570c7f03a Reformat all the things. Have fun with merge conflicts. 2016-06-24 10:43:46 +02:00
Lioncash d9fec92628 VideoCommon: Header cleanup
Also remedies places where the video backends and core rely on things
being indirectly included.
2016-01-17 20:11:45 -05:00
Scott Mansell bed102ae89 Revert "ShaderGen: Toggle value of uninitialized color." 2015-12-27 02:28:29 +13:00
degasus 7b34319e53 ShaderGen: Toggle value of uninitialized color.
SMS seems to need 0, no regressions either.
2015-12-06 12:39:18 +01:00
Ryan Houdek 9618738278 Remove all of our workarounds for Qualcomm devices we don't support anymore. 2015-09-04 23:45:35 -05:00
NanoByte011 06d1b8c63a VideoSW: rewrite lighting attenuation
- Fixes remaining lighting issues (Mario Tennis, etc)
- Apply same fixes to Software Renderer
- Corrected zero length light direction vector to resolve with normal direction (essentially becomes LIGHTDIF_NONE which was what I was after)
2015-06-08 23:20:27 +02:00
Tillmann Karras 30ebb2459e Set copyright year to when a file was created 2015-05-25 13:22:31 +02:00
Tillmann Karras cefcb0ace9 Update license headers to GPLv2+ 2015-05-25 13:22:31 +02:00
Dwayne Slater ae83a1b821 Fix OpenGLES 3.0 on Qualcomm's crappy driver, it can't bitshift sometimes.
[fixed lint issues and grammar ~comex]
2015-04-23 16:33:12 -04:00
NanoByte011 0a9257ad37 Cleaned up whitespace
Fixed Directional Attenuation (assumed, data was light dir vector already, but it was not!)
2015-01-21 22:30:41 -07:00
NanoByte011 f475e367f2 Lighting Attenuation Fixes 2015-01-21 15:55:32 -07:00
Jules Blok 3ed777b0f9 PixelShaderGen: Don't assign to input variables. 2014-12-28 23:37:05 +01:00
degasus 924ad1ee9f LightingShader: hard code const variable 2014-06-19 16:46:53 +02:00
Tony Wasserka fc34d5a130 Merge pull request #360 from magumagu/lighting-rounding
Video backends: fix rounding in lighting computation.
2014-05-17 21:06:31 +02:00
magumagu 1357277f40 Video backends: mass-replace "xfregs" with "xfmem". 2014-05-16 18:58:07 -07:00
magumagu 9e4eeb3b9b Video backends: fix rounding in lighting computation.
For whatever reason, the hardware doesn't do a full divide by 255, but
instead uses an approximation with shifting, similar to the way it is done
in TEV.
2014-05-11 12:53:02 -07:00
Tony Wasserka c1016205d3 Pixel/LightingShaderGen: Fix code alignment issues.
Most of these weren't even introduced by me, but hey - I'm nice and love wasting my time :p
2014-03-14 22:33:26 +01:00
Tony Wasserka 3e6efdb53e LightingShaderGen: Perform more lighting calculations with integers. 2014-03-14 22:31:19 +01:00
Tony Wasserka 387b9bf3c2 LightingShaderGen: Perform some lighting calculations with integers. 2014-03-14 22:31:19 +01:00
Tony Wasserka 78623871f9 ShaderGen: Store material uniforms as integers. 2014-03-14 22:31:19 +01:00
Tony Wasserka 4bf57565e8 ShaderGen: Store light color uniforms as integers. 2014-03-14 22:31:18 +01:00
Matthew Parlane 31cfc73a09 Fixes spacing for "for", "while", "switch" and "if"
Also moved && and || to ends of lines instead of start.
Fixed misc vertical alignments and some { needed newlining.
2014-03-11 00:35:07 +13:00
Pierre Bourdon ffe588cc24 Fix more header sorting issues in VideoCommon/ (now check-includes clean). 2014-02-20 01:01:10 +01:00
Lioncash 2afe215271 Convert all includes to relative paths. 2014-02-18 02:19:10 -05:00
lioncash d2038049f5 Replace all include guard ifdefs with "#pragma once" 2014-02-10 18:07:16 -05:00
Lioncash ebb48d019e Clean up some struct indentations
Also cleaned up the indentations of some variable declarations.
2014-02-09 19:40:11 -05:00
Jasper St. Pierre 34692ab826 Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00