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

"multiply" blending mode? #9

Open
suicvne opened this issue Jul 19, 2016 · 1 comment
Open

"multiply" blending mode? #9

suicvne opened this issue Jul 19, 2016 · 1 comment

Comments

@suicvne
Copy link

suicvne commented Jul 19, 2016

is a "multiply" blending mode possible at all? i'd like to use it to implement some psuedo 2D lighting (which I've done before in XNA) but the best I could get was additive which didn't look as good.

@suicvne
Copy link
Author

suicvne commented Jul 19, 2016

i experimented with the source code a bit trying the following blend func:

sceGuBlendFunc(GU_ADD, GU_FIX, GU_SRC_COLOR, 0, 0);

it works with a non-transparent image (ie: black background white radial gradient) but completely breaks with a transparent one (only renders the pixels in the corners as full black?)

essentially, what my custom "mult" mode looks like is this:

sceGuBlendFunc(GU_ADD, GU_FIX, GU_SRC_COLOR, 0, 0);
sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
sceGuAmbientColor(coeff1);
osl_currentAlphaCoeff = coeff1;
osl_currentAlphaCoeff2 = coeff2;

i'm not quite familiar with sceGuTexFunc or sceGuAmbientColor so I just left those similar as the other cases.

the method i use is:

  1. draw the base scene
  2. set blend to mult
  3. overlay a rectangle with the 'ambient light'
  4. draw lightmaps

image
here is a non-transparent png being used as the base light

image
and here is a semi-transparent png being used as the base light.

both images are identical with the exception of one having a black background and the other having a transparent background.

something like this is essentially what i'm going for

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

No branches or pull requests

1 participant