cloud layer example

This commit is contained in:
marauder2k7 2024-12-21 12:23:57 +00:00
parent eca0820134
commit 24b374f545
4 changed files with 45 additions and 18 deletions

View file

@ -112,8 +112,6 @@ CloudLayer::CloudLayer()
mTexOffset[0] = mTexOffset[1] = mTexOffset[2] = Point2F::Zero;
mHeight = 4.0f;
INIT_ASSET(Texture);
}
IMPLEMENT_CO_NETOBJECT_V1( CloudLayer );
@ -131,8 +129,6 @@ bool CloudLayer::onAdd()
addToScene();
LOAD_IMAGEASSET(Texture);
if ( isClientObject() )
{
_initBuffers();
@ -194,8 +190,8 @@ void CloudLayer::initPersistFields()
docsURL;
addGroup( "CloudLayer" );
INITPERSISTFIELD_IMAGEASSET(Texture, CloudLayer, "An RGBA texture which should contain normals and opacity (density).");
INITPERSISTFIELD_IMAGEASSET_REFACTOR(Texture, CloudLayer, "An RGBA texture which should contain normals and opacity (density).")
addArray( "Textures", TEX_COUNT );
addField( "texScale", TypeF32, Offset( mTexScale, CloudLayer ), TEX_COUNT,
@ -243,7 +239,9 @@ U32 CloudLayer::packUpdate( NetConnection *conn, U32 mask, BitStream *stream )
{
U32 retMask = Parent::packUpdate( conn, mask, stream );
PACK_ASSET(conn, Texture);
if (stream->writeFlag(mTextureAsset.notNull())) {
NetStringHandle assetIdStr = mTextureAsset.getAssetId(); conn->packNetStringHandleU(stream, assetIdStr);
}
for ( U32 i = 0; i < TEX_COUNT; i++ )
{
@ -265,10 +263,9 @@ void CloudLayer::unpackUpdate( NetConnection *conn, BitStream *stream )
{
Parent::unpackUpdate( conn, stream );
UNPACK_ASSET(conn, Texture);
if(mTextureAssetId != StringTable->EmptyString())
mTextureAsset = mTextureAssetId;
if (stream->readFlag()) {
mTextureAsset.setAssetId(_getStringTable()->insert(conn->unpackNetStringHandleU(stream).getString()));
}
for ( U32 i = 0; i < TEX_COUNT; i++ )
{
@ -334,7 +331,7 @@ void CloudLayer::renderObject( ObjectRenderInst *ri, SceneRenderState *state, Ba
{
GFXTransformSaver saver;
if (!mTextureAsset || !mTextureAsset->isAssetValid())
if (!mTextureAsset)
return;
const Point3F &camPos = state->getCameraPosition();
@ -385,7 +382,7 @@ void CloudLayer::renderObject( ObjectRenderInst *ri, SceneRenderState *state, Ba
mShaderConsts->setSafe( mExposureSC, mExposure );
GFX->setTexture( mNormalHeightMapSC->getSamplerRegister(), getTextureResource());
GFX->setTexture( mNormalHeightMapSC->getSamplerRegister(), mTextureAsset->getTexture(&GFXStaticTextureSRGBProfile));
GFX->setVertexBuffer( mVB );
GFX->setPrimitiveBuffer( mPB );