-
Notifications
You must be signed in to change notification settings - Fork 127
add custom directx psshader buffer unique to a material controllable via SQ client vm #888
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
base: main
Are you sure you want to change the base?
Conversation
update dx context and device to static error out if guid is malformed fix random if true
ASpoonPlaysGames
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just quickly looked at this
| g_pSquirrel[ScriptContext::CLIENT]->AddFuncRegistration( | ||
| "void", | ||
| "NSSetCustomDXBuffer", | ||
| "string rPakMaterialGUID array NSCustomBufferPerMaterialData", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why untyped array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tbh, I was probably unsure if u can make it a typed array with this, but it still works. No matter what type u feed it if the data is too much it should still error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tbh, I was probably unsure if u can make it a typed array with this, but it still works. No matter what type u feed it if the data is too much it should still error
| return true; | ||
| } | ||
|
|
||
| template <ScriptContext context> SQRESULT NSSetCustomDXBuffer(HSQUIRRELVM sqvm) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why doesn't this use the the ADD_SQFUNC macro?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs access the the sqvm to get data from the array, don't have a reference the sqvm from the macro version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs access the the sqvm to get data from the array, don't have a reference the sqvm from the macro version
the macro version gives you a sqvm reference
This adds a new Flag check for the glueflag in a material in after executing shaderexecute, adding it at the right spot in the graphics pipeline of the game.
the flag is 0x04089901
if called a new buffer is bound to the shader and stored in static memory.
this is stored associated with a material GUID passed via a SQ command
struct Ns_Constant_Buffer { float data[320]; };The buffer has 320 floats accessible, you can bind in a buffer in a pixel shader like so:
cbuffer NorthstarCustomBuffer : register(b4) { float4 NS_custom_float4_0 : packoffset(c0); float4 NS_custom_float4_1 : packoffset(c1); float4 NS_custom_float4_2 : packoffset(c2); float4 NS_custom_float4_3 : packoffset(c3); float4 NS_custom_float4_4 : packoffset(c4); float4 NS_custom_float4_5 : packoffset(c5); ... ... };to access this buffer and write to it in script call
NSSetCustomDXBuffer(string materialGUID, array floats)ex.:
NSSetCustomDXBuffer( "0x8CFD6305B9061988", myCoolArray)if the array is smaller then the buffer the floats are populated in order.
if its too big the vm will throw an error to avoid overflow
this is usefull to create script controlled shader settings, or do logic for things like ammo counters with custom shaders in sqvm and pass for example an ammo count or other such things
Code review:
im pretty new to this, so be harsh thanks
Testing:
you can download my examplemod:
em4v.prtest.zip
and then go on any map, equip the Devotion and see that its mostly black. in console run:
script_client thread changeColorBasedOnLocation(GetLocalClientPlayer())this runs changeColorBasedOnLocation() a function implemented in "shadertest.nut" in the mod, which changes certain values every frame in the shader, such as certain color settings to update them based on your world position. this results in changing color based on this.
Video of this:
output3.mp4
to get the guid of a material you can either call -pakguid on the rpak string via rePak or use rsx