[2269] | 1 | ///////////////////////////////////////////////////////////////////////////////
|
---|
| 2 | //
|
---|
| 3 | // ## ######
|
---|
| 4 | // ###### ###
|
---|
| 5 | // ## ############### Shark 3D Engine (www.shark3d.com)
|
---|
| 6 | // ########## # # #
|
---|
| 7 | // ######## Copyright (c) 1996-2006 Spinor GmbH.
|
---|
| 8 | // ######### # # # All rights reserved.
|
---|
| 9 | // ## ##########
|
---|
| 10 | // ##
|
---|
| 11 | //
|
---|
| 12 | ///////////////////////////////////////////////////////////////////////////////
|
---|
| 13 |
|
---|
| 14 | //@cpp
|
---|
| 15 |
|
---|
| 16 | #include "gtp_shader_causticcube.h"
|
---|
| 17 | #include "../../interf/eng_gfxvar.h"
|
---|
| 18 | #include "../../util/eng_util_gfxutil.h"
|
---|
| 19 | #include "../../util/eng_util_gfxparamutil.h"
|
---|
| 20 | #include "../../util/eng_util_shaderutil.h"
|
---|
| 21 | #include "../../util/eng_util_shaderitemjob.h"
|
---|
| 22 | #include "../../../drv/interf/drv_vartypes.h"
|
---|
| 23 | #include "../../../drv/util/drv_util_varutil.h"
|
---|
| 24 | #include "../../../drv/util/drv_util_gfxutil.h"
|
---|
| 25 | #include "../../../drv/util/drv_util_paintprim.h"
|
---|
| 26 | #include "../../../util/snk/util_snk_extractutil.h"
|
---|
| 27 | #include "../../util/eng_util_mathutil.h"
|
---|
| 28 | #include "../../../util/math/util_geo_types.h"
|
---|
| 29 |
|
---|
| 30 | ///////////////////////////////////////////////////////////////////////////////
|
---|
| 31 | /*@{
|
---|
| 32 |
|
---|
| 33 | @declare{shadercomp.class}{eng_shader_special.filter}{}
|
---|
| 34 |
|
---|
| 35 | This component performs some iterative texture filtering.
|
---|
| 36 | @p
|
---|
| 37 |
|
---|
| 38 | The component takes none, one or multiple source textures as input,
|
---|
| 39 | see @sident{comp}{eng_shader_special.filter.src_array}.
|
---|
| 40 | Then it passes them to a shaderprogram,
|
---|
| 41 | see @sident{comp}{eng_shader_special.filter.shaderprog_ident}.
|
---|
| 42 | Then it writes the result to none, one or multiple @em{destination} textures,
|
---|
| 43 | see @sident{comp}{eng_shader_special.filter.dest_array}.
|
---|
| 44 | @p
|
---|
| 45 |
|
---|
| 46 | If the destination textures have already been allocated
|
---|
| 47 | they are used "as is", but only if they all have the same size.
|
---|
| 48 | Otherwise temporary textures will fetched.
|
---|
| 49 | Their size is the maximum of the source textures scaled by
|
---|
| 50 | @sident{comp}{eng_shader_special.filter.width_scale} and
|
---|
| 51 | @sident{comp}{eng_shader_special.filter.height_scale}.
|
---|
| 52 | If necessary the destination texture size is @em{snapped}
|
---|
| 53 | to a value acceptable to the graphics card.
|
---|
| 54 | @p
|
---|
| 55 |
|
---|
| 56 | @}*/
|
---|
| 57 | ///////////////////////////////////////////////////////////////////////////////
|
---|
| 58 |
|
---|
| 59 | S3D_UTIL_RTTI_TABLE_DEFINE_BEGIN(gtp_Shader_CausticCube)
|
---|
| 60 | S3D_UTIL_RTTI_TABLE_DEFINE_BASE(s3d_CEngShader)
|
---|
| 61 | S3D_UTIL_RTTI_TABLE_DEFINE_BASE(s3d_CCompUtilUniqueBase)
|
---|
| 62 | S3D_UTIL_RTTI_TABLE_DEFINE_BASE(s3d_CCompSetup)
|
---|
| 63 | S3D_UTIL_RTTI_TABLE_DEFINE_END
|
---|
| 64 |
|
---|
| 65 | gtp_Shader_CausticCube::gtp_Shader_CausticCube()
|
---|
| 66 | {
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | void gtp_Shader_CausticCube::SetupInit(
|
---|
| 70 | s3d_CUtilMsgHandler *MsgHandler, s3d_CUtilStr_cr Info,
|
---|
| 71 | s3d_CCompSuppl *FetchSuppl, s3d_CUtilSnkChunk *Param)
|
---|
| 72 | {
|
---|
| 73 | m_Data = S3D_SYS_NEW gtp_Shader_CausticCubeData;
|
---|
| 74 |
|
---|
| 75 | s3d_CUtilSnkExtract SnkExtract;
|
---|
| 76 | SnkExtract.Assign(MsgHandler, Param);
|
---|
| 77 | m_Data->m_Info = SnkExtract.GetInfo();
|
---|
| 78 |
|
---|
| 79 | /*@{ @declare{shadercomp.param}{eng_shader_special.filter.env}{$ [str]}
|
---|
| 80 | See @ident{comp}{eng_shader_std.group.env}.
|
---|
| 81 | @}*/
|
---|
| 82 | s3d_CUtilStr EnvIdent, EnvInfo;
|
---|
| 83 | SnkExtract.ExtractStr(EnvInfo, EnvIdent, "env", true);
|
---|
| 84 |
|
---|
| 85 | m_ShaderEnv = s3d_CompSupplObjT<s3d_CEngShaderEnv>(
|
---|
| 86 | MsgHandler, EnvInfo, FetchSuppl,
|
---|
| 87 | EnvIdent, S3D_GENERAL_INTEROP_INTERF);
|
---|
| 88 | if(!m_ShaderEnv)
|
---|
| 89 | return;
|
---|
| 90 |
|
---|
| 91 | /*@{ @declare{shadercomp.param}
|
---|
| 92 | {eng_shader_special.filter.methods}{$ [str] .. [str]}
|
---|
| 93 | See @ref{prog_man.shader.methods}.
|
---|
| 94 | @}*/
|
---|
| 95 | s3d_CUtilSnkExtractUtil::ExtractAtomSortedArray(
|
---|
| 96 | m_Data->m_MethodArray, m_ShaderEnv->m_AtomMgr,
|
---|
| 97 | SnkExtract, "methods", true);
|
---|
| 98 |
|
---|
| 99 | /*@{ @declare{shadercomp.param}
|
---|
| 100 | {eng_shader_special.filter.rank}{$ [str]}
|
---|
| 101 | Rank of the shader in the rendering sequence.
|
---|
| 102 | @}*/
|
---|
| 103 | SnkExtract.ExtractInt(m_Data->m_RankInfo, m_Data->m_Rank, "rank", true);
|
---|
| 104 |
|
---|
| 105 | /*@{ @declare{shadercomp.param}
|
---|
| 106 | {eng_shader_special.filter.iter_start}{$ [int]}
|
---|
| 107 | Iteration start value.
|
---|
| 108 | @}*/
|
---|
| 109 | m_Data->m_IterStart = SnkExtract.ExtractInt("iter_start", true);
|
---|
| 110 |
|
---|
| 111 | /*@{ @declare{shadercomp.param}
|
---|
| 112 | {eng_shader_special.filter.iter_end}{$ [int]}
|
---|
| 113 | Iteration end value.
|
---|
| 114 | @}*/
|
---|
| 115 | m_Data->m_IterEnd = SnkExtract.ExtractInt("iter_end", true);
|
---|
| 116 |
|
---|
| 117 | /*@{ @declare{shadercomp.param}
|
---|
| 118 | {eng_shader_special.filter.iter_step}{$ [int]}
|
---|
| 119 | Iteration step.
|
---|
| 120 | If the step is positive, then the step is added to the start value
|
---|
| 121 | until the value is larger than the end.
|
---|
| 122 | If the step is negative, then the step is added to the start value
|
---|
| 123 | until the value is smaller than the end.
|
---|
| 124 | If the step is zero, the iteration is only executed once
|
---|
| 125 | for the start value.
|
---|
| 126 | @}*/
|
---|
| 127 | m_Data->m_IterStep = SnkExtract.ExtractInt("iter_step", true);
|
---|
| 128 |
|
---|
| 129 | /*@{ @declare{shadercomp.param}
|
---|
| 130 | {eng_shader_special.filter.iter_width_scale}{$ [float]}
|
---|
| 131 | Scale the image by this scale each iteration.
|
---|
| 132 | The last iteration
|
---|
| 133 | @}*/
|
---|
| 134 | m_Data->m_IterWidthScale = SnkExtract.ExtractFloat(
|
---|
| 135 | "iter_width_scale", false);
|
---|
| 136 | if(m_Data->m_IterWidthScale <= 0)
|
---|
| 137 | m_Data->m_IterWidthScale = 1;
|
---|
| 138 |
|
---|
| 139 | /*@{ @declare{shadercomp.param}
|
---|
| 140 | {eng_shader_special.filter.iter_height_scale}{$ [float]}
|
---|
| 141 | Scale the image by this scale each iteration.
|
---|
| 142 | The last iteration
|
---|
| 143 | @}*/
|
---|
| 144 | m_Data->m_IterHeightScale
|
---|
| 145 | = SnkExtract.ExtractFloat("iter_height_scale", false);
|
---|
| 146 | if(m_Data->m_IterHeightScale <= 0)
|
---|
| 147 | m_Data->m_IterHeightScale = 1;
|
---|
| 148 |
|
---|
| 149 | m_Data->m_DestProp = 0;
|
---|
| 150 |
|
---|
| 151 | /*@{ @declare{shadercomp.param}
|
---|
| 152 | {eng_shader_special.filter.destprop_antialias}{$ [bool]}
|
---|
| 153 | Render the filtering with antialiasing.
|
---|
| 154 | @}*/
|
---|
| 155 | if(SnkExtract.ExtractBool("destprop_antialias", true))
|
---|
| 156 | m_Data->m_DestProp |= s3d_CDrvGfxEng::DestProp_Antialias;
|
---|
| 157 |
|
---|
| 158 | /*@{ @declare{shadercomp.param}
|
---|
| 159 | {eng_shader_special.filter.width_scale}{$ [float]}
|
---|
| 160 | Requested final horizontal scaling factor.
|
---|
| 161 | @}*/
|
---|
| 162 | m_Data->m_WidthScale = SnkExtract.ExtractFloat("width_scale", false);
|
---|
| 163 | if(m_Data->m_WidthScale <= 0)
|
---|
| 164 | m_Data->m_WidthScale = 1;
|
---|
| 165 |
|
---|
| 166 | /*@{ @declare{shadercomp.param}
|
---|
| 167 | {eng_shader_special.filter.height_scale}{$ [float]}
|
---|
| 168 | Requested final vertical scaling factor.
|
---|
| 169 | @}*/
|
---|
| 170 | m_Data->m_HeightScale = SnkExtract.ExtractFloat("height_scale", false);
|
---|
| 171 | if(m_Data->m_HeightScale <= 0)
|
---|
| 172 | m_Data->m_HeightScale = 1;
|
---|
| 173 |
|
---|
| 174 | /*@{ @declare{shadercomp.param}
|
---|
| 175 | {eng_shader_special.filter.passinfo_var}{$ [str]}
|
---|
| 176 | This variable is a name for the float4-vector
|
---|
| 177 | containing information about the iteration.
|
---|
| 178 | The first component of the vector contains the current iteration number,
|
---|
| 179 | The second the total number of iterations.
|
---|
| 180 | The remaining components are unused.
|
---|
| 181 | @}*/
|
---|
| 182 | s3d_CUtilSnkExtractUtil::ExtractAtom(
|
---|
| 183 | m_Data->m_TaskInfoVarInfo, m_Data->m_TaskInfoVarAtom,
|
---|
| 184 | m_ShaderEnv->m_AtomMgr, SnkExtract, "passinfo_var", true);
|
---|
| 185 |
|
---|
| 186 | /*@{ @declare{shadercomp.param}
|
---|
| 187 | {eng_shader_special.filter.shaderprog_ident}{$ [str]}
|
---|
| 188 | Shader program used for the smoothing iterations.
|
---|
| 189 | @}*/
|
---|
| 190 | SnkExtract.ExtractStr(
|
---|
| 191 | m_Data->m_ProgInfo, m_Data->m_ProgIdent,
|
---|
| 192 | "shaderprog_ident", true);
|
---|
| 193 |
|
---|
| 194 | /*@{ @declare{shadercomp.param}
|
---|
| 195 | {eng_shader_special.filter.shaderprog_param_array}
|
---|
| 196 | {$ [chunk] .. [chunk]}
|
---|
| 197 | Defines which variables are passed to the shader program.
|
---|
| 198 | See @ident{comp}{<shaderprog.map_prog_array>} for details.
|
---|
| 199 | @}*/
|
---|
| 200 | s3d_CUtilSnkChunkArray ProgParamChunkArray;
|
---|
| 201 | SnkExtract.ExtractChunkArray(
|
---|
| 202 | m_Data->m_ProgParamInfo, ProgParamChunkArray,
|
---|
| 203 | "shaderprog_param_array", true);
|
---|
| 204 |
|
---|
| 205 | /*@{ @declare{shadercomp.param}
|
---|
| 206 | {eng_shader_special.filter.src_array}{$ [str]..[str]}
|
---|
| 207 | @}*/
|
---|
| 208 | s3d_CUtilSnkExtractUtil::ExtractAtomArray(
|
---|
| 209 | m_Data->m_SrcVarInfo, m_Data->m_SrcVarAtomArray,
|
---|
| 210 | m_ShaderEnv->m_AtomMgr, SnkExtract, "src_array", true);
|
---|
| 211 |
|
---|
| 212 | /*@{ @declare{shadercomp.param}
|
---|
| 213 | {eng_shader_special.filter.dest_array}{$ [chunk]..[chunk]}
|
---|
| 214 | See @ident{comp}{<dest_array>}.
|
---|
| 215 | @}*/
|
---|
| 216 | s3d_CUtilSnkChunkArray DestChunkArray;
|
---|
| 217 | SnkExtract.ExtractChunkArray(DestChunkArray, "dest_array", true);
|
---|
| 218 |
|
---|
| 219 | m_Data->m_UpdateInterval = SnkExtract.ExtractInt("update_interval", true, 1);
|
---|
| 220 | m_Data->m_StartFrame = SnkExtract.ExtractInt("start_frame", true, 0);
|
---|
| 221 | m_Data->m_UpdateAllFace = SnkExtract.ExtractBool("update_all_face", true, true);
|
---|
| 222 | m_Data->m_UsePoints = SnkExtract.ExtractBool("use_points", true, true);
|
---|
| 223 | m_Data->m_PhotonCount = SnkExtract.ExtractInt("photon_count", true, 32*32);
|
---|
| 224 |
|
---|
| 225 | SnkExtract.CheckForUnknown();
|
---|
| 226 |
|
---|
| 227 | int ExtraTexProp = 0;
|
---|
| 228 | int ExtraSampMode = 0;
|
---|
| 229 | m_Data->m_Dest.Init(m_ShaderEnv, ExtraTexProp,
|
---|
| 230 | ExtraSampMode, DestChunkArray);
|
---|
| 231 |
|
---|
| 232 | s3d_CEngUtilGfxParamUtil::EvalMapProg(
|
---|
| 233 | MsgHandler, m_Data->m_ProgParamInfo,
|
---|
| 234 | m_ShaderEnv->m_AtomMgr, ProgParamChunkArray,
|
---|
| 235 | m_Data->m_ProgParamMapArray);
|
---|
| 236 | }
|
---|
| 237 |
|
---|
| 238 | void gtp_Shader_CausticCube::SetupDone()
|
---|
| 239 | {
|
---|
| 240 | }
|
---|
| 241 |
|
---|
| 242 | s3d_CUtilStr gtp_Shader_CausticCube::GetInfo()
|
---|
| 243 | {
|
---|
| 244 | return m_Data->m_Info;
|
---|
| 245 | }
|
---|
| 246 |
|
---|
| 247 | void gtp_Shader_CausticCube::RegisterNotif(s3d_CUtilNotifRecip *Recip)
|
---|
| 248 | {
|
---|
| 249 | }
|
---|
| 250 |
|
---|
| 251 | s3d_CEngShaderGfxPtr gtp_Shader_CausticCube::FindShaderGfx(
|
---|
| 252 | s3d_CUtilNotifGather *NotifGather, s3d_CEngGfxCtx *GfxCtx)
|
---|
| 253 | {
|
---|
| 254 | if(!m_ShaderEnv)
|
---|
| 255 | return 0;
|
---|
| 256 |
|
---|
| 257 | gtp_Shader_CausticCubeGfxPtr ShaderGfx;
|
---|
| 258 | gtp_Shader_CausticCubeGfxTree::CNode *Pos
|
---|
| 259 | = s3d_UtilTreeSortedGetStart(m_ShaderGfxTree, GfxCtx);
|
---|
| 260 | if(s3d_UtilTreeIsEqualAt(Pos, GfxCtx))
|
---|
| 261 | ShaderGfx = Pos->m_Data.m_Val;
|
---|
| 262 | else
|
---|
| 263 | {
|
---|
| 264 | ShaderGfx = S3D_SYS_NEW gtp_Shader_CausticCubeGfx(
|
---|
| 265 | m_ShaderEnv, NotifGather, GfxCtx, m_Data);
|
---|
| 266 | gtp_Shader_CausticCubeGfxTree::CNode *Node
|
---|
| 267 | = ShaderGfx->GetNode();
|
---|
| 268 | m_ShaderGfxTree.InsertBefore(Pos, Node);
|
---|
| 269 | }
|
---|
| 270 | return ShaderGfx.Get();
|
---|
| 271 | }
|
---|
| 272 |
|
---|
| 273 | ///////////////////////////////////////////////////////////////////////////////
|
---|
| 274 |
|
---|
| 275 | gtp_Shader_CausticCubeGfx::gtp_Shader_CausticCubeGfx(
|
---|
| 276 | s3d_CEngShaderEnv *ShaderEnv, s3d_CUtilNotifGather *NotifGather,
|
---|
| 277 | s3d_CEngGfxCtx *GfxCtx,
|
---|
| 278 | gtp_Shader_CausticCubeData *Data)
|
---|
| 279 | {
|
---|
| 280 | m_Node.m_Data.m_Key = GfxCtx;
|
---|
| 281 | m_Node.m_Data.m_Val = this;
|
---|
| 282 | m_ShaderEnv = ShaderEnv;
|
---|
| 283 | m_Data = Data;
|
---|
| 284 |
|
---|
| 285 | m_FilterDestGfx.Init(ShaderEnv, GfxCtx);
|
---|
| 286 |
|
---|
| 287 | s3d_CEngGfxProgMgr *GfxProgMgr = ShaderEnv->m_GfxProgMgr;
|
---|
| 288 | if(GfxProgMgr)
|
---|
| 289 | m_GfxProg = GfxProgMgr->CreateGfxProg(
|
---|
| 290 | Data->m_ProgInfo, GfxCtx, NotifGather,
|
---|
| 291 | Data->m_ProgIdent);
|
---|
| 292 | }
|
---|
| 293 |
|
---|
| 294 | gtp_Shader_CausticCubeGfxTree::CNode
|
---|
| 295 | *gtp_Shader_CausticCubeGfx::GetNode()
|
---|
| 296 | {
|
---|
| 297 | return &m_Node;
|
---|
| 298 | }
|
---|
| 299 |
|
---|
| 300 | void gtp_Shader_CausticCubeGfx::RegisterNotif(
|
---|
| 301 | s3d_CUtilNotifRecip *Recip)
|
---|
| 302 | {
|
---|
| 303 | }
|
---|
| 304 |
|
---|
| 305 | void gtp_Shader_CausticCubeGfx::ExtractGfx()
|
---|
| 306 | {
|
---|
| 307 | m_Node.Extract();
|
---|
| 308 | }
|
---|
| 309 |
|
---|
| 310 | bool gtp_Shader_CausticCubeGfx::IsValid()
|
---|
| 311 | {
|
---|
| 312 | if(m_GfxProg && !m_GfxProg->IsValid())
|
---|
| 313 | return false;
|
---|
| 314 | return true;
|
---|
| 315 | }
|
---|
| 316 |
|
---|
| 317 | void gtp_Shader_CausticCubeGfx::LinkCollect(
|
---|
| 318 | s3d_CUtilAtomSet &VarAtomSet)
|
---|
| 319 | {
|
---|
| 320 | s3d_CDrvUtilVarUtil::LinkCollect(
|
---|
| 321 | VarAtomSet, m_Data->m_TaskInfoVarAtom);
|
---|
| 322 | s3d_CDrvUtilVarUtil::LinkCollectArray(
|
---|
| 323 | VarAtomSet, m_Data->m_SrcVarAtomArray);
|
---|
| 324 |
|
---|
| 325 | m_FilterDestGfx.LinkCollect(VarAtomSet, m_Data->m_Dest);
|
---|
| 326 |
|
---|
| 327 | s3d_CDrvUtilVarUtil::LinkCollectExport(
|
---|
| 328 | VarAtomSet, m_Data->m_ProgParamMapArray);
|
---|
| 329 | }
|
---|
| 330 |
|
---|
| 331 | void gtp_Shader_CausticCubeGfx::LinkAppoint(
|
---|
| 332 | s3d_CDrvVarDecl *VarDecl)
|
---|
| 333 | {
|
---|
| 334 | s3d_CDrvUtilVarUtil::LinkAppoint(
|
---|
| 335 | m_TaskInfoVarSlot.m_Val,
|
---|
| 336 | VarDecl, m_Data->m_TaskInfoVarAtom);
|
---|
| 337 | s3d_CDrvUtilVarUtil::LinkAppointArray(
|
---|
| 338 | m_SrcVarSlotArray,
|
---|
| 339 | VarDecl, m_Data->m_SrcVarAtomArray);
|
---|
| 340 |
|
---|
| 341 | m_FilterDestGfx.LinkAppoint(VarDecl, m_Data->m_Dest);
|
---|
| 342 |
|
---|
| 343 | s3d_CDrvUtilVarUtil::LinkAppointExport(
|
---|
| 344 | m_ShaderEnv->m_MsgHandler, m_Data->m_ProgParamInfo,
|
---|
| 345 | m_ProgParamDecl, VarDecl,
|
---|
| 346 | m_Data->m_ProgParamMapArray);
|
---|
| 347 | }
|
---|
| 348 |
|
---|
| 349 | s3d_CEngShaderInstPtr gtp_Shader_CausticCubeGfx::CreateShaderInst(
|
---|
| 350 | s3d_CEngShaderHead *Head)
|
---|
| 351 | {
|
---|
| 352 | s3d_CEngGfxCtx *GfxCtx = m_Node.m_Data.m_Key;
|
---|
| 353 | return S3D_SYS_NEW gtp_Shader_CausticCubeInst(
|
---|
| 354 | m_ShaderEnv, GfxCtx, this, m_GfxProg);
|
---|
| 355 | }
|
---|
| 356 |
|
---|
| 357 | ///////////////////////////////////////////////////////////////////////////////
|
---|
| 358 |
|
---|
| 359 | gtp_Shader_CausticCubeInst::gtp_Shader_CausticCubeInst(
|
---|
| 360 | s3d_CEngShaderEnv *ShaderEnv,
|
---|
| 361 | s3d_CEngGfxCtx *GfxCtx,
|
---|
| 362 | gtp_Shader_CausticCubeGfx *ShaderGfx,
|
---|
| 363 | s3d_CEngGfxProg *GfxProg)
|
---|
| 364 | {
|
---|
| 365 | m_FrameCount = 0;
|
---|
| 366 | m_ShaderEnv = ShaderEnv;
|
---|
| 367 | m_GfxCtx = GfxCtx;
|
---|
| 368 | m_ShaderGfx = ShaderGfx;
|
---|
| 369 | m_GfxProg = GfxProg;
|
---|
| 370 | }
|
---|
| 371 |
|
---|
| 372 | void gtp_Shader_CausticCubeInst::RegisterNotif(
|
---|
| 373 | s3d_CUtilNotifRecip *Recip)
|
---|
| 374 | {
|
---|
| 375 | }
|
---|
| 376 |
|
---|
| 377 | void gtp_Shader_CausticCubeInst::SetShaderCtx(
|
---|
| 378 | s3d_CEngShaderCtx *ShaderCtx)
|
---|
| 379 | {
|
---|
| 380 | }
|
---|
| 381 |
|
---|
| 382 | void gtp_Shader_CausticCubeInst::SetGfxState(
|
---|
| 383 | s3d_CEngGfxState *GfxState)
|
---|
| 384 | {
|
---|
| 385 | }
|
---|
| 386 |
|
---|
| 387 | void gtp_Shader_CausticCubeInst::SetPos(s3d_CEngPos *Pos)
|
---|
| 388 | {
|
---|
| 389 | }
|
---|
| 390 |
|
---|
| 391 | void gtp_Shader_CausticCubeInst::SetModel(s3d_CEngModel *Model)
|
---|
| 392 | {
|
---|
| 393 | }
|
---|
| 394 |
|
---|
| 395 | void gtp_Shader_CausticCubeInst::ArrangeCollect(
|
---|
| 396 | s3d_CUtilMemPool *MemPool,
|
---|
| 397 | s3d_CEngShaderScopeArray &ScopeArray)
|
---|
| 398 | {
|
---|
| 399 | }
|
---|
| 400 |
|
---|
| 401 | void gtp_Shader_CausticCubeInst::ArrangeInit(
|
---|
| 402 | s3d_CUtilMemPool *MemPool,
|
---|
| 403 | s3d_CEngShaderScopeArray_cr ScopeArray)
|
---|
| 404 | {
|
---|
| 405 | }
|
---|
| 406 |
|
---|
| 407 | void gtp_Shader_CausticCubeInst::ArrangePerform(
|
---|
| 408 | s3d_CUtilMemPool *MemPool,
|
---|
| 409 | s3d_CEngShaderScopeArray_cr ScopeArray)
|
---|
| 410 | {
|
---|
| 411 | }
|
---|
| 412 |
|
---|
| 413 | void gtp_Shader_CausticCubeInst::ArrangeFeedback(
|
---|
| 414 | s3d_CUtilMemPool *MemPool,
|
---|
| 415 | s3d_CEngShaderScopeArray_cr ScopeArray)
|
---|
| 416 | {
|
---|
| 417 | }
|
---|
| 418 |
|
---|
| 419 | void gtp_Shader_CausticCubeInst::ArrangeGather(
|
---|
| 420 | s3d_CEngShaderExecArray &ExecArray)
|
---|
| 421 | {
|
---|
| 422 | gtp_Shader_CausticCubeData *Data = m_ShaderGfx->m_Data;
|
---|
| 423 |
|
---|
| 424 | s3d_CEngUtilShaderUtil::ArrangeGather(
|
---|
| 425 | ExecArray, Data->m_MethodArray, this);
|
---|
| 426 | }
|
---|
| 427 |
|
---|
| 428 | void gtp_Shader_CausticCubeInst::ShaderExecPerform(
|
---|
| 429 | s3d_CEngShaderScope *Scope,
|
---|
| 430 | s3d_CUtilAtom *Method,
|
---|
| 431 | s3d_CEngGfxTaskArray &TaskArray)
|
---|
| 432 | {
|
---|
| 433 | gtp_Shader_CausticCubeData *Data = m_ShaderGfx->m_Data;
|
---|
| 434 |
|
---|
| 435 | bool doRender = true;
|
---|
| 436 | if(Data->m_UpdateInterval > 1)
|
---|
| 437 | {
|
---|
| 438 | if(m_FrameCount == Data->m_UpdateInterval)
|
---|
| 439 | m_FrameCount = 0;
|
---|
| 440 | m_FrameCount++;
|
---|
| 441 | if(!(m_FrameCount % Data->m_UpdateInterval == 1))
|
---|
| 442 | doRender = false;
|
---|
| 443 | }
|
---|
| 444 | if(Data->m_UpdateInterval < 0)
|
---|
| 445 | doRender = false;
|
---|
| 446 | if(Data->m_UpdateInterval == 0)
|
---|
| 447 | {
|
---|
| 448 | Data->m_UpdateInterval = -1;
|
---|
| 449 | Data->m_UpdateAllFace = true;
|
---|
| 450 | }
|
---|
| 451 |
|
---|
| 452 | int Rank = Data->m_Rank;
|
---|
| 453 | if(Rank == 0)
|
---|
| 454 | return;
|
---|
| 455 |
|
---|
| 456 | if(doRender)
|
---|
| 457 | {
|
---|
| 458 | s3d_CEngGfxElemJob *GfxElemJob = new(m_ShaderEnv->m_MemPool)
|
---|
| 459 | s3d_CEngUtilShaderItemJob<gtp_Shader_CausticCubeInst>(
|
---|
| 460 | Scope, 0,
|
---|
| 461 | this, >p_Shader_CausticCubeInst::GfxElemJobExec);
|
---|
| 462 |
|
---|
| 463 | s3d_CEngGfxTaskOrder KeyOrder = 0;
|
---|
| 464 | s3d_CEngUtilGfxUtil::AppendTask(
|
---|
| 465 | m_ShaderEnv->m_MemPool, TaskArray, Rank, KeyOrder, GfxElemJob);
|
---|
| 466 | }
|
---|
| 467 | }
|
---|
| 468 |
|
---|
| 469 | void *gtp_Shader_CausticCubeInst::GfxElemJobExec(
|
---|
| 470 | s3d_CEngShaderScope *Scope,
|
---|
| 471 | void *GfxMark)
|
---|
| 472 | {
|
---|
| 473 | gtp_Shader_CausticCubeGfx *ShaderGfx = m_ShaderGfx;
|
---|
| 474 | const gtp_Shader_CausticCubeData *Data = ShaderGfx->m_Data;
|
---|
| 475 |
|
---|
| 476 | s3d_CDrvGfxEng *GfxEng = m_GfxCtx->m_GfxEng;
|
---|
| 477 | if(!GfxEng)
|
---|
| 478 | return GfxMark;
|
---|
| 479 |
|
---|
| 480 | s3d_CEngUtilShaderDestGfx *FilterDestGfx = &ShaderGfx->m_FilterDestGfx;
|
---|
| 481 |
|
---|
| 482 | s3d_CEngGfxVarTexChanArray FilterSrcTexArray;
|
---|
| 483 | FetchSrcArray(
|
---|
| 484 | m_ShaderEnv->m_MemPool, Scope, Data->m_SrcVarInfo.GetChars(),
|
---|
| 485 | FilterSrcTexArray, ShaderGfx->m_SrcVarSlotArray);
|
---|
| 486 |
|
---|
| 487 | int RawBaseWidth = 0;
|
---|
| 488 | int RawBaseHeight = 0;
|
---|
| 489 | CalcSrcTexSize(
|
---|
| 490 | m_ShaderEnv->m_MemPool, Scope, GfxEng,
|
---|
| 491 | RawBaseWidth, RawBaseHeight, FilterSrcTexArray);
|
---|
| 492 |
|
---|
| 493 | int DestProp = 0;
|
---|
| 494 | if(!FilterDestGfx->GetSnapTexPropWidthHeight(
|
---|
| 495 | m_ShaderEnv, Scope, Data->m_Dest,
|
---|
| 496 | RawBaseWidth, RawBaseHeight, DestProp))
|
---|
| 497 | return GfxMark;
|
---|
| 498 |
|
---|
| 499 | float BaseWidth = RawBaseWidth * Data->m_WidthScale;
|
---|
| 500 | float BaseHeight = RawBaseHeight * Data->m_HeightScale;
|
---|
| 501 | if(BaseWidth <= 0)
|
---|
| 502 | return GfxMark;
|
---|
| 503 | if(BaseHeight <= 0)
|
---|
| 504 | return GfxMark;
|
---|
| 505 |
|
---|
| 506 | int IterStart = Data->m_IterStart;
|
---|
| 507 | int IterEnd = Data->m_IterEnd;
|
---|
| 508 | int IterStep = Data->m_IterStep;
|
---|
| 509 | if(IterStep > 0)
|
---|
| 510 | {
|
---|
| 511 | float CurWidth = BaseWidth;
|
---|
| 512 | float CurHeight = BaseHeight;
|
---|
| 513 | int Iter;
|
---|
| 514 | for(Iter = IterStart; Iter <= IterEnd; Iter += IterStep)
|
---|
| 515 | {
|
---|
| 516 | CurWidth /= Data->m_IterWidthScale;
|
---|
| 517 | CurHeight /= Data->m_IterHeightScale;
|
---|
| 518 | }
|
---|
| 519 | for(Iter = IterStart; Iter <= IterEnd; Iter += IterStep)
|
---|
| 520 | {
|
---|
| 521 | CurWidth *= Data->m_IterWidthScale;
|
---|
| 522 | CurHeight *= Data->m_IterHeightScale;
|
---|
| 523 | Iteration(Scope, Iter, DestProp, CurWidth, CurHeight);
|
---|
| 524 | }
|
---|
| 525 | }
|
---|
| 526 | else if(IterStep < 0)
|
---|
| 527 | {
|
---|
| 528 | float CurWidth = BaseWidth;
|
---|
| 529 | float CurHeight = BaseHeight;
|
---|
| 530 | int Iter;
|
---|
| 531 | for(Iter = IterStart; Iter >= IterEnd; Iter += IterStep)
|
---|
| 532 | {
|
---|
| 533 | CurWidth /= Data->m_IterWidthScale;
|
---|
| 534 | CurHeight /= Data->m_IterHeightScale;
|
---|
| 535 | }
|
---|
| 536 | for(Iter = IterStart; Iter >= IterEnd; Iter += IterStep)
|
---|
| 537 | {
|
---|
| 538 | CurWidth *= Data->m_IterWidthScale;
|
---|
| 539 | CurHeight *= Data->m_IterHeightScale;
|
---|
| 540 | Iteration(Scope, Iter, DestProp, CurWidth, CurHeight);
|
---|
| 541 | }
|
---|
| 542 | }
|
---|
| 543 | else
|
---|
| 544 | Iteration(Scope, IterStart, 0/*DestProp*/, BaseWidth, BaseHeight);
|
---|
| 545 |
|
---|
| 546 | return 0;
|
---|
| 547 | }
|
---|
| 548 |
|
---|
| 549 | void gtp_Shader_CausticCubeInst::Iteration(
|
---|
| 550 | s3d_CEngShaderScope *Scope, int Iter,
|
---|
| 551 | int DestProp, float WantWidth, float WantHeight)
|
---|
| 552 | {
|
---|
| 553 | gtp_Shader_CausticCubeGfx *ShaderGfx = m_ShaderGfx;
|
---|
| 554 | gtp_Shader_CausticCubeData *Data = ShaderGfx->m_Data;
|
---|
| 555 | s3d_CEngUtilShaderDestGfx *FilterDestGfx = &ShaderGfx->m_FilterDestGfx;
|
---|
| 556 |
|
---|
| 557 | if(!Scope)
|
---|
| 558 | return;
|
---|
| 559 |
|
---|
| 560 | s3d_CEngGfxPortion *Portion = Scope->m_Portion;
|
---|
| 561 | if(!Portion)
|
---|
| 562 | return;
|
---|
| 563 | s3d_CEngGfxCycle *Cycle = Portion->m_Cycle;
|
---|
| 564 | if(!Cycle)
|
---|
| 565 | return;
|
---|
| 566 |
|
---|
| 567 | s3d_CUtilMemPool *MemPool = m_ShaderEnv->m_MemPool;
|
---|
| 568 |
|
---|
| 569 | s3d_CDrvVarVec4f *TaskInfoVar = new(MemPool) s3d_CDrvVarVec4f;
|
---|
| 570 | TaskInfoVar->m_Val = 0;
|
---|
| 571 | TaskInfoVar->m_Val.m_x = s3d_SysFloatOfInt<float>(Iter);
|
---|
| 572 | s3d_DrvVarSet(Scope->m_VarBlk, ShaderGfx->m_TaskInfoVarSlot, TaskInfoVar);
|
---|
| 573 |
|
---|
| 574 | if(!s3d_CEngUtilGfxUtil::VerifyGfxClosed(
|
---|
| 575 | m_ShaderEnv->m_MsgHandler, Data->m_RankInfo.GetChars(),
|
---|
| 576 | Portion->m_Cycle))
|
---|
| 577 | {
|
---|
| 578 | Data->m_Rank = 0; // Avoid the error being reported each frame
|
---|
| 579 | return;
|
---|
| 580 | }
|
---|
| 581 |
|
---|
| 582 | s3d_CDrvGfxEng *GfxEng = m_GfxCtx->m_GfxEng;
|
---|
| 583 | if(!GfxEng)
|
---|
| 584 | return;
|
---|
| 585 |
|
---|
| 586 | s3d_CEngGfxVarTexChanArray FilterSrcTexArray;
|
---|
| 587 | FetchSrcArray(
|
---|
| 588 | MemPool, Scope, Data->m_SrcVarInfo.GetChars(),
|
---|
| 589 | FilterSrcTexArray, ShaderGfx->m_SrcVarSlotArray);
|
---|
| 590 |
|
---|
| 591 | int DestWidth = s3d_SysIntOfFloatNearest(WantWidth);
|
---|
| 592 | int DestHeight = s3d_SysIntOfFloatNearest(WantHeight);
|
---|
| 593 | int DestDepth = 1;
|
---|
| 594 | int DestSnap = s3d_CDrvGfxEng::TexSnap_PreferUp;
|
---|
| 595 | GfxEng->SnapTexSize(DestWidth, DestHeight, DestDepth, DestProp, DestSnap);
|
---|
| 596 |
|
---|
| 597 | s3d_CEngUtilShaderDestJob *DestJob = FilterDestGfx->CreateJob(
|
---|
| 598 | m_ShaderEnv, Scope, Data->m_Dest, DestWidth, DestHeight);
|
---|
| 599 | if(!DestJob)
|
---|
| 600 | return;
|
---|
| 601 |
|
---|
| 602 | s3d_CSysIntps nSrcTex = FilterSrcTexArray.GetCnt();
|
---|
| 603 | int nSamp = GfxEng->GetSampCnt();
|
---|
| 604 |
|
---|
| 605 | if(nSrcTex > nSamp)
|
---|
| 606 | {
|
---|
| 607 | s3d_CUtilMsg e;
|
---|
| 608 | e.m_Code = "eng/shader/eng_shader_special_filter.too_many_tex";
|
---|
| 609 | e.m_StdTempl = "Too many textures specified. "
|
---|
| 610 | "Max textures allowed '[1]'.";
|
---|
| 611 | e.AddInfo(Data->m_Info);
|
---|
| 612 | e.AddInfo(s3d_CUtilStrUtil::StrOfInt(nSamp));
|
---|
| 613 | s3d_UtilMsgReportError(m_ShaderEnv->m_MsgHandler, e);
|
---|
| 614 | return;
|
---|
| 615 | }
|
---|
| 616 |
|
---|
| 617 | // Filter:
|
---|
| 618 |
|
---|
| 619 | GfxEng->SetPaintMode(s3d_CDrvGfxEng::PaintMode_Fill);
|
---|
| 620 | GfxEng->SetCullMode(s3d_CDrvGfxEng::CullMode_None);
|
---|
| 621 | GfxEng->SetDepthTest(s3d_CDrvGfxEng::TestMode_Always);
|
---|
| 622 | GfxEng->SetDepthWrite(false);
|
---|
| 623 | GfxEng->SetDepthBias(0, 0);
|
---|
| 624 | GfxEng->SetStencilMode(
|
---|
| 625 | 0,
|
---|
| 626 | 0,
|
---|
| 627 | s3d_CDrvGfxEng::TestMode_Always,
|
---|
| 628 | s3d_CDrvGfxEng::TestMode_Always,
|
---|
| 629 | 0,
|
---|
| 630 | s3d_CDrvGfxEng::StencilOp_Keep,
|
---|
| 631 | s3d_CDrvGfxEng::StencilOp_Keep,
|
---|
| 632 | s3d_CDrvGfxEng::StencilOp_Keep,
|
---|
| 633 | s3d_CDrvGfxEng::StencilOp_Keep,
|
---|
| 634 | s3d_CDrvGfxEng::StencilOp_Keep,
|
---|
| 635 | s3d_CDrvGfxEng::StencilOp_Keep);
|
---|
| 636 | GfxEng->SetFogNone();
|
---|
| 637 |
|
---|
| 638 | GfxEng->SetAlphaTest(s3d_CDrvGfxEng::TestMode_Always, 0);
|
---|
| 639 | GfxEng->DisableLighting();
|
---|
| 640 | GfxEng->SetColorAlpha(0);
|
---|
| 641 |
|
---|
| 642 | GfxEng->SetSampTexElseNone(int(nSrcTex));
|
---|
| 643 |
|
---|
| 644 | s3d_CDrvGfxProg *DrvProg = 0;
|
---|
| 645 | if(m_GfxProg)
|
---|
| 646 | DrvProg = m_GfxProg->GetDrvProg();
|
---|
| 647 |
|
---|
| 648 | s3d_CDrvGfxParam GfxParam;
|
---|
| 649 | GfxParam.m_Blk.m_Decl = ShaderGfx->m_ProgParamDecl;
|
---|
| 650 | GfxParam.m_Blk.m_Data = Scope->m_VarBlk.m_Data;
|
---|
| 651 |
|
---|
| 652 | s3d_CUtilMemPoolFrm MemPoolFrm(MemPool);
|
---|
| 653 | s3d_CDrvUtilPaintTri PaintTri(
|
---|
| 654 | Data->m_Info.GetChars(), MemPool, GfxEng, DrvProg);
|
---|
| 655 |
|
---|
| 656 | s3d_CDrvGfxClearParam ClearParam;
|
---|
| 657 | s3d_CDrvGfxDest *Dest = DestJob->m_DrvGfxDestArray.GetPtrRaw();
|
---|
| 658 | s3d_CSysIntps nDestTex = DestJob->m_DrvGfxDestArray.GetCnt();
|
---|
| 659 |
|
---|
| 660 |
|
---|
| 661 |
|
---|
| 662 | static const int CubeFaceMap[] =
|
---|
| 663 | {
|
---|
| 664 | s3d_CDrvGfxEng::TexPart_CubeNegX, s3d_CDrvGfxEng::TexPart_CubePosX,
|
---|
| 665 | s3d_CDrvGfxEng::TexPart_CubeNegY, s3d_CDrvGfxEng::TexPart_CubePosY,
|
---|
| 666 | s3d_CDrvGfxEng::TexPart_CubePosZ, s3d_CDrvGfxEng::TexPart_CubeNegZ,
|
---|
| 667 | };
|
---|
| 668 | static const s3d_CUtilVec3f ViewDirMap[] =
|
---|
| 669 | {
|
---|
| 670 | s3d_CUtilVec3f( 1.f, 0.f, 0.f), s3d_CUtilVec3f(-1.f, 0.f, 0.f),
|
---|
| 671 | s3d_CUtilVec3f( 0.f, 1.f, 0.f), s3d_CUtilVec3f( 0.f, -1.f, 0.f),
|
---|
| 672 | s3d_CUtilVec3f( 0.f, 0.f, 1.f), s3d_CUtilVec3f( 0.f, 0.f, -1.f),
|
---|
| 673 | };
|
---|
| 674 | static const s3d_CUtilVec3f AlsoFromMap[] =
|
---|
| 675 | {
|
---|
| 676 | s3d_CUtilVec3f( 1.f, 0.f, 0.f), s3d_CUtilVec3f( 1.f, 0.f, 0.f),
|
---|
| 677 | s3d_CUtilVec3f( 0.f, 1.f, 0.f), s3d_CUtilVec3f( 0.f, 1.f, 0.f),
|
---|
| 678 | s3d_CUtilVec3f( 1.f, 0.f, 0.f), s3d_CUtilVec3f( 1.f, 0.f, 0.f),
|
---|
| 679 | };
|
---|
| 680 | static const s3d_CUtilVec3f AlsoToMap[] =
|
---|
| 681 | {
|
---|
| 682 | s3d_CUtilVec3f( 0.f, 0.f, -1.f), s3d_CUtilVec3f( 0.f, 0.f, 1.f),
|
---|
| 683 | s3d_CUtilVec3f( 0.f, 0.f, -1.f), s3d_CUtilVec3f( 0.f, 0.f, 1.f),
|
---|
| 684 | s3d_CUtilVec3f( 1.f, 0.f, 0.f), s3d_CUtilVec3f( -1.f, 0.f, 0.f),
|
---|
| 685 | };
|
---|
| 686 |
|
---|
| 687 | GfxEng->SetTransfIdentity(s3d_CDrvGfxEng::TransfChan_Proj, 0);
|
---|
| 688 | GfxEng->SetTransfIdentity(s3d_CDrvGfxEng::TransfChan_View, 0);
|
---|
| 689 |
|
---|
| 690 | const s3d_CUtilVec3f CamDir(0, 0, 1);
|
---|
| 691 | s3d_CUtilMat4x4f projMat = s3d_CEngUtilMathUtil::CalcProjStd(
|
---|
| 692 | false, 1, -1, 0, 0, 0.1, 5.0);
|
---|
| 693 | GfxEng->SetTransf(s3d_CDrvGfxEng::TransfChan_Proj, 0, projMat);
|
---|
| 694 |
|
---|
| 695 | s3d_CUtilTranslQuatf ViewTransf;
|
---|
| 696 | ViewTransf.m_Transl = s3d_CUtilVec3f(0,0,0);
|
---|
| 697 |
|
---|
| 698 | s3d_CUtilMat4x4f viewMat;
|
---|
| 699 |
|
---|
| 700 | int steps = 1;
|
---|
| 701 | if(Data->m_UsePoints)
|
---|
| 702 | {
|
---|
| 703 | steps = 2;
|
---|
| 704 | GfxEng->SetPaintMode(s3d_CDrvGfxEng::PaintMode_Point);
|
---|
| 705 | }
|
---|
| 706 | float pixelSize = 1.0f / (float) Data->m_PhotonCount;
|
---|
| 707 | float halfPixelSize = 0.5f * pixelSize;
|
---|
| 708 |
|
---|
| 709 |
|
---|
| 710 | ClearParam.m_MustColorAlpha = true;
|
---|
| 711 | ClearParam.m_MustDepth = false;
|
---|
| 712 | ClearParam.m_Depth = 1.0;
|
---|
| 713 | ClearParam.m_ColorAlpha = s3d_CUtilVec4f(0.0,0.0,0.0,1.0);
|
---|
| 714 |
|
---|
| 715 | for(int iFace = 0; iFace < 6; iFace++)
|
---|
| 716 | {
|
---|
| 717 | if(!Data->m_UpdateAllFace)
|
---|
| 718 | {
|
---|
| 719 | iFace = m_CurrentFace;
|
---|
| 720 | m_CurrentFace = (++m_CurrentFace) % 6;
|
---|
| 721 | }
|
---|
| 722 |
|
---|
| 723 | for(int i = 0; i < Data->m_PhotonCount - 1; i += steps)
|
---|
| 724 | for(int j = 0; j < Data->m_PhotonCount - 1; j += steps)
|
---|
| 725 | {
|
---|
| 726 | float X1 = i * pixelSize + halfPixelSize;
|
---|
| 727 | float Y1 = j * pixelSize + halfPixelSize;
|
---|
| 728 | float X2 = (i + 1) * pixelSize + halfPixelSize;
|
---|
| 729 | float Y2 = (j + 1) * pixelSize + halfPixelSize;
|
---|
| 730 |
|
---|
| 731 | PaintTri.AddQuadAligned(
|
---|
| 732 | s3d_CUtilVec2f(X1, Y1),
|
---|
| 733 | s3d_CUtilVec2f(0, 0),
|
---|
| 734 | s3d_CUtilVec2f(X2, Y2),
|
---|
| 735 | s3d_CUtilVec2f(1, 1),
|
---|
| 736 | 0, s3d_CUtilVec4f(0,0,0,0));
|
---|
| 737 | }
|
---|
| 738 |
|
---|
| 739 | s3d_CUtilQuatf EffQuat = s3d_CUtilQuatf::ByPathAlso(
|
---|
| 740 | CamDir, ViewDirMap[iFace], AlsoFromMap[iFace],
|
---|
| 741 | AlsoToMap[iFace]);
|
---|
| 742 | ViewTransf.m_Quat = EffQuat;
|
---|
| 743 | viewMat = s3d_CUtilGeof::GetMapOfTransf3(ViewTransf);
|
---|
| 744 | GfxEng->SetTransf(s3d_CDrvGfxEng::TransfChan_View, 0, viewMat);
|
---|
| 745 |
|
---|
| 746 | for(int j = 0; j < nDestTex; j++)
|
---|
| 747 | Dest[j].m_Part = CubeFaceMap[iFace];
|
---|
| 748 |
|
---|
| 749 | GfxEng->BeginRenderTex(Data->m_DestProp, ClearParam,
|
---|
| 750 | DestWidth, DestHeight, nDestTex, Dest);
|
---|
| 751 |
|
---|
| 752 | GfxEng->SetBlendMode(
|
---|
| 753 | s3d_CDrvGfxEng::BlendFac_SrcAlpha,
|
---|
| 754 | s3d_CDrvGfxEng::BlendFac_One,
|
---|
| 755 | s3d_CDrvGfxEng::BlendOp_SrcPlusDest,
|
---|
| 756 | s3d_CDrvGfxEng::BlendFac_One,
|
---|
| 757 | s3d_CDrvGfxEng::BlendFac_One,
|
---|
| 758 | s3d_CDrvGfxEng::BlendOp_SrcPlusDest);
|
---|
| 759 |
|
---|
| 760 | GfxEng->SetViewRect(1);
|
---|
| 761 |
|
---|
| 762 | int iSamp;
|
---|
| 763 | for(iSamp = 0; iSamp < nSrcTex; iSamp++)
|
---|
| 764 | {
|
---|
| 765 | const s3d_CEngGfxVarTexChan *SrcTexChanVar =
|
---|
| 766 | FilterSrcTexArray[iSamp];
|
---|
| 767 | s3d_CDrvGfxTex *DrvTex = 0;
|
---|
| 768 | if(SrcTexChanVar)
|
---|
| 769 | DrvTex = SrcTexChanVar->m_Val.m_FixedDrvTex;
|
---|
| 770 | GfxEng->SetSampTex(iSamp, DrvTex);
|
---|
| 771 | GfxEng->SetSampMode(iSamp, SrcTexChanVar->m_Val.m_FixedSampMode);
|
---|
| 772 | }
|
---|
| 773 |
|
---|
| 774 | PaintTri.Perform(GfxParam);
|
---|
| 775 |
|
---|
| 776 | GfxEng->EndRender();
|
---|
| 777 | }
|
---|
| 778 |
|
---|
| 779 | FilterDestGfx->FinishJob(
|
---|
| 780 | m_ShaderEnv, Scope, Data->m_Dest, DestJob);
|
---|
| 781 | }
|
---|
| 782 |
|
---|
| 783 | void gtp_Shader_CausticCubeInst::FetchSrcArray(
|
---|
| 784 | s3d_CUtilMemPool *MemPool, s3d_CEngShaderScope *Scope,
|
---|
| 785 | const s3d_CSysChar *Info,
|
---|
| 786 | s3d_CEngGfxVarTexChanArray &SrcTexArray,
|
---|
| 787 | s3d_CDrvVarSlotArray &SrcVarSlotArray)
|
---|
| 788 | {
|
---|
| 789 | s3d_CSysIntps nTex = SrcVarSlotArray.GetCnt();
|
---|
| 790 | SrcTexArray.SetCnt(MemPool, nTex);
|
---|
| 791 | s3d_CSysIntps iTex;
|
---|
| 792 | for(iTex = 0; iTex < nTex; iTex++)
|
---|
| 793 | {
|
---|
| 794 | s3d_CEngGfxVarTexChan *TexChanVar =
|
---|
| 795 | s3d_EngGfxVarFetchWaryTexChan(
|
---|
| 796 | m_ShaderEnv->m_MsgHandler, Info, Scope->m_VarBlk,
|
---|
| 797 | SrcVarSlotArray.RefAt(iTex));
|
---|
| 798 | SrcTexArray.SetAt(iTex, TexChanVar);
|
---|
| 799 | }
|
---|
| 800 | }
|
---|
| 801 |
|
---|
| 802 | void gtp_Shader_CausticCubeInst::CalcSrcTexSize(
|
---|
| 803 | s3d_CUtilMemPool *MemPool, s3d_CEngShaderScope *Scope,
|
---|
| 804 | s3d_CDrvGfxEng *GfxEng, int &Width, int &Height,
|
---|
| 805 | s3d_CEngGfxVarTexChanArray &FilterSrcTexArray)
|
---|
| 806 | {
|
---|
| 807 | Width = 0;
|
---|
| 808 | Height = 0;
|
---|
| 809 |
|
---|
| 810 | s3d_CSysIntps nSrcTex = FilterSrcTexArray.GetCnt();
|
---|
| 811 | s3d_CSysIntps iSrcTex;
|
---|
| 812 | for(iSrcTex = 0; iSrcTex < nSrcTex; iSrcTex++)
|
---|
| 813 | {
|
---|
| 814 | s3d_CEngGfxVarTexChan *SrcTexChan = FilterSrcTexArray[iSrcTex];
|
---|
| 815 | if(!SrcTexChan)
|
---|
| 816 | continue;
|
---|
| 817 | s3d_CDrvGfxTex *SrcDrvTex = SrcTexChan->m_Val.m_FixedDrvTex;
|
---|
| 818 | if(!SrcDrvTex)
|
---|
| 819 | continue;
|
---|
| 820 |
|
---|
| 821 | int SrcTexWidth, SrcTexHeight, SrcTexDepth;
|
---|
| 822 | SrcDrvTex->GetSize(SrcTexWidth, SrcTexHeight, SrcTexDepth);
|
---|
| 823 |
|
---|
| 824 | if(Width < SrcTexWidth)
|
---|
| 825 | Width = SrcTexWidth;
|
---|
| 826 | if(Height < SrcTexHeight)
|
---|
| 827 | Height = SrcTexHeight;
|
---|
| 828 | }
|
---|
| 829 | }
|
---|
| 830 |
|
---|
| 831 | ///////////////////////////////////////////////////////////////////////////////
|
---|