Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for more vertex attributes (e.g. tangents, binormals) #25

Closed
Arparso opened this issue Sep 21, 2019 · 4 comments
Closed

Support for more vertex attributes (e.g. tangents, binormals) #25

Arparso opened this issue Sep 21, 2019 · 4 comments

Comments

@Arparso
Copy link

Arparso commented Sep 21, 2019

First of all, great tool!

As far as I can tell, it only supports a limited set of per-vertex attributes, though: Positions, normals and one set of texture coordinates.

I tried implementing a simple normal mapping shader, which requires tangent and binormal vectors for each vertex. Using the HLSL shader semantics for tangents and binormals did not work, though - the float3 vectors were all 0.

The tool also does not seem to respect the semantics in my HLSL shader at all, it always stores position in the first attribute, normals in the second attribute and texture coordinate in the thrid. E.g.

struct VSInput { float3 Position : POSITION; float2 TexCoord : TEXCOORD0; float3 Normal : NORMAL; };

This does not work as expected: "TexCoord" will contain the normal instead and "Normal" will contain texture coordinates.

It would be nice if we could configure the vertex attributes that are supplied to the shader, including ones that are not supported right now (e.g. tangents, binormals, vertex color or multiple sets of texture coordinates).

(if there is a way to do that, already, I haven't found it)

@dfranx
Copy link
Owner

dfranx commented Sep 21, 2019

Thanks!

Currently tangents and binormals aren't implemented. I could definitely try adding those two in the v1.2.2.

The semantics are ignored and don't actually matter. The reason for this is that I am transcompiling HLSL to GLSL. But I guess I could internally reorganize the inputs during HLSL->GLSL conversion if I detect some semantic such as "POSITION", etc... I am not promising anything though. I will look more into this and see if it is possible (I believe that it should be possible).

In the Direct3D 11 version of SHADERed there was an "Input layout manager" option. You could modify the inputs. I removed it because I thought it made SHADERed more difficult to get started with. I guess I could reintroduce that feature again now.

Also, how would vertex color attribute work? Do I allow the user to set the color for all vertices or? And do you have an example/tutorial on how multiple sets of texture coordinates are used? I've seen this mentioned before but haven't looked into it too much.

@Arparso
Copy link
Author

Arparso commented Sep 21, 2019

Having access to tangents and binormals would be very helpful to me.

Semantics support would be nice, as well, but not a must have for me - as long as I know how to access the correct vertex attribute. I was just caught off-guard this time, because I assumed I had made some error in my calculations, when it was in fact faulty/missing vertex data.

"Input layout manager" would be nice. I've used ATI Rendermonkey in the past (years ago) and they had something similar to configure the vertexbuffer layout to match your requirements. Maybe default to some sensible "auto" mode that mimics the current behaviour, but allow manual configuration of the layout, if users want to.

With regards to vertex color: I think that needs to come from the model itself. Probably not useful for the built-in geometry, but for loading external models. I think you're using Assimp to load these models? That should be able to extract vertex colors if it finds any. I don't personally use vertex color right now, but someone else might.

Multiple texture coordinates: I haven't ever used them, either, but I'm also just an amateur/hobbyist. I guess this could be useful if applying more than one texture to a model, e.g. a coarse color map and then some (repeated) detail map for finer details. Or you'd store some other material/object properties in these extra UVs.

Right now I'd only need tangents (and binormals, if possible). Depending on how far you want to take this tool, you might want to consider the other types of attributes and custom input layouts, too.

@dfranx
Copy link
Owner

dfranx commented Sep 21, 2019

Thanks for the detailed feedback. I will try to include these features (input layout manager, semantics, binormals, tangents, etc...) next week. Should come out with the v1.2.2

dfranx added a commit that referenced this issue Sep 23, 2019
@dfranx
Copy link
Owner

dfranx commented Sep 23, 2019

Hi! The feature is implemented in the v1.2.2.

I've implemented input layouts, bitangents, tangents and vertex colors.

The semantics currently don't work as there isn't, as far as I know, an easy way to get input variable's semantic. I will implement semantics when I learn how to properly use glslang's AST tree.
But you can change the locations of vertex shader's input variables (throught the input layout manager) and "emulate" semantics that way.

I will implement multiple texture coordinates but not right now.

Also, I hope that the tangents and bitangents/binormals have proper values.
I used this tutorial to calculate them: http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-13-normal-mapping/
And here is my code in case that the values are not proper: https://github.com/dfranx/SHADERed/blob/master/Engine/GeometryFactory.cpp#L113-L172

Also, could you provide a screenshot of your normal map shader if tangents and bitangents in SHADERed work? I would like to add it to the README.md

@dfranx dfranx closed this as completed Sep 27, 2019
AlvaroRuizDelgado added a commit to AlvaroRuizDelgado/SHADERed that referenced this issue Dec 21, 2019
* Cross platform update

* Minor CMake changes

* Use inotify for file watcing on linux

* Fix for dfranx#5

* Fix GLSL shaders + fix for a bug that occurs when using multiple textures

* Add steps for Windows in the README

* Add FindGLM.cmake

* Variable pointers

* Small fix for variable pointers

* Shader macros

* fix sdl linking on Linux

* Update CHANGELOG

* Fix for dfranx#13

* Add FrameIndex system variable dfranx#14

* Add option that disables RT clear dfranx#15

* UIHelper -> include clocale

* Shader variable flags dfranx#12

* Fix CopyState() crash

* Fix last frame flag for GeometryTransform dfranx#12

* Disable last frame for IsPicked + change var manager default size

* Icons

* Add format property to render textures dfranx#17

* Add toolbar

* Add elapsed time to status bar + make the toolbar buttons work

* Pause and increase time

* Fix float4/int4/bool4 variables

* Add Mouse and MouseButton system variables

* Zoom in/out functionality

* Zoom controls

* Fix RT filtering and model rendering

* Fix a bug where SHADERed would crash with multiple 3D models dfranx#18

* Replace glm::identity<glm::mat4>() with glm::mat4(1) dfranx#6

* Add option to reset time

* Fix zoom area dragging & limit zoom selection bounds

* Add CTRL+ALT+MWheel to zoom in/out

* Add FindSFML.cmake

* Add USE_FINDSFML variable

* Add cubemap preview

* Fix picking when zoomed in

* Improve gizmo, bounding box & zoom area performance

* Add option to modify system variables when rendering to an image

* macOS changes

* Object preview window

* Fix CMakeLists.txt

* Add proper cubemap and audio preview to the object preview window

* Add buffers

* Add instancing

* Add ability to use buffers as inputs for instanced objects

* Fix 3D model instancing

* Make it compilable on windows

* Add auto check for updates on startup

* Add buffer to toolbar & minor improvements to UpdateChecker

* Update TextEditor dfranx#19

* Add show whitespace option

* Update external libraries

* Add auto recompile option - compile changed shaders every 200ms

* Add option to disable window's alpha channel

* Add ScreenQuadNDC

* Add the ability to set CodeUI.Save and Project.Save to same shortcut

* Add option to stream logs to file

* Bump version

* Fix loading files from different drives on Windows dfranx#18

* Add ImageObject

* Add compute shaders

* Compute shader examples + fixes

* Minor changes

* Update README.md & TUTORIAL.md

* Fix README gif

* Remove some gifs

* Fix crash on RWTexture2D

* Fix crash on HLSL function calls with no arguments (update glslang)

* Fix various transcompiler crashes

* Various TextEditor fixes (check CHANGELOG) - update ImGuiColorTextEdit submodule

* Fix a bug that occurs when fetching texel data from a texture without a sampler

* Write item type in the properties

* Use different color to write shader pass with an error in the PipelineUI

* Disable various path textboxes

* Prevent pause button from overlapping

* Update TextEditor, add hlsl compute example, bump version

* Add Vulkan GLSL support dfranx#21

* Minor fixes

* Add input layout (dfranx#25)

* Exporting/importing shader pass input layout

* Add input layout manager

* Fix tangents and bitangents

* Add option to export a sequence of images dfranx#23

* Improve performance mode dfranx#24

* Various fixes & changes

* Add CameraPosition3 and CameraDirection3 variables

* Add drag & drop

* Add 'Are you sure?' message box

* Multiple bug fixes

* Rework ImageObject & fix ScreenQuadNDC rendering

* Add resource manager

* Add CTRL+F/search box in the text editor

* Fix for dfranx#27

* Fix a bug where SHADERed would recompile file two times after clicking Compile button

* Add ability to change variable type after variable has been created

* Add a window where all system variables are listed

* Add magnifier tool to object preview window

* Make it so that any form of project save also saves all shader code modifications

* Shader code modifications now also count as project modifications

* Minor changes

* Add context menu and replace feature in the text editor & fix copy and paste functionalities

* Some internal changes to the magnifier tool in ObjectPreviewUI

* Detect if some Editor shortcuts are missing

* Remove all the maps from ObjectManager

* Fix for gcc

* Fixes

* Add support for HLSL types in the buffer format

* Recompile shader pass after we change it's shader path

* Add ability to change warning, message and error text colors in the theme files

* CodeEditorUI now holds pointers to PipelineItems

* Close code editors after a shader pass has been deleted

* Add feature that automatically creates variables when creating a shader pass

* Add Editor.FindNext & improve text editor find feature

* Add 3D textures

* Add Project -> Options

* Fix 3D textures

* Fix texture loading

* Add various checks to prevent crashes

* Add multi-camera system (+ ShadowMapping example) & fix matrix variable export/import

* Update readme

* Add audio shaders (+ audioshader example)

* Update libraries

* Update TODO.md

* Fix a bug where openning Sobel -> Edge -> Sobel examples would break the rendered

* Fix a crash on openning 'cubemap' example

* Update README.md & settings.ini

* Improve image sequence export speed & add ability to use sprintf format specifiers in filename (dfranx#23)

* Add Fedora Dependencies

* Scroll to the selection & fix FindNext highlighting

* Update TODO.md

* Fix Editor.Find and Editor.Replace shortcuts

* Fix HOME/END shortcuts

* Fix gizmo interaction when preview is zoomed in

* Add drag & drop to PipelineUI

* Bump version

* Add ability to deactivate certain shader pass

* Pausing preview now also pauses compute shaders

* Improve TextEditor shortcuts

* Revert

* Update TODO.md & CHANGELOG.txt

* Fix a bug where TextEditor would lose focus on ALT key press

* Plugin API base

* Fixed missed return ArcBallCamera '=' operator

* Fixed missed return value for '=' operator

* Memory leak fix

```
		if (m_item.Data != nullptr)
			delete m_item.Data;
```
m_item.Data:
https://github.com/dfranx/SHADERed/blob/24ba95faebfde61581a08792b82f5ad2cb13d69f/Objects/PipelineItem.h#L45

it leads to mem leak as 'delete' operator can't delete 'void*' proper. (not type information -> not size data, and no information about destructor, ... )
https://github.com/dfranx/SHADERed/blob/24ba95faebfde61581a08792b82f5ad2cb13d69f/Objects/PipelineItem.h#L45
i.e. destructors of internal fields (ex https://github.com/dfranx/SHADERed/blob/24ba95faebfde61581a08792b82f5ad2cb13d69f/Objects/PipelineItem.h#L78)  won't be executed.

* Mem-leak fix

Base class should have a virtual destructor otherwise delete (UIView*) ... won't be able to call derived destructor (even a default one).

* Add support for #include

* Update TODO.md & minor changes to KeyboardShortcuts (dfranx#35)

* Fix #include's for HLSL

* Fix message line numbers when using #include in GLSL shaders

* Add 'Recursive #include detected' message

* Update default theme & font (dfranx#9)

* Add an option to save supersampled screenshots (dfranx#34)

* Update imgui

* Add search in Options -> Shortcuts

* Bump version

* Add ability to load projects by drag and dropping them

* Toolbar item for openning projects should now also show 'Are you sure?' message box

* Somewhat fix autocomplete and find window background colors

* Update and expand the API

* Hide object view window in performance mode

* Add MSAA (dfranx#36)

* Change how MouseButton works

* Fix a bug where user could select same RT multiple times for the same pass

* Fix camera rotation loading from project file

* Add ability to add custom system variable types

* Check if user doesn't have required plugins for a project

* Add ability to disable certain plugins

* Consistency between auto-recompile and normal recompile when using #include

* Add ability to add custom functions

* Add ability to install SHADERed binaries (dfranx#33)

* make install -> lowercase (dfranx#33)

* Compiles on linux

* Plugins can now add custom ObjectManager items

* Add PipelineItem::PluginItem

* Fixes, improvements & add various plugin functions

* Add GetPluginVersion() & fix bugs

* More fixes

* Update shortcuts.kb

* Add ShowContextItems(pluginitem_add, item_type)

* Add GetDPI, Log, FileExists, ClearMessageGroup to plugin API

* Add GetObjectCount, GetObjectName, IsTexture, GetTexture, GetTextureSize plugin functions + fix pipelineitem_add

* Add XDG desktop and AppData files for Linux integration

This also installs those files in CMake to expose SHADERed
to the application launcher once installed.

* Add BeginRender and EndRender to PluginAPI

* Prevent SHADERed from crashing when plugins directory doesn't exist (dfranx#38)

* Cache PluginItems in RenderEngine

* Add BindDefaultStateFn

* Add ability to check for changes in plugin's custom files

* Plugin API can now access CodeEditorUI features

* Auto recompile now works with plugin items

* Plugin API changes

* Prevent crashes when one of the directories (themes, templates, data) doesn't exist

* Create data directory if it doesn't exist

* Update plugin API

Co-authored-by: Franx <dfranx00@gmail.com>
Co-authored-by: CuriousTommy <CuriousTommy@users.noreply.github.com>
Co-authored-by: Denis <denis.ovod@gmail.com>
Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants