Skip to content

New effect function fxAddShadow #1003

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

Closed
wants to merge 791 commits into from
Closed

New effect function fxAddShadow #1003

wants to merge 791 commits into from

Conversation

CrosRoad95
Copy link

@CrosRoad95 CrosRoad95 commented Jun 19, 2019

syntax:

bool fxAddShadow ( [ string shadowType, ] Vector3 position, Vector2 offsetA, Vector2 offsetB [, int color = 0x80FFFFFF, float zDistance = 4, bool drawOnWater = false, bool drawOnBuildings = true ] )

Must be used in render function like other dx functions, works better in PreRender ( avoid 1 frame lag )
returns nil if arguments are invalid, or false if limit of up to 48 shadows reach. size of shadow should not be greater than 64x64 units. the more shadows in the larger size, they started to be less precise.

if shadowType skipped, plain color will used
they are small graphical glitches at connetion of triangles

  • zDistance - how far below shadow will looking for collision
  • drawOnWater - seems to not working properly
  • drawOnBuildings - increese amount of objects which supports shadows
  • offsetA/B - are defining size of shadow, typicaly -X, 0, 0, X is shadow X units in all 4 direction
  • color - if you don't know, back to school

All allowed shadows types are below

Example script:

shadows = {"car", "ped", "heli", "bike", "rcbaron", "explosion", "headlight1", "headlight2", "blood", "headman", "wincrack", "lamp"}

addEventHandler( "onClientPreRender", root, function()
  x,y,z = getElementPosition(localPlayer)
  fxAddShadow(x,y,z, -1, 0, 0, 1, tocolor(255,0,0,128), 10, false, true)
  for i,v in ipairs(shadows)do
    fxAddShadow(v,2331.64697 - i * 2.5, -1658.43030, 13.43058, -1, 0, 0, 1, tocolor(255,255,255,255), 10, false, true)
  end
end)

Screenshots:
image
image
image

image
"car", "ped", "heli", "bike", "rcbaron", "explosion", "headlight1", "headlight2", "blood", "headman", "wincrack", "lamp" from left to right

@Einheit-101
Copy link

Einheit-101 commented Jun 21, 2019

drawOnWater may work if you apply a shader to the water which enables depth buffer usage.

technique simple
{
    pass P0
    {
		ZEnable = true;
		ZWriteEnable = true;
		ZFunc = 4;
		DepthBias = 0.000001;
		SlopeScaleDepthBias = 2;
    }
}

@patrikjuvonen patrikjuvonen added the enhancement New feature or request label Jun 21, 2019
@CrosRoad95
Copy link
Author

i fixed conflicts and i'm waiting for marge

@qaisjp qaisjp added this to the 1.6 milestone Oct 14, 2019
Copy link
Contributor

@qaisjp qaisjp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work overall, good job. I've left a few comments.

Also some files affect all line endings - please can you fix? If you don't know how, I can try to document instructions when I find the time. Just let me know.

@CrosRoad95
Copy link
Author

Make an tutorial how to fix line endings and pin up somewhere future

@CrosRoad95
Copy link
Author

fixed again, unteaded due #1122

@qaisjp
Copy link
Contributor

qaisjp commented Mar 14, 2020

#1122 is resolved, please can you test this? and resolve conversations for the bits above that you've done

@qaisjp qaisjp added the feedback Further information is requested label Mar 14, 2020
Copy link
Contributor

@qaisjp qaisjp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice PR. here's some changes for you.

Comment on lines 30 to 31
m_textureMap[eShadowType::PLANE] = new RwTexture();
}
Copy link

@ghost ghost Apr 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can crash the program. You don't allocate memory for Rw textures using the new operator. You have to use RwTextureCreate. I want to know where you are deleting this texture? It looks like this will cause a memory leak.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont know how properly use wrcreatetexture, and current code doesnt crash

@qaisjp qaisjp modified the milestones: 1.5.8, 1.6 Apr 20, 2020
@buepas
Copy link
Contributor

buepas commented Jun 8, 2020

What's the current state of this @CrosRoad95 ?

@CrosRoad95
Copy link
Author

after some updates, it starts crashing almost all time

@patrikjuvonen patrikjuvonen marked this pull request as draft January 16, 2021 22:54
@patrikjuvonen patrikjuvonen self-requested a review January 17, 2021 10:43
@patrikjuvonen patrikjuvonen marked this pull request as ready for review January 17, 2021 10:44
@patrikjuvonen patrikjuvonen modified the milestones: 1.6, Confirmed Issues Jan 17, 2021
@patrikjuvonen patrikjuvonen removed their request for review September 25, 2022 11:25
@multitheftauto multitheftauto deleted a comment from CrosRoad95 Feb 3, 2023
@patrikjuvonen patrikjuvonen removed the feedback Further information is requested label Apr 8, 2023
@patrikjuvonen patrikjuvonen marked this pull request as draft April 8, 2023 09:10
@patrikjuvonen patrikjuvonen added the feedback Further information is requested label Apr 8, 2023
@botder
Copy link
Member

botder commented Sep 19, 2023

The changes seem fine, but you have translation commits in the branch and pull request now.

@botder botder removed the feedback Further information is requested label Sep 19, 2023
@CrosRoad95
Copy link
Author

updated

@botder
Copy link
Member

botder commented Sep 20, 2023

The changes for the translation files are still there.

@CrosRoad95
Copy link
Author

The changes for the translation files are still there.

fixed

@CrosRoad95 CrosRoad95 closed this by deleting the head repository Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants