Page 1 of 1

Help with the getsurface functions

Posted: Thu May 19, 2016 10:32 pm
by silverjoel
I can't seem to find much information on the getsurface functions (DP and others?). I'm trying to get the pixel color at a point, which I think I can do with one of these. Getsurfacepointattribute is probably what I need, but I'm not sure what to use as inputs.

vector(entity e, float s, float n, float a) getsurfacepointattribute = #486;

e is understood, s is the surfacenearpoint?, n?, a is one of the surface constants?

Any help would be appreciated.

Re: Help with the getsurface functions

Posted: Fri May 20, 2016 12:00 am
by Spike
e is the entity who's model you're querying. s is the surface number that you're after. n is the point number that you're trying to query the attribute of. a is the attribute name that you're asking for.
you can't query texture colours.

Re: Help with the getsurface functions

Posted: Fri May 20, 2016 3:23 am
by silverjoel
Thanks, but that's too bad. I take it there is no way to get a pixel color?

Re: Help with the getsurface functions

Posted: Fri May 20, 2016 5:59 am
by toneddu2000
glsl? FTE, through CSQC, has a quite robust GSLS(shader and post process) system. You could get texture pixel color with fragment shader and then pass it somehow(maybe through a cvar? Not sure, ask Spike)to CSQC_InputEvent back again. I think it's teorically possible. But, in this case, no dp compatible.
Maybe there could be another way but probably you should tell us more what you're trying to accomplish, so we can help you better! :biggrin:

Re: Help with the getsurface functions

Posted: Fri May 20, 2016 6:23 am
by Spike
FTE provides no way to read back textures in any way. Even if you use glsl to write back to some buffer or hackily typepun a texture to something you can write to, there is no practical way to retrieve that data from the renderer.
reading back textures is generally frowned upon due to various driver bugs that might leak memory from other processes. Its easier to just not provide support for it.
However, it is possible to take screenshots, which is of course not a practical way, if only because it'll spam the console if you're doing it frequently.

if you just want light levels, there's a getlight builtin that you can use.

what exactly is your use-case?

Re: Help with the getsurface functions

Posted: Fri May 20, 2016 3:27 pm
by silverjoel
I was going for a hit skin on entities. By that I mean a simple 4 color skin and apply damage based on which color was hit. I figured I could at least pull the coordinates of where the texture was hit, that appeared to be one of the surface attributes, but it doesn't seem to be working out either.

Re: Help with the getsurface functions

Posted: Fri May 20, 2016 3:47 pm
by toneddu2000
I'd use (with FTE ) .sub entities with bounding boxes attached and oriented to skeleton bones. I used that technique for my game and it works
FTE provides no way to read back textures in any way. Even if you use glsl to write back to some buffer or hackily typepun a texture to something you can write to, there is no practical way to retrieve that data from the renderer.
Dunno about textures per se, but screen pixel color it should be fairly trivial, since fragment shader does exactly that! :)
Tbh I tried several months ago to extract only red pixels from post processing scene and discard it from computation and it didn't work..uhrm...

Re: Help with the getsurface functions

Posted: Fri May 20, 2016 5:22 pm
by frag.machine
silverjoel wrote:I was going for a hit skin on entities. By that I mean a simple 4 color skin and apply damage based on which color was hit. I figured I could at least pull the coordinates of where the texture was hit, that appeared to be one of the surface attributes, but it doesn't seem to be working out either.
Assuming single frame .BSP entities the hit coordinate relative to the model origins could be used to have a quite approximated collision point. If we are talking about non .BSP models then per poly collision would be the better solution, and TBH I have absolutely no idea if Darkplaces does support it, and even so, for which model formats.