Scaling Models

Posted By: DLively

Scaling Models - 04/20/14 19:09

I read that scaling models reduces frame rate - Does this only apply to > 1.000 or does it also apply if Im scaling a model smaller?
Posted By: Superku

Re: Scaling Models - 04/20/14 19:48

If you change the scale of a model (many or few with a reasonable number of vertices) every frame this does indeed have a notable impact on the framerate (the value is not really important, only bigger models result in more pixels to be drawn), if you only do it once or a few times or only for a few models it's perfectly fine.
Generally speaking just go ahead and do it and only optimize if necessary (one optimization - what I normally do - is to scale the model in the vertex shader via vecSkill41).
Posted By: DLively

Re: Scaling Models - 04/20/14 23:39

Thanks for your feedback Superku,

So I now understand that regardless of scaling up or down it has an effect, and will alter the fps. Now is this limited to objects within the Clipping range? So lets say I have 4 quadrants for example, one in each corner of a Huge Level, so they are not in the same clipped area - Would this be acceptable? (remember this is just for my knowledge) tongue

Related to the shader option -> Is that something complex that you figured out, or is it preset somehow that I could figure it out? tongue Keeping in mind that I'm still in the grey with shaders xD

Does anyone know if this comes with Shade-c?
Posted By: Superku

Re: Scaling Models - 04/21/14 00:26

I think I don't understand your first question, sorry. wink
However, I am not sure if the scaling is (framerate) dependent on rendering or not, I'd guess it's not the case (one would have to test that, and maybe with or without PASSABLE flag).

I am not familiar with writing shaders like the default engine shaders (because I don't know or really like those macros) or Shade-C at all but in my own vertex shader I'd proceed as follows:
For pretty much all of my shaders I use the following base shader (roughly taken from the shader tutorial):
Code:
float4x4 matWorldViewProj;
float4x4 matWorld;
float4 vecAmbient;
float4 vecSunDir;

texture entSkin1;

sampler ColorMapSampler = sampler_state 
{ 
   Texture = <entSkin1>; 
   AddressU  = Clamp; 
   AddressV  = Clamp; 
}; 
    
void DiffuseVS( 
   in float4 InPos: POSITION, 
   in float3 InNormal: NORMAL, 
   in float2 InTex: TEXCOORD0, 
   out float4 OutPos: POSITION, 
   out float2 OutTex: TEXCOORD0, 
   out float3 OutNormal: TEXCOORD1) 
{ 
   OutPos = mul(InPos, matWorldViewProj); 
   OutNormal = normalize(mul(InNormal, matWorld));
   OutTex = InTex; 
} 
    
float4 DiffusePS( 
   in float2 InTex: TEXCOORD0, 
   in float3 InNormal: TEXCOORD1): COLOR 
{ 
   float4 Color = tex2D(ColorMapSampler, InTex); 
   float Diffuse = 0.5+0.5*saturate(dot(-vecSunDir, normalize(InNormal))); 
   float4 final = Color*Diffuse;
   
   return final;
} 
 
technique DiffuseTechnique 
{ 
   pass P0 
   { 
      VertexShader = compile vs_3_0 DiffuseVS(); 
      PixelShader  = compile ps_3_0 DiffusePS(); 
   } 
}


Then I modify it as needed. In this case I'd add vecSkill41 as a float4, then multiply InPos.xyz in the vertex shader with vecSkill41.x or vecSkill41.xyz (when I want to have axis independent scaling) (and of course initialize those skills in script with floatv()).
Posted By: DLively

Re: Scaling Models - 04/21/14 01:16

I re-read the manual and understand it more correctly now -> I think you already answered the question though.

Quote:

The bigger a model or sprite is scaled, and the closer it is to the camera, the slower it is rendered. The rendering time depends on the number of pixels that the object covers on the monitor.


So if I had 5 models in 5 different sectors of the level, they wouldn't be on camera anyway. this would apply to such things as Grass, if they were randomly scaled.


Thanks for the base Shader. I don't know too much about them, as said, but I do appreciate this kind resource! I will have to study more to understand the adding of more commands to a shader, but this is a very huge head start when I use custom shaders!

You're custom shaders (in your recent videos) are very well done btw laugh
© 2024 lite-C Forums