Help with the getsurface functions

Discuss programming in the QuakeC language.
Post Reply
silverjoel
Posts: 52
Joined: Thu Sep 30, 2010 6:46 am

Help with the getsurface functions

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

Re: Help with the getsurface functions

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

Re: Help with the getsurface functions

Post by silverjoel »

Thanks, but that's too bad. I take it there is no way to get a pixel color?
toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: Help with the getsurface functions

Post 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:
Meadow Fun!! - my first commercial game, made with FTEQW game engine
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Help with the getsurface functions

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

Re: Help with the getsurface functions

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

Re: Help with the getsurface functions

Post 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...
Meadow Fun!! - my first commercial game, made with FTEQW game engine
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: Help with the getsurface functions

Post 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.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Post Reply