Forum

Help with the getsurface functions

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Help with the getsurface functions

Postby silverjoel » Thu May 19, 2016 10:32 pm

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.
silverjoel
 
Posts: 51
Joined: Thu Sep 30, 2010 6:46 am

Re: Help with the getsurface functions

Postby Spike » Fri May 20, 2016 12:00 am

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.
Spike
 
Posts: 2883
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Help with the getsurface functions

Postby silverjoel » Fri May 20, 2016 3:23 am

Thanks, but that's too bad. I take it there is no way to get a pixel color?
silverjoel
 
Posts: 51
Joined: Thu Sep 30, 2010 6:46 am

Re: Help with the getsurface functions

Postby toneddu2000 » Fri May 20, 2016 5:59 am

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:
toneddu2000
 
Posts: 1318
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: Help with the getsurface functions

Postby Spike » Fri May 20, 2016 6:23 am

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?
Spike
 
Posts: 2883
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Help with the getsurface functions

Postby silverjoel » Fri May 20, 2016 3:27 pm

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.
silverjoel
 
Posts: 51
Joined: Thu Sep 30, 2010 6:46 am

Re: Help with the getsurface functions

Postby toneddu2000 » Fri May 20, 2016 3:47 pm

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...
toneddu2000
 
Posts: 1318
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: Help with the getsurface functions

Postby frag.machine » Fri May 20, 2016 5:22 pm

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.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2077
Joined: Sat Nov 25, 2006 1:49 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 4 guests